OLD | NEW |
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 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 media_channel(), ssrc, renderer)); | 1264 media_channel(), ssrc, renderer)); |
1265 } | 1265 } |
1266 | 1266 |
1267 bool VoiceChannel::SetAudioSend(uint32 ssrc, bool mute, | 1267 bool VoiceChannel::SetAudioSend(uint32 ssrc, bool mute, |
1268 const AudioOptions* options, | 1268 const AudioOptions* options, |
1269 AudioRenderer* renderer) { | 1269 AudioRenderer* renderer) { |
1270 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, | 1270 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, |
1271 media_channel(), ssrc, mute, options, renderer)); | 1271 media_channel(), ssrc, mute, options, renderer)); |
1272 } | 1272 } |
1273 | 1273 |
1274 bool VoiceChannel::SetRingbackTone(const void* buf, int len) { | |
1275 return InvokeOnWorker(Bind(&VoiceChannel::SetRingbackTone_w, this, buf, len)); | |
1276 } | |
1277 | |
1278 // TODO(juberti): Handle early media the right way. We should get an explicit | 1274 // TODO(juberti): Handle early media the right way. We should get an explicit |
1279 // ringing message telling us to start playing local ringback, which we cancel | 1275 // ringing message telling us to start playing local ringback, which we cancel |
1280 // if any early media actually arrives. For now, we do the opposite, which is | 1276 // if any early media actually arrives. For now, we do the opposite, which is |
1281 // to wait 1 second for early media, and start playing local ringback if none | 1277 // to wait 1 second for early media, and start playing local ringback if none |
1282 // arrives. | 1278 // arrives. |
1283 void VoiceChannel::SetEarlyMedia(bool enable) { | 1279 void VoiceChannel::SetEarlyMedia(bool enable) { |
1284 if (enable) { | 1280 if (enable) { |
1285 // Start the early media timeout | 1281 // Start the early media timeout |
1286 worker_thread()->PostDelayed(kEarlyMediaTimeout, this, | 1282 worker_thread()->PostDelayed(kEarlyMediaTimeout, this, |
1287 MSG_EARLYMEDIATIMEOUT); | 1283 MSG_EARLYMEDIATIMEOUT); |
1288 } else { | 1284 } else { |
1289 // Stop the timeout if currently going. | 1285 // Stop the timeout if currently going. |
1290 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT); | 1286 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT); |
1291 } | 1287 } |
1292 } | 1288 } |
1293 | 1289 |
1294 bool VoiceChannel::PlayRingbackTone(uint32 ssrc, bool play, bool loop) { | |
1295 return InvokeOnWorker(Bind(&VoiceChannel::PlayRingbackTone_w, | |
1296 this, ssrc, play, loop)); | |
1297 } | |
1298 | |
1299 bool VoiceChannel::PressDTMF(int digit, bool playout) { | 1290 bool VoiceChannel::PressDTMF(int digit, bool playout) { |
1300 int flags = DF_SEND; | 1291 int flags = DF_SEND; |
1301 if (playout) { | 1292 if (playout) { |
1302 flags |= DF_PLAY; | 1293 flags |= DF_PLAY; |
1303 } | 1294 } |
1304 int duration_ms = 160; | 1295 int duration_ms = 160; |
1305 return InsertDtmf(0, digit, duration_ms, flags); | 1296 return InsertDtmf(0, digit, duration_ms, flags); |
1306 } | 1297 } |
1307 | 1298 |
1308 bool VoiceChannel::CanInsertDtmf() { | 1299 bool VoiceChannel::CanInsertDtmf() { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 | 1489 |
1499 if (audio->rtp_header_extensions_set()) { | 1490 if (audio->rtp_header_extensions_set()) { |
1500 MaybeCacheRtpAbsSendTimeHeaderExtension(audio->rtp_header_extensions()); | 1491 MaybeCacheRtpAbsSendTimeHeaderExtension(audio->rtp_header_extensions()); |
1501 } | 1492 } |
1502 | 1493 |
1503 set_remote_content_direction(content->direction()); | 1494 set_remote_content_direction(content->direction()); |
1504 ChangeState(); | 1495 ChangeState(); |
1505 return true; | 1496 return true; |
1506 } | 1497 } |
1507 | 1498 |
1508 bool VoiceChannel::SetRingbackTone_w(const void* buf, int len) { | |
1509 ASSERT(worker_thread() == rtc::Thread::Current()); | |
1510 return media_channel()->SetRingbackTone(static_cast<const char*>(buf), len); | |
1511 } | |
1512 | |
1513 bool VoiceChannel::PlayRingbackTone_w(uint32 ssrc, bool play, bool loop) { | |
1514 ASSERT(worker_thread() == rtc::Thread::Current()); | |
1515 if (play) { | |
1516 LOG(LS_INFO) << "Playing ringback tone, loop=" << loop; | |
1517 } else { | |
1518 LOG(LS_INFO) << "Stopping ringback tone"; | |
1519 } | |
1520 return media_channel()->PlayRingbackTone(ssrc, play, loop); | |
1521 } | |
1522 | |
1523 void VoiceChannel::HandleEarlyMediaTimeout() { | 1499 void VoiceChannel::HandleEarlyMediaTimeout() { |
1524 // This occurs on the main thread, not the worker thread. | 1500 // This occurs on the main thread, not the worker thread. |
1525 if (!received_media_) { | 1501 if (!received_media_) { |
1526 LOG(LS_INFO) << "No early media received before timeout"; | 1502 LOG(LS_INFO) << "No early media received before timeout"; |
1527 SignalEarlyMediaTimeout(this); | 1503 SignalEarlyMediaTimeout(this); |
1528 } | 1504 } |
1529 } | 1505 } |
1530 | 1506 |
1531 bool VoiceChannel::InsertDtmf_w(uint32 ssrc, int event, int duration, | 1507 bool VoiceChannel::InsertDtmf_w(uint32 ssrc, int event, int duration, |
1532 int flags) { | 1508 int flags) { |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 return (data_channel_type_ == DCT_RTP); | 2355 return (data_channel_type_ == DCT_RTP); |
2380 } | 2356 } |
2381 | 2357 |
2382 void DataChannel::OnStreamClosedRemotely(uint32 sid) { | 2358 void DataChannel::OnStreamClosedRemotely(uint32 sid) { |
2383 rtc::TypedMessageData<uint32>* message = | 2359 rtc::TypedMessageData<uint32>* message = |
2384 new rtc::TypedMessageData<uint32>(sid); | 2360 new rtc::TypedMessageData<uint32>(sid); |
2385 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); | 2361 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); |
2386 } | 2362 } |
2387 | 2363 |
2388 } // namespace cricket | 2364 } // namespace cricket |
OLD | NEW |