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 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1681 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. | 1681 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. |
1682 // PeerConnection will make sure invalidating the pointer before the object | 1682 // PeerConnection will make sure invalidating the pointer before the object |
1683 // goes away. | 1683 // goes away. |
1684 AudioRenderer* renderer_; | 1684 AudioRenderer* renderer_; |
1685 | 1685 |
1686 // Protects |renderer_| in Start(), Stop() and OnClose(). | 1686 // Protects |renderer_| in Start(), Stop() and OnClose(). |
1687 rtc::CriticalSection lock_; | 1687 rtc::CriticalSection lock_; |
1688 }; | 1688 }; |
1689 | 1689 |
1690 // WebRtcVoiceMediaChannel | 1690 // WebRtcVoiceMediaChannel |
1691 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine) | 1691 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
1692 webrtc::Call* call) | |
1692 : engine_(engine), | 1693 : engine_(engine), |
1693 voe_channel_(engine->CreateMediaVoiceChannel()), | 1694 voe_channel_(engine->CreateMediaVoiceChannel()), |
1694 send_bitrate_setting_(false), | 1695 send_bitrate_setting_(false), |
1695 send_bitrate_bps_(0), | 1696 send_bitrate_bps_(0), |
1696 options_(), | 1697 options_(), |
1697 dtmf_allowed_(false), | 1698 dtmf_allowed_(false), |
1698 desired_playout_(false), | 1699 desired_playout_(false), |
1699 nack_enabled_(false), | 1700 nack_enabled_(false), |
1700 playout_(false), | 1701 playout_(false), |
1701 typing_noise_detected_(false), | 1702 typing_noise_detected_(false), |
1702 desired_send_(SEND_NOTHING), | 1703 desired_send_(SEND_NOTHING), |
1703 send_(SEND_NOTHING), | 1704 send_(SEND_NOTHING), |
1704 call_(nullptr), | 1705 call_(call), |
1705 default_receive_ssrc_(0) { | 1706 default_receive_ssrc_(0) { |
1706 engine->RegisterChannel(this); | 1707 engine->RegisterChannel(this); |
1707 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel " | 1708 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel " |
1708 << voe_channel(); | 1709 << voe_channel(); |
1710 DCHECK(nullptr != call); | |
1709 ConfigureSendChannel(voe_channel()); | 1711 ConfigureSendChannel(voe_channel()); |
1710 } | 1712 } |
1711 | 1713 |
1712 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { | 1714 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { |
1713 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel " | 1715 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel " |
1714 << voe_channel(); | 1716 << voe_channel(); |
1715 DCHECK(receive_streams_.empty() || call_); | |
1716 | 1717 |
1717 // Remove any remaining send streams, the default channel will be deleted | 1718 // Remove any remaining send streams, the default channel will be deleted |
1718 // later. | 1719 // later. |
1719 while (!send_channels_.empty()) | 1720 while (!send_channels_.empty()) |
1720 RemoveSendStream(send_channels_.begin()->first); | 1721 RemoveSendStream(send_channels_.begin()->first); |
1721 | 1722 |
1722 // Unregister ourselves from the engine. | 1723 // Unregister ourselves from the engine. |
1723 engine()->UnregisterChannel(this); | 1724 engine()->UnregisterChannel(this); |
1724 // Remove any remaining streams. | 1725 // Remove any remaining streams. |
1725 while (!receive_channels_.empty()) { | 1726 while (!receive_channels_.empty()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1825 } | 1826 } |
1826 if (dscp_option_changed) { | 1827 if (dscp_option_changed) { |
1827 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; | 1828 rtc::DiffServCodePoint dscp = rtc::DSCP_DEFAULT; |
1828 if (options_.dscp.GetWithDefaultIfUnset(false)) | 1829 if (options_.dscp.GetWithDefaultIfUnset(false)) |
1829 dscp = kAudioDscpValue; | 1830 dscp = kAudioDscpValue; |
1830 if (MediaChannel::SetDscp(dscp) != 0) { | 1831 if (MediaChannel::SetDscp(dscp) != 0) { |
1831 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; | 1832 LOG(LS_WARNING) << "Failed to set DSCP settings for audio channel"; |
1832 } | 1833 } |
1833 } | 1834 } |
1834 | 1835 |
1835 SetCall(call_); | 1836 RecreateCallStreams(); |
1836 | 1837 |
1837 LOG(LS_INFO) << "Set voice channel options. Current options: " | 1838 LOG(LS_INFO) << "Set voice channel options. Current options: " |
1838 << options_.ToString(); | 1839 << options_.ToString(); |
1839 return true; | 1840 return true; |
1840 } | 1841 } |
1841 | 1842 |
1842 bool WebRtcVoiceMediaChannel::SetRecvCodecs( | 1843 bool WebRtcVoiceMediaChannel::SetRecvCodecs( |
1843 const std::vector<AudioCodec>& codecs) { | 1844 const std::vector<AudioCodec>& codecs) { |
1844 // Set the payload types to be used for incoming media. | 1845 // Set the payload types to be used for incoming media. |
1845 LOG(LS_INFO) << "Setting receive voice codecs:"; | 1846 LOG(LS_INFO) << "Setting receive voice codecs:"; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2194 } | 2195 } |
2195 | 2196 |
2196 const RtpHeaderExtension* send_time_extension = | 2197 const RtpHeaderExtension* send_time_extension = |
2197 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); | 2198 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); |
2198 if (send_time_extension) { | 2199 if (send_time_extension) { |
2199 exts.push_back({ | 2200 exts.push_back({ |
2200 kRtpAbsoluteSenderTimeHeaderExtension, send_time_extension->id}); | 2201 kRtpAbsoluteSenderTimeHeaderExtension, send_time_extension->id}); |
2201 } | 2202 } |
2202 | 2203 |
2203 recv_rtp_extensions_.swap(exts); | 2204 recv_rtp_extensions_.swap(exts); |
2204 SetCall(call_); | 2205 RecreateCallStreams(); |
2205 } | 2206 } |
2206 | 2207 |
2207 return true; | 2208 return true; |
2208 } | 2209 } |
2209 | 2210 |
2210 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( | 2211 bool WebRtcVoiceMediaChannel::SetChannelRecvRtpHeaderExtensions( |
2211 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { | 2212 int channel_id, const std::vector<RtpHeaderExtension>& extensions) { |
2212 const RtpHeaderExtension* audio_level_extension = | 2213 const RtpHeaderExtension* audio_level_extension = |
2213 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); | 2214 FindHeaderExtension(extensions, kRtpAudioLevelHeaderExtension); |
2214 if (!SetHeaderExtension( | 2215 if (!SetHeaderExtension( |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2536 // when the default channel is not being used. | 2537 // when the default channel is not being used. |
2537 webrtc::AudioTransport* audio_transport = | 2538 webrtc::AudioTransport* audio_transport = |
2538 engine()->voe()->base()->audio_transport(); | 2539 engine()->voe()->base()->audio_transport(); |
2539 if (!InConferenceMode() && default_receive_ssrc_ == 0) { | 2540 if (!InConferenceMode() && default_receive_ssrc_ == 0) { |
2540 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; | 2541 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; |
2541 default_receive_ssrc_ = ssrc; | 2542 default_receive_ssrc_ = ssrc; |
2542 WebRtcVoiceChannelRenderer* channel_renderer = | 2543 WebRtcVoiceChannelRenderer* channel_renderer = |
2543 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); | 2544 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); |
2544 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2545 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
2545 receive_stream_params_[ssrc] = sp; | 2546 receive_stream_params_[ssrc] = sp; |
2546 TryAddAudioRecvStream(ssrc); | 2547 AddAudioRecvStream(ssrc); |
2547 return SetPlayout(voe_channel(), playout_); | 2548 return SetPlayout(voe_channel(), playout_); |
2548 } | 2549 } |
2549 | 2550 |
2550 // Create a new channel for receiving audio data. | 2551 // Create a new channel for receiving audio data. |
2551 int channel = engine()->CreateMediaVoiceChannel(); | 2552 int channel = engine()->CreateMediaVoiceChannel(); |
2552 if (channel == -1) { | 2553 if (channel == -1) { |
2553 LOG_RTCERR0(CreateChannel); | 2554 LOG_RTCERR0(CreateChannel); |
2554 return false; | 2555 return false; |
2555 } | 2556 } |
2556 | 2557 |
2557 if (!ConfigureRecvChannel(channel)) { | 2558 if (!ConfigureRecvChannel(channel)) { |
2558 DeleteChannel(channel); | 2559 DeleteChannel(channel); |
2559 return false; | 2560 return false; |
2560 } | 2561 } |
2561 | 2562 |
2562 WebRtcVoiceChannelRenderer* channel_renderer = | 2563 WebRtcVoiceChannelRenderer* channel_renderer = |
2563 new WebRtcVoiceChannelRenderer(channel, audio_transport); | 2564 new WebRtcVoiceChannelRenderer(channel, audio_transport); |
2564 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2565 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
2565 receive_stream_params_[ssrc] = sp; | 2566 receive_stream_params_[ssrc] = sp; |
2566 TryAddAudioRecvStream(ssrc); | 2567 AddAudioRecvStream(ssrc); |
2567 | 2568 |
2568 LOG(LS_INFO) << "New audio stream " << ssrc | 2569 LOG(LS_INFO) << "New audio stream " << ssrc |
2569 << " registered to VoiceEngine channel #" | 2570 << " registered to VoiceEngine channel #" |
2570 << channel << "."; | 2571 << channel << "."; |
2571 return true; | 2572 return true; |
2572 } | 2573 } |
2573 | 2574 |
2574 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { | 2575 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { |
2575 // Configure to use external transport, like our default channel. | 2576 // Configure to use external transport, like our default channel. |
2576 if (engine()->voe()->network()->RegisterExternalTransport( | 2577 if (engine()->voe()->network()->RegisterExternalTransport( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2645 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { | 2646 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { |
2646 DCHECK(thread_checker_.CalledOnValidThread()); | 2647 DCHECK(thread_checker_.CalledOnValidThread()); |
2647 rtc::CritScope lock(&receive_channels_cs_); | 2648 rtc::CritScope lock(&receive_channels_cs_); |
2648 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2649 ChannelMap::iterator it = receive_channels_.find(ssrc); |
2649 if (it == receive_channels_.end()) { | 2650 if (it == receive_channels_.end()) { |
2650 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2651 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
2651 << " which doesn't exist."; | 2652 << " which doesn't exist."; |
2652 return false; | 2653 return false; |
2653 } | 2654 } |
2654 | 2655 |
2655 TryRemoveAudioRecvStream(ssrc); | 2656 RemoveAudioRecvStream(ssrc); |
2656 receive_stream_params_.erase(ssrc); | 2657 receive_stream_params_.erase(ssrc); |
2657 | 2658 |
2658 // Delete the WebRtcVoiceChannelRenderer object connected to the channel, this | 2659 // Delete the WebRtcVoiceChannelRenderer object connected to the channel, this |
2659 // will disconnect the audio renderer with the receive channel. | 2660 // will disconnect the audio renderer with the receive channel. |
2660 // Cache the channel before the deletion. | 2661 // Cache the channel before the deletion. |
2661 const int channel = it->second->channel(); | 2662 const int channel = it->second->channel(); |
2662 delete it->second; | 2663 delete it->second; |
2663 receive_channels_.erase(it); | 2664 receive_channels_.erase(it); |
2664 | 2665 |
2665 if (ssrc == default_receive_ssrc_) { | 2666 if (ssrc == default_receive_ssrc_) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2973 } | 2974 } |
2974 } | 2975 } |
2975 | 2976 |
2976 return true; | 2977 return true; |
2977 } | 2978 } |
2978 | 2979 |
2979 void WebRtcVoiceMediaChannel::OnPacketReceived( | 2980 void WebRtcVoiceMediaChannel::OnPacketReceived( |
2980 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2981 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
2981 DCHECK(thread_checker_.CalledOnValidThread()); | 2982 DCHECK(thread_checker_.CalledOnValidThread()); |
2982 | 2983 |
2983 // If hooked up to a "Call", forward packet there too. | 2984 // Forward packet to Call as well. |
2984 if (call_) { | 2985 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2985 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, | 2986 reinterpret_cast<const uint8_t*>(packet->data()), packet->size()); |
2986 reinterpret_cast<const uint8_t*>(packet->data()), packet->size()); | |
2987 } | |
2988 | 2987 |
2989 // Pick which channel to send this packet to. If this packet doesn't match | 2988 // Pick which channel to send this packet to. If this packet doesn't match |
2990 // any multiplexed streams, just send it to the default channel. Otherwise, | 2989 // any multiplexed streams, just send it to the default channel. Otherwise, |
2991 // send it to the specific decoder instance for that stream. | 2990 // send it to the specific decoder instance for that stream. |
2992 int which_channel = | 2991 int which_channel = |
2993 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); | 2992 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); |
2994 if (which_channel == -1) { | 2993 if (which_channel == -1) { |
2995 which_channel = voe_channel(); | 2994 which_channel = voe_channel(); |
2996 } | 2995 } |
2997 | 2996 |
(...skipping 16 matching lines...) Expand all Loading... | |
3014 // Pass it off to the decoder. | 3013 // Pass it off to the decoder. |
3015 engine()->voe()->network()->ReceivedRTPPacket( | 3014 engine()->voe()->network()->ReceivedRTPPacket( |
3016 which_channel, packet->data(), packet->size(), | 3015 which_channel, packet->data(), packet->size(), |
3017 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); | 3016 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); |
3018 } | 3017 } |
3019 | 3018 |
3020 void WebRtcVoiceMediaChannel::OnRtcpReceived( | 3019 void WebRtcVoiceMediaChannel::OnRtcpReceived( |
3021 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 3020 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
3022 DCHECK(thread_checker_.CalledOnValidThread()); | 3021 DCHECK(thread_checker_.CalledOnValidThread()); |
3023 | 3022 |
3024 // If hooked up to a "Call", forward packet there too. | 3023 // Forward packet to Call as well. |
3025 if (call_) { | 3024 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
3026 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, | 3025 reinterpret_cast<const uint8_t*>(packet->data()), packet->size()); |
3027 reinterpret_cast<const uint8_t*>(packet->data()), packet->size()); | |
3028 } | |
3029 | 3026 |
3030 // Sending channels need all RTCP packets with feedback information. | 3027 // Sending channels need all RTCP packets with feedback information. |
3031 // Even sender reports can contain attached report blocks. | 3028 // Even sender reports can contain attached report blocks. |
3032 // Receiving channels need sender reports in order to create | 3029 // Receiving channels need sender reports in order to create |
3033 // correct receiver reports. | 3030 // correct receiver reports. |
3034 int type = 0; | 3031 int type = 0; |
3035 if (!GetRtcpType(packet->data(), packet->size(), &type)) { | 3032 if (!GetRtcpType(packet->data(), packet->size(), &type)) { |
3036 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; | 3033 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; |
3037 return; | 3034 return; |
3038 } | 3035 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3403 } | 3400 } |
3404 | 3401 |
3405 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { | 3402 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { |
3406 ChannelMap::const_iterator it = send_channels_.find(ssrc); | 3403 ChannelMap::const_iterator it = send_channels_.find(ssrc); |
3407 if (it != send_channels_.end()) | 3404 if (it != send_channels_.end()) |
3408 return it->second->channel(); | 3405 return it->second->channel(); |
3409 | 3406 |
3410 return -1; | 3407 return -1; |
3411 } | 3408 } |
3412 | 3409 |
3413 void WebRtcVoiceMediaChannel::SetCall(webrtc::Call* call) { | |
3414 DCHECK(thread_checker_.CalledOnValidThread()); | |
3415 for (const auto& it : receive_channels_) { | |
3416 TryRemoveAudioRecvStream(it.first); | |
3417 } | |
3418 call_ = call; | |
3419 for (const auto& it : receive_channels_) { | |
3420 TryAddAudioRecvStream(it.first); | |
3421 } | |
3422 } | |
3423 | |
3424 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, | 3410 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, |
3425 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { | 3411 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { |
3426 // Get the RED encodings from the parameter with no name. This may | 3412 // Get the RED encodings from the parameter with no name. This may |
3427 // change based on what is discussed on the Jingle list. | 3413 // change based on what is discussed on the Jingle list. |
3428 // The encoding parameter is of the form "a/b"; we only support where | 3414 // The encoding parameter is of the form "a/b"; we only support where |
3429 // a == b. Verify this and parse out the value into red_pt. | 3415 // a == b. Verify this and parse out the value into red_pt. |
3430 // If the parameter value is absent (as it will be until we wire up the | 3416 // If the parameter value is absent (as it will be until we wire up the |
3431 // signaling of this message), use the second codec specified (i.e. the | 3417 // signaling of this message), use the second codec specified (i.e. the |
3432 // one after "red") as the encoding parameter. | 3418 // one after "red") as the encoding parameter. |
3433 int red_pt = -1; | 3419 int red_pt = -1; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3560 id = extension->id; | 3546 id = extension->id; |
3561 uri = extension->uri; | 3547 uri = extension->uri; |
3562 } | 3548 } |
3563 if ((engine()->voe()->rtp()->*setter)(channel_id, enable, id) != 0) { | 3549 if ((engine()->voe()->rtp()->*setter)(channel_id, enable, id) != 0) { |
3564 LOG_RTCERR4(*setter, uri, channel_id, enable, id); | 3550 LOG_RTCERR4(*setter, uri, channel_id, enable, id); |
3565 return false; | 3551 return false; |
3566 } | 3552 } |
3567 return true; | 3553 return true; |
3568 } | 3554 } |
3569 | 3555 |
3570 void WebRtcVoiceMediaChannel::TryAddAudioRecvStream(uint32 ssrc) { | 3556 void WebRtcVoiceMediaChannel::RecreateCallStreams() { |
pthatcher1
2015/09/02 21:24:22
I think RecreateRecvStreams or RemoveAndAddRecvStr
the sun
2015/09/03 15:00:46
I've changed the name to RecreateAudioReceiveStrea
| |
3557 DCHECK(thread_checker_.CalledOnValidThread()); | |
3558 for (const auto& it : receive_channels_) { | |
3559 RemoveAudioRecvStream(it.first); | |
3560 } | |
3561 for (const auto& it : receive_channels_) { | |
3562 AddAudioRecvStream(it.first); | |
3563 } | |
3564 } | |
3565 | |
3566 void WebRtcVoiceMediaChannel::AddAudioRecvStream(uint32 ssrc) { | |
pthatcher1
2015/09/02 21:24:22
Since it's obviously not video streams, why not ju
the sun
2015/09/03 15:00:47
Remember that "Stream" is an overloaded word here,
| |
3571 DCHECK(thread_checker_.CalledOnValidThread()); | 3567 DCHECK(thread_checker_.CalledOnValidThread()); |
3572 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; | 3568 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; |
3573 DCHECK(channel != nullptr); | 3569 DCHECK(channel != nullptr); |
3574 DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); | 3570 DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); |
3575 // If we are hooked up to a webrtc::Call, create an AudioReceiveStream too. | |
3576 if (!call_) { | |
3577 return; | |
3578 } | |
3579 webrtc::AudioReceiveStream::Config config; | 3571 webrtc::AudioReceiveStream::Config config; |
3580 config.rtp.remote_ssrc = ssrc; | 3572 config.rtp.remote_ssrc = ssrc; |
3581 // Only add RTP extensions if we support combined A/V BWE. | 3573 // Only add RTP extensions if we support combined A/V BWE. |
3582 config.rtp.extensions = recv_rtp_extensions_; | 3574 config.rtp.extensions = recv_rtp_extensions_; |
3583 config.combined_audio_video_bwe = | 3575 config.combined_audio_video_bwe = |
3584 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); | 3576 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); |
3585 config.voe_channel_id = channel->channel(); | 3577 config.voe_channel_id = channel->channel(); |
3586 config.sync_group = receive_stream_params_[ssrc].sync_label; | 3578 config.sync_group = receive_stream_params_[ssrc].sync_label; |
3587 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); | 3579 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); |
3588 receive_streams_.insert(std::make_pair(ssrc, s)); | 3580 receive_streams_.insert(std::make_pair(ssrc, s)); |
3589 } | 3581 } |
3590 | 3582 |
3591 void WebRtcVoiceMediaChannel::TryRemoveAudioRecvStream(uint32 ssrc) { | 3583 void WebRtcVoiceMediaChannel::RemoveAudioRecvStream(uint32 ssrc) { |
3592 DCHECK(thread_checker_.CalledOnValidThread()); | 3584 DCHECK(thread_checker_.CalledOnValidThread()); |
3593 // If we are hooked up to a webrtc::Call, assume there is an | 3585 auto stream_it = receive_streams_.find(ssrc); |
3594 // AudioReceiveStream to destroy too. | 3586 if (stream_it != receive_streams_.end()) { |
3595 if (call_) { | 3587 call_->DestroyAudioReceiveStream(stream_it->second); |
3596 auto stream_it = receive_streams_.find(ssrc); | 3588 receive_streams_.erase(stream_it); |
3597 if (stream_it != receive_streams_.end()) { | |
3598 call_->DestroyAudioReceiveStream(stream_it->second); | |
3599 receive_streams_.erase(stream_it); | |
3600 } | |
3601 } | 3589 } |
3602 } | 3590 } |
3603 | 3591 |
3604 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( | 3592 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( |
3605 const std::vector<AudioCodec>& new_codecs) { | 3593 const std::vector<AudioCodec>& new_codecs) { |
3606 for (const AudioCodec& codec : new_codecs) { | 3594 for (const AudioCodec& codec : new_codecs) { |
3607 webrtc::CodecInst voe_codec; | 3595 webrtc::CodecInst voe_codec; |
3608 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { | 3596 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { |
3609 LOG(LS_INFO) << ToString(codec); | 3597 LOG(LS_INFO) << ToString(codec); |
3610 voe_codec.pltype = codec.id; | 3598 voe_codec.pltype = codec.id; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3647 | 3635 |
3648 int WebRtcSoundclipStream::Rewind() { | 3636 int WebRtcSoundclipStream::Rewind() { |
3649 mem_.Rewind(); | 3637 mem_.Rewind(); |
3650 // Return -1 to keep VoiceEngine from looping. | 3638 // Return -1 to keep VoiceEngine from looping. |
3651 return (loop_) ? 0 : -1; | 3639 return (loop_) ? 0 : -1; |
3652 } | 3640 } |
3653 | 3641 |
3654 } // namespace cricket | 3642 } // namespace cricket |
3655 | 3643 |
3656 #endif // HAVE_WEBRTC_VOICE | 3644 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |