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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 // Dumps an AudioCodec in RFC 2327-ish format. | 138 // Dumps an AudioCodec in RFC 2327-ish format. |
139 std::string ToString(const AudioCodec& codec) { | 139 std::string ToString(const AudioCodec& codec) { |
140 std::stringstream ss; | 140 std::stringstream ss; |
141 ss << codec.name << "/" << codec.clockrate << "/" << codec.channels | 141 ss << codec.name << "/" << codec.clockrate << "/" << codec.channels |
142 << " (" << codec.id << ")"; | 142 << " (" << codec.id << ")"; |
143 return ss.str(); | 143 return ss.str(); |
144 } | 144 } |
145 | 145 |
146 std::string ToString(const webrtc::CodecInst& codec) { | |
147 std::stringstream ss; | |
148 ss << codec.plname << "/" << codec.plfreq << "/" << codec.channels | |
149 << " (" << codec.pltype << ")"; | |
150 return ss.str(); | |
151 } | |
152 | |
153 bool IsCodec(const AudioCodec& codec, const char* ref_name) { | 146 bool IsCodec(const AudioCodec& codec, const char* ref_name) { |
154 return (_stricmp(codec.name.c_str(), ref_name) == 0); | 147 return (_stricmp(codec.name.c_str(), ref_name) == 0); |
155 } | 148 } |
156 | 149 |
157 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { | 150 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
158 return (_stricmp(codec.plname, ref_name) == 0); | 151 return (_stricmp(codec.plname, ref_name) == 0); |
159 } | 152 } |
160 | 153 |
161 bool FindCodec(const std::vector<AudioCodec>& codecs, | 154 bool FindCodec(const std::vector<AudioCodec>& codecs, |
162 const AudioCodec& codec, | 155 const AudioCodec& codec, |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 WebRtcAudioReceiveStream( | 1491 WebRtcAudioReceiveStream( |
1499 int ch, | 1492 int ch, |
1500 uint32_t remote_ssrc, | 1493 uint32_t remote_ssrc, |
1501 uint32_t local_ssrc, | 1494 uint32_t local_ssrc, |
1502 bool use_transport_cc, | 1495 bool use_transport_cc, |
1503 bool use_nack, | 1496 bool use_nack, |
1504 const std::string& sync_group, | 1497 const std::string& sync_group, |
1505 const std::vector<webrtc::RtpExtension>& extensions, | 1498 const std::vector<webrtc::RtpExtension>& extensions, |
1506 webrtc::Call* call, | 1499 webrtc::Call* call, |
1507 webrtc::Transport* rtcp_send_transport, | 1500 webrtc::Transport* rtcp_send_transport, |
1508 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory) | 1501 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
| 1502 const std::map<int, webrtc::SdpAudioFormat>& decoder_map) |
1509 : call_(call), config_() { | 1503 : call_(call), config_() { |
1510 RTC_DCHECK_GE(ch, 0); | 1504 RTC_DCHECK_GE(ch, 0); |
1511 RTC_DCHECK(call); | 1505 RTC_DCHECK(call); |
1512 config_.rtp.remote_ssrc = remote_ssrc; | 1506 config_.rtp.remote_ssrc = remote_ssrc; |
1513 config_.rtp.local_ssrc = local_ssrc; | 1507 config_.rtp.local_ssrc = local_ssrc; |
1514 config_.rtp.transport_cc = use_transport_cc; | 1508 config_.rtp.transport_cc = use_transport_cc; |
1515 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; | 1509 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; |
1516 config_.rtp.extensions = extensions; | 1510 config_.rtp.extensions = extensions; |
1517 config_.rtcp_send_transport = rtcp_send_transport; | 1511 config_.rtcp_send_transport = rtcp_send_transport; |
1518 config_.voe_channel_id = ch; | 1512 config_.voe_channel_id = ch; |
1519 config_.sync_group = sync_group; | 1513 config_.sync_group = sync_group; |
1520 config_.decoder_factory = decoder_factory; | 1514 config_.decoder_factory = decoder_factory; |
| 1515 config_.decoder_map = decoder_map; |
1521 RecreateAudioReceiveStream(); | 1516 RecreateAudioReceiveStream(); |
1522 } | 1517 } |
1523 | 1518 |
1524 ~WebRtcAudioReceiveStream() { | 1519 ~WebRtcAudioReceiveStream() { |
1525 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1520 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1526 call_->DestroyAudioReceiveStream(stream_); | 1521 call_->DestroyAudioReceiveStream(stream_); |
1527 } | 1522 } |
1528 | 1523 |
1529 void RecreateAudioReceiveStream(uint32_t local_ssrc) { | 1524 void RecreateAudioReceiveStream(uint32_t local_ssrc) { |
1530 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1525 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 } | 1894 } |
1900 decoder_map.insert({codec.id, std::move(format)}); | 1895 decoder_map.insert({codec.id, std::move(format)}); |
1901 } | 1896 } |
1902 | 1897 |
1903 if (playout_) { | 1898 if (playout_) { |
1904 // Receive codecs can not be changed while playing. So we temporarily | 1899 // Receive codecs can not be changed while playing. So we temporarily |
1905 // pause playout. | 1900 // pause playout. |
1906 ChangePlayout(false); | 1901 ChangePlayout(false); |
1907 } | 1902 } |
1908 | 1903 |
| 1904 decoder_map_ = std::move(decoder_map); |
1909 for (auto& kv : recv_streams_) { | 1905 for (auto& kv : recv_streams_) { |
1910 kv.second->RecreateAudioReceiveStream(decoder_map); | 1906 kv.second->RecreateAudioReceiveStream(decoder_map_); |
1911 } | 1907 } |
1912 recv_codecs_ = codecs; | 1908 recv_codecs_ = codecs; |
1913 | 1909 |
1914 if (desired_playout_ && !playout_) { | 1910 if (desired_playout_ && !playout_) { |
1915 ChangePlayout(desired_playout_); | 1911 ChangePlayout(desired_playout_); |
1916 } | 1912 } |
1917 return true; | 1913 return true; |
1918 } | 1914 } |
1919 | 1915 |
1920 // Utility function called from SetSendParameters() to extract current send | 1916 // Utility function called from SetSendParameters() to extract current send |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2253 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
2258 return false; | 2254 return false; |
2259 } | 2255 } |
2260 | 2256 |
2261 // Create a new channel for receiving audio data. | 2257 // Create a new channel for receiving audio data. |
2262 const int channel = CreateVoEChannel(); | 2258 const int channel = CreateVoEChannel(); |
2263 if (channel == -1) { | 2259 if (channel == -1) { |
2264 return false; | 2260 return false; |
2265 } | 2261 } |
2266 | 2262 |
2267 // Turn off all supported codecs. | |
2268 // TODO(solenberg): Remove once "no codecs" is the default state of a stream. | |
2269 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { | |
2270 voe_codec.pltype = -1; | |
2271 if (engine()->voe()->codec()->SetRecPayloadType(channel, voe_codec) == -1) { | |
2272 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); | |
2273 DeleteVoEChannel(channel); | |
2274 return false; | |
2275 } | |
2276 } | |
2277 | |
2278 // Only enable those configured for this channel. | |
2279 for (const auto& codec : recv_codecs_) { | |
2280 webrtc::CodecInst voe_codec = {0}; | |
2281 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) { | |
2282 voe_codec.pltype = codec.id; | |
2283 if (engine()->voe()->codec()->SetRecPayloadType( | |
2284 channel, voe_codec) == -1) { | |
2285 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); | |
2286 DeleteVoEChannel(channel); | |
2287 return false; | |
2288 } | |
2289 } | |
2290 } | |
2291 | |
2292 recv_streams_.insert(std::make_pair( | 2263 recv_streams_.insert(std::make_pair( |
2293 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, | 2264 ssrc, |
2294 recv_transport_cc_enabled_, | 2265 new WebRtcAudioReceiveStream( |
2295 recv_nack_enabled_, | 2266 channel, ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_, |
2296 sp.sync_label, recv_rtp_extensions_, | 2267 recv_nack_enabled_, sp.sync_label, recv_rtp_extensions_, call_, this, |
2297 call_, this, | 2268 engine()->decoder_factory_, decoder_map_))); |
2298 engine()->decoder_factory_))); | |
2299 recv_streams_[ssrc]->SetPlayout(playout_); | 2269 recv_streams_[ssrc]->SetPlayout(playout_); |
2300 | 2270 |
2301 return true; | 2271 return true; |
2302 } | 2272 } |
2303 | 2273 |
2304 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { | 2274 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2305 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); | 2275 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); |
2306 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2276 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2307 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; | 2277 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; |
2308 | 2278 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 ssrc); | 2663 ssrc); |
2694 if (it != unsignaled_recv_ssrcs_.end()) { | 2664 if (it != unsignaled_recv_ssrcs_.end()) { |
2695 unsignaled_recv_ssrcs_.erase(it); | 2665 unsignaled_recv_ssrcs_.erase(it); |
2696 return true; | 2666 return true; |
2697 } | 2667 } |
2698 return false; | 2668 return false; |
2699 } | 2669 } |
2700 } // namespace cricket | 2670 } // namespace cricket |
2701 | 2671 |
2702 #endif // HAVE_WEBRTC_VOICE | 2672 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |