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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 StopAecDump(); | 572 StopAecDump(); |
573 | 573 |
574 voe_wrapper_->base()->Terminate(); | 574 voe_wrapper_->base()->Terminate(); |
575 desired_local_monitor_enable_ = false; | 575 desired_local_monitor_enable_ = false; |
576 } | 576 } |
577 | 577 |
578 int WebRtcVoiceEngine::GetCapabilities() { | 578 int WebRtcVoiceEngine::GetCapabilities() { |
579 return AUDIO_SEND | AUDIO_RECV; | 579 return AUDIO_SEND | AUDIO_RECV; |
580 } | 580 } |
581 | 581 |
582 VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel( | 582 VoiceMediaChannel* WebRtcVoiceEngine::CreateChannel(webrtc::Call* call, |
583 const AudioOptions& options) { | 583 const AudioOptions& options) { |
584 WebRtcVoiceMediaChannel* ch = new WebRtcVoiceMediaChannel(this); | 584 WebRtcVoiceMediaChannel* ch = new WebRtcVoiceMediaChannel(this, call); |
585 if (!ch->valid()) { | 585 if (!ch->valid()) { |
586 delete ch; | 586 delete ch; |
587 return nullptr; | 587 return nullptr; |
588 } | 588 } |
589 if (!ch->SetOptions(options)) { | 589 if (!ch->SetOptions(options)) { |
590 LOG(LS_WARNING) << "Failed to set options while creating channel."; | 590 LOG(LS_WARNING) << "Failed to set options while creating channel."; |
591 } | 591 } |
592 return ch; | 592 return ch; |
593 } | 593 } |
594 | 594 |
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. | 1682 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. |
1683 // PeerConnection will make sure invalidating the pointer before the object | 1683 // PeerConnection will make sure invalidating the pointer before the object |
1684 // goes away. | 1684 // goes away. |
1685 AudioRenderer* renderer_; | 1685 AudioRenderer* renderer_; |
1686 | 1686 |
1687 // Protects |renderer_| in Start(), Stop() and OnClose(). | 1687 // Protects |renderer_| in Start(), Stop() and OnClose(). |
1688 rtc::CriticalSection lock_; | 1688 rtc::CriticalSection lock_; |
1689 }; | 1689 }; |
1690 | 1690 |
1691 // WebRtcVoiceMediaChannel | 1691 // WebRtcVoiceMediaChannel |
1692 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine) | 1692 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
| 1693 webrtc::Call* call) |
1693 : engine_(engine), | 1694 : engine_(engine), |
1694 voe_channel_(engine->CreateMediaVoiceChannel()), | 1695 voe_channel_(engine->CreateMediaVoiceChannel()), |
1695 send_bitrate_setting_(false), | 1696 send_bitrate_setting_(false), |
1696 send_bitrate_bps_(0), | 1697 send_bitrate_bps_(0), |
1697 options_(), | 1698 options_(), |
1698 dtmf_allowed_(false), | 1699 dtmf_allowed_(false), |
1699 desired_playout_(false), | 1700 desired_playout_(false), |
1700 nack_enabled_(false), | 1701 nack_enabled_(false), |
1701 playout_(false), | 1702 playout_(false), |
1702 typing_noise_detected_(false), | 1703 typing_noise_detected_(false), |
1703 desired_send_(SEND_NOTHING), | 1704 desired_send_(SEND_NOTHING), |
1704 send_(SEND_NOTHING), | 1705 send_(SEND_NOTHING), |
1705 call_(nullptr), | 1706 call_(call), |
1706 default_receive_ssrc_(0) { | 1707 default_receive_ssrc_(0) { |
1707 engine->RegisterChannel(this); | 1708 engine->RegisterChannel(this); |
1708 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel " | 1709 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel " |
1709 << voe_channel(); | 1710 << voe_channel(); |
| 1711 DCHECK(nullptr != call); |
1710 ConfigureSendChannel(voe_channel()); | 1712 ConfigureSendChannel(voe_channel()); |
1711 } | 1713 } |
1712 | 1714 |
1713 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { | 1715 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { |
1714 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel " | 1716 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel " |
1715 << voe_channel(); | 1717 << voe_channel(); |
1716 DCHECK(receive_streams_.empty() || call_); | |
1717 | 1718 |
1718 // Remove any remaining send streams, the default channel will be deleted | 1719 // Remove any remaining send streams, the default channel will be deleted |
1719 // later. | 1720 // later. |
1720 while (!send_channels_.empty()) | 1721 while (!send_channels_.empty()) |
1721 RemoveSendStream(send_channels_.begin()->first); | 1722 RemoveSendStream(send_channels_.begin()->first); |
1722 | 1723 |
1723 // Unregister ourselves from the engine. | 1724 // Unregister ourselves from the engine. |
1724 engine()->UnregisterChannel(this); | 1725 engine()->UnregisterChannel(this); |
1725 // Remove any remaining streams. | 1726 // Remove any remaining streams. |
1726 while (!receive_channels_.empty()) { | 1727 while (!receive_channels_.empty()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 } | 1827 } |
1827 if (dscp_option_changed) { | 1828 if (dscp_option_changed) { |
1828 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; | 1829 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; |
1829 if (options_.dscp.GetWithDefaultIfUnset(false)) | 1830 if (options_.dscp.GetWithDefaultIfUnset(false)) |
1830 dscp = kAudioDscpValue; | 1831 dscp = kAudioDscpValue; |
1831 if (MediaChannel::SetDscp(dscp) != 0) { | 1832 if (MediaChannel::SetDscp(dscp) != 0) { |
1832 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; | 1833 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; |
1833 } | 1834 } |
1834 } | 1835 } |
1835 | 1836 |
1836 SetCall(call_); | 1837 RecreateAudioReceiveStreams(); |
1837 | 1838 |
1838 LOG(LS_INFO) << "Set voice channel options. Current options: " | 1839 LOG(LS_INFO) << "Set voice channel options. Current options: " |
1839 << options_.ToString(); | 1840 << options_.ToString(); |
1840 return true; | 1841 return true; |
1841 } | 1842 } |
1842 | 1843 |
1843 bool WebRtcVoiceMediaChannel::SetRecvCodecs( | 1844 bool WebRtcVoiceMediaChannel::SetRecvCodecs( |
1844 const std::vector<AudioCodec>& codecs) { | 1845 const std::vector<AudioCodec>& codecs) { |
1845 // Set the payload types to be used for incoming media. | 1846 // Set the payload types to be used for incoming media. |
1846 LOG(LS_INFO) << "Setting receive voice codecs:"; | 1847 LOG(LS_INFO) << "Setting receive voice codecs:"; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 } | 2196 } |
2196 | 2197 |
2197 const RtpHeaderExtension* send_time_extension = | 2198 const RtpHeaderExtension* send_time_extension = |
2198 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); | 2199 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); |
2199 if (send_time_extension) { | 2200 if (send_time_extension) { |
2200 exts.push_back({ | 2201 exts.push_back({ |
2201 kRtpAbsoluteSenderTimeHeaderExtension, send_time_extension->id}); | 2202 kRtpAbsoluteSenderTimeHeaderExtension, send_time_extension->id}); |
2202 } | 2203 } |
2203 | 2204 |
2204 recv_rtp_extensions_.swap(exts); | 2205 recv_rtp_extensions_.swap(exts); |
2205 SetCall(call_); | 2206 RecreateAudioReceiveStreams(); |
2206 } | 2207 } |
2207 | 2208 |
2208 return true; | 2209 return true; |
2209 } | 2210 } |
2210 | 2211 |
2211 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( | 2212 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( |
2212 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { | 2213 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { |
2213 const RtpHeaderExtension* audio_level_extension = | 2214 const RtpHeaderExtension* audio_level_extension = |
2214 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); | 2215 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); |
2215 if (!SetHeaderExtension( | 2216 if (!SetHeaderExtension( |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2554 // when the default channel is not being used. | 2555 // when the default channel is not being used. |
2555 webrtc::AudioTransport* audio_transport = | 2556 webrtc::AudioTransport* audio_transport = |
2556 engine()->voe()->base()->audio_transport(); | 2557 engine()->voe()->base()->audio_transport(); |
2557 if (!InConferenceMode() && default_receive_ssrc_ == 0) { | 2558 if (!InConferenceMode() && default_receive_ssrc_ == 0) { |
2558 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; | 2559 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; |
2559 default_receive_ssrc_ = ssrc; | 2560 default_receive_ssrc_ = ssrc; |
2560 WebRtcVoiceChannelRenderer* channel_renderer = | 2561 WebRtcVoiceChannelRenderer* channel_renderer = |
2561 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); | 2562 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); |
2562 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2563 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
2563 receive_stream_params_[ssrc] = sp; | 2564 receive_stream_params_[ssrc] = sp; |
2564 TryAddAudioRecvStream(ssrc); | 2565 AddAudioReceiveStream(ssrc); |
2565 return SetPlayout(voe_channel(), playout_); | 2566 return SetPlayout(voe_channel(), playout_); |
2566 } | 2567 } |
2567 | 2568 |
2568 // Create a new channel for receiving audio data. | 2569 // Create a new channel for receiving audio data. |
2569 int channel = engine()->CreateMediaVoiceChannel(); | 2570 int channel = engine()->CreateMediaVoiceChannel(); |
2570 if (channel == -1) { | 2571 if (channel == -1) { |
2571 LOG_RTCERR0(CreateChannel); | 2572 LOG_RTCERR0(CreateChannel); |
2572 return false; | 2573 return false; |
2573 } | 2574 } |
2574 | 2575 |
2575 if (!ConfigureRecvChannel(channel)) { | 2576 if (!ConfigureRecvChannel(channel)) { |
2576 DeleteChannel(channel); | 2577 DeleteChannel(channel); |
2577 return false; | 2578 return false; |
2578 } | 2579 } |
2579 | 2580 |
2580 WebRtcVoiceChannelRenderer* channel_renderer = | 2581 WebRtcVoiceChannelRenderer* channel_renderer = |
2581 new WebRtcVoiceChannelRenderer(channel, audio_transport); | 2582 new WebRtcVoiceChannelRenderer(channel, audio_transport); |
2582 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2583 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
2583 receive_stream_params_[ssrc] = sp; | 2584 receive_stream_params_[ssrc] = sp; |
2584 TryAddAudioRecvStream(ssrc); | 2585 AddAudioReceiveStream(ssrc); |
2585 | 2586 |
2586 LOG(LS_INFO) << "New audio stream " << ssrc | 2587 LOG(LS_INFO) << "New audio stream " << ssrc |
2587 << " registered to VoiceEngine channel #" | 2588 << " registered to VoiceEngine channel #" |
2588 << channel << "."; | 2589 << channel << "."; |
2589 return true; | 2590 return true; |
2590 } | 2591 } |
2591 | 2592 |
2592 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { | 2593 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { |
2593 // Configure to use external transport, like our default channel. | 2594 // Configure to use external transport, like our default channel. |
2594 if (engine()->voe()->network()->RegisterExternalTransport( | 2595 if (engine()->voe()->network()->RegisterExternalTransport( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { | 2664 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { |
2664 DCHECK(thread_checker_.CalledOnValidThread()); | 2665 DCHECK(thread_checker_.CalledOnValidThread()); |
2665 rtc::CritScope lock(&receive_channels_cs_); | 2666 rtc::CritScope lock(&receive_channels_cs_); |
2666 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2667 ChannelMap::iterator it = receive_channels_.find(ssrc); |
2667 if (it == receive_channels_.end()) { | 2668 if (it == receive_channels_.end()) { |
2668 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2669 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
2669 << " which doesn't exist."; | 2670 << " which doesn't exist."; |
2670 return false; | 2671 return false; |
2671 } | 2672 } |
2672 | 2673 |
2673 TryRemoveAudioRecvStream(ssrc); | 2674 RemoveAudioReceiveStream(ssrc); |
2674 receive_stream_params_.erase(ssrc); | 2675 receive_stream_params_.erase(ssrc); |
2675 | 2676 |
2676 // Delete the WebRtcVoiceChannelRenderer object connected to the channel, this | 2677 // Delete the WebRtcVoiceChannelRenderer object connected to the channel, this |
2677 // will disconnect the audio renderer with the receive channel. | 2678 // will disconnect the audio renderer with the receive channel. |
2678 // Cache the channel before the deletion. | 2679 // Cache the channel before the deletion. |
2679 const int channel = it->second->channel(); | 2680 const int channel = it->second->channel(); |
2680 delete it->second; | 2681 delete it->second; |
2681 receive_channels_.erase(it); | 2682 receive_channels_.erase(it); |
2682 | 2683 |
2683 if (ssrc == default_receive_ssrc_) { | 2684 if (ssrc == default_receive_ssrc_) { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 } | 2958 } |
2958 } | 2959 } |
2959 | 2960 |
2960 return true; | 2961 return true; |
2961 } | 2962 } |
2962 | 2963 |
2963 void WebRtcVoiceMediaChannel::OnPacketReceived( | 2964 void WebRtcVoiceMediaChannel::OnPacketReceived( |
2964 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2965 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
2965 DCHECK(thread_checker_.CalledOnValidThread()); | 2966 DCHECK(thread_checker_.CalledOnValidThread()); |
2966 | 2967 |
2967 // If hooked up to a "Call", forward packet there too. | 2968 // Forward packet to Call as well. |
2968 if (call_) { | 2969 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
2969 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 2970 packet_time.not_before); |
2970 packet_time.not_before); | 2971 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2971 call_->Receiver()->DeliverPacket( | 2972 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), |
2972 webrtc::MediaType::AUDIO, | 2973 webrtc_packet_time); |
2973 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | |
2974 webrtc_packet_time); | |
2975 } | |
2976 | 2974 |
2977 // Pick which channel to send this packet to. If this packet doesn't match | 2975 // Pick which channel to send this packet to. If this packet doesn't match |
2978 // any multiplexed streams, just send it to the default channel. Otherwise, | 2976 // any multiplexed streams, just send it to the default channel. Otherwise, |
2979 // send it to the specific decoder instance for that stream. | 2977 // send it to the specific decoder instance for that stream. |
2980 int which_channel = | 2978 int which_channel = |
2981 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); | 2979 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); |
2982 if (which_channel == -1) { | 2980 if (which_channel == -1) { |
2983 which_channel = voe_channel(); | 2981 which_channel = voe_channel(); |
2984 } | 2982 } |
2985 | 2983 |
(...skipping 16 matching lines...) Expand all Loading... |
3002 // Pass it off to the decoder. | 3000 // Pass it off to the decoder. |
3003 engine()->voe()->network()->ReceivedRTPPacket( | 3001 engine()->voe()->network()->ReceivedRTPPacket( |
3004 which_channel, packet->data(), packet->size(), | 3002 which_channel, packet->data(), packet->size(), |
3005 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); | 3003 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); |
3006 } | 3004 } |
3007 | 3005 |
3008 void WebRtcVoiceMediaChannel::OnRtcpReceived( | 3006 void WebRtcVoiceMediaChannel::OnRtcpReceived( |
3009 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 3007 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
3010 DCHECK(thread_checker_.CalledOnValidThread()); | 3008 DCHECK(thread_checker_.CalledOnValidThread()); |
3011 | 3009 |
3012 // If hooked up to a "Call", forward packet there too. | 3010 // Forward packet to Call as well. |
3013 if (call_) { | 3011 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
3014 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 3012 packet_time.not_before); |
3015 packet_time.not_before); | 3013 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
3016 call_->Receiver()->DeliverPacket( | 3014 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), |
3017 webrtc::MediaType::AUDIO, | 3015 webrtc_packet_time); |
3018 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | |
3019 webrtc_packet_time); | |
3020 } | |
3021 | 3016 |
3022 // Sending channels need all RTCP packets with feedback information. | 3017 // Sending channels need all RTCP packets with feedback information. |
3023 // Even sender reports can contain attached report blocks. | 3018 // Even sender reports can contain attached report blocks. |
3024 // Receiving channels need sender reports in order to create | 3019 // Receiving channels need sender reports in order to create |
3025 // correct receiver reports. | 3020 // correct receiver reports. |
3026 int type = 0; | 3021 int type = 0; |
3027 if (!GetRtcpType(packet->data(), packet->size(), &type)) { | 3022 if (!GetRtcpType(packet->data(), packet->size(), &type)) { |
3028 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; | 3023 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; |
3029 return; | 3024 return; |
3030 } | 3025 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3395 } | 3390 } |
3396 | 3391 |
3397 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { | 3392 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { |
3398 ChannelMap::const_iterator it = send_channels_.find(ssrc); | 3393 ChannelMap::const_iterator it = send_channels_.find(ssrc); |
3399 if (it != send_channels_.end()) | 3394 if (it != send_channels_.end()) |
3400 return it->second->channel(); | 3395 return it->second->channel(); |
3401 | 3396 |
3402 return -1; | 3397 return -1; |
3403 } | 3398 } |
3404 | 3399 |
3405 void WebRtcVoiceMediaChannel::SetCall(webrtc::Call* call) { | |
3406 DCHECK(thread_checker_.CalledOnValidThread()); | |
3407 for (const auto& it : receive_channels_) { | |
3408 TryRemoveAudioRecvStream(it.first); | |
3409 } | |
3410 call_ = call; | |
3411 for (const auto& it : receive_channels_) { | |
3412 TryAddAudioRecvStream(it.first); | |
3413 } | |
3414 } | |
3415 | |
3416 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, | 3400 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, |
3417 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { | 3401 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { |
3418 // Get the RED encodings from the parameter with no name. This may | 3402 // Get the RED encodings from the parameter with no name. This may |
3419 // change based on what is discussed on the Jingle list. | 3403 // change based on what is discussed on the Jingle list. |
3420 // The encoding parameter is of the form "a/b"; we only support where | 3404 // The encoding parameter is of the form "a/b"; we only support where |
3421 // a == b. Verify this and parse out the value into red_pt. | 3405 // a == b. Verify this and parse out the value into red_pt. |
3422 // If the parameter value is absent (as it will be until we wire up the | 3406 // If the parameter value is absent (as it will be until we wire up the |
3423 // signaling of this message), use the second codec specified (i.e. the | 3407 // signaling of this message), use the second codec specified (i.e. the |
3424 // one after "red") as the encoding parameter. | 3408 // one after "red") as the encoding parameter. |
3425 int red_pt = -1; | 3409 int red_pt = -1; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 id = extension->id; | 3536 id = extension->id; |
3553 uri = extension->uri; | 3537 uri = extension->uri; |
3554 } | 3538 } |
3555 if ((engine()->voe()->rtp()->*setter)(channel_id, enable, id) != 0) { | 3539 if ((engine()->voe()->rtp()->*setter)(channel_id, enable, id) != 0) { |
3556 LOG_RTCERR4(*setter, uri, channel_id, enable, id); | 3540 LOG_RTCERR4(*setter, uri, channel_id, enable, id); |
3557 return false; | 3541 return false; |
3558 } | 3542 } |
3559 return true; | 3543 return true; |
3560 } | 3544 } |
3561 | 3545 |
3562 void WebRtcVoiceMediaChannel::TryAddAudioRecvStream(uint32 ssrc) { | 3546 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { |
| 3547 DCHECK(thread_checker_.CalledOnValidThread()); |
| 3548 for (const auto& it : receive_channels_) { |
| 3549 RemoveAudioReceiveStream(it.first); |
| 3550 } |
| 3551 for (const auto& it : receive_channels_) { |
| 3552 AddAudioReceiveStream(it.first); |
| 3553 } |
| 3554 } |
| 3555 |
| 3556 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { |
3563 DCHECK(thread_checker_.CalledOnValidThread()); | 3557 DCHECK(thread_checker_.CalledOnValidThread()); |
3564 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; | 3558 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; |
3565 DCHECK(channel != nullptr); | 3559 DCHECK(channel != nullptr); |
3566 DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); | 3560 DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); |
3567 // If we are hooked up to a webrtc::Call, create an AudioReceiveStream too. | |
3568 if (!call_) { | |
3569 return; | |
3570 } | |
3571 webrtc::AudioReceiveStream::Config config; | 3561 webrtc::AudioReceiveStream::Config config; |
3572 config.rtp.remote_ssrc = ssrc; | 3562 config.rtp.remote_ssrc = ssrc; |
3573 // Only add RTP extensions if we support combined A/V BWE. | 3563 // Only add RTP extensions if we support combined A/V BWE. |
3574 config.rtp.extensions = recv_rtp_extensions_; | 3564 config.rtp.extensions = recv_rtp_extensions_; |
3575 config.combined_audio_video_bwe = | 3565 config.combined_audio_video_bwe = |
3576 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); | 3566 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); |
3577 config.voe_channel_id = channel->channel(); | 3567 config.voe_channel_id = channel->channel(); |
3578 config.sync_group = receive_stream_params_[ssrc].sync_label; | 3568 config.sync_group = receive_stream_params_[ssrc].sync_label; |
3579 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); | 3569 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); |
3580 receive_streams_.insert(std::make_pair(ssrc, s)); | 3570 receive_streams_.insert(std::make_pair(ssrc, s)); |
3581 } | 3571 } |
3582 | 3572 |
3583 void WebRtcVoiceMediaChannel::TryRemoveAudioRecvStream(uint32 ssrc) { | 3573 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) { |
3584 DCHECK(thread_checker_.CalledOnValidThread()); | 3574 DCHECK(thread_checker_.CalledOnValidThread()); |
3585 // If we are hooked up to a webrtc::Call, assume there is an | 3575 auto stream_it = receive_streams_.find(ssrc); |
3586 // AudioReceiveStream to destroy too. | 3576 if (stream_it != receive_streams_.end()) { |
3587 if (call_) { | 3577 call_->DestroyAudioReceiveStream(stream_it->second); |
3588 auto stream_it = receive_streams_.find(ssrc); | 3578 receive_streams_.erase(stream_it); |
3589 if (stream_it != receive_streams_.end()) { | |
3590 call_->DestroyAudioReceiveStream(stream_it->second); | |
3591 receive_streams_.erase(stream_it); | |
3592 } | |
3593 } | 3579 } |
3594 } | 3580 } |
3595 | 3581 |
3596 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( | 3582 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( |
3597 const std::vector<AudioCodec>& new_codecs) { | 3583 const std::vector<AudioCodec>& new_codecs) { |
3598 for (const AudioCodec& codec : new_codecs) { | 3584 for (const AudioCodec& codec : new_codecs) { |
3599 webrtc::CodecInst voe_codec; | 3585 webrtc::CodecInst voe_codec; |
3600 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { | 3586 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { |
3601 LOG(LS_INFO) << ToString(codec); | 3587 LOG(LS_INFO) << ToString(codec); |
3602 voe_codec.pltype = codec.id; | 3588 voe_codec.pltype = codec.id; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3639 | 3625 |
3640 int WebRtcSoundclipStream::Rewind() { | 3626 int WebRtcSoundclipStream::Rewind() { |
3641 mem_.Rewind(); | 3627 mem_.Rewind(); |
3642 // Return -1 to keep VoiceEngine from looping. | 3628 // Return -1 to keep VoiceEngine from looping. |
3643 return (loop_) ? 0 : -1; | 3629 return (loop_) ? 0 : -1; |
3644 } | 3630 } |
3645 | 3631 |
3646 } // namespace cricket | 3632 } // namespace cricket |
3647 | 3633 |
3648 #endif // HAVE_WEBRTC_VOICE | 3634 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |