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 } | |
1383 config_.rtp.extensions = extensions; | |
tommi
2015/11/12 13:44:57
possibly silly question - does the caller need the
the sun
2015/11/12 15:16:43
Yes, the caller needs it. The same extensions are
| |
1384 stream_ = call_->CreateAudioSendStream(config_); | |
tommi
2015/11/12 13:44:56
should we first DCHECK that stream_ is nullptr?
the sun
2015/11/12 15:16:43
Done.
| |
1385 RTC_CHECK(stream_); | |
1386 } | |
1387 | |
1388 webrtc::AudioSendStream::Stats GetStats() const { | |
1389 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
1390 return stream_->GetStats(); | |
tommi
2015/11/12 13:44:56
any chance that stream_ might be null?
the sun
2015/11/12 15:16:44
Yes, stream_ is mutable so a check is in place.
| |
1391 } | |
1392 | |
1361 // Starts the rendering by setting a sink to the renderer to get data | 1393 // Starts the rendering by setting a sink to the renderer to get data |
1362 // callback. | 1394 // callback. |
1363 // This method is called on the libjingle worker thread. | 1395 // This method is called on the libjingle worker thread. |
1364 // TODO(xians): Make sure Start() is called only once. | 1396 // TODO(xians): Make sure Start() is called only once. |
1365 void Start(AudioRenderer* renderer) { | 1397 void Start(AudioRenderer* renderer) { |
1366 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1398 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1367 RTC_DCHECK(renderer); | 1399 RTC_DCHECK(renderer); |
1368 if (renderer_) { | 1400 if (renderer_) { |
1369 RTC_DCHECK(renderer_ == renderer); | 1401 RTC_DCHECK(renderer_ == renderer); |
1370 return; | 1402 return; |
1371 } | 1403 } |
1372 renderer->SetSink(this); | 1404 renderer->SetSink(this); |
1373 renderer_ = renderer; | 1405 renderer_ = renderer; |
1374 } | 1406 } |
1375 | 1407 |
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 | 1408 // Stops rendering by setting the sink of the renderer to nullptr. No data |
1382 // callback will be received after this method. | 1409 // callback will be received after this method. |
1383 // This method is called on the libjingle worker thread. | 1410 // This method is called on the libjingle worker thread. |
1384 void Stop() { | 1411 void Stop() { |
1385 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1412 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1386 if (renderer_) { | 1413 if (renderer_) { |
1387 renderer_->SetSink(nullptr); | 1414 renderer_->SetSink(nullptr); |
1388 renderer_ = nullptr; | 1415 renderer_ = nullptr; |
1389 } | 1416 } |
1390 } | 1417 } |
(...skipping 30 matching lines...) Expand all Loading... | |
1421 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1448 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1422 return channel_; | 1449 return channel_; |
1423 } | 1450 } |
1424 | 1451 |
1425 private: | 1452 private: |
1426 rtc::ThreadChecker worker_thread_checker_; | 1453 rtc::ThreadChecker worker_thread_checker_; |
1427 rtc::ThreadChecker audio_capture_thread_checker_; | 1454 rtc::ThreadChecker audio_capture_thread_checker_; |
1428 const int channel_ = -1; | 1455 const int channel_ = -1; |
1429 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; | 1456 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; |
1430 webrtc::Call* call_ = nullptr; | 1457 webrtc::Call* call_ = nullptr; |
1458 webrtc::AudioSendStream::Config config_; | |
1431 webrtc::AudioSendStream* stream_ = nullptr; | 1459 webrtc::AudioSendStream* stream_ = nullptr; |
tommi
2015/11/12 13:44:56
nit: if you could add a note about ownership or li
the sun
2015/11/12 15:16:44
Done.
| |
1432 | 1460 |
1433 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. | 1461 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. |
1434 // PeerConnection will make sure invalidating the pointer before the object | 1462 // PeerConnection will make sure invalidating the pointer before the object |
1435 // goes away. | 1463 // goes away. |
1436 AudioRenderer* renderer_ = nullptr; | 1464 AudioRenderer* renderer_ = nullptr; |
1437 | 1465 |
1438 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); | 1466 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); |
1439 }; | 1467 }; |
1440 | 1468 |
1441 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { | 1469 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 | 1507 |
1480 // Unregister ourselves from the engine. | 1508 // Unregister ourselves from the engine. |
1481 engine()->UnregisterChannel(this); | 1509 engine()->UnregisterChannel(this); |
1482 } | 1510 } |
1483 | 1511 |
1484 bool WebRtcVoiceMediaChannel::SetSendParameters( | 1512 bool WebRtcVoiceMediaChannel::SetSendParameters( |
1485 const AudioSendParameters& params) { | 1513 const AudioSendParameters& params) { |
1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1514 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1487 // TODO(pthatcher): Refactor this to be more clean now that we have | 1515 // TODO(pthatcher): Refactor this to be more clean now that we have |
1488 // all the information at once. | 1516 // all the information at once. |
1489 return (SetSendCodecs(params.codecs) && | 1517 |
1490 SetSendRtpHeaderExtensions(params.extensions) && | 1518 if (!SetSendCodecs(params.codecs)) { |
1491 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 1519 return false; |
1492 SetOptions(params.options)); | 1520 } |
1521 | |
1522 std::vector<webrtc::RtpExtension> send_rtp_extensions = | |
1523 FindAudioRtpHeaderExtensions(params.extensions); | |
1524 if (send_rtp_extensions_ != send_rtp_extensions) { | |
tommi
2015/11/12 13:44:57
does order matter or is it guaranteed that a vecto
the sun
2015/11/12 15:16:44
Order does not matter.
I don't think a set makes
tommi
2015/11/12 16:36:18
Just in case we're talking about different things,
the sun
2015/11/16 13:49:51
No, you're quite right. Sorry for being daft.
On
tommi
2015/11/16 14:05:27
Yes, another CL is fine.
| |
1525 send_rtp_extensions_ = send_rtp_extensions; | |
tommi
2015/11/12 13:44:56
do the send streams have a pointer back to the cha
the sun
2015/11/12 15:16:44
There is some pessimisation here, yes. Keep in min
tommi
2015/11/12 16:36:18
Agreed. I don't want to add a circular relationsh
the sun
2015/11/16 13:49:51
Well, strictly speaking there is an implicit circu
tommi
2015/11/16 14:05:27
Acknowledged.
| |
1526 for (auto& it : send_streams_) { | |
1527 it.second->RecreateAudioSendStream(send_rtp_extensions); | |
1528 } | |
1529 } | |
1530 | |
1531 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { | |
1532 return false; | |
1533 } | |
1534 if (!SetOptions(params.options)) { | |
tommi
2015/11/12 13:44:56
nit:
return SetOptions(params.options);
the sun
2015/11/12 15:16:43
Done.
| |
1535 return false; | |
1536 } | |
1537 return true; | |
1493 } | 1538 } |
1494 | 1539 |
1495 bool WebRtcVoiceMediaChannel::SetRecvParameters( | 1540 bool WebRtcVoiceMediaChannel::SetRecvParameters( |
1496 const AudioRecvParameters& params) { | 1541 const AudioRecvParameters& params) { |
1497 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1542 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1498 // TODO(pthatcher): Refactor this to be more clean now that we have | 1543 // TODO(pthatcher): Refactor this to be more clean now that we have |
1499 // all the information at once. | 1544 // all the information at once. |
1500 return (SetRecvCodecs(params.codecs) && | 1545 return (SetRecvCodecs(params.codecs) && |
1501 SetRecvRtpHeaderExtensions(params.extensions)); | 1546 SetRecvRtpHeaderExtensions(params.extensions)); |
1502 } | 1547 } |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1863 | 1908 |
1864 for (const auto& ch : receive_channels_) { | 1909 for (const auto& ch : receive_channels_) { |
1865 if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) { | 1910 if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) { |
1866 return false; | 1911 return false; |
1867 } | 1912 } |
1868 } | 1913 } |
1869 | 1914 |
1870 receive_extensions_ = extensions; | 1915 receive_extensions_ = extensions; |
1871 | 1916 |
1872 // Recreate AudioReceiveStream:s. | 1917 // Recreate AudioReceiveStream:s. |
1873 { | 1918 recv_rtp_extensions_ = FindAudioRtpHeaderExtensions(extensions); |
1874 std::vector<webrtc::RtpExtension> exts; | 1919 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 | 1920 |
1894 return true; | 1921 return true; |
1895 } | 1922 } |
1896 | 1923 |
1897 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( | 1924 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( |
1898 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { | 1925 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { |
1899 const RtpHeaderExtension* audio_level_extension = | 1926 const RtpHeaderExtension* audio_level_extension = |
1900 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); | 1927 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); |
1901 if (!SetHeaderExtension( | 1928 if (!SetHeaderExtension( |
1902 &webrtc::VoERTP_RTCP::SetReceiveAudioLevelIndicationStatus, channel_id, | 1929 &webrtc::VoERTP_RTCP::SetReceiveAudioLevelIndicationStatus, channel_id, |
1903 audio_level_extension)) { | 1930 audio_level_extension)) { |
1904 return false; | 1931 return false; |
1905 } | 1932 } |
1906 | 1933 |
1907 const RtpHeaderExtension* send_time_extension = | 1934 const RtpHeaderExtension* send_time_extension = |
1908 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); | 1935 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); |
1909 if (!SetHeaderExtension( | 1936 if (!SetHeaderExtension( |
1910 &webrtc::VoERTP_RTCP::SetReceiveAbsoluteSenderTimeStatus, channel_id, | 1937 &webrtc::VoERTP_RTCP::SetReceiveAbsoluteSenderTimeStatus, channel_id, |
1911 send_time_extension)) { | 1938 send_time_extension)) { |
1912 return false; | 1939 return false; |
1913 } | 1940 } |
1914 | 1941 |
1915 return true; | 1942 return true; |
1916 } | 1943 } |
1917 | 1944 |
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) { | 1945 bool WebRtcVoiceMediaChannel::SetPlayout(bool playout) { |
1958 desired_playout_ = playout; | 1946 desired_playout_ = playout; |
1959 return ChangePlayout(desired_playout_); | 1947 return ChangePlayout(desired_playout_); |
1960 } | 1948 } |
1961 | 1949 |
1962 bool WebRtcVoiceMediaChannel::PausePlayout() { | 1950 bool WebRtcVoiceMediaChannel::PausePlayout() { |
1963 return ChangePlayout(false); | 1951 return ChangePlayout(false); |
1964 } | 1952 } |
1965 | 1953 |
1966 bool WebRtcVoiceMediaChannel::ResumePlayout() { | 1954 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; | 2088 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
2101 return false; | 2089 return false; |
2102 } | 2090 } |
2103 | 2091 |
2104 // Create a new channel for sending audio data. | 2092 // Create a new channel for sending audio data. |
2105 int channel = CreateVoEChannel(); | 2093 int channel = CreateVoEChannel(); |
2106 if (channel == -1) { | 2094 if (channel == -1) { |
2107 return false; | 2095 return false; |
2108 } | 2096 } |
2109 | 2097 |
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 | 2098 // Save the channel to send_streams_, so that RemoveSendStream() can still |
2131 // delete the channel in case failure happens below. | 2099 // delete the channel in case failure happens below. |
2132 webrtc::AudioTransport* audio_transport = | 2100 webrtc::AudioTransport* audio_transport = |
2133 engine()->voe()->base()->audio_transport(); | 2101 engine()->voe()->base()->audio_transport(); |
2134 send_streams_.insert( | 2102 send_streams_.insert(std::make_pair(ssrc, new WebRtcAudioSendStream( |
2135 std::make_pair(ssrc, | 2103 channel, audio_transport, ssrc, sp.cname, send_rtp_extensions_, call_))); |
2136 new WebRtcAudioSendStream(channel, audio_transport, ssrc, call_))); | |
2137 | 2104 |
2138 // Set the current codecs to be used for the new channel. We need to do this | 2105 // 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 | 2106 // after adding the channel to send_channels_, because of how max bitrate is |
2140 // currently being configured by SetSendCodec(). | 2107 // currently being configured by SetSendCodec(). |
2141 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) { | 2108 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) { |
2142 RemoveSendStream(ssrc); | 2109 RemoveSendStream(ssrc); |
2143 return false; | 2110 return false; |
2144 } | 2111 } |
2145 | 2112 |
2146 // At this point the channel's local SSRC has been updated. If the channel is | 2113 // 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 | 2125 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel |
2159 << " is associated with channel #" << channel << "."; | 2126 << " is associated with channel #" << channel << "."; |
2160 } | 2127 } |
2161 } | 2128 } |
2162 | 2129 |
2163 return ChangeSend(channel, desired_send_); | 2130 return ChangeSend(channel, desired_send_); |
2164 } | 2131 } |
2165 | 2132 |
2166 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { | 2133 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { |
2167 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2134 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2135 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; | |
2136 | |
2168 auto it = send_streams_.find(ssrc); | 2137 auto it = send_streams_.find(ssrc); |
2169 if (it == send_streams_.end()) { | 2138 if (it == send_streams_.end()) { |
2170 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2139 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
2171 << " which doesn't exist."; | 2140 << " which doesn't exist."; |
2172 return false; | 2141 return false; |
2173 } | 2142 } |
2174 | 2143 |
2175 int channel = it->second->channel(); | 2144 int channel = it->second->channel(); |
2176 ChangeSend(channel, SEND_NOTHING); | 2145 ChangeSend(channel, SEND_NOTHING); |
2177 | 2146 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2858 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 2827 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
2859 return false; | 2828 return false; |
2860 } | 2829 } |
2861 } | 2830 } |
2862 return true; | 2831 return true; |
2863 } | 2832 } |
2864 | 2833 |
2865 } // namespace cricket | 2834 } // namespace cricket |
2866 | 2835 |
2867 #endif // HAVE_WEBRTC_VOICE | 2836 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |