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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 } | 133 } |
134 | 134 |
135 // Dumps an AudioCodec in RFC 2327-ish format. | 135 // Dumps an AudioCodec in RFC 2327-ish format. |
136 std::string ToString(const AudioCodec& codec) { | 136 std::string ToString(const AudioCodec& codec) { |
137 std::stringstream ss; | 137 std::stringstream ss; |
138 ss << codec.name << "/" << codec.clockrate << "/" << codec.channels | 138 ss << codec.name << "/" << codec.clockrate << "/" << codec.channels |
139 << " (" << codec.id << ")"; | 139 << " (" << codec.id << ")"; |
140 return ss.str(); | 140 return ss.str(); |
141 } | 141 } |
142 | 142 |
143 std::string ToString(const webrtc::CodecInst& codec) { | |
144 std::stringstream ss; | |
145 ss << codec.plname << "/" << codec.plfreq << "/" << codec.channels | |
146 << " (" << codec.pltype << ")"; | |
147 return ss.str(); | |
148 } | |
149 | |
150 bool IsCodec(const AudioCodec& codec, const char* ref_name) { | 143 bool IsCodec(const AudioCodec& codec, const char* ref_name) { |
151 return (_stricmp(codec.name.c_str(), ref_name) == 0); | 144 return (_stricmp(codec.name.c_str(), ref_name) == 0); |
152 } | 145 } |
153 | 146 |
154 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { | 147 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
155 return (_stricmp(codec.plname, ref_name) == 0); | 148 return (_stricmp(codec.plname, ref_name) == 0); |
156 } | 149 } |
157 | 150 |
158 bool FindCodec(const std::vector<AudioCodec>& codecs, | 151 bool FindCodec(const std::vector<AudioCodec>& codecs, |
159 const AudioCodec& codec, | 152 const AudioCodec& codec, |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1496 WebRtcAudioReceiveStream( | 1489 WebRtcAudioReceiveStream( |
1497 int ch, | 1490 int ch, |
1498 uint32_t remote_ssrc, | 1491 uint32_t remote_ssrc, |
1499 uint32_t local_ssrc, | 1492 uint32_t local_ssrc, |
1500 bool use_transport_cc, | 1493 bool use_transport_cc, |
1501 bool use_nack, | 1494 bool use_nack, |
1502 const std::string& sync_group, | 1495 const std::string& sync_group, |
1503 const std::vector<webrtc::RtpExtension>& extensions, | 1496 const std::vector<webrtc::RtpExtension>& extensions, |
1504 webrtc::Call* call, | 1497 webrtc::Call* call, |
1505 webrtc::Transport* rtcp_send_transport, | 1498 webrtc::Transport* rtcp_send_transport, |
1506 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory) | 1499 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
1500 const std::map<int, webrtc::SdpAudioFormat>& decoder_map) | |
1507 : call_(call), config_() { | 1501 : call_(call), config_() { |
1508 RTC_DCHECK_GE(ch, 0); | 1502 RTC_DCHECK_GE(ch, 0); |
1509 RTC_DCHECK(call); | 1503 RTC_DCHECK(call); |
1510 config_.rtp.remote_ssrc = remote_ssrc; | 1504 config_.rtp.remote_ssrc = remote_ssrc; |
1511 config_.rtp.local_ssrc = local_ssrc; | 1505 config_.rtp.local_ssrc = local_ssrc; |
1512 config_.rtp.transport_cc = use_transport_cc; | 1506 config_.rtp.transport_cc = use_transport_cc; |
1513 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; | 1507 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; |
1514 config_.rtp.extensions = extensions; | 1508 config_.rtp.extensions = extensions; |
1515 config_.rtcp_send_transport = rtcp_send_transport; | 1509 config_.rtcp_send_transport = rtcp_send_transport; |
1516 config_.voe_channel_id = ch; | 1510 config_.voe_channel_id = ch; |
1517 config_.sync_group = sync_group; | 1511 config_.sync_group = sync_group; |
1518 config_.decoder_factory = decoder_factory; | 1512 config_.decoder_factory = decoder_factory; |
1513 config_.decoder_map = decoder_map; | |
1519 RecreateAudioReceiveStream(); | 1514 RecreateAudioReceiveStream(); |
1520 } | 1515 } |
1521 | 1516 |
1522 ~WebRtcAudioReceiveStream() { | 1517 ~WebRtcAudioReceiveStream() { |
1523 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1518 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1524 call_->DestroyAudioReceiveStream(stream_); | 1519 call_->DestroyAudioReceiveStream(stream_); |
1525 } | 1520 } |
1526 | 1521 |
1527 void RecreateAudioReceiveStream(uint32_t local_ssrc) { | 1522 void RecreateAudioReceiveStream(uint32_t local_ssrc) { |
1528 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1523 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1891 } | 1886 } |
1892 decoder_map.insert({codec.id, std::move(format)}); | 1887 decoder_map.insert({codec.id, std::move(format)}); |
1893 } | 1888 } |
1894 | 1889 |
1895 if (playout_) { | 1890 if (playout_) { |
1896 // Receive codecs can not be changed while playing. So we temporarily | 1891 // Receive codecs can not be changed while playing. So we temporarily |
1897 // pause playout. | 1892 // pause playout. |
1898 ChangePlayout(false); | 1893 ChangePlayout(false); |
1899 } | 1894 } |
1900 | 1895 |
1896 decoder_map_ = std::move(decoder_map); | |
the sun
2017/02/27 10:10:19
hmm, is this a move or a swap?
ossu
2017/03/02 16:55:09
Since we're not holding on to decoder_map outside
| |
1901 for (auto& kv : recv_streams_) { | 1897 for (auto& kv : recv_streams_) { |
1902 kv.second->RecreateAudioReceiveStream(decoder_map); | 1898 kv.second->RecreateAudioReceiveStream(decoder_map_); |
1903 } | 1899 } |
1904 recv_codecs_ = codecs; | 1900 recv_codecs_ = codecs; |
1905 | 1901 |
1906 if (desired_playout_ && !playout_) { | 1902 if (desired_playout_ && !playout_) { |
1907 ChangePlayout(desired_playout_); | 1903 ChangePlayout(desired_playout_); |
1908 } | 1904 } |
1909 return true; | 1905 return true; |
1910 } | 1906 } |
1911 | 1907 |
1912 // Utility function called from SetSendParameters() to extract current send | 1908 // Utility function called from SetSendParameters() to extract current send |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2250 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2246 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
2251 return false; | 2247 return false; |
2252 } | 2248 } |
2253 | 2249 |
2254 // Create a new channel for receiving audio data. | 2250 // Create a new channel for receiving audio data. |
2255 const int channel = CreateVoEChannel(); | 2251 const int channel = CreateVoEChannel(); |
2256 if (channel == -1) { | 2252 if (channel == -1) { |
2257 return false; | 2253 return false; |
2258 } | 2254 } |
2259 | 2255 |
2260 // Turn off all supported codecs. | |
2261 // TODO(solenberg): Remove once "no codecs" is the default state of a stream. | |
the sun
2017/02/27 10:10:19
Is there any change required to VoE::Channel to ma
| |
2262 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { | |
2263 voe_codec.pltype = -1; | |
2264 if (engine()->voe()->codec()->SetRecPayloadType(channel, voe_codec) == -1) { | |
2265 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); | |
2266 DeleteVoEChannel(channel); | |
2267 return false; | |
2268 } | |
2269 } | |
2270 | |
2271 // Only enable those configured for this channel. | |
2272 for (const auto& codec : recv_codecs_) { | |
2273 webrtc::CodecInst voe_codec = {0}; | |
2274 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) { | |
2275 voe_codec.pltype = codec.id; | |
2276 if (engine()->voe()->codec()->SetRecPayloadType( | |
2277 channel, voe_codec) == -1) { | |
2278 LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec)); | |
2279 DeleteVoEChannel(channel); | |
2280 return false; | |
2281 } | |
2282 } | |
2283 } | |
2284 | |
2285 recv_streams_.insert(std::make_pair( | 2256 recv_streams_.insert(std::make_pair( |
2286 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, | 2257 ssrc, |
2287 recv_transport_cc_enabled_, | 2258 new WebRtcAudioReceiveStream( |
2288 recv_nack_enabled_, | 2259 channel, ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_, |
2289 sp.sync_label, recv_rtp_extensions_, | 2260 recv_nack_enabled_, sp.sync_label, recv_rtp_extensions_, call_, this, |
2290 call_, this, | 2261 engine()->decoder_factory_, decoder_map_))); |
2291 engine()->decoder_factory_))); | |
2292 recv_streams_[ssrc]->SetPlayout(playout_); | 2262 recv_streams_[ssrc]->SetPlayout(playout_); |
2293 | 2263 |
2294 return true; | 2264 return true; |
2295 } | 2265 } |
2296 | 2266 |
2297 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { | 2267 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2298 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); | 2268 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); |
2299 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2269 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2300 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; | 2270 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; |
2301 | 2271 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2662 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2632 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2663 const auto it = send_streams_.find(ssrc); | 2633 const auto it = send_streams_.find(ssrc); |
2664 if (it != send_streams_.end()) { | 2634 if (it != send_streams_.end()) { |
2665 return it->second->channel(); | 2635 return it->second->channel(); |
2666 } | 2636 } |
2667 return -1; | 2637 return -1; |
2668 } | 2638 } |
2669 } // namespace cricket | 2639 } // namespace cricket |
2670 | 2640 |
2671 #endif // HAVE_WEBRTC_VOICE | 2641 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |