| 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 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 | 1383 |
| 1384 // Protects |renderer_| in Start(), Stop() and OnClose(). | 1384 // Protects |renderer_| in Start(), Stop() and OnClose(). |
| 1385 rtc::CriticalSection lock_; | 1385 rtc::CriticalSection lock_; |
| 1386 }; | 1386 }; |
| 1387 | 1387 |
| 1388 // WebRtcVoiceMediaChannel | 1388 // WebRtcVoiceMediaChannel |
| 1389 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 1389 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
| 1390 const AudioOptions& options, | 1390 const AudioOptions& options, |
| 1391 webrtc::Call* call) | 1391 webrtc::Call* call) |
| 1392 : engine_(engine), | 1392 : engine_(engine), |
| 1393 voe_channel_(engine->CreateMediaVoiceChannel()), | 1393 default_send_channel_id_(engine->CreateMediaVoiceChannel()), |
| 1394 send_bitrate_setting_(false), | 1394 send_bitrate_setting_(false), |
| 1395 send_bitrate_bps_(0), | 1395 send_bitrate_bps_(0), |
| 1396 options_(), | 1396 options_(), |
| 1397 dtmf_allowed_(false), | 1397 dtmf_allowed_(false), |
| 1398 desired_playout_(false), | 1398 desired_playout_(false), |
| 1399 nack_enabled_(false), | 1399 nack_enabled_(false), |
| 1400 playout_(false), | 1400 playout_(false), |
| 1401 typing_noise_detected_(false), | 1401 typing_noise_detected_(false), |
| 1402 desired_send_(SEND_NOTHING), | 1402 desired_send_(SEND_NOTHING), |
| 1403 send_(SEND_NOTHING), | 1403 send_(SEND_NOTHING), |
| 1404 call_(call), | 1404 call_(call), |
| 1405 default_receive_ssrc_(0) { | 1405 default_receive_ssrc_(0) { |
| 1406 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1406 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1407 engine->RegisterChannel(this); | 1407 engine->RegisterChannel(this); |
| 1408 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel " | 1408 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel " |
| 1409 << voe_channel(); | 1409 << default_send_channel_id(); |
| 1410 RTC_DCHECK(nullptr != call); | 1410 RTC_DCHECK(nullptr != call); |
| 1411 ConfigureSendChannel(voe_channel()); | 1411 ConfigureSendChannel(default_send_channel_id()); |
| 1412 SetOptions(options); | 1412 SetOptions(options); |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { | 1415 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { |
| 1416 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1416 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1417 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel " | 1417 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel " |
| 1418 << voe_channel(); | 1418 << default_send_channel_id(); |
| 1419 | 1419 |
| 1420 // Remove any remaining send streams, the default channel will be deleted | 1420 // Remove any remaining send streams, the default channel will be deleted |
| 1421 // later. | 1421 // later. |
| 1422 while (!send_channels_.empty()) { | 1422 while (!send_channels_.empty()) { |
| 1423 RemoveSendStream(send_channels_.begin()->first); | 1423 RemoveSendStream(send_channels_.begin()->first); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 // Unregister ourselves from the engine. | 1426 // Unregister ourselves from the engine. |
| 1427 engine()->UnregisterChannel(this); | 1427 engine()->UnregisterChannel(this); |
| 1428 | 1428 |
| 1429 // Remove any remaining streams. | 1429 // Remove any remaining streams. |
| 1430 while (!receive_channels_.empty()) { | 1430 while (!receive_channels_.empty()) { |
| 1431 RemoveRecvStream(receive_channels_.begin()->first); | 1431 RemoveRecvStream(receive_channels_.begin()->first); |
| 1432 } | 1432 } |
| 1433 RTC_DCHECK(receive_streams_.empty()); | 1433 RTC_DCHECK(receive_streams_.empty()); |
| 1434 | 1434 |
| 1435 // Delete the default channel. | 1435 // Delete the default channel. |
| 1436 DeleteChannel(voe_channel()); | 1436 DeleteChannel(default_send_channel_id()); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 bool WebRtcVoiceMediaChannel::SetSendParameters( | 1439 bool WebRtcVoiceMediaChannel::SetSendParameters( |
| 1440 const AudioSendParameters& params) { | 1440 const AudioSendParameters& params) { |
| 1441 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1441 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1442 // TODO(pthatcher): Refactor this to be more clean now that we have | 1442 // TODO(pthatcher): Refactor this to be more clean now that we have |
| 1443 // all the information at once. | 1443 // all the information at once. |
| 1444 return (SetSendCodecs(params.codecs) && | 1444 return (SetSendCodecs(params.codecs) && |
| 1445 SetSendRtpHeaderExtensions(params.extensions) && | 1445 SetSendRtpHeaderExtensions(params.extensions) && |
| 1446 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 1446 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 } | 1478 } |
| 1479 | 1479 |
| 1480 if (dscp_option_changed) { | 1480 if (dscp_option_changed) { |
| 1481 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; | 1481 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; |
| 1482 if (options_.dscp.GetWithDefaultIfUnset(false)) | 1482 if (options_.dscp.GetWithDefaultIfUnset(false)) |
| 1483 dscp = kAudioDscpValue; | 1483 dscp = kAudioDscpValue; |
| 1484 if (MediaChannel::SetDscp(dscp) != 0) { | 1484 if (MediaChannel::SetDscp(dscp) != 0) { |
| 1485 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; | 1485 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; |
| 1486 } | 1486 } |
| 1487 } | 1487 } |
| 1488 |
| 1488 RecreateAudioReceiveStreams(); | 1489 RecreateAudioReceiveStreams(); |
| 1490 |
| 1489 LOG(LS_INFO) << "Set voice channel options. Current options: " | 1491 LOG(LS_INFO) << "Set voice channel options. Current options: " |
| 1490 << options_.ToString(); | 1492 << options_.ToString(); |
| 1491 return true; | 1493 return true; |
| 1492 } | 1494 } |
| 1493 | 1495 |
| 1494 bool WebRtcVoiceMediaChannel::SetRecvCodecs( | 1496 bool WebRtcVoiceMediaChannel::SetRecvCodecs( |
| 1495 const std::vector<AudioCodec>& codecs) { | 1497 const std::vector<AudioCodec>& codecs) { |
| 1498 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1499 |
| 1496 // Set the payload types to be used for incoming media. | 1500 // Set the payload types to be used for incoming media. |
| 1497 LOG(LS_INFO) << "Setting receive voice codecs."; | 1501 LOG(LS_INFO) << "Setting receive voice codecs."; |
| 1498 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1499 | 1502 |
| 1500 if (!VerifyUniquePayloadTypes(codecs)) { | 1503 if (!VerifyUniquePayloadTypes(codecs)) { |
| 1501 LOG(LS_ERROR) << "Codec payload types overlap."; | 1504 LOG(LS_ERROR) << "Codec payload types overlap."; |
| 1502 return false; | 1505 return false; |
| 1503 } | 1506 } |
| 1504 | 1507 |
| 1505 std::vector<AudioCodec> new_codecs; | 1508 std::vector<AudioCodec> new_codecs; |
| 1506 // Find all new codecs. We allow adding new codecs but don't allow changing | 1509 // Find all new codecs. We allow adding new codecs but don't allow changing |
| 1507 // the payload type of codecs that is already configured since we might | 1510 // the payload type of codecs that is already configured since we might |
| 1508 // already be receiving packets with that payload type. | 1511 // already be receiving packets with that payload type. |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 | 1826 |
| 1824 bool WebRtcVoiceMediaChannel::SetRecvRtpHeaderExtensions( | 1827 bool WebRtcVoiceMediaChannel::SetRecvRtpHeaderExtensions( |
| 1825 const std::vector<RtpHeaderExtension>& extensions) { | 1828 const std::vector<RtpHeaderExtension>& extensions) { |
| 1826 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1829 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1827 if (receive_extensions_ == extensions) { | 1830 if (receive_extensions_ == extensions) { |
| 1828 return true; | 1831 return true; |
| 1829 } | 1832 } |
| 1830 | 1833 |
| 1831 // The default channel may or may not be in |receive_channels_|. Set the rtp | 1834 // The default channel may or may not be in |receive_channels_|. Set the rtp |
| 1832 // header extensions for default channel regardless. | 1835 // header extensions for default channel regardless. |
| 1833 if (!SetChannelRecvRtpHeaderExtensions(voe_channel(), extensions)) { | 1836 if (!SetChannelRecvRtpHeaderExtensions(default_send_channel_id(), |
| 1837 extensions)) { |
| 1834 return false; | 1838 return false; |
| 1835 } | 1839 } |
| 1836 | 1840 |
| 1837 // Loop through all receive channels and enable/disable the extensions. | 1841 // Loop through all receive channels and enable/disable the extensions. |
| 1838 for (const auto& ch : receive_channels_) { | 1842 for (const auto& ch : receive_channels_) { |
| 1839 if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) { | 1843 if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) { |
| 1840 return false; | 1844 return false; |
| 1841 } | 1845 } |
| 1842 } | 1846 } |
| 1843 | 1847 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 bool WebRtcVoiceMediaChannel::SetSendRtpHeaderExtensions( | 1896 bool WebRtcVoiceMediaChannel::SetSendRtpHeaderExtensions( |
| 1893 const std::vector<RtpHeaderExtension>& extensions) { | 1897 const std::vector<RtpHeaderExtension>& extensions) { |
| 1894 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1898 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1895 if (send_extensions_ == extensions) { | 1899 if (send_extensions_ == extensions) { |
| 1896 return true; | 1900 return true; |
| 1897 } | 1901 } |
| 1898 | 1902 |
| 1899 // The default channel may or may not be in |send_channels_|. Set the rtp | 1903 // The default channel may or may not be in |send_channels_|. Set the rtp |
| 1900 // header extensions for default channel regardless. | 1904 // header extensions for default channel regardless. |
| 1901 | 1905 |
| 1902 if (!SetChannelSendRtpHeaderExtensions(voe_channel(), extensions)) { | 1906 if (!SetChannelSendRtpHeaderExtensions(default_send_channel_id(), |
| 1907 extensions)) { |
| 1903 return false; | 1908 return false; |
| 1904 } | 1909 } |
| 1905 | 1910 |
| 1906 // Loop through all send channels and enable/disable the extensions. | 1911 // Loop through all send channels and enable/disable the extensions. |
| 1907 for (const auto& ch : send_channels_) { | 1912 for (const auto& ch : send_channels_) { |
| 1908 if (!SetChannelSendRtpHeaderExtensions(ch.second->channel(), extensions)) { | 1913 if (!SetChannelSendRtpHeaderExtensions(ch.second->channel(), extensions)) { |
| 1909 return false; | 1914 return false; |
| 1910 } | 1915 } |
| 1911 } | 1916 } |
| 1912 | 1917 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 bool WebRtcVoiceMediaChannel::ChangePlayout(bool playout) { | 1957 bool WebRtcVoiceMediaChannel::ChangePlayout(bool playout) { |
| 1953 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1958 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1954 if (playout_ == playout) { | 1959 if (playout_ == playout) { |
| 1955 return true; | 1960 return true; |
| 1956 } | 1961 } |
| 1957 | 1962 |
| 1958 // Change the playout of all channels to the new state. | 1963 // Change the playout of all channels to the new state. |
| 1959 bool result = true; | 1964 bool result = true; |
| 1960 if (receive_channels_.empty()) { | 1965 if (receive_channels_.empty()) { |
| 1961 // Only toggle the default channel if we don't have any other channels. | 1966 // Only toggle the default channel if we don't have any other channels. |
| 1962 result = SetPlayout(voe_channel(), playout); | 1967 result = SetPlayout(default_send_channel_id(), playout); |
| 1963 } | 1968 } |
| 1964 for (const auto& ch : receive_channels_) { | 1969 for (const auto& ch : receive_channels_) { |
| 1965 if (!SetPlayout(ch.second->channel(), playout)) { | 1970 if (!SetPlayout(ch.second->channel(), playout)) { |
| 1966 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel " | 1971 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel " |
| 1967 << ch.second->channel() << " failed"; | 1972 << ch.second->channel() << " failed"; |
| 1968 result = false; | 1973 result = false; |
| 1969 break; | 1974 break; |
| 1970 } | 1975 } |
| 1971 } | 1976 } |
| 1972 | 1977 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 } | 2101 } |
| 2097 | 2102 |
| 2098 bool default_channel_is_available = true; | 2103 bool default_channel_is_available = true; |
| 2099 for (const auto& ch : send_channels_) { | 2104 for (const auto& ch : send_channels_) { |
| 2100 if (IsDefaultChannel(ch.second->channel())) { | 2105 if (IsDefaultChannel(ch.second->channel())) { |
| 2101 default_channel_is_available = false; | 2106 default_channel_is_available = false; |
| 2102 break; | 2107 break; |
| 2103 } | 2108 } |
| 2104 } | 2109 } |
| 2105 if (default_channel_is_available) { | 2110 if (default_channel_is_available) { |
| 2106 channel = voe_channel(); | 2111 channel = default_send_channel_id(); |
| 2107 } else { | 2112 } else { |
| 2108 // Create a new channel for sending audio data. | 2113 // Create a new channel for sending audio data. |
| 2109 channel = engine()->CreateMediaVoiceChannel(); | 2114 channel = engine()->CreateMediaVoiceChannel(); |
| 2110 if (channel == -1) { | 2115 if (channel == -1) { |
| 2111 LOG_RTCERR0(CreateChannel); | 2116 LOG_RTCERR0(CreateChannel); |
| 2112 return false; | 2117 return false; |
| 2113 } | 2118 } |
| 2114 | 2119 |
| 2115 ConfigureSendChannel(channel); | 2120 ConfigureSendChannel(channel); |
| 2116 } | 2121 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 RTC_DCHECK(receive_stream_params_.find(ssrc) == receive_stream_params_.end()); | 2224 RTC_DCHECK(receive_stream_params_.find(ssrc) == receive_stream_params_.end()); |
| 2220 | 2225 |
| 2221 // Reuse default channel for recv stream in non-conference mode call | 2226 // Reuse default channel for recv stream in non-conference mode call |
| 2222 // when the default channel is not being used. | 2227 // when the default channel is not being used. |
| 2223 webrtc::AudioTransport* audio_transport = | 2228 webrtc::AudioTransport* audio_transport = |
| 2224 engine()->voe()->base()->audio_transport(); | 2229 engine()->voe()->base()->audio_transport(); |
| 2225 if (!InConferenceMode() && default_receive_ssrc_ == 0) { | 2230 if (!InConferenceMode() && default_receive_ssrc_ == 0) { |
| 2226 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; | 2231 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; |
| 2227 default_receive_ssrc_ = ssrc; | 2232 default_receive_ssrc_ = ssrc; |
| 2228 WebRtcVoiceChannelRenderer* channel_renderer = | 2233 WebRtcVoiceChannelRenderer* channel_renderer = |
| 2229 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); | 2234 new WebRtcVoiceChannelRenderer(default_send_channel_id(), |
| 2235 audio_transport); |
| 2230 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2236 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
| 2231 receive_stream_params_[ssrc] = sp; | 2237 receive_stream_params_[ssrc] = sp; |
| 2232 AddAudioReceiveStream(ssrc); | 2238 AddAudioReceiveStream(ssrc); |
| 2233 return SetPlayout(voe_channel(), playout_); | 2239 return SetPlayout(default_send_channel_id(), playout_); |
| 2234 } | 2240 } |
| 2235 | 2241 |
| 2236 // Create a new channel for receiving audio data. | 2242 // Create a new channel for receiving audio data. |
| 2237 int channel = engine()->CreateMediaVoiceChannel(); | 2243 int channel = engine()->CreateMediaVoiceChannel(); |
| 2238 if (channel == -1) { | 2244 if (channel == -1) { |
| 2239 LOG_RTCERR0(CreateChannel); | 2245 LOG_RTCERR0(CreateChannel); |
| 2240 return false; | 2246 return false; |
| 2241 } | 2247 } |
| 2242 | |
| 2243 if (!ConfigureRecvChannel(channel)) { | 2248 if (!ConfigureRecvChannel(channel)) { |
| 2244 DeleteChannel(channel); | 2249 DeleteChannel(channel); |
| 2245 return false; | 2250 return false; |
| 2246 } | 2251 } |
| 2247 | 2252 |
| 2248 WebRtcVoiceChannelRenderer* channel_renderer = | 2253 WebRtcVoiceChannelRenderer* channel_renderer = |
| 2249 new WebRtcVoiceChannelRenderer(channel, audio_transport); | 2254 new WebRtcVoiceChannelRenderer(channel, audio_transport); |
| 2250 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2255 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
| 2251 receive_stream_params_[ssrc] = sp; | 2256 receive_stream_params_[ssrc] = sp; |
| 2252 AddAudioReceiveStream(ssrc); | 2257 AddAudioReceiveStream(ssrc); |
| 2253 | 2258 |
| 2254 LOG(LS_INFO) << "New audio stream " << ssrc | 2259 LOG(LS_INFO) << "New audio stream " << ssrc |
| 2255 << " registered to VoiceEngine channel #" | 2260 << " registered to VoiceEngine channel #" |
| 2256 << channel << "."; | 2261 << channel << "."; |
| 2257 return true; | 2262 return true; |
| 2258 } | 2263 } |
| 2259 | 2264 |
| 2260 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { | 2265 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { |
| 2261 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2266 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2262 // Configure to use external transport, like our default channel. | 2267 // Configure to use external transport. |
| 2263 if (engine()->voe()->network()->RegisterExternalTransport( | 2268 if (engine()->voe()->network()->RegisterExternalTransport( |
| 2264 channel, *this) == -1) { | 2269 channel, *this) == -1) { |
| 2265 LOG_RTCERR2(SetExternalTransport, channel, this); | 2270 LOG_RTCERR2(SetExternalTransport, channel, this); |
| 2266 return false; | 2271 return false; |
| 2267 } | 2272 } |
| 2268 | 2273 |
| 2269 // Use the same SSRC as our default channel (so the RTCP reports are correct). | 2274 // Use the same SSRC as our default send channel, so the RTCP reports are |
| 2275 // correct. |
| 2270 unsigned int send_ssrc = 0; | 2276 unsigned int send_ssrc = 0; |
| 2271 webrtc::VoERTP_RTCP* rtp = engine()->voe()->rtp(); | 2277 webrtc::VoERTP_RTCP* rtp = engine()->voe()->rtp(); |
| 2272 if (rtp->GetLocalSSRC(voe_channel(), send_ssrc) == -1) { | 2278 if (rtp->GetLocalSSRC(default_send_channel_id(), send_ssrc) == -1) { |
| 2273 LOG_RTCERR1(GetSendSSRC, channel); | 2279 LOG_RTCERR1(GetSendSSRC, channel); |
| 2274 return false; | 2280 return false; |
| 2275 } | 2281 } |
| 2276 if (rtp->SetLocalSSRC(channel, send_ssrc) == -1) { | 2282 if (rtp->SetLocalSSRC(channel, send_ssrc) == -1) { |
| 2277 LOG_RTCERR1(SetSendSSRC, channel); | 2283 LOG_RTCERR1(SetSendSSRC, channel); |
| 2278 return false; | 2284 return false; |
| 2279 } | 2285 } |
| 2280 | 2286 |
| 2281 // Associate receive channel to default channel (so the receive channel can | 2287 // Associate receive channel to default send channel (so the receive channel |
| 2282 // obtain RTT from the send channel) | 2288 // can obtain RTT from the send channel). |
| 2283 engine()->voe()->base()->AssociateSendChannel(channel, voe_channel()); | 2289 engine()->voe()->base()->AssociateSendChannel(channel, |
| 2290 default_send_channel_id()); |
| 2284 LOG(LS_INFO) << "VoiceEngine channel #" | 2291 LOG(LS_INFO) << "VoiceEngine channel #" |
| 2285 << channel << " is associated with channel #" | 2292 << channel << " is associated with channel #" |
| 2286 << voe_channel() << "."; | 2293 << default_send_channel_id() << "."; |
| 2287 | 2294 |
| 2288 // Use the same recv payload types as our default channel. | 2295 // Use the same recv payload types as our default channel. |
| 2289 ResetRecvCodecs(channel); | 2296 ResetRecvCodecs(channel); |
| 2290 if (!recv_codecs_.empty()) { | 2297 if (!recv_codecs_.empty()) { |
| 2291 for (const auto& codec : recv_codecs_) { | 2298 for (const auto& codec : recv_codecs_) { |
| 2292 webrtc::CodecInst voe_codec; | 2299 webrtc::CodecInst voe_codec; |
| 2293 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { | 2300 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { |
| 2294 voe_codec.pltype = codec.id; | 2301 voe_codec.pltype = codec.id; |
| 2295 voe_codec.rate = 0; // Needed to make GetRecPayloadType work for ISAC | 2302 voe_codec.rate = 0; // Needed to make GetRecPayloadType work for ISAC |
| 2296 if (engine()->voe()->codec()->GetRecPayloadType( | 2303 if (engine()->voe()->codec()->GetRecPayloadType( |
| 2297 voe_channel(), voe_codec) != -1) { | 2304 default_send_channel_id(), voe_codec) != -1) { |
| 2298 if (engine()->voe()->codec()->SetRecPayloadType( | 2305 if (engine()->voe()->codec()->SetRecPayloadType( |
| 2299 channel, voe_codec) == -1) { | 2306 channel, voe_codec) == -1) { |
| 2300 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); | 2307 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); |
| 2301 return false; | 2308 return false; |
| 2302 } | 2309 } |
| 2303 } | 2310 } |
| 2304 } | 2311 } |
| 2305 } | 2312 } |
| 2306 } | 2313 } |
| 2307 | 2314 |
| 2308 if (InConferenceMode()) { | 2315 if (InConferenceMode()) { |
| 2309 // To be in par with the video, voe_channel() is not used for receiving in | 2316 // To be in par with the video, default_send_channel_id() is not used for |
| 2310 // a conference call. | 2317 // receiving in a conference call. |
| 2311 if (receive_channels_.empty() && default_receive_ssrc_ == 0 && playout_) { | 2318 if (receive_channels_.empty() && default_receive_ssrc_ == 0 && playout_) { |
| 2312 // This is the first stream in a multi user meeting. We can now | 2319 // This is the first stream in a multi user meeting. We can now |
| 2313 // disable playback of the default stream. This since the default | 2320 // disable playback of the default stream. This since the default |
| 2314 // stream will probably have received some initial packets before | 2321 // stream will probably have received some initial packets before |
| 2315 // the new stream was added. This will mean that the CN state from | 2322 // the new stream was added. This will mean that the CN state from |
| 2316 // the default channel will be mixed in with the other streams | 2323 // the default channel will be mixed in with the other streams |
| 2317 // throughout the whole meeting, which might be disturbing. | 2324 // throughout the whole meeting, which might be disturbing. |
| 2318 LOG(LS_INFO) << "Disabling playback on the default voice channel"; | 2325 LOG(LS_INFO) << "Disabling playback on the default voice channel"; |
| 2319 SetPlayout(voe_channel(), false); | 2326 SetPlayout(default_send_channel_id(), false); |
| 2320 } | 2327 } |
| 2321 } | 2328 } |
| 2329 |
| 2322 SetNack(channel, nack_enabled_); | 2330 SetNack(channel, nack_enabled_); |
| 2323 | 2331 |
| 2324 // Set RTP header extension for the new channel. | 2332 // Set RTP header extension for the new channel. |
| 2325 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { | 2333 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { |
| 2326 return false; | 2334 return false; |
| 2327 } | 2335 } |
| 2328 | 2336 |
| 2329 return SetPlayout(channel, playout_); | 2337 return SetPlayout(channel, playout_); |
| 2330 } | 2338 } |
| 2331 | 2339 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2348 // will disconnect the audio renderer with the receive channel. | 2356 // will disconnect the audio renderer with the receive channel. |
| 2349 // Cache the channel before the deletion. | 2357 // Cache the channel before the deletion. |
| 2350 const int channel = it->second->channel(); | 2358 const int channel = it->second->channel(); |
| 2351 delete it->second; | 2359 delete it->second; |
| 2352 receive_channels_.erase(it); | 2360 receive_channels_.erase(it); |
| 2353 | 2361 |
| 2354 if (ssrc == default_receive_ssrc_) { | 2362 if (ssrc == default_receive_ssrc_) { |
| 2355 RTC_DCHECK(IsDefaultChannel(channel)); | 2363 RTC_DCHECK(IsDefaultChannel(channel)); |
| 2356 // Recycle the default channel is for recv stream. | 2364 // Recycle the default channel is for recv stream. |
| 2357 if (playout_) | 2365 if (playout_) |
| 2358 SetPlayout(voe_channel(), false); | 2366 SetPlayout(default_send_channel_id(), false); |
| 2359 | 2367 |
| 2360 default_receive_ssrc_ = 0; | 2368 default_receive_ssrc_ = 0; |
| 2361 return true; | 2369 return true; |
| 2362 } | 2370 } |
| 2363 | 2371 |
| 2364 LOG(LS_INFO) << "Removing audio stream " << ssrc | 2372 LOG(LS_INFO) << "Removing audio stream " << ssrc |
| 2365 << " with VoiceEngine channel #" << channel << "."; | 2373 << " with VoiceEngine channel #" << channel << "."; |
| 2366 if (!DeleteChannel(channel)) | 2374 if (!DeleteChannel(channel)) |
| 2367 return false; | 2375 return false; |
| 2368 | 2376 |
| 2369 bool enable_default_channel_playout = false; | 2377 bool enable_default_channel_playout = false; |
| 2370 if (receive_channels_.empty()) { | 2378 if (receive_channels_.empty()) { |
| 2371 // The last stream was removed. We can now enable the default | 2379 // The last stream was removed. We can now enable the default |
| 2372 // channel for new channels to be played out immediately without | 2380 // channel for new channels to be played out immediately without |
| 2373 // waiting for AddStream messages. | 2381 // waiting for AddStream messages. |
| 2374 // We do this for both conference mode and non-conference mode. | 2382 // We do this for both conference mode and non-conference mode. |
| 2375 // TODO(oja): Does the default channel still have it's CN state? | 2383 // TODO(oja): Does the default channel still have it's CN state? |
| 2376 enable_default_channel_playout = true; | 2384 enable_default_channel_playout = true; |
| 2377 } | 2385 } |
| 2378 if (!InConferenceMode() && receive_channels_.size() == 1 && | 2386 if (!InConferenceMode() && receive_channels_.size() == 1 && |
| 2379 default_receive_ssrc_ != 0) { | 2387 default_receive_ssrc_ != 0) { |
| 2380 // Only the default channel is active, enable the playout on default | 2388 // Only the default channel is active, enable the playout on default |
| 2381 // channel. | 2389 // channel. |
| 2382 enable_default_channel_playout = true; | 2390 enable_default_channel_playout = true; |
| 2383 } | 2391 } |
| 2384 if (enable_default_channel_playout && playout_) { | 2392 if (enable_default_channel_playout && playout_) { |
| 2385 LOG(LS_INFO) << "Enabling playback on the default voice channel"; | 2393 LOG(LS_INFO) << "Enabling playback on the default voice channel"; |
| 2386 SetPlayout(voe_channel(), true); | 2394 SetPlayout(default_send_channel_id(), true); |
| 2387 } | 2395 } |
| 2388 | 2396 |
| 2389 return true; | 2397 return true; |
| 2390 } | 2398 } |
| 2391 | 2399 |
| 2392 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, | 2400 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, |
| 2393 AudioRenderer* renderer) { | 2401 AudioRenderer* renderer) { |
| 2394 ChannelMap::iterator it = send_channels_.find(ssrc); | 2402 ChannelMap::iterator it = send_channels_.find(ssrc); |
| 2395 if (it == send_channels_.end()) { | 2403 if (it == send_channels_.end()) { |
| 2396 if (renderer) { | 2404 if (renderer) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2422 if (level > 0) { | 2430 if (level > 0) { |
| 2423 actives->push_back(std::make_pair(ch.first, level)); | 2431 actives->push_back(std::make_pair(ch.first, level)); |
| 2424 } | 2432 } |
| 2425 } | 2433 } |
| 2426 return true; | 2434 return true; |
| 2427 } | 2435 } |
| 2428 | 2436 |
| 2429 int WebRtcVoiceMediaChannel::GetOutputLevel() { | 2437 int WebRtcVoiceMediaChannel::GetOutputLevel() { |
| 2430 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2438 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2431 // return the highest output level of all streams | 2439 // return the highest output level of all streams |
| 2432 int highest = GetOutputLevel(voe_channel()); | 2440 int highest = GetOutputLevel(default_send_channel_id()); |
| 2433 for (const auto& ch : receive_channels_) { | 2441 for (const auto& ch : receive_channels_) { |
| 2434 int level = GetOutputLevel(ch.second->channel()); | 2442 highest = std::max(GetOutputLevel(ch.second->channel()), highest); |
| 2435 highest = std::max(level, highest); | |
| 2436 } | 2443 } |
| 2437 return highest; | 2444 return highest; |
| 2438 } | 2445 } |
| 2439 | 2446 |
| 2440 int WebRtcVoiceMediaChannel::GetTimeSinceLastTyping() { | 2447 int WebRtcVoiceMediaChannel::GetTimeSinceLastTyping() { |
| 2441 int ret; | 2448 int ret; |
| 2442 if (engine()->voe()->processing()->TimeSinceLastTyping(ret) == -1) { | 2449 if (engine()->voe()->processing()->TimeSinceLastTyping(ret) == -1) { |
| 2443 // In case of error, log the info and continue | 2450 // In case of error, log the info and continue |
| 2444 LOG_RTCERR0(TimeSinceLastTyping); | 2451 LOG_RTCERR0(TimeSinceLastTyping); |
| 2445 ret = -1; | 2452 ret = -1; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2464 | 2471 |
| 2465 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { | 2472 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { |
| 2466 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2473 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2467 rtc::CritScope lock(&receive_channels_cs_); | 2474 rtc::CritScope lock(&receive_channels_cs_); |
| 2468 // Collect the channels to scale the output volume. | 2475 // Collect the channels to scale the output volume. |
| 2469 std::vector<int> channels; | 2476 std::vector<int> channels; |
| 2470 if (0 == ssrc) { // Collect all channels, including the default one. | 2477 if (0 == ssrc) { // Collect all channels, including the default one. |
| 2471 // Default channel is not in receive_channels_ if it is not being used for | 2478 // Default channel is not in receive_channels_ if it is not being used for |
| 2472 // playout. | 2479 // playout. |
| 2473 if (default_receive_ssrc_ == 0) | 2480 if (default_receive_ssrc_ == 0) |
| 2474 channels.push_back(voe_channel()); | 2481 channels.push_back(default_send_channel_id()); |
| 2475 for (const auto& ch : receive_channels_) { | 2482 for (const auto& ch : receive_channels_) { |
| 2476 channels.push_back(ch.second->channel()); | 2483 channels.push_back(ch.second->channel()); |
| 2477 } | 2484 } |
| 2478 } else { // Collect only the channel of the specified ssrc. | 2485 } else { // Collect only the channel of the specified ssrc. |
| 2479 int channel = GetReceiveChannelId(ssrc); | 2486 int channel = GetReceiveChannelId(ssrc); |
| 2480 if (-1 == channel) { | 2487 if (-1 == channel) { |
| 2481 LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc; | 2488 LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc; |
| 2482 return false; | 2489 return false; |
| 2483 } | 2490 } |
| 2484 channels.push_back(channel); | 2491 channels.push_back(channel); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2513 int channel = -1; | 2520 int channel = -1; |
| 2514 if (ssrc == 0) { | 2521 if (ssrc == 0) { |
| 2515 bool default_channel_is_inuse = false; | 2522 bool default_channel_is_inuse = false; |
| 2516 for (const auto& ch : send_channels_) { | 2523 for (const auto& ch : send_channels_) { |
| 2517 if (IsDefaultChannel(ch.second->channel())) { | 2524 if (IsDefaultChannel(ch.second->channel())) { |
| 2518 default_channel_is_inuse = true; | 2525 default_channel_is_inuse = true; |
| 2519 break; | 2526 break; |
| 2520 } | 2527 } |
| 2521 } | 2528 } |
| 2522 if (default_channel_is_inuse) { | 2529 if (default_channel_is_inuse) { |
| 2523 channel = voe_channel(); | 2530 channel = default_send_channel_id(); |
| 2524 } else if (!send_channels_.empty()) { | 2531 } else if (!send_channels_.empty()) { |
| 2525 channel = send_channels_.begin()->second->channel(); | 2532 channel = send_channels_.begin()->second->channel(); |
| 2526 } | 2533 } |
| 2527 } else { | 2534 } else { |
| 2528 channel = GetSendChannelId(ssrc); | 2535 channel = GetSendChannelId(ssrc); |
| 2529 } | 2536 } |
| 2530 if (channel == -1) { | 2537 if (channel == -1) { |
| 2531 LOG(LS_WARNING) << "InsertDtmf - The specified ssrc " | 2538 LOG(LS_WARNING) << "InsertDtmf - The specified ssrc " |
| 2532 << ssrc << " is not in use."; | 2539 << ssrc << " is not in use."; |
| 2533 return false; | 2540 return false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2562 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, | 2569 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
| 2563 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | 2570 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), |
| 2564 webrtc_packet_time); | 2571 webrtc_packet_time); |
| 2565 | 2572 |
| 2566 // Pick which channel to send this packet to. If this packet doesn't match | 2573 // Pick which channel to send this packet to. If this packet doesn't match |
| 2567 // any multiplexed streams, just send it to the default channel. Otherwise, | 2574 // any multiplexed streams, just send it to the default channel. Otherwise, |
| 2568 // send it to the specific decoder instance for that stream. | 2575 // send it to the specific decoder instance for that stream. |
| 2569 int which_channel = | 2576 int which_channel = |
| 2570 GetReceiveChannelId(ParseSsrc(packet->data(), packet->size(), false)); | 2577 GetReceiveChannelId(ParseSsrc(packet->data(), packet->size(), false)); |
| 2571 if (which_channel == -1) { | 2578 if (which_channel == -1) { |
| 2572 which_channel = voe_channel(); | 2579 which_channel = default_send_channel_id(); |
| 2573 } | 2580 } |
| 2574 | 2581 |
| 2575 // Pass it off to the decoder. | 2582 // Pass it off to the decoder. |
| 2576 engine()->voe()->network()->ReceivedRTPPacket( | 2583 engine()->voe()->network()->ReceivedRTPPacket( |
| 2577 which_channel, packet->data(), packet->size(), | 2584 which_channel, packet->data(), packet->size(), |
| 2578 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); | 2585 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); |
| 2579 } | 2586 } |
| 2580 | 2587 |
| 2581 void WebRtcVoiceMediaChannel::OnRtcpReceived( | 2588 void WebRtcVoiceMediaChannel::OnRtcpReceived( |
| 2582 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2589 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2624 if (IsDefaultChannel(ch.second->channel()) && | 2631 if (IsDefaultChannel(ch.second->channel()) && |
| 2625 has_sent_to_default_channel) | 2632 has_sent_to_default_channel) |
| 2626 continue; | 2633 continue; |
| 2627 | 2634 |
| 2628 engine()->voe()->network()->ReceivedRTCPPacket( | 2635 engine()->voe()->network()->ReceivedRTCPPacket( |
| 2629 ch.second->channel(), packet->data(), packet->size()); | 2636 ch.second->channel(), packet->data(), packet->size()); |
| 2630 } | 2637 } |
| 2631 } | 2638 } |
| 2632 | 2639 |
| 2633 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { | 2640 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { |
| 2634 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelId(ssrc); | 2641 int channel = |
| 2642 (ssrc == 0) ? default_send_channel_id() : GetSendChannelId(ssrc); |
| 2635 if (channel == -1) { | 2643 if (channel == -1) { |
| 2636 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; | 2644 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; |
| 2637 return false; | 2645 return false; |
| 2638 } | 2646 } |
| 2639 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { | 2647 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { |
| 2640 LOG_RTCERR2(SetInputMute, channel, muted); | 2648 LOG_RTCERR2(SetInputMute, channel, muted); |
| 2641 return false; | 2649 return false; |
| 2642 } | 2650 } |
| 2643 // We set the AGC to mute state only when all the channels are muted. | 2651 // We set the AGC to mute state only when all the channels are muted. |
| 2644 // This implementation is not ideal, instead we should signal the AGC when | 2652 // This implementation is not ideal, instead we should signal the AGC when |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 info->senders.push_back(sinfo); | 2826 info->senders.push_back(sinfo); |
| 2819 } | 2827 } |
| 2820 | 2828 |
| 2821 // Build the list of receivers, one for each receiving channel, or 1 in | 2829 // Build the list of receivers, one for each receiving channel, or 1 in |
| 2822 // a 1:1 call. | 2830 // a 1:1 call. |
| 2823 std::vector<int> channels; | 2831 std::vector<int> channels; |
| 2824 for (const auto& ch : receive_channels_) { | 2832 for (const auto& ch : receive_channels_) { |
| 2825 channels.push_back(ch.second->channel()); | 2833 channels.push_back(ch.second->channel()); |
| 2826 } | 2834 } |
| 2827 if (channels.empty()) { | 2835 if (channels.empty()) { |
| 2828 channels.push_back(voe_channel()); | 2836 channels.push_back(default_send_channel_id()); |
| 2829 } | 2837 } |
| 2830 | 2838 |
| 2831 // Get the SSRC and stats for each receiver, based on our own calculations. | 2839 // Get the SSRC and stats for each receiver, based on our own calculations. |
| 2832 for (int ch_id : channels) { | 2840 for (int ch_id : channels) { |
| 2833 memset(&cs, 0, sizeof(cs)); | 2841 memset(&cs, 0, sizeof(cs)); |
| 2834 if (engine()->voe()->rtp()->GetRemoteSSRC(ch_id, ssrc) != -1 && | 2842 if (engine()->voe()->rtp()->GetRemoteSSRC(ch_id, ssrc) != -1 && |
| 2835 engine()->voe()->rtp()->GetRTCPStatistics(ch_id, cs) != -1 && | 2843 engine()->voe()->rtp()->GetRTCPStatistics(ch_id, cs) != -1 && |
| 2836 engine()->voe()->codec()->GetRecCodec(ch_id, codec) != -1) { | 2844 engine()->voe()->codec()->GetRecCodec(ch_id, codec) != -1) { |
| 2837 VoiceReceiverInfo rinfo; | 2845 VoiceReceiverInfo rinfo; |
| 2838 rinfo.add_ssrc(ssrc); | 2846 rinfo.add_ssrc(ssrc); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 | 2924 |
| 2917 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { | 2925 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { |
| 2918 unsigned int ulevel = 0; | 2926 unsigned int ulevel = 0; |
| 2919 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); | 2927 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); |
| 2920 return (ret == 0) ? static_cast<int>(ulevel) : -1; | 2928 return (ret == 0) ? static_cast<int>(ulevel) : -1; |
| 2921 } | 2929 } |
| 2922 | 2930 |
| 2923 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { | 2931 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { |
| 2924 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2932 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2925 ChannelMap::const_iterator it = receive_channels_.find(ssrc); | 2933 ChannelMap::const_iterator it = receive_channels_.find(ssrc); |
| 2926 if (it != receive_channels_.end()) | 2934 if (it != receive_channels_.end()) { |
| 2927 return it->second->channel(); | 2935 return it->second->channel(); |
| 2928 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; | 2936 } |
| 2937 return (ssrc == default_receive_ssrc_) ? default_send_channel_id() : -1; |
| 2929 } | 2938 } |
| 2930 | 2939 |
| 2931 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { | 2940 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { |
| 2932 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2941 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2933 ChannelMap::const_iterator it = send_channels_.find(ssrc); | 2942 ChannelMap::const_iterator it = send_channels_.find(ssrc); |
| 2934 if (it != send_channels_.end()) | 2943 if (it != send_channels_.end()) { |
| 2935 return it->second->channel(); | 2944 return it->second->channel(); |
| 2936 | 2945 } |
| 2937 return -1; | 2946 return -1; |
| 2938 } | 2947 } |
| 2939 | 2948 |
| 2940 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, | 2949 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, |
| 2941 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { | 2950 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { |
| 2942 // Get the RED encodings from the parameter with no name. This may | 2951 // Get the RED encodings from the parameter with no name. This may |
| 2943 // change based on what is discussed on the Jingle list. | 2952 // change based on what is discussed on the Jingle list. |
| 2944 // The encoding parameter is of the form "a/b"; we only support where | 2953 // The encoding parameter is of the form "a/b"; we only support where |
| 2945 // a == b. Verify this and parse out the value into red_pt. | 2954 // a == b. Verify this and parse out the value into red_pt. |
| 2946 // If the parameter value is absent (as it will be until we wire up the | 2955 // If the parameter value is absent (as it will be until we wire up the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 return false; | 2990 return false; |
| 2982 } | 2991 } |
| 2983 | 2992 |
| 2984 bool WebRtcVoiceMediaChannel::EnableRtcp(int channel) { | 2993 bool WebRtcVoiceMediaChannel::EnableRtcp(int channel) { |
| 2985 if (engine()->voe()->rtp()->SetRTCPStatus(channel, true) == -1) { | 2994 if (engine()->voe()->rtp()->SetRTCPStatus(channel, true) == -1) { |
| 2986 LOG_RTCERR2(SetRTCPStatus, channel, 1); | 2995 LOG_RTCERR2(SetRTCPStatus, channel, 1); |
| 2987 return false; | 2996 return false; |
| 2988 } | 2997 } |
| 2989 // TODO(juberti): Enable VQMon and RTCP XR reports, once we know what | 2998 // TODO(juberti): Enable VQMon and RTCP XR reports, once we know what |
| 2990 // what we want to do with them. | 2999 // what we want to do with them. |
| 2991 // engine()->voe().EnableVQMon(voe_channel(), true); | 3000 // engine()->voe().EnableVQMon(default_send_channel_id(), true); |
| 2992 // engine()->voe().EnableRTCP_XR(voe_channel(), true); | 3001 // engine()->voe().EnableRTCP_XR(default_send_channel_id(), true); |
| 2993 return true; | 3002 return true; |
| 2994 } | 3003 } |
| 2995 | 3004 |
| 2996 bool WebRtcVoiceMediaChannel::ResetRecvCodecs(int channel) { | 3005 bool WebRtcVoiceMediaChannel::ResetRecvCodecs(int channel) { |
| 2997 int ncodecs = engine()->voe()->codec()->NumOfCodecs(); | 3006 int ncodecs = engine()->voe()->codec()->NumOfCodecs(); |
| 2998 for (int i = 0; i < ncodecs; ++i) { | 3007 for (int i = 0; i < ncodecs; ++i) { |
| 2999 webrtc::CodecInst voe_codec; | 3008 webrtc::CodecInst voe_codec; |
| 3000 if (engine()->voe()->codec()->GetCodec(i, voe_codec) != -1) { | 3009 if (engine()->voe()->codec()->GetCodec(i, voe_codec) != -1) { |
| 3001 voe_codec.pltype = -1; | 3010 voe_codec.pltype = -1; |
| 3002 if (engine()->voe()->codec()->SetRecPayloadType( | 3011 if (engine()->voe()->codec()->SetRecPayloadType( |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 LOG(LS_INFO) << ToString(codec); | 3138 LOG(LS_INFO) << ToString(codec); |
| 3130 voe_codec.pltype = codec.id; | 3139 voe_codec.pltype = codec.id; |
| 3131 if (default_receive_ssrc_ == 0) { | 3140 if (default_receive_ssrc_ == 0) { |
| 3132 // Set the receive codecs on the default channel explicitly if the | 3141 // Set the receive codecs on the default channel explicitly if the |
| 3133 // default channel is not used by |receive_channels_|, this happens in | 3142 // default channel is not used by |receive_channels_|, this happens in |
| 3134 // conference mode or in non-conference mode when there is no playout | 3143 // conference mode or in non-conference mode when there is no playout |
| 3135 // channel. | 3144 // channel. |
| 3136 // TODO(xians): Figure out how we use the default channel in conference | 3145 // TODO(xians): Figure out how we use the default channel in conference |
| 3137 // mode. | 3146 // mode. |
| 3138 if (engine()->voe()->codec()->SetRecPayloadType( | 3147 if (engine()->voe()->codec()->SetRecPayloadType( |
| 3139 voe_channel(), voe_codec) == -1) { | 3148 default_send_channel_id(), voe_codec) == -1) { |
| 3140 LOG_RTCERR2(SetRecPayloadType, voe_channel(), ToString(voe_codec)); | 3149 LOG_RTCERR2(SetRecPayloadType, default_send_channel_id(), |
| 3150 ToString(voe_codec)); |
| 3141 return false; | 3151 return false; |
| 3142 } | 3152 } |
| 3143 } | 3153 } |
| 3144 | 3154 |
| 3145 // Set the receive codecs on all receiving channels. | 3155 // Set the receive codecs on all receiving channels. |
| 3146 for (const auto& ch : receive_channels_) { | 3156 for (const auto& ch : receive_channels_) { |
| 3147 if (engine()->voe()->codec()->SetRecPayloadType( | 3157 if (engine()->voe()->codec()->SetRecPayloadType( |
| 3148 ch.second->channel(), voe_codec) == -1) { | 3158 ch.second->channel(), voe_codec) == -1) { |
| 3149 LOG_RTCERR2(SetRecPayloadType, ch.second->channel(), | 3159 LOG_RTCERR2(SetRecPayloadType, ch.second->channel(), |
| 3150 ToString(voe_codec)); | 3160 ToString(voe_codec)); |
| 3151 return false; | 3161 return false; |
| 3152 } | 3162 } |
| 3153 } | 3163 } |
| 3154 } else { | 3164 } else { |
| 3155 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 3165 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
| 3156 return false; | 3166 return false; |
| 3157 } | 3167 } |
| 3158 } | 3168 } |
| 3159 return true; | 3169 return true; |
| 3160 } | 3170 } |
| 3161 | 3171 |
| 3162 } // namespace cricket | 3172 } // namespace cricket |
| 3163 | 3173 |
| 3164 #endif // HAVE_WEBRTC_VOICE | 3174 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |