OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 114 matching lines...) Loading... |
125 } | 125 } |
126 | 126 |
127 // Dumps an AudioCodec in RFC 2327-ish format. | 127 // Dumps an AudioCodec in RFC 2327-ish format. |
128 std::string ToString(const AudioCodec& codec) { | 128 std::string ToString(const AudioCodec& codec) { |
129 std::stringstream ss; | 129 std::stringstream ss; |
130 ss << codec.name << "/" << codec.clockrate << "/" << codec.channels | 130 ss << codec.name << "/" << codec.clockrate << "/" << codec.channels |
131 << " (" << codec.id << ")"; | 131 << " (" << codec.id << ")"; |
132 return ss.str(); | 132 return ss.str(); |
133 } | 133 } |
134 | 134 |
| 135 std::string ToString(const webrtc::CodecInst& codec) { |
| 136 std::stringstream ss; |
| 137 ss << codec.plname << "/" << codec.plfreq << "/" << codec.channels |
| 138 << " (" << codec.pltype << ")"; |
| 139 return ss.str(); |
| 140 } |
| 141 |
135 bool IsCodec(const AudioCodec& codec, const char* ref_name) { | 142 bool IsCodec(const AudioCodec& codec, const char* ref_name) { |
136 return (_stricmp(codec.name.c_str(), ref_name) == 0); | 143 return (_stricmp(codec.name.c_str(), ref_name) == 0); |
137 } | 144 } |
138 | 145 |
139 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { | 146 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
140 return (_stricmp(codec.plname, ref_name) == 0); | 147 return (_stricmp(codec.plname, ref_name) == 0); |
141 } | 148 } |
142 | 149 |
143 bool FindCodec(const std::vector<AudioCodec>& codecs, | 150 bool FindCodec(const std::vector<AudioCodec>& codecs, |
144 const AudioCodec& codec, | 151 const AudioCodec& codec, |
(...skipping 1307 matching lines...) Loading... |
1452 WebRtcAudioReceiveStream( | 1459 WebRtcAudioReceiveStream( |
1453 int ch, | 1460 int ch, |
1454 uint32_t remote_ssrc, | 1461 uint32_t remote_ssrc, |
1455 uint32_t local_ssrc, | 1462 uint32_t local_ssrc, |
1456 bool use_transport_cc, | 1463 bool use_transport_cc, |
1457 bool use_nack, | 1464 bool use_nack, |
1458 const std::string& sync_group, | 1465 const std::string& sync_group, |
1459 const std::vector<webrtc::RtpExtension>& extensions, | 1466 const std::vector<webrtc::RtpExtension>& extensions, |
1460 webrtc::Call* call, | 1467 webrtc::Call* call, |
1461 webrtc::Transport* rtcp_send_transport, | 1468 webrtc::Transport* rtcp_send_transport, |
1462 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, | 1469 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory) |
1463 const std::map<int, webrtc::SdpAudioFormat>& decoder_map) | |
1464 : call_(call), config_() { | 1470 : call_(call), config_() { |
1465 RTC_DCHECK_GE(ch, 0); | 1471 RTC_DCHECK_GE(ch, 0); |
1466 RTC_DCHECK(call); | 1472 RTC_DCHECK(call); |
1467 config_.rtp.remote_ssrc = remote_ssrc; | 1473 config_.rtp.remote_ssrc = remote_ssrc; |
1468 config_.rtp.local_ssrc = local_ssrc; | 1474 config_.rtp.local_ssrc = local_ssrc; |
1469 config_.rtp.transport_cc = use_transport_cc; | 1475 config_.rtp.transport_cc = use_transport_cc; |
1470 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; | 1476 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; |
1471 config_.rtp.extensions = extensions; | 1477 config_.rtp.extensions = extensions; |
1472 config_.rtcp_send_transport = rtcp_send_transport; | 1478 config_.rtcp_send_transport = rtcp_send_transport; |
1473 config_.voe_channel_id = ch; | 1479 config_.voe_channel_id = ch; |
1474 config_.sync_group = sync_group; | 1480 config_.sync_group = sync_group; |
1475 config_.decoder_factory = decoder_factory; | 1481 config_.decoder_factory = decoder_factory; |
1476 config_.decoder_map = decoder_map; | |
1477 RecreateAudioReceiveStream(); | 1482 RecreateAudioReceiveStream(); |
1478 } | 1483 } |
1479 | 1484 |
1480 ~WebRtcAudioReceiveStream() { | 1485 ~WebRtcAudioReceiveStream() { |
1481 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1482 call_->DestroyAudioReceiveStream(stream_); | 1487 call_->DestroyAudioReceiveStream(stream_); |
1483 } | 1488 } |
1484 | 1489 |
1485 void RecreateAudioReceiveStream(uint32_t local_ssrc) { | 1490 void RecreateAudioReceiveStream(uint32_t local_ssrc) { |
1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1491 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 368 matching lines...) Loading... |
1855 } | 1860 } |
1856 decoder_map.insert({codec.id, std::move(format)}); | 1861 decoder_map.insert({codec.id, std::move(format)}); |
1857 } | 1862 } |
1858 | 1863 |
1859 if (playout_) { | 1864 if (playout_) { |
1860 // Receive codecs can not be changed while playing. So we temporarily | 1865 // Receive codecs can not be changed while playing. So we temporarily |
1861 // pause playout. | 1866 // pause playout. |
1862 ChangePlayout(false); | 1867 ChangePlayout(false); |
1863 } | 1868 } |
1864 | 1869 |
1865 decoder_map_ = std::move(decoder_map); | |
1866 for (auto& kv : recv_streams_) { | 1870 for (auto& kv : recv_streams_) { |
1867 kv.second->RecreateAudioReceiveStream(decoder_map_); | 1871 kv.second->RecreateAudioReceiveStream(decoder_map); |
1868 } | 1872 } |
1869 recv_codecs_ = codecs; | 1873 recv_codecs_ = codecs; |
1870 | 1874 |
1871 if (desired_playout_ && !playout_) { | 1875 if (desired_playout_ && !playout_) { |
1872 ChangePlayout(desired_playout_); | 1876 ChangePlayout(desired_playout_); |
1873 } | 1877 } |
1874 return true; | 1878 return true; |
1875 } | 1879 } |
1876 | 1880 |
1877 // Utility function called from SetSendParameters() to extract current send | 1881 // Utility function called from SetSendParameters() to extract current send |
(...skipping 336 matching lines...) Loading... |
2214 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2218 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
2215 return false; | 2219 return false; |
2216 } | 2220 } |
2217 | 2221 |
2218 // Create a new channel for receiving audio data. | 2222 // Create a new channel for receiving audio data. |
2219 const int channel = CreateVoEChannel(); | 2223 const int channel = CreateVoEChannel(); |
2220 if (channel == -1) { | 2224 if (channel == -1) { |
2221 return false; | 2225 return false; |
2222 } | 2226 } |
2223 | 2227 |
| 2228 // Turn off all supported codecs. |
| 2229 // TODO(solenberg): Remove once "no codecs" is the default state of a stream. |
| 2230 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { |
| 2231 voe_codec.pltype = -1; |
| 2232 if (engine()->voe()->codec()->SetRecPayloadType(channel, voe_codec) == -1) { |
| 2233 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); |
| 2234 DeleteVoEChannel(channel); |
| 2235 return false; |
| 2236 } |
| 2237 } |
| 2238 |
| 2239 // Only enable those configured for this channel. |
| 2240 for (const auto& codec : recv_codecs_) { |
| 2241 webrtc::CodecInst voe_codec = {0}; |
| 2242 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) { |
| 2243 voe_codec.pltype = codec.id; |
| 2244 if (engine()->voe()->codec()->SetRecPayloadType( |
| 2245 channel, voe_codec) == -1) { |
| 2246 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); |
| 2247 DeleteVoEChannel(channel); |
| 2248 return false; |
| 2249 } |
| 2250 } |
| 2251 } |
| 2252 |
2224 recv_streams_.insert(std::make_pair( | 2253 recv_streams_.insert(std::make_pair( |
2225 ssrc, | 2254 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, |
2226 new WebRtcAudioReceiveStream( | 2255 recv_transport_cc_enabled_, |
2227 channel, ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_, | 2256 recv_nack_enabled_, |
2228 recv_nack_enabled_, sp.sync_label, recv_rtp_extensions_, call_, this, | 2257 sp.sync_label, recv_rtp_extensions_, |
2229 engine()->decoder_factory_, decoder_map_))); | 2258 call_, this, |
| 2259 engine()->decoder_factory_))); |
2230 recv_streams_[ssrc]->SetPlayout(playout_); | 2260 recv_streams_[ssrc]->SetPlayout(playout_); |
2231 | 2261 |
2232 return true; | 2262 return true; |
2233 } | 2263 } |
2234 | 2264 |
2235 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { | 2265 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2236 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); | 2266 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); |
2237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2267 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2238 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; | 2268 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; |
2239 | 2269 |
(...skipping 384 matching lines...) Loading... |
2624 ssrc); | 2654 ssrc); |
2625 if (it != unsignaled_recv_ssrcs_.end()) { | 2655 if (it != unsignaled_recv_ssrcs_.end()) { |
2626 unsignaled_recv_ssrcs_.erase(it); | 2656 unsignaled_recv_ssrcs_.erase(it); |
2627 return true; | 2657 return true; |
2628 } | 2658 } |
2629 return false; | 2659 return false; |
2630 } | 2660 } |
2631 } // namespace cricket | 2661 } // namespace cricket |
2632 | 2662 |
2633 #endif // HAVE_WEBRTC_VOICE | 2663 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |