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...) Expand 10 before | Expand all | Expand 10 after 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 | |
142 bool IsCodec(const AudioCodec& codec, const char* ref_name) { | 135 bool IsCodec(const AudioCodec& codec, const char* ref_name) { |
143 return (_stricmp(codec.name.c_str(), ref_name) == 0); | 136 return (_stricmp(codec.name.c_str(), ref_name) == 0); |
144 } | 137 } |
145 | 138 |
146 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { | 139 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
147 return (_stricmp(codec.plname, ref_name) == 0); | 140 return (_stricmp(codec.plname, ref_name) == 0); |
148 } | 141 } |
149 | 142 |
150 bool FindCodec(const std::vector<AudioCodec>& codecs, | 143 bool FindCodec(const std::vector<AudioCodec>& codecs, |
151 const AudioCodec& codec, | 144 const AudioCodec& codec, |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 WebRtcAudioReceiveStream( | 1452 WebRtcAudioReceiveStream( |
1460 int ch, | 1453 int ch, |
1461 uint32_t remote_ssrc, | 1454 uint32_t remote_ssrc, |
1462 uint32_t local_ssrc, | 1455 uint32_t local_ssrc, |
1463 bool use_transport_cc, | 1456 bool use_transport_cc, |
1464 bool use_nack, | 1457 bool use_nack, |
1465 const std::string& sync_group, | 1458 const std::string& sync_group, |
1466 const std::vector<webrtc::RtpExtension>& extensions, | 1459 const std::vector<webrtc::RtpExtension>& extensions, |
1467 webrtc::Call* call, | 1460 webrtc::Call* call, |
1468 webrtc::Transport* rtcp_send_transport, | 1461 webrtc::Transport* rtcp_send_transport, |
1469 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory) | 1462 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
| 1463 const std::map<int, webrtc::SdpAudioFormat>& decoder_map) |
1470 : call_(call), config_() { | 1464 : call_(call), config_() { |
1471 RTC_DCHECK_GE(ch, 0); | 1465 RTC_DCHECK_GE(ch, 0); |
1472 RTC_DCHECK(call); | 1466 RTC_DCHECK(call); |
1473 config_.rtp.remote_ssrc = remote_ssrc; | 1467 config_.rtp.remote_ssrc = remote_ssrc; |
1474 config_.rtp.local_ssrc = local_ssrc; | 1468 config_.rtp.local_ssrc = local_ssrc; |
1475 config_.rtp.transport_cc = use_transport_cc; | 1469 config_.rtp.transport_cc = use_transport_cc; |
1476 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; | 1470 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; |
1477 config_.rtp.extensions = extensions; | 1471 config_.rtp.extensions = extensions; |
1478 config_.rtcp_send_transport = rtcp_send_transport; | 1472 config_.rtcp_send_transport = rtcp_send_transport; |
1479 config_.voe_channel_id = ch; | 1473 config_.voe_channel_id = ch; |
1480 config_.sync_group = sync_group; | 1474 config_.sync_group = sync_group; |
1481 config_.decoder_factory = decoder_factory; | 1475 config_.decoder_factory = decoder_factory; |
| 1476 config_.decoder_map = decoder_map; |
1482 RecreateAudioReceiveStream(); | 1477 RecreateAudioReceiveStream(); |
1483 } | 1478 } |
1484 | 1479 |
1485 ~WebRtcAudioReceiveStream() { | 1480 ~WebRtcAudioReceiveStream() { |
1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1481 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1487 call_->DestroyAudioReceiveStream(stream_); | 1482 call_->DestroyAudioReceiveStream(stream_); |
1488 } | 1483 } |
1489 | 1484 |
1490 void RecreateAudioReceiveStream(uint32_t local_ssrc) { | 1485 void RecreateAudioReceiveStream(uint32_t local_ssrc) { |
1491 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1486 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 } | 1855 } |
1861 decoder_map.insert({codec.id, std::move(format)}); | 1856 decoder_map.insert({codec.id, std::move(format)}); |
1862 } | 1857 } |
1863 | 1858 |
1864 if (playout_) { | 1859 if (playout_) { |
1865 // Receive codecs can not be changed while playing. So we temporarily | 1860 // Receive codecs can not be changed while playing. So we temporarily |
1866 // pause playout. | 1861 // pause playout. |
1867 ChangePlayout(false); | 1862 ChangePlayout(false); |
1868 } | 1863 } |
1869 | 1864 |
| 1865 decoder_map_ = std::move(decoder_map); |
1870 for (auto& kv : recv_streams_) { | 1866 for (auto& kv : recv_streams_) { |
1871 kv.second->RecreateAudioReceiveStream(decoder_map); | 1867 kv.second->RecreateAudioReceiveStream(decoder_map_); |
1872 } | 1868 } |
1873 recv_codecs_ = codecs; | 1869 recv_codecs_ = codecs; |
1874 | 1870 |
1875 if (desired_playout_ && !playout_) { | 1871 if (desired_playout_ && !playout_) { |
1876 ChangePlayout(desired_playout_); | 1872 ChangePlayout(desired_playout_); |
1877 } | 1873 } |
1878 return true; | 1874 return true; |
1879 } | 1875 } |
1880 | 1876 |
1881 // Utility function called from SetSendParameters() to extract current send | 1877 // Utility function called from SetSendParameters() to extract current send |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2214 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
2219 return false; | 2215 return false; |
2220 } | 2216 } |
2221 | 2217 |
2222 // Create a new channel for receiving audio data. | 2218 // Create a new channel for receiving audio data. |
2223 const int channel = CreateVoEChannel(); | 2219 const int channel = CreateVoEChannel(); |
2224 if (channel == -1) { | 2220 if (channel == -1) { |
2225 return false; | 2221 return false; |
2226 } | 2222 } |
2227 | 2223 |
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 | |
2253 recv_streams_.insert(std::make_pair( | 2224 recv_streams_.insert(std::make_pair( |
2254 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, | 2225 ssrc, |
2255 recv_transport_cc_enabled_, | 2226 new WebRtcAudioReceiveStream( |
2256 recv_nack_enabled_, | 2227 channel, ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_, |
2257 sp.sync_label, recv_rtp_extensions_, | 2228 recv_nack_enabled_, sp.sync_label, recv_rtp_extensions_, call_, this, |
2258 call_, this, | 2229 engine()->decoder_factory_, decoder_map_))); |
2259 engine()->decoder_factory_))); | |
2260 recv_streams_[ssrc]->SetPlayout(playout_); | 2230 recv_streams_[ssrc]->SetPlayout(playout_); |
2261 | 2231 |
2262 return true; | 2232 return true; |
2263 } | 2233 } |
2264 | 2234 |
2265 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { | 2235 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2266 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); | 2236 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); |
2267 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2268 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; | 2238 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; |
2269 | 2239 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 ssrc); | 2624 ssrc); |
2655 if (it != unsignaled_recv_ssrcs_.end()) { | 2625 if (it != unsignaled_recv_ssrcs_.end()) { |
2656 unsignaled_recv_ssrcs_.erase(it); | 2626 unsignaled_recv_ssrcs_.erase(it); |
2657 return true; | 2627 return true; |
2658 } | 2628 } |
2659 return false; | 2629 return false; |
2660 } | 2630 } |
2661 } // namespace cricket | 2631 } // namespace cricket |
2662 | 2632 |
2663 #endif // HAVE_WEBRTC_VOICE | 2633 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |