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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 // when the default channel is not being used. | 2538 // when the default channel is not being used. |
2538 webrtc::AudioTransport* audio_transport = | 2539 webrtc::AudioTransport* audio_transport = |
2539 engine()->voe()->base()->audio_transport(); | 2540 engine()->voe()->base()->audio_transport(); |
2540 if (!InConferenceMode() && default_receive_ssrc_ == 0) { | 2541 if (!InConferenceMode() && default_receive_ssrc_ == 0) { |
2541 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; | 2542 LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel"; |
2542 default_receive_ssrc_ = ssrc; | 2543 default_receive_ssrc_ = ssrc; |
2543 WebRtcVoiceChannelRenderer* channel_renderer = | 2544 WebRtcVoiceChannelRenderer* channel_renderer = |
2544 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); | 2545 new WebRtcVoiceChannelRenderer(voe_channel(), audio_transport); |
2545 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2546 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
2546 receive_stream_params_[ssrc] = sp; | 2547 receive_stream_params_[ssrc] = sp; |
2547 TryAddAudioRecvStream(ssrc); | 2548 AddAudioReceiveStream(ssrc); |
2548 return SetPlayout(voe_channel(), playout_); | 2549 return SetPlayout(voe_channel(), playout_); |
2549 } | 2550 } |
2550 | 2551 |
2551 // Create a new channel for receiving audio data. | 2552 // Create a new channel for receiving audio data. |
2552 int channel = engine()->CreateMediaVoiceChannel(); | 2553 int channel = engine()->CreateMediaVoiceChannel(); |
2553 if (channel == -1) { | 2554 if (channel == -1) { |
2554 LOG_RTCERR0(CreateChannel); | 2555 LOG_RTCERR0(CreateChannel); |
2555 return false; | 2556 return false; |
2556 } | 2557 } |
2557 | 2558 |
2558 if (!ConfigureRecvChannel(channel)) { | 2559 if (!ConfigureRecvChannel(channel)) { |
2559 DeleteChannel(channel); | 2560 DeleteChannel(channel); |
2560 return false; | 2561 return false; |
2561 } | 2562 } |
2562 | 2563 |
2563 WebRtcVoiceChannelRenderer* channel_renderer = | 2564 WebRtcVoiceChannelRenderer* channel_renderer = |
2564 new WebRtcVoiceChannelRenderer(channel, audio_transport); | 2565 new WebRtcVoiceChannelRenderer(channel, audio_transport); |
2565 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); | 2566 receive_channels_.insert(std::make_pair(ssrc, channel_renderer)); |
2566 receive_stream_params_[ssrc] = sp; | 2567 receive_stream_params_[ssrc] = sp; |
2567 TryAddAudioRecvStream(ssrc); | 2568 AddAudioReceiveStream(ssrc); |
2568 | 2569 |
2569 LOG(LS_INFO) << "New audio stream " << ssrc | 2570 LOG(LS_INFO) << "New audio stream " << ssrc |
2570 << " registered to VoiceEngine channel #" | 2571 << " registered to VoiceEngine channel #" |
2571 << channel << "."; | 2572 << channel << "."; |
2572 return true; | 2573 return true; |
2573 } | 2574 } |
2574 | 2575 |
2575 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { | 2576 bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { |
2576 // Configure to use external transport, like our default channel. | 2577 // Configure to use external transport, like our default channel. |
2577 if (engine()->voe()->network()->RegisterExternalTransport( | 2578 if (engine()->voe()->network()->RegisterExternalTransport( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { | 2647 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { |
2647 DCHECK(thread_checker_.CalledOnValidThread()); | 2648 DCHECK(thread_checker_.CalledOnValidThread()); |
2648 rtc::CritScope lock(&receive_channels_cs_); | 2649 rtc::CritScope lock(&receive_channels_cs_); |
2649 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2650 ChannelMap::iterator it = receive_channels_.find(ssrc); |
2650 if (it == receive_channels_.end()) { | 2651 if (it == receive_channels_.end()) { |
2651 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2652 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
2652 << " which doesn't exist."; | 2653 << " which doesn't exist."; |
2653 return false; | 2654 return false; |
2654 } | 2655 } |
2655 | 2656 |
2656 TryRemoveAudioRecvStream(ssrc); | 2657 RemoveAudioReceiveStream(ssrc); |
2657 receive_stream_params_.erase(ssrc); | 2658 receive_stream_params_.erase(ssrc); |
2658 | 2659 |
2659 // Delete the WebRtcVoiceChannelRenderer object connected to the channel, this | 2660 // Delete the WebRtcVoiceChannelRenderer object connected to the channel, this |
2660 // will disconnect the audio renderer with the receive channel. | 2661 // will disconnect the audio renderer with the receive channel. |
2661 // Cache the channel before the deletion. | 2662 // Cache the channel before the deletion. |
2662 const int channel = it->second->channel(); | 2663 const int channel = it->second->channel(); |
2663 delete it->second; | 2664 delete it->second; |
2664 receive_channels_.erase(it); | 2665 receive_channels_.erase(it); |
2665 | 2666 |
2666 if (ssrc == default_receive_ssrc_) { | 2667 if (ssrc == default_receive_ssrc_) { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2940 } | 2941 } |
2941 } | 2942 } |
2942 | 2943 |
2943 return true; | 2944 return true; |
2944 } | 2945 } |
2945 | 2946 |
2946 void WebRtcVoiceMediaChannel::OnPacketReceived( | 2947 void WebRtcVoiceMediaChannel::OnPacketReceived( |
2947 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2948 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
2948 DCHECK(thread_checker_.CalledOnValidThread()); | 2949 DCHECK(thread_checker_.CalledOnValidThread()); |
2949 | 2950 |
2950 // If hooked up to a "Call", forward packet there too. | 2951 // Forward packet to Call as well. |
2951 if (call_) { | 2952 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
2952 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 2953 packet_time.not_before); |
2953 packet_time.not_before); | 2954 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2954 call_->Receiver()->DeliverPacket( | 2955 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), |
2955 webrtc::MediaType::AUDIO, | 2956 webrtc_packet_time); |
2956 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | |
2957 webrtc_packet_time); | |
2958 } | |
2959 | 2957 |
2960 // Pick which channel to send this packet to. If this packet doesn't match | 2958 // Pick which channel to send this packet to. If this packet doesn't match |
2961 // any multiplexed streams, just send it to the default channel. Otherwise, | 2959 // any multiplexed streams, just send it to the default channel. Otherwise, |
2962 // send it to the specific decoder instance for that stream. | 2960 // send it to the specific decoder instance for that stream. |
2963 int which_channel = | 2961 int which_channel = |
2964 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); | 2962 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); |
2965 if (which_channel == -1) { | 2963 if (which_channel == -1) { |
2966 which_channel = voe_channel(); | 2964 which_channel = voe_channel(); |
2967 } | 2965 } |
2968 | 2966 |
(...skipping 16 matching lines...) Expand all Loading... |
2985 // Pass it off to the decoder. | 2983 // Pass it off to the decoder. |
2986 engine()->voe()->network()->ReceivedRTPPacket( | 2984 engine()->voe()->network()->ReceivedRTPPacket( |
2987 which_channel, packet->data(), packet->size(), | 2985 which_channel, packet->data(), packet->size(), |
2988 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); | 2986 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); |
2989 } | 2987 } |
2990 | 2988 |
2991 void WebRtcVoiceMediaChannel::OnRtcpReceived( | 2989 void WebRtcVoiceMediaChannel::OnRtcpReceived( |
2992 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2990 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { |
2993 DCHECK(thread_checker_.CalledOnValidThread()); | 2991 DCHECK(thread_checker_.CalledOnValidThread()); |
2994 | 2992 |
2995 // If hooked up to a "Call", forward packet there too. | 2993 // Forward packet to Call as well. |
2996 if (call_) { | 2994 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
2997 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 2995 packet_time.not_before); |
2998 packet_time.not_before); | 2996 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2999 call_->Receiver()->DeliverPacket( | 2997 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), |
3000 webrtc::MediaType::AUDIO, | 2998 webrtc_packet_time); |
3001 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | |
3002 webrtc_packet_time); | |
3003 } | |
3004 | 2999 |
3005 // Sending channels need all RTCP packets with feedback information. | 3000 // Sending channels need all RTCP packets with feedback information. |
3006 // Even sender reports can contain attached report blocks. | 3001 // Even sender reports can contain attached report blocks. |
3007 // Receiving channels need sender reports in order to create | 3002 // Receiving channels need sender reports in order to create |
3008 // correct receiver reports. | 3003 // correct receiver reports. |
3009 int type = 0; | 3004 int type = 0; |
3010 if (!GetRtcpType(packet->data(), packet->size(), &type)) { | 3005 if (!GetRtcpType(packet->data(), packet->size(), &type)) { |
3011 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; | 3006 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; |
3012 return; | 3007 return; |
3013 } | 3008 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3378 } | 3373 } |
3379 | 3374 |
3380 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { | 3375 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { |
3381 ChannelMap::const_iterator it = send_channels_.find(ssrc); | 3376 ChannelMap::const_iterator it = send_channels_.find(ssrc); |
3382 if (it != send_channels_.end()) | 3377 if (it != send_channels_.end()) |
3383 return it->second->channel(); | 3378 return it->second->channel(); |
3384 | 3379 |
3385 return -1; | 3380 return -1; |
3386 } | 3381 } |
3387 | 3382 |
3388 void WebRtcVoiceMediaChannel::SetCall(webrtc::Call* call) { | |
3389 DCHECK(thread_checker_.CalledOnValidThread()); | |
3390 for (const auto& it : receive_channels_) { | |
3391 TryRemoveAudioRecvStream(it.first); | |
3392 } | |
3393 call_ = call; | |
3394 for (const auto& it : receive_channels_) { | |
3395 TryAddAudioRecvStream(it.first); | |
3396 } | |
3397 } | |
3398 | |
3399 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, | 3383 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, |
3400 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { | 3384 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { |
3401 // Get the RED encodings from the parameter with no name. This may | 3385 // Get the RED encodings from the parameter with no name. This may |
3402 // change based on what is discussed on the Jingle list. | 3386 // change based on what is discussed on the Jingle list. |
3403 // The encoding parameter is of the form "a/b"; we only support where | 3387 // The encoding parameter is of the form "a/b"; we only support where |
3404 // a == b. Verify this and parse out the value into red_pt. | 3388 // a == b. Verify this and parse out the value into red_pt. |
3405 // If the parameter value is absent (as it will be until we wire up the | 3389 // If the parameter value is absent (as it will be until we wire up the |
3406 // signaling of this message), use the second codec specified (i.e. the | 3390 // signaling of this message), use the second codec specified (i.e. the |
3407 // one after "red") as the encoding parameter. | 3391 // one after "red") as the encoding parameter. |
3408 int red_pt = -1; | 3392 int red_pt = -1; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3535 id = extension->id; | 3519 id = extension->id; |
3536 uri = extension->uri; | 3520 uri = extension->uri; |
3537 } | 3521 } |
3538 if ((engine()->voe()->rtp()->*setter)(channel_id, enable, id) != 0) { | 3522 if ((engine()->voe()->rtp()->*setter)(channel_id, enable, id) != 0) { |
3539 LOG_RTCERR4(*setter, uri, channel_id, enable, id); | 3523 LOG_RTCERR4(*setter, uri, channel_id, enable, id); |
3540 return false; | 3524 return false; |
3541 } | 3525 } |
3542 return true; | 3526 return true; |
3543 } | 3527 } |
3544 | 3528 |
3545 void WebRtcVoiceMediaChannel::TryAddAudioRecvStream(uint32 ssrc) { | 3529 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { |
| 3530 DCHECK(thread_checker_.CalledOnValidThread()); |
| 3531 for (const auto& it : receive_channels_) { |
| 3532 RemoveAudioReceiveStream(it.first); |
| 3533 } |
| 3534 for (const auto& it : receive_channels_) { |
| 3535 AddAudioReceiveStream(it.first); |
| 3536 } |
| 3537 } |
| 3538 |
| 3539 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { |
3546 DCHECK(thread_checker_.CalledOnValidThread()); | 3540 DCHECK(thread_checker_.CalledOnValidThread()); |
3547 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; | 3541 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; |
3548 DCHECK(channel != nullptr); | 3542 DCHECK(channel != nullptr); |
3549 DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); | 3543 DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); |
3550 // If we are hooked up to a webrtc::Call, create an AudioReceiveStream too. | |
3551 if (!call_) { | |
3552 return; | |
3553 } | |
3554 webrtc::AudioReceiveStream::Config config; | 3544 webrtc::AudioReceiveStream::Config config; |
3555 config.rtp.remote_ssrc = ssrc; | 3545 config.rtp.remote_ssrc = ssrc; |
3556 // Only add RTP extensions if we support combined A/V BWE. | 3546 // Only add RTP extensions if we support combined A/V BWE. |
3557 config.rtp.extensions = recv_rtp_extensions_; | 3547 config.rtp.extensions = recv_rtp_extensions_; |
3558 config.combined_audio_video_bwe = | 3548 config.combined_audio_video_bwe = |
3559 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); | 3549 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); |
3560 config.voe_channel_id = channel->channel(); | 3550 config.voe_channel_id = channel->channel(); |
3561 config.sync_group = receive_stream_params_[ssrc].sync_label; | 3551 config.sync_group = receive_stream_params_[ssrc].sync_label; |
3562 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); | 3552 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); |
3563 receive_streams_.insert(std::make_pair(ssrc, s)); | 3553 receive_streams_.insert(std::make_pair(ssrc, s)); |
3564 } | 3554 } |
3565 | 3555 |
3566 void WebRtcVoiceMediaChannel::TryRemoveAudioRecvStream(uint32 ssrc) { | 3556 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) { |
3567 DCHECK(thread_checker_.CalledOnValidThread()); | 3557 DCHECK(thread_checker_.CalledOnValidThread()); |
3568 // If we are hooked up to a webrtc::Call, assume there is an | 3558 auto stream_it = receive_streams_.find(ssrc); |
3569 // AudioReceiveStream to destroy too. | 3559 if (stream_it != receive_streams_.end()) { |
3570 if (call_) { | 3560 call_->DestroyAudioReceiveStream(stream_it->second); |
3571 auto stream_it = receive_streams_.find(ssrc); | 3561 receive_streams_.erase(stream_it); |
3572 if (stream_it != receive_streams_.end()) { | |
3573 call_->DestroyAudioReceiveStream(stream_it->second); | |
3574 receive_streams_.erase(stream_it); | |
3575 } | |
3576 } | 3562 } |
3577 } | 3563 } |
3578 | 3564 |
3579 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( | 3565 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( |
3580 const std::vector<AudioCodec>& new_codecs) { | 3566 const std::vector<AudioCodec>& new_codecs) { |
3581 for (const AudioCodec& codec : new_codecs) { | 3567 for (const AudioCodec& codec : new_codecs) { |
3582 webrtc::CodecInst voe_codec; | 3568 webrtc::CodecInst voe_codec; |
3583 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { | 3569 if (engine()->FindWebRtcCodec(codec, &voe_codec)) { |
3584 LOG(LS_INFO) << ToString(codec); | 3570 LOG(LS_INFO) << ToString(codec); |
3585 voe_codec.pltype = codec.id; | 3571 voe_codec.pltype = codec.id; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3622 | 3608 |
3623 int WebRtcSoundclipStream::Rewind() { | 3609 int WebRtcSoundclipStream::Rewind() { |
3624 mem_.Rewind(); | 3610 mem_.Rewind(); |
3625 // Return -1 to keep VoiceEngine from looping. | 3611 // Return -1 to keep VoiceEngine from looping. |
3626 return (loop_) ? 0 : -1; | 3612 return (loop_) ? 0 : -1; |
3627 } | 3613 } |
3628 | 3614 |
3629 } // namespace cricket | 3615 } // namespace cricket |
3630 | 3616 |
3631 #endif // HAVE_WEBRTC_VOICE | 3617 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |