| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 std::string GetEnableString(bool enable) { | 389 std::string GetEnableString(bool enable) { |
| 390 return enable ? "enable" : "disable"; | 390 return enable ? "enable" : "disable"; |
| 391 } | 391 } |
| 392 | 392 |
| 393 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { | 393 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { |
| 394 webrtc::AudioState::Config config; | 394 webrtc::AudioState::Config config; |
| 395 config.voice_engine = voe_wrapper->engine(); | 395 config.voice_engine = voe_wrapper->engine(); |
| 396 return config; | 396 return config; |
| 397 } | 397 } |
| 398 | 398 |
| 399 std::vector<webrtc::RtpExtension> FindAudioRtpHeaderExtensions( |
| 400 const std::vector<RtpHeaderExtension>& extensions) { |
| 401 std::vector<webrtc::RtpExtension> result; |
| 402 for (const auto& extension : extensions) { |
| 403 if (extension.uri == kRtpAbsoluteSenderTimeHeaderExtension || |
| 404 extension.uri == kRtpAudioLevelHeaderExtension) { |
| 405 result.push_back({extension.uri, extension.id}); |
| 406 } else { |
| 407 LOG(LS_WARNING) << "Unsupported RTP extension: " << extension.ToString(); |
| 408 } |
| 409 } |
| 410 return result; |
| 411 } |
| 399 } // namespace { | 412 } // namespace { |
| 400 | 413 |
| 401 WebRtcVoiceEngine::WebRtcVoiceEngine() | 414 WebRtcVoiceEngine::WebRtcVoiceEngine() |
| 402 : voe_wrapper_(new VoEWrapper()), | 415 : voe_wrapper_(new VoEWrapper()), |
| 403 tracing_(new VoETraceWrapper()), | 416 tracing_(new VoETraceWrapper()), |
| 404 audio_state_(webrtc::AudioState::Create(MakeAudioStateConfig(voe()))), | 417 audio_state_(webrtc::AudioState::Create(MakeAudioStateConfig(voe()))), |
| 405 log_filter_(SeverityToFilter(kDefaultLogSeverity)) { | 418 log_filter_(SeverityToFilter(kDefaultLogSeverity)) { |
| 406 Construct(); | 419 Construct(); |
| 407 } | 420 } |
| 408 | 421 |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 | 1343 |
| 1331 int WebRtcVoiceEngine::CreateVoEChannel() { | 1344 int WebRtcVoiceEngine::CreateVoEChannel() { |
| 1332 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1345 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1333 return voe_wrapper_->base()->CreateChannel(voe_config_); | 1346 return voe_wrapper_->base()->CreateChannel(voe_config_); |
| 1334 } | 1347 } |
| 1335 | 1348 |
| 1336 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream | 1349 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream |
| 1337 : public AudioRenderer::Sink { | 1350 : public AudioRenderer::Sink { |
| 1338 public: | 1351 public: |
| 1339 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport, | 1352 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport, |
| 1340 uint32_t ssrc, webrtc::Call* call) | 1353 uint32_t ssrc, const std::string& c_name, |
| 1354 const std::vector<webrtc::RtpExtension>& extensions, |
| 1355 webrtc::Call* call) |
| 1341 : channel_(ch), | 1356 : channel_(ch), |
| 1342 voe_audio_transport_(voe_audio_transport), | 1357 voe_audio_transport_(voe_audio_transport), |
| 1343 call_(call) { | 1358 call_(call), |
| 1359 config_(nullptr) { |
| 1344 RTC_DCHECK_GE(ch, 0); | 1360 RTC_DCHECK_GE(ch, 0); |
| 1345 // TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore: | 1361 // TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore: |
| 1346 // RTC_DCHECK(voe_audio_transport); | 1362 // RTC_DCHECK(voe_audio_transport); |
| 1347 RTC_DCHECK(call); | 1363 RTC_DCHECK(call); |
| 1348 audio_capture_thread_checker_.DetachFromThread(); | 1364 audio_capture_thread_checker_.DetachFromThread(); |
| 1349 webrtc::AudioSendStream::Config config(nullptr); | 1365 config_.rtp.ssrc = ssrc; |
| 1350 config.voe_channel_id = channel_; | 1366 config_.rtp.c_name = c_name; |
| 1351 config.rtp.ssrc = ssrc; | 1367 config_.voe_channel_id = ch; |
| 1352 stream_ = call_->CreateAudioSendStream(config); | 1368 RecreateAudioSendStream(extensions); |
| 1353 RTC_DCHECK(stream_); | |
| 1354 } | 1369 } |
| 1370 |
| 1355 ~WebRtcAudioSendStream() override { | 1371 ~WebRtcAudioSendStream() override { |
| 1356 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1372 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1357 Stop(); | 1373 Stop(); |
| 1358 call_->DestroyAudioSendStream(stream_); | 1374 call_->DestroyAudioSendStream(stream_); |
| 1359 } | 1375 } |
| 1360 | 1376 |
| 1377 void RecreateAudioSendStream( |
| 1378 const std::vector<webrtc::RtpExtension>& extensions) { |
| 1379 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1380 if (stream_) { |
| 1381 call_->DestroyAudioSendStream(stream_); |
| 1382 stream_ = nullptr; |
| 1383 } |
| 1384 config_.rtp.extensions = extensions; |
| 1385 RTC_DCHECK(!stream_); |
| 1386 stream_ = call_->CreateAudioSendStream(config_); |
| 1387 RTC_CHECK(stream_); |
| 1388 } |
| 1389 |
| 1390 webrtc::AudioSendStream::Stats GetStats() const { |
| 1391 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1392 RTC_DCHECK(stream_); |
| 1393 return stream_->GetStats(); |
| 1394 } |
| 1395 |
| 1361 // Starts the rendering by setting a sink to the renderer to get data | 1396 // Starts the rendering by setting a sink to the renderer to get data |
| 1362 // callback. | 1397 // callback. |
| 1363 // This method is called on the libjingle worker thread. | 1398 // This method is called on the libjingle worker thread. |
| 1364 // TODO(xians): Make sure Start() is called only once. | 1399 // TODO(xians): Make sure Start() is called only once. |
| 1365 void Start(AudioRenderer* renderer) { | 1400 void Start(AudioRenderer* renderer) { |
| 1366 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1401 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1367 RTC_DCHECK(renderer); | 1402 RTC_DCHECK(renderer); |
| 1368 if (renderer_) { | 1403 if (renderer_) { |
| 1369 RTC_DCHECK(renderer_ == renderer); | 1404 RTC_DCHECK(renderer_ == renderer); |
| 1370 return; | 1405 return; |
| 1371 } | 1406 } |
| 1372 renderer->SetSink(this); | 1407 renderer->SetSink(this); |
| 1373 renderer_ = renderer; | 1408 renderer_ = renderer; |
| 1374 } | 1409 } |
| 1375 | 1410 |
| 1376 webrtc::AudioSendStream::Stats GetStats() const { | |
| 1377 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 1378 return stream_->GetStats(); | |
| 1379 } | |
| 1380 | |
| 1381 // Stops rendering by setting the sink of the renderer to nullptr. No data | 1411 // Stops rendering by setting the sink of the renderer to nullptr. No data |
| 1382 // callback will be received after this method. | 1412 // callback will be received after this method. |
| 1383 // This method is called on the libjingle worker thread. | 1413 // This method is called on the libjingle worker thread. |
| 1384 void Stop() { | 1414 void Stop() { |
| 1385 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1415 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1386 if (renderer_) { | 1416 if (renderer_) { |
| 1387 renderer_->SetSink(nullptr); | 1417 renderer_->SetSink(nullptr); |
| 1388 renderer_ = nullptr; | 1418 renderer_ = nullptr; |
| 1389 } | 1419 } |
| 1390 } | 1420 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1421 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1451 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1422 return channel_; | 1452 return channel_; |
| 1423 } | 1453 } |
| 1424 | 1454 |
| 1425 private: | 1455 private: |
| 1426 rtc::ThreadChecker worker_thread_checker_; | 1456 rtc::ThreadChecker worker_thread_checker_; |
| 1427 rtc::ThreadChecker audio_capture_thread_checker_; | 1457 rtc::ThreadChecker audio_capture_thread_checker_; |
| 1428 const int channel_ = -1; | 1458 const int channel_ = -1; |
| 1429 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; | 1459 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; |
| 1430 webrtc::Call* call_ = nullptr; | 1460 webrtc::Call* call_ = nullptr; |
| 1461 webrtc::AudioSendStream::Config config_; |
| 1462 // The stream is owned by WebRtcAudioSendStream and may be reallocated if |
| 1463 // configuration changes. |
| 1431 webrtc::AudioSendStream* stream_ = nullptr; | 1464 webrtc::AudioSendStream* stream_ = nullptr; |
| 1432 | 1465 |
| 1433 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. | 1466 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. |
| 1434 // PeerConnection will make sure invalidating the pointer before the object | 1467 // PeerConnection will make sure invalidating the pointer before the object |
| 1435 // goes away. | 1468 // goes away. |
| 1436 AudioRenderer* renderer_ = nullptr; | 1469 AudioRenderer* renderer_ = nullptr; |
| 1437 | 1470 |
| 1438 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); | 1471 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); |
| 1439 }; | 1472 }; |
| 1440 | 1473 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 | 1512 |
| 1480 // Unregister ourselves from the engine. | 1513 // Unregister ourselves from the engine. |
| 1481 engine()->UnregisterChannel(this); | 1514 engine()->UnregisterChannel(this); |
| 1482 } | 1515 } |
| 1483 | 1516 |
| 1484 bool WebRtcVoiceMediaChannel::SetSendParameters( | 1517 bool WebRtcVoiceMediaChannel::SetSendParameters( |
| 1485 const AudioSendParameters& params) { | 1518 const AudioSendParameters& params) { |
| 1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1519 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1487 // TODO(pthatcher): Refactor this to be more clean now that we have | 1520 // TODO(pthatcher): Refactor this to be more clean now that we have |
| 1488 // all the information at once. | 1521 // all the information at once. |
| 1489 return (SetSendCodecs(params.codecs) && | 1522 |
| 1490 SetSendRtpHeaderExtensions(params.extensions) && | 1523 if (!SetSendCodecs(params.codecs)) { |
| 1491 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 1524 return false; |
| 1492 SetOptions(params.options)); | 1525 } |
| 1526 |
| 1527 std::vector<webrtc::RtpExtension> send_rtp_extensions = |
| 1528 FindAudioRtpHeaderExtensions(params.extensions); |
| 1529 if (send_rtp_extensions_ != send_rtp_extensions) { |
| 1530 send_rtp_extensions_.swap(send_rtp_extensions); |
| 1531 for (auto& it : send_streams_) { |
| 1532 it.second->RecreateAudioSendStream(send_rtp_extensions_); |
| 1533 } |
| 1534 } |
| 1535 |
| 1536 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { |
| 1537 return false; |
| 1538 } |
| 1539 return SetOptions(params.options); |
| 1493 } | 1540 } |
| 1494 | 1541 |
| 1495 bool WebRtcVoiceMediaChannel::SetRecvParameters( | 1542 bool WebRtcVoiceMediaChannel::SetRecvParameters( |
| 1496 const AudioRecvParameters& params) { | 1543 const AudioRecvParameters& params) { |
| 1497 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1544 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1498 // TODO(pthatcher): Refactor this to be more clean now that we have | 1545 // TODO(pthatcher): Refactor this to be more clean now that we have |
| 1499 // all the information at once. | 1546 // all the information at once. |
| 1500 return (SetRecvCodecs(params.codecs) && | 1547 return (SetRecvCodecs(params.codecs) && |
| 1501 SetRecvRtpHeaderExtensions(params.extensions)); | 1548 SetRecvRtpHeaderExtensions(params.extensions)); |
| 1502 } | 1549 } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 | 1910 |
| 1864 for (const auto& ch : receive_channels_) { | 1911 for (const auto& ch : receive_channels_) { |
| 1865 if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) { | 1912 if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) { |
| 1866 return false; | 1913 return false; |
| 1867 } | 1914 } |
| 1868 } | 1915 } |
| 1869 | 1916 |
| 1870 receive_extensions_ = extensions; | 1917 receive_extensions_ = extensions; |
| 1871 | 1918 |
| 1872 // Recreate AudioReceiveStream:s. | 1919 // Recreate AudioReceiveStream:s. |
| 1873 { | 1920 recv_rtp_extensions_ = FindAudioRtpHeaderExtensions(extensions); |
| 1874 std::vector<webrtc::RtpExtension> exts; | 1921 RecreateAudioReceiveStreams(); |
| 1875 | |
| 1876 const RtpHeaderExtension* audio_level_extension = | |
| 1877 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); | |
| 1878 if (audio_level_extension) { | |
| 1879 exts.push_back({ | |
| 1880 kRtpAudioLevelHeaderExtension, audio_level_extension->id}); | |
| 1881 } | |
| 1882 | |
| 1883 const RtpHeaderExtension* send_time_extension = | |
| 1884 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); | |
| 1885 if (send_time_extension) { | |
| 1886 exts.push_back({ | |
| 1887 kRtpAbsoluteSenderTimeHeaderExtension, send_time_extension->id}); | |
| 1888 } | |
| 1889 | |
| 1890 recv_rtp_extensions_.swap(exts); | |
| 1891 RecreateAudioReceiveStreams(); | |
| 1892 } | |
| 1893 | 1922 |
| 1894 return true; | 1923 return true; |
| 1895 } | 1924 } |
| 1896 | 1925 |
| 1897 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( | 1926 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( |
| 1898 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { | 1927 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { |
| 1899 const RtpHeaderExtension* audio_level_extension = | 1928 const RtpHeaderExtension* audio_level_extension = |
| 1900 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); | 1929 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); |
| 1901 if (!SetHeaderExtension( | 1930 if (!SetHeaderExtension( |
| 1902 &webrtc::VoERTP_RTCP::SetReceiveAudioLevelIndicationStatus, channel_id, | 1931 &webrtc::VoERTP_RTCP::SetReceiveAudioLevelIndicationStatus, channel_id, |
| 1903 audio_level_extension)) { | 1932 audio_level_extension)) { |
| 1904 return false; | 1933 return false; |
| 1905 } | 1934 } |
| 1906 | 1935 |
| 1907 const RtpHeaderExtension* send_time_extension = | 1936 const RtpHeaderExtension* send_time_extension = |
| 1908 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); | 1937 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); |
| 1909 if (!SetHeaderExtension( | 1938 if (!SetHeaderExtension( |
| 1910 &webrtc::VoERTP_RTCP::SetReceiveAbsoluteSenderTimeStatus, channel_id, | 1939 &webrtc::VoERTP_RTCP::SetReceiveAbsoluteSenderTimeStatus, channel_id, |
| 1911 send_time_extension)) { | 1940 send_time_extension)) { |
| 1912 return false; | 1941 return false; |
| 1913 } | 1942 } |
| 1914 | 1943 |
| 1915 return true; | 1944 return true; |
| 1916 } | 1945 } |
| 1917 | 1946 |
| 1918 bool WebRtcVoiceMediaChannel::SetSendRtpHeaderExtensions( | |
| 1919 const std::vector<RtpHeaderExtension>& extensions) { | |
| 1920 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 1921 if (send_extensions_ == extensions) { | |
| 1922 return true; | |
| 1923 } | |
| 1924 | |
| 1925 for (const auto& ch : send_streams_) { | |
| 1926 if (!SetChannelSendRtpHeaderExtensions(ch.second->channel(), extensions)) { | |
| 1927 return false; | |
| 1928 } | |
| 1929 } | |
| 1930 | |
| 1931 send_extensions_ = extensions; | |
| 1932 return true; | |
| 1933 } | |
| 1934 | |
| 1935 bool WebRtcVoiceMediaChannel::SetChannelSendRtpHeaderExtensions( | |
| 1936 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { | |
| 1937 const RtpHeaderExtension* audio_level_extension = | |
| 1938 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); | |
| 1939 | |
| 1940 if (!SetHeaderExtension( | |
| 1941 &webrtc::VoERTP_RTCP::SetSendAudioLevelIndicationStatus, channel_id, | |
| 1942 audio_level_extension)) { | |
| 1943 return false; | |
| 1944 } | |
| 1945 | |
| 1946 const RtpHeaderExtension* send_time_extension = | |
| 1947 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); | |
| 1948 if (!SetHeaderExtension( | |
| 1949 &webrtc::VoERTP_RTCP::SetSendAbsoluteSenderTimeStatus, channel_id, | |
| 1950 send_time_extension)) { | |
| 1951 return false; | |
| 1952 } | |
| 1953 | |
| 1954 return true; | |
| 1955 } | |
| 1956 | |
| 1957 bool WebRtcVoiceMediaChannel::SetPlayout(bool playout) { | 1947 bool WebRtcVoiceMediaChannel::SetPlayout(bool playout) { |
| 1958 desired_playout_ = playout; | 1948 desired_playout_ = playout; |
| 1959 return ChangePlayout(desired_playout_); | 1949 return ChangePlayout(desired_playout_); |
| 1960 } | 1950 } |
| 1961 | 1951 |
| 1962 bool WebRtcVoiceMediaChannel::PausePlayout() { | 1952 bool WebRtcVoiceMediaChannel::PausePlayout() { |
| 1963 return ChangePlayout(false); | 1953 return ChangePlayout(false); |
| 1964 } | 1954 } |
| 1965 | 1955 |
| 1966 bool WebRtcVoiceMediaChannel::ResumePlayout() { | 1956 bool WebRtcVoiceMediaChannel::ResumePlayout() { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2090 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
| 2101 return false; | 2091 return false; |
| 2102 } | 2092 } |
| 2103 | 2093 |
| 2104 // Create a new channel for sending audio data. | 2094 // Create a new channel for sending audio data. |
| 2105 int channel = CreateVoEChannel(); | 2095 int channel = CreateVoEChannel(); |
| 2106 if (channel == -1) { | 2096 if (channel == -1) { |
| 2107 return false; | 2097 return false; |
| 2108 } | 2098 } |
| 2109 | 2099 |
| 2110 // Enable RTCP (for quality stats and feedback messages). | |
| 2111 if (engine()->voe()->rtp()->SetRTCPStatus(channel, true) == -1) { | |
| 2112 LOG_RTCERR2(SetRTCPStatus, channel, 1); | |
| 2113 } | |
| 2114 | |
| 2115 SetChannelSendRtpHeaderExtensions(channel, send_extensions_); | |
| 2116 | |
| 2117 // Set the local (send) SSRC. | |
| 2118 if (engine()->voe()->rtp()->SetLocalSSRC(channel, ssrc) == -1) { | |
| 2119 LOG_RTCERR2(SetLocalSSRC, channel, ssrc); | |
| 2120 DeleteChannel(channel); | |
| 2121 return false; | |
| 2122 } | |
| 2123 | |
| 2124 if (engine()->voe()->rtp()->SetRTCP_CNAME(channel, sp.cname.c_str()) == -1) { | |
| 2125 LOG_RTCERR2(SetRTCP_CNAME, channel, sp.cname); | |
| 2126 DeleteChannel(channel); | |
| 2127 return false; | |
| 2128 } | |
| 2129 | |
| 2130 // Save the channel to send_streams_, so that RemoveSendStream() can still | 2100 // Save the channel to send_streams_, so that RemoveSendStream() can still |
| 2131 // delete the channel in case failure happens below. | 2101 // delete the channel in case failure happens below. |
| 2132 webrtc::AudioTransport* audio_transport = | 2102 webrtc::AudioTransport* audio_transport = |
| 2133 engine()->voe()->base()->audio_transport(); | 2103 engine()->voe()->base()->audio_transport(); |
| 2134 send_streams_.insert( | 2104 send_streams_.insert(std::make_pair(ssrc, new WebRtcAudioSendStream( |
| 2135 std::make_pair(ssrc, | 2105 channel, audio_transport, ssrc, sp.cname, send_rtp_extensions_, call_))); |
| 2136 new WebRtcAudioSendStream(channel, audio_transport, ssrc, call_))); | |
| 2137 | 2106 |
| 2138 // Set the current codecs to be used for the new channel. We need to do this | 2107 // Set the current codecs to be used for the new channel. We need to do this |
| 2139 // after adding the channel to send_channels_, because of how max bitrate is | 2108 // after adding the channel to send_channels_, because of how max bitrate is |
| 2140 // currently being configured by SetSendCodec(). | 2109 // currently being configured by SetSendCodec(). |
| 2141 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) { | 2110 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) { |
| 2142 RemoveSendStream(ssrc); | 2111 RemoveSendStream(ssrc); |
| 2143 return false; | 2112 return false; |
| 2144 } | 2113 } |
| 2145 | 2114 |
| 2146 // At this point the channel's local SSRC has been updated. If the channel is | 2115 // At this point the channel's local SSRC has been updated. If the channel is |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2158 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel | 2127 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel |
| 2159 << " is associated with channel #" << channel << "."; | 2128 << " is associated with channel #" << channel << "."; |
| 2160 } | 2129 } |
| 2161 } | 2130 } |
| 2162 | 2131 |
| 2163 return ChangeSend(channel, desired_send_); | 2132 return ChangeSend(channel, desired_send_); |
| 2164 } | 2133 } |
| 2165 | 2134 |
| 2166 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { | 2135 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { |
| 2167 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2136 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 2137 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; |
| 2138 |
| 2168 auto it = send_streams_.find(ssrc); | 2139 auto it = send_streams_.find(ssrc); |
| 2169 if (it == send_streams_.end()) { | 2140 if (it == send_streams_.end()) { |
| 2170 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2141 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
| 2171 << " which doesn't exist."; | 2142 << " which doesn't exist."; |
| 2172 return false; | 2143 return false; |
| 2173 } | 2144 } |
| 2174 | 2145 |
| 2175 int channel = it->second->channel(); | 2146 int channel = it->second->channel(); |
| 2176 ChangeSend(channel, SEND_NOTHING); | 2147 ChangeSend(channel, SEND_NOTHING); |
| 2177 | 2148 |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2858 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 2829 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
| 2859 return false; | 2830 return false; |
| 2860 } | 2831 } |
| 2861 } | 2832 } |
| 2862 return true; | 2833 return true; |
| 2863 } | 2834 } |
| 2864 | 2835 |
| 2865 } // namespace cricket | 2836 } // namespace cricket |
| 2866 | 2837 |
| 2867 #endif // HAVE_WEBRTC_VOICE | 2838 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |