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

Side by Side Diff: talk/session/media/channel.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/session/media/channel.h ('k') | talk/session/media/channel_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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 if (enable) { 1310 if (enable) {
1311 // Start the early media timeout 1311 // Start the early media timeout
1312 worker_thread()->PostDelayed(kEarlyMediaTimeout, this, 1312 worker_thread()->PostDelayed(kEarlyMediaTimeout, this,
1313 MSG_EARLYMEDIATIMEOUT); 1313 MSG_EARLYMEDIATIMEOUT);
1314 } else { 1314 } else {
1315 // Stop the timeout if currently going. 1315 // Stop the timeout if currently going.
1316 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT); 1316 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT);
1317 } 1317 }
1318 } 1318 }
1319 1319
1320 bool VoiceChannel::PressDTMF(int digit, bool playout) {
1321 int flags = DF_SEND;
1322 if (playout) {
1323 flags |= DF_PLAY;
1324 }
1325 int duration_ms = 160;
1326 return InsertDtmf(0, digit, duration_ms, flags);
1327 }
1328
1329 bool VoiceChannel::CanInsertDtmf() { 1320 bool VoiceChannel::CanInsertDtmf() {
1330 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf, 1321 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf,
1331 media_channel())); 1322 media_channel()));
1332 } 1323 }
1333 1324
1334 bool VoiceChannel::InsertDtmf(uint32_t ssrc, 1325 bool VoiceChannel::InsertDtmf(uint32_t ssrc,
1335 int event_code, 1326 int event_code,
1336 int duration, 1327 int duration) {
1337 int flags) {
1338 return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this, 1328 return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this,
1339 ssrc, event_code, duration, flags)); 1329 ssrc, event_code, duration));
1340 } 1330 }
1341 1331
1342 bool VoiceChannel::SetOutputVolume(uint32_t ssrc, double volume) { 1332 bool VoiceChannel::SetOutputVolume(uint32_t ssrc, double volume) {
1343 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputVolume, 1333 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputVolume,
1344 media_channel(), ssrc, volume)); 1334 media_channel(), ssrc, volume));
1345 } 1335 }
1346 1336
1347 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) { 1337 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
1348 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats, 1338 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats,
1349 media_channel(), stats)); 1339 media_channel(), stats));
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 void VoiceChannel::HandleEarlyMediaTimeout() { 1515 void VoiceChannel::HandleEarlyMediaTimeout() {
1526 // This occurs on the main thread, not the worker thread. 1516 // This occurs on the main thread, not the worker thread.
1527 if (!received_media_) { 1517 if (!received_media_) {
1528 LOG(LS_INFO) << "No early media received before timeout"; 1518 LOG(LS_INFO) << "No early media received before timeout";
1529 SignalEarlyMediaTimeout(this); 1519 SignalEarlyMediaTimeout(this);
1530 } 1520 }
1531 } 1521 }
1532 1522
1533 bool VoiceChannel::InsertDtmf_w(uint32_t ssrc, 1523 bool VoiceChannel::InsertDtmf_w(uint32_t ssrc,
1534 int event, 1524 int event,
1535 int duration, 1525 int duration) {
1536 int flags) {
1537 if (!enabled()) { 1526 if (!enabled()) {
1538 return false; 1527 return false;
1539 } 1528 }
1540 1529 return media_channel()->InsertDtmf(ssrc, event, duration);
1541 return media_channel()->InsertDtmf(ssrc, event, duration, flags);
1542 } 1530 }
1543 1531
1544 void VoiceChannel::OnMessage(rtc::Message *pmsg) { 1532 void VoiceChannel::OnMessage(rtc::Message *pmsg) {
1545 switch (pmsg->message_id) { 1533 switch (pmsg->message_id) {
1546 case MSG_EARLYMEDIATIMEOUT: 1534 case MSG_EARLYMEDIATIMEOUT:
1547 HandleEarlyMediaTimeout(); 1535 HandleEarlyMediaTimeout();
1548 break; 1536 break;
1549 case MSG_CHANNEL_ERROR: { 1537 case MSG_CHANNEL_ERROR: {
1550 VoiceChannelErrorMessageData* data = 1538 VoiceChannelErrorMessageData* data =
1551 static_cast<VoiceChannelErrorMessageData*>(pmsg->pdata); 1539 static_cast<VoiceChannelErrorMessageData*>(pmsg->pdata);
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 return (data_channel_type_ == DCT_RTP); 2266 return (data_channel_type_ == DCT_RTP);
2279 } 2267 }
2280 2268
2281 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2269 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2282 rtc::TypedMessageData<uint32_t>* message = 2270 rtc::TypedMessageData<uint32_t>* message =
2283 new rtc::TypedMessageData<uint32_t>(sid); 2271 new rtc::TypedMessageData<uint32_t>(sid);
2284 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2272 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2285 } 2273 }
2286 2274
2287 } // namespace cricket 2275 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/session/media/channel.h ('k') | talk/session/media/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698