| 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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 new webrtc::ExperimentalNs(experimental_ns)); | 838 new webrtc::ExperimentalNs(experimental_ns)); |
| 839 } | 839 } |
| 840 | 840 |
| 841 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine | 841 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine |
| 842 // returns NULL on audio_processing(). | 842 // returns NULL on audio_processing(). |
| 843 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); | 843 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); |
| 844 if (audioproc) { | 844 if (audioproc) { |
| 845 audioproc->SetExtraOptions(config); | 845 audioproc->SetExtraOptions(config); |
| 846 } | 846 } |
| 847 | 847 |
| 848 uint32 recording_sample_rate; | 848 uint32_t recording_sample_rate; |
| 849 if (options.recording_sample_rate.Get(&recording_sample_rate)) { | 849 if (options.recording_sample_rate.Get(&recording_sample_rate)) { |
| 850 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; | 850 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; |
| 851 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { | 851 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { |
| 852 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate); | 852 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate); |
| 853 } | 853 } |
| 854 } | 854 } |
| 855 | 855 |
| 856 uint32 playout_sample_rate; | 856 uint32_t playout_sample_rate; |
| 857 if (options.playout_sample_rate.Get(&playout_sample_rate)) { | 857 if (options.playout_sample_rate.Get(&playout_sample_rate)) { |
| 858 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; | 858 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; |
| 859 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { | 859 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { |
| 860 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate); | 860 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate); |
| 861 } | 861 } |
| 862 } | 862 } |
| 863 | 863 |
| 864 return true; | 864 return true; |
| 865 } | 865 } |
| 866 | 866 |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 RTC_DCHECK(send == SEND_NOTHING); | 2059 RTC_DCHECK(send == SEND_NOTHING); |
| 2060 if (engine()->voe()->base()->StopSend(channel) == -1) { | 2060 if (engine()->voe()->base()->StopSend(channel) == -1) { |
| 2061 LOG_RTCERR1(StopSend, channel); | 2061 LOG_RTCERR1(StopSend, channel); |
| 2062 return false; | 2062 return false; |
| 2063 } | 2063 } |
| 2064 } | 2064 } |
| 2065 | 2065 |
| 2066 return true; | 2066 return true; |
| 2067 } | 2067 } |
| 2068 | 2068 |
| 2069 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32 ssrc, bool enable, | 2069 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, |
| 2070 bool enable, |
| 2070 const AudioOptions* options, | 2071 const AudioOptions* options, |
| 2071 AudioRenderer* renderer) { | 2072 AudioRenderer* renderer) { |
| 2072 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2073 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2073 // TODO(solenberg): The state change should be fully rolled back if any one of | 2074 // TODO(solenberg): The state change should be fully rolled back if any one of |
| 2074 // these calls fail. | 2075 // these calls fail. |
| 2075 if (!SetLocalRenderer(ssrc, renderer)) { | 2076 if (!SetLocalRenderer(ssrc, renderer)) { |
| 2076 return false; | 2077 return false; |
| 2077 } | 2078 } |
| 2078 if (!MuteStream(ssrc, !enable)) { | 2079 if (!MuteStream(ssrc, !enable)) { |
| 2079 return false; | 2080 return false; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 return false; | 2184 return false; |
| 2184 } | 2185 } |
| 2185 | 2186 |
| 2186 // Set the current codecs to be used for the new channel. | 2187 // Set the current codecs to be used for the new channel. |
| 2187 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) | 2188 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) |
| 2188 return false; | 2189 return false; |
| 2189 | 2190 |
| 2190 return ChangeSend(channel, desired_send_); | 2191 return ChangeSend(channel, desired_send_); |
| 2191 } | 2192 } |
| 2192 | 2193 |
| 2193 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32 ssrc) { | 2194 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { |
| 2194 ChannelMap::iterator it = send_channels_.find(ssrc); | 2195 ChannelMap::iterator it = send_channels_.find(ssrc); |
| 2195 if (it == send_channels_.end()) { | 2196 if (it == send_channels_.end()) { |
| 2196 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2197 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
| 2197 << " which doesn't exist."; | 2198 << " which doesn't exist."; |
| 2198 return false; | 2199 return false; |
| 2199 } | 2200 } |
| 2200 | 2201 |
| 2201 int channel = it->second->channel(); | 2202 int channel = it->second->channel(); |
| 2202 ChangeSend(channel, SEND_NOTHING); | 2203 ChangeSend(channel, SEND_NOTHING); |
| 2203 | 2204 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2225 } | 2226 } |
| 2226 | 2227 |
| 2227 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { | 2228 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { |
| 2228 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2229 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2229 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); | 2230 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); |
| 2230 | 2231 |
| 2231 rtc::CritScope lock(&receive_channels_cs_); | 2232 rtc::CritScope lock(&receive_channels_cs_); |
| 2232 | 2233 |
| 2233 if (!VERIFY(sp.ssrcs.size() == 1)) | 2234 if (!VERIFY(sp.ssrcs.size() == 1)) |
| 2234 return false; | 2235 return false; |
| 2235 uint32 ssrc = sp.first_ssrc(); | 2236 uint32_t ssrc = sp.first_ssrc(); |
| 2236 | 2237 |
| 2237 if (ssrc == 0) { | 2238 if (ssrc == 0) { |
| 2238 LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported."; | 2239 LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported."; |
| 2239 return false; | 2240 return false; |
| 2240 } | 2241 } |
| 2241 | 2242 |
| 2242 if (receive_channels_.find(ssrc) != receive_channels_.end()) { | 2243 if (receive_channels_.find(ssrc) != receive_channels_.end()) { |
| 2243 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2244 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
| 2244 return false; | 2245 return false; |
| 2245 } | 2246 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 SetNack(channel, nack_enabled_); | 2351 SetNack(channel, nack_enabled_); |
| 2351 | 2352 |
| 2352 // Set RTP header extension for the new channel. | 2353 // Set RTP header extension for the new channel. |
| 2353 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { | 2354 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { |
| 2354 return false; | 2355 return false; |
| 2355 } | 2356 } |
| 2356 | 2357 |
| 2357 return SetPlayout(channel, playout_); | 2358 return SetPlayout(channel, playout_); |
| 2358 } | 2359 } |
| 2359 | 2360 |
| 2360 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { | 2361 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
| 2361 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2362 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2362 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; | 2363 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; |
| 2363 | 2364 |
| 2364 rtc::CritScope lock(&receive_channels_cs_); | 2365 rtc::CritScope lock(&receive_channels_cs_); |
| 2365 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2366 ChannelMap::iterator it = receive_channels_.find(ssrc); |
| 2366 if (it == receive_channels_.end()) { | 2367 if (it == receive_channels_.end()) { |
| 2367 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2368 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
| 2368 << " which doesn't exist."; | 2369 << " which doesn't exist."; |
| 2369 return false; | 2370 return false; |
| 2370 } | 2371 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 enable_default_channel_playout = true; | 2411 enable_default_channel_playout = true; |
| 2411 } | 2412 } |
| 2412 if (enable_default_channel_playout && playout_) { | 2413 if (enable_default_channel_playout && playout_) { |
| 2413 LOG(LS_INFO) << "Enabling playback on the default voice channel"; | 2414 LOG(LS_INFO) << "Enabling playback on the default voice channel"; |
| 2414 SetPlayout(voe_channel(), true); | 2415 SetPlayout(voe_channel(), true); |
| 2415 } | 2416 } |
| 2416 | 2417 |
| 2417 return true; | 2418 return true; |
| 2418 } | 2419 } |
| 2419 | 2420 |
| 2420 bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32 ssrc, | 2421 bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32_t ssrc, |
| 2421 AudioRenderer* renderer) { | 2422 AudioRenderer* renderer) { |
| 2422 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2423 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2423 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2424 ChannelMap::iterator it = receive_channels_.find(ssrc); |
| 2424 if (it == receive_channels_.end()) { | 2425 if (it == receive_channels_.end()) { |
| 2425 if (renderer) { | 2426 if (renderer) { |
| 2426 // Return an error if trying to set a valid renderer with an invalid ssrc. | 2427 // Return an error if trying to set a valid renderer with an invalid ssrc. |
| 2427 LOG(LS_ERROR) << "SetRemoteRenderer failed with ssrc "<< ssrc; | 2428 LOG(LS_ERROR) << "SetRemoteRenderer failed with ssrc "<< ssrc; |
| 2428 return false; | 2429 return false; |
| 2429 } | 2430 } |
| 2430 | 2431 |
| 2431 // The channel likely has gone away, do nothing. | 2432 // The channel likely has gone away, do nothing. |
| 2432 return true; | 2433 return true; |
| 2433 } | 2434 } |
| 2434 | 2435 |
| 2435 if (renderer) | 2436 if (renderer) |
| 2436 it->second->Start(renderer); | 2437 it->second->Start(renderer); |
| 2437 else | 2438 else |
| 2438 it->second->Stop(); | 2439 it->second->Stop(); |
| 2439 | 2440 |
| 2440 return true; | 2441 return true; |
| 2441 } | 2442 } |
| 2442 | 2443 |
| 2443 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32 ssrc, | 2444 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, |
| 2444 AudioRenderer* renderer) { | 2445 AudioRenderer* renderer) { |
| 2445 ChannelMap::iterator it = send_channels_.find(ssrc); | 2446 ChannelMap::iterator it = send_channels_.find(ssrc); |
| 2446 if (it == send_channels_.end()) { | 2447 if (it == send_channels_.end()) { |
| 2447 if (renderer) { | 2448 if (renderer) { |
| 2448 // Return an error if trying to set a valid renderer with an invalid ssrc. | 2449 // Return an error if trying to set a valid renderer with an invalid ssrc. |
| 2449 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; | 2450 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; |
| 2450 return false; | 2451 return false; |
| 2451 } | 2452 } |
| 2452 | 2453 |
| 2453 // The channel likely has gone away, do nothing. | 2454 // The channel likely has gone away, do nothing. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 if (engine()->voe()->processing()->SetTypingDetectionParameters( | 2507 if (engine()->voe()->processing()->SetTypingDetectionParameters( |
| 2507 time_window, cost_per_typing, | 2508 time_window, cost_per_typing, |
| 2508 reporting_threshold, penalty_decay, type_event_delay) == -1) { | 2509 reporting_threshold, penalty_decay, type_event_delay) == -1) { |
| 2509 // In case of error, log the info and continue | 2510 // In case of error, log the info and continue |
| 2510 LOG_RTCERR5(SetTypingDetectionParameters, time_window, | 2511 LOG_RTCERR5(SetTypingDetectionParameters, time_window, |
| 2511 cost_per_typing, reporting_threshold, penalty_decay, | 2512 cost_per_typing, reporting_threshold, penalty_decay, |
| 2512 type_event_delay); | 2513 type_event_delay); |
| 2513 } | 2514 } |
| 2514 } | 2515 } |
| 2515 | 2516 |
| 2516 bool WebRtcVoiceMediaChannel::SetOutputScaling( | 2517 bool WebRtcVoiceMediaChannel::SetOutputScaling(uint32_t ssrc, |
| 2517 uint32 ssrc, double left, double right) { | 2518 double left, |
| 2519 double right) { |
| 2518 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2520 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2519 rtc::CritScope lock(&receive_channels_cs_); | 2521 rtc::CritScope lock(&receive_channels_cs_); |
| 2520 // Collect the channels to scale the output volume. | 2522 // Collect the channels to scale the output volume. |
| 2521 std::vector<int> channels; | 2523 std::vector<int> channels; |
| 2522 if (0 == ssrc) { // Collect all channels, including the default one. | 2524 if (0 == ssrc) { // Collect all channels, including the default one. |
| 2523 // Default channel is not in receive_channels_ if it is not being used for | 2525 // Default channel is not in receive_channels_ if it is not being used for |
| 2524 // playout. | 2526 // playout. |
| 2525 if (default_receive_ssrc_ == 0) | 2527 if (default_receive_ssrc_ == 0) |
| 2526 channels.push_back(voe_channel()); | 2528 channels.push_back(voe_channel()); |
| 2527 for (const auto& ch : receive_channels_) { | 2529 for (const auto& ch : receive_channels_) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2559 << " right=" << right * scale | 2561 << " right=" << right * scale |
| 2560 << " for channel " << ch_id << " and ssrc " << ssrc; | 2562 << " for channel " << ch_id << " and ssrc " << ssrc; |
| 2561 } | 2563 } |
| 2562 return true; | 2564 return true; |
| 2563 } | 2565 } |
| 2564 | 2566 |
| 2565 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { | 2567 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { |
| 2566 return dtmf_allowed_; | 2568 return dtmf_allowed_; |
| 2567 } | 2569 } |
| 2568 | 2570 |
| 2569 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event, | 2571 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, |
| 2570 int duration, int flags) { | 2572 int event, |
| 2573 int duration, |
| 2574 int flags) { |
| 2571 if (!dtmf_allowed_) { | 2575 if (!dtmf_allowed_) { |
| 2572 return false; | 2576 return false; |
| 2573 } | 2577 } |
| 2574 | 2578 |
| 2575 // Send the event. | 2579 // Send the event. |
| 2576 if (flags & cricket::DF_SEND) { | 2580 if (flags & cricket::DF_SEND) { |
| 2577 int channel = -1; | 2581 int channel = -1; |
| 2578 if (ssrc == 0) { | 2582 if (ssrc == 0) { |
| 2579 bool default_channel_is_inuse = false; | 2583 bool default_channel_is_inuse = false; |
| 2580 for (const auto& ch : send_channels_) { | 2584 for (const auto& ch : send_channels_) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 // Make sure not sending the same packet to default channel more than once. | 2688 // Make sure not sending the same packet to default channel more than once. |
| 2685 if (IsDefaultChannel(ch.second->channel()) && | 2689 if (IsDefaultChannel(ch.second->channel()) && |
| 2686 has_sent_to_default_channel) | 2690 has_sent_to_default_channel) |
| 2687 continue; | 2691 continue; |
| 2688 | 2692 |
| 2689 engine()->voe()->network()->ReceivedRTCPPacket( | 2693 engine()->voe()->network()->ReceivedRTCPPacket( |
| 2690 ch.second->channel(), packet->data(), packet->size()); | 2694 ch.second->channel(), packet->data(), packet->size()); |
| 2691 } | 2695 } |
| 2692 } | 2696 } |
| 2693 | 2697 |
| 2694 bool WebRtcVoiceMediaChannel::MuteStream(uint32 ssrc, bool muted) { | 2698 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { |
| 2695 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelId(ssrc); | 2699 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelId(ssrc); |
| 2696 if (channel == -1) { | 2700 if (channel == -1) { |
| 2697 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; | 2701 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; |
| 2698 return false; | 2702 return false; |
| 2699 } | 2703 } |
| 2700 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { | 2704 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { |
| 2701 LOG_RTCERR2(SetInputMute, channel, muted); | 2705 LOG_RTCERR2(SetInputMute, channel, muted); |
| 2702 return false; | 2706 return false; |
| 2703 } | 2707 } |
| 2704 // We set the AGC to mute state only when all the channels are muted. | 2708 // We set the AGC to mute state only when all the channels are muted. |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2974 typing_noise_detected_ = false; | 2978 typing_noise_detected_ = false; |
| 2975 } | 2979 } |
| 2976 } | 2980 } |
| 2977 | 2981 |
| 2978 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { | 2982 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { |
| 2979 unsigned int ulevel = 0; | 2983 unsigned int ulevel = 0; |
| 2980 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); | 2984 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); |
| 2981 return (ret == 0) ? static_cast<int>(ulevel) : -1; | 2985 return (ret == 0) ? static_cast<int>(ulevel) : -1; |
| 2982 } | 2986 } |
| 2983 | 2987 |
| 2984 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32 ssrc) const { | 2988 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { |
| 2985 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2989 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2986 ChannelMap::const_iterator it = receive_channels_.find(ssrc); | 2990 ChannelMap::const_iterator it = receive_channels_.find(ssrc); |
| 2987 if (it != receive_channels_.end()) | 2991 if (it != receive_channels_.end()) |
| 2988 return it->second->channel(); | 2992 return it->second->channel(); |
| 2989 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; | 2993 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; |
| 2990 } | 2994 } |
| 2991 | 2995 |
| 2992 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32 ssrc) const { | 2996 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { |
| 2993 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2997 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 2994 ChannelMap::const_iterator it = send_channels_.find(ssrc); | 2998 ChannelMap::const_iterator it = send_channels_.find(ssrc); |
| 2995 if (it != send_channels_.end()) | 2999 if (it != send_channels_.end()) |
| 2996 return it->second->channel(); | 3000 return it->second->channel(); |
| 2997 | 3001 |
| 2998 return -1; | 3002 return -1; |
| 2999 } | 3003 } |
| 3000 | 3004 |
| 3001 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, | 3005 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, |
| 3002 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { | 3006 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 LOG_RTCERR1(StartPlayout, channel); | 3081 LOG_RTCERR1(StartPlayout, channel); |
| 3078 return false; | 3082 return false; |
| 3079 } | 3083 } |
| 3080 } else { | 3084 } else { |
| 3081 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 3085 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
| 3082 engine()->voe()->base()->StopPlayout(channel); | 3086 engine()->voe()->base()->StopPlayout(channel); |
| 3083 } | 3087 } |
| 3084 return true; | 3088 return true; |
| 3085 } | 3089 } |
| 3086 | 3090 |
| 3087 uint32 WebRtcVoiceMediaChannel::ParseSsrc(const void* data, size_t len, | 3091 uint32_t WebRtcVoiceMediaChannel::ParseSsrc(const void* data, |
| 3088 bool rtcp) { | 3092 size_t len, |
| 3093 bool rtcp) { |
| 3089 size_t ssrc_pos = (!rtcp) ? 8 : 4; | 3094 size_t ssrc_pos = (!rtcp) ? 8 : 4; |
| 3090 uint32 ssrc = 0; | 3095 uint32_t ssrc = 0; |
| 3091 if (len >= (ssrc_pos + sizeof(ssrc))) { | 3096 if (len >= (ssrc_pos + sizeof(ssrc))) { |
| 3092 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos); | 3097 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos); |
| 3093 } | 3098 } |
| 3094 return ssrc; | 3099 return ssrc; |
| 3095 } | 3100 } |
| 3096 | 3101 |
| 3097 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum. | 3102 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum. |
| 3098 VoiceMediaChannel::Error | 3103 VoiceMediaChannel::Error |
| 3099 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) { | 3104 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) { |
| 3100 switch (err_code) { | 3105 switch (err_code) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { | 3152 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { |
| 3148 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 3153 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 3149 for (const auto& it : receive_channels_) { | 3154 for (const auto& it : receive_channels_) { |
| 3150 RemoveAudioReceiveStream(it.first); | 3155 RemoveAudioReceiveStream(it.first); |
| 3151 } | 3156 } |
| 3152 for (const auto& it : receive_channels_) { | 3157 for (const auto& it : receive_channels_) { |
| 3153 AddAudioReceiveStream(it.first); | 3158 AddAudioReceiveStream(it.first); |
| 3154 } | 3159 } |
| 3155 } | 3160 } |
| 3156 | 3161 |
| 3157 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { | 3162 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32_t ssrc) { |
| 3158 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 3163 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 3159 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; | 3164 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; |
| 3160 RTC_DCHECK(channel != nullptr); | 3165 RTC_DCHECK(channel != nullptr); |
| 3161 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); | 3166 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); |
| 3162 webrtc::AudioReceiveStream::Config config; | 3167 webrtc::AudioReceiveStream::Config config; |
| 3163 config.rtp.remote_ssrc = ssrc; | 3168 config.rtp.remote_ssrc = ssrc; |
| 3164 // Only add RTP extensions if we support combined A/V BWE. | 3169 // Only add RTP extensions if we support combined A/V BWE. |
| 3165 config.rtp.extensions = recv_rtp_extensions_; | 3170 config.rtp.extensions = recv_rtp_extensions_; |
| 3166 config.combined_audio_video_bwe = | 3171 config.combined_audio_video_bwe = |
| 3167 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); | 3172 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); |
| 3168 config.voe_channel_id = channel->channel(); | 3173 config.voe_channel_id = channel->channel(); |
| 3169 config.sync_group = receive_stream_params_[ssrc].sync_label; | 3174 config.sync_group = receive_stream_params_[ssrc].sync_label; |
| 3170 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); | 3175 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); |
| 3171 receive_streams_.insert(std::make_pair(ssrc, s)); | 3176 receive_streams_.insert(std::make_pair(ssrc, s)); |
| 3172 } | 3177 } |
| 3173 | 3178 |
| 3174 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) { | 3179 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32_t ssrc) { |
| 3175 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 3180 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 3176 auto stream_it = receive_streams_.find(ssrc); | 3181 auto stream_it = receive_streams_.find(ssrc); |
| 3177 if (stream_it != receive_streams_.end()) { | 3182 if (stream_it != receive_streams_.end()) { |
| 3178 call_->DestroyAudioReceiveStream(stream_it->second); | 3183 call_->DestroyAudioReceiveStream(stream_it->second); |
| 3179 receive_streams_.erase(stream_it); | 3184 receive_streams_.erase(stream_it); |
| 3180 } | 3185 } |
| 3181 } | 3186 } |
| 3182 | 3187 |
| 3183 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( | 3188 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( |
| 3184 const std::vector<AudioCodec>& new_codecs) { | 3189 const std::vector<AudioCodec>& new_codecs) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3215 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 3220 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
| 3216 return false; | 3221 return false; |
| 3217 } | 3222 } |
| 3218 } | 3223 } |
| 3219 return true; | 3224 return true; |
| 3220 } | 3225 } |
| 3221 | 3226 |
| 3222 } // namespace cricket | 3227 } // namespace cricket |
| 3223 | 3228 |
| 3224 #endif // HAVE_WEBRTC_VOICE | 3229 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |