Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1487393002: Refactor WVoE DTMF handling #1 (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 } 2279 }
2280 LOG(LS_INFO) << "SetOutputVolume to " << volume 2280 LOG(LS_INFO) << "SetOutputVolume to " << volume
2281 << " for channel " << ch_id << " and ssrc " << ssrc; 2281 << " for channel " << ch_id << " and ssrc " << ssrc;
2282 return true; 2282 return true;
2283 } 2283 }
2284 2284
2285 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { 2285 bool WebRtcVoiceMediaChannel::CanInsertDtmf() {
2286 return dtmf_allowed_; 2286 return dtmf_allowed_;
2287 } 2287 }
2288 2288
2289 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, 2289 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, int event,
2290 int event, 2290 int duration) {
2291 int duration,
2292 int flags) {
2293 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2291 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2294 if (!dtmf_allowed_) { 2292 if (!dtmf_allowed_) {
2295 return false; 2293 return false;
2296 } 2294 }
2297 2295
2298 // Send the event. 2296 // Send the event.
2299 if (flags & cricket::DF_SEND) { 2297 int channel = -1;
2300 int channel = -1; 2298 if (ssrc == 0) {
2301 if (ssrc == 0) { 2299 if (send_streams_.size() > 0) {
2302 if (send_streams_.size() > 0) { 2300 channel = send_streams_.begin()->second->channel();
2303 channel = send_streams_.begin()->second->channel();
2304 }
2305 } else {
2306 channel = GetSendChannelId(ssrc);
2307 } 2301 }
2308 if (channel == -1) { 2302 } else {
2309 LOG(LS_WARNING) << "InsertDtmf - The specified ssrc " 2303 channel = GetSendChannelId(ssrc);
2310 << ssrc << " is not in use.";
2311 return false;
2312 }
2313 // Send DTMF using out-of-band DTMF. ("true", as 3rd arg)
2314 if (engine()->voe()->dtmf()->SendTelephoneEvent(
2315 channel, event, true, duration) == -1) {
2316 LOG_RTCERR4(SendTelephoneEvent, channel, event, true, duration);
2317 return false;
2318 }
2319 } 2304 }
2320 2305 if (channel == -1) {
2321 // Play the event. 2306 LOG(LS_WARNING) << "InsertDtmf - The specified ssrc "
2322 if (flags & cricket::DF_PLAY) { 2307 << ssrc << " is not in use.";
2323 // Play DTMF tone locally. 2308 return false;
2324 if (engine()->voe()->dtmf()->PlayDtmfTone(event, duration) == -1) { 2309 }
2325 LOG_RTCERR2(PlayDtmfTone, event, duration); 2310 // Send DTMF using out-of-band DTMF. ("true", as 3rd arg)
2326 return false; 2311 if (engine()->voe()->dtmf()->SendTelephoneEvent(
2327 } 2312 channel, event, true, duration) == -1) {
2313 LOG_RTCERR4(SendTelephoneEvent, channel, event, true, duration);
2314 return false;
2328 } 2315 }
2329 2316
2330 return true; 2317 return true;
2331 } 2318 }
2332 2319
2333 void WebRtcVoiceMediaChannel::OnPacketReceived( 2320 void WebRtcVoiceMediaChannel::OnPacketReceived(
2334 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { 2321 rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
2335 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2322 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2336 2323
2337 uint32_t ssrc = 0; 2324 uint32_t ssrc = 0;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 } 2639 }
2653 } else { 2640 } else {
2654 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2641 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2655 engine()->voe()->base()->StopPlayout(channel); 2642 engine()->voe()->base()->StopPlayout(channel);
2656 } 2643 }
2657 return true; 2644 return true;
2658 } 2645 }
2659 } // namespace cricket 2646 } // namespace cricket
2660 2647
2661 #endif // HAVE_WEBRTC_VOICE 2648 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698