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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 new webrtc::ExperimentalNs(experimental_ns)); | 836 new webrtc::ExperimentalNs(experimental_ns)); |
837 } | 837 } |
838 | 838 |
839 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine | 839 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine |
840 // returns NULL on audio_processing(). | 840 // returns NULL on audio_processing(). |
841 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); | 841 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); |
842 if (audioproc) { | 842 if (audioproc) { |
843 audioproc->SetExtraOptions(config); | 843 audioproc->SetExtraOptions(config); |
844 } | 844 } |
845 | 845 |
846 uint32 recording_sample_rate; | 846 uint32_t recording_sample_rate; |
847 if (options.recording_sample_rate.Get(&recording_sample_rate)) { | 847 if (options.recording_sample_rate.Get(&recording_sample_rate)) { |
848 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; | 848 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; |
849 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { | 849 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { |
850 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate); | 850 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate); |
851 } | 851 } |
852 } | 852 } |
853 | 853 |
854 uint32 playout_sample_rate; | 854 uint32_t playout_sample_rate; |
855 if (options.playout_sample_rate.Get(&playout_sample_rate)) { | 855 if (options.playout_sample_rate.Get(&playout_sample_rate)) { |
856 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; | 856 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; |
857 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { | 857 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { |
858 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate); | 858 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate); |
859 } | 859 } |
860 } | 860 } |
861 | 861 |
862 return true; | 862 return true; |
863 } | 863 } |
864 | 864 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 LOG_V(sev) << msg; | 1182 LOG_V(sev) << msg; |
1183 } else { | 1183 } else { |
1184 std::string msg(trace + 71, length - 72); | 1184 std::string msg(trace + 71, length - 72); |
1185 LOG_V(sev) << "webrtc: " << msg; | 1185 LOG_V(sev) << "webrtc: " << msg; |
1186 } | 1186 } |
1187 } | 1187 } |
1188 | 1188 |
1189 void WebRtcVoiceEngine::CallbackOnError(int channel_num, int err_code) { | 1189 void WebRtcVoiceEngine::CallbackOnError(int channel_num, int err_code) { |
1190 rtc::CritScope lock(&channels_cs_); | 1190 rtc::CritScope lock(&channels_cs_); |
1191 WebRtcVoiceMediaChannel* channel = NULL; | 1191 WebRtcVoiceMediaChannel* channel = NULL; |
1192 uint32 ssrc = 0; | 1192 uint32_t ssrc = 0; |
1193 LOG(LS_WARNING) << "VoiceEngine error " << err_code << " reported on channel " | 1193 LOG(LS_WARNING) << "VoiceEngine error " << err_code << " reported on channel " |
1194 << channel_num << "."; | 1194 << channel_num << "."; |
1195 if (FindChannelAndSsrc(channel_num, &channel, &ssrc)) { | 1195 if (FindChannelAndSsrc(channel_num, &channel, &ssrc)) { |
1196 RTC_DCHECK(channel != NULL); | 1196 RTC_DCHECK(channel != NULL); |
1197 channel->OnError(ssrc, err_code); | 1197 channel->OnError(ssrc, err_code); |
1198 } else { | 1198 } else { |
1199 LOG(LS_ERROR) << "VoiceEngine channel " << channel_num | 1199 LOG(LS_ERROR) << "VoiceEngine channel " << channel_num |
1200 << " could not be found in channel list when error reported."; | 1200 << " could not be found in channel list when error reported."; |
1201 } | 1201 } |
1202 } | 1202 } |
1203 | 1203 |
1204 bool WebRtcVoiceEngine::FindChannelAndSsrc( | 1204 bool WebRtcVoiceEngine::FindChannelAndSsrc(int channel_num, |
1205 int channel_num, WebRtcVoiceMediaChannel** channel, uint32* ssrc) const { | 1205 WebRtcVoiceMediaChannel** channel, |
| 1206 uint32_t* ssrc) const { |
1206 RTC_DCHECK(channel != NULL && ssrc != NULL); | 1207 RTC_DCHECK(channel != NULL && ssrc != NULL); |
1207 | 1208 |
1208 *channel = NULL; | 1209 *channel = NULL; |
1209 *ssrc = 0; | 1210 *ssrc = 0; |
1210 // Find corresponding channel and ssrc | 1211 // Find corresponding channel and ssrc |
1211 for (WebRtcVoiceMediaChannel* ch : channels_) { | 1212 for (WebRtcVoiceMediaChannel* ch : channels_) { |
1212 RTC_DCHECK(ch != NULL); | 1213 RTC_DCHECK(ch != NULL); |
1213 if (ch->FindSsrc(channel_num, ssrc)) { | 1214 if (ch->FindSsrc(channel_num, ssrc)) { |
1214 *channel = ch; | 1215 *channel = ch; |
1215 return true; | 1216 return true; |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2078 RTC_DCHECK(send == SEND_NOTHING); | 2079 RTC_DCHECK(send == SEND_NOTHING); |
2079 if (engine()->voe()->base()->StopSend(channel) == -1) { | 2080 if (engine()->voe()->base()->StopSend(channel) == -1) { |
2080 LOG_RTCERR1(StopSend, channel); | 2081 LOG_RTCERR1(StopSend, channel); |
2081 return false; | 2082 return false; |
2082 } | 2083 } |
2083 } | 2084 } |
2084 | 2085 |
2085 return true; | 2086 return true; |
2086 } | 2087 } |
2087 | 2088 |
2088 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32 ssrc, bool enable, | 2089 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, |
| 2090 bool enable, |
2089 const AudioOptions* options, | 2091 const AudioOptions* options, |
2090 AudioRenderer* renderer) { | 2092 AudioRenderer* renderer) { |
2091 // TODO(solenberg): The state change should be fully rolled back if any one of | 2093 // TODO(solenberg): The state change should be fully rolled back if any one of |
2092 // these calls fail. | 2094 // these calls fail. |
2093 if (!SetLocalRenderer(ssrc, renderer)) { | 2095 if (!SetLocalRenderer(ssrc, renderer)) { |
2094 return false; | 2096 return false; |
2095 } | 2097 } |
2096 if (!MuteStream(ssrc, !enable)) { | 2098 if (!MuteStream(ssrc, !enable)) { |
2097 return false; | 2099 return false; |
2098 } | 2100 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 return false; | 2202 return false; |
2201 } | 2203 } |
2202 | 2204 |
2203 // Set the current codecs to be used for the new channel. | 2205 // Set the current codecs to be used for the new channel. |
2204 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) | 2206 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) |
2205 return false; | 2207 return false; |
2206 | 2208 |
2207 return ChangeSend(channel, desired_send_); | 2209 return ChangeSend(channel, desired_send_); |
2208 } | 2210 } |
2209 | 2211 |
2210 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32 ssrc) { | 2212 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { |
2211 ChannelMap::iterator it = send_channels_.find(ssrc); | 2213 ChannelMap::iterator it = send_channels_.find(ssrc); |
2212 if (it == send_channels_.end()) { | 2214 if (it == send_channels_.end()) { |
2213 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2215 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
2214 << " which doesn't exist."; | 2216 << " which doesn't exist."; |
2215 return false; | 2217 return false; |
2216 } | 2218 } |
2217 | 2219 |
2218 int channel = it->second->channel(); | 2220 int channel = it->second->channel(); |
2219 ChangeSend(channel, SEND_NOTHING); | 2221 ChangeSend(channel, SEND_NOTHING); |
2220 | 2222 |
(...skipping 19 matching lines...) Expand all Loading... |
2240 | 2242 |
2241 return true; | 2243 return true; |
2242 } | 2244 } |
2243 | 2245 |
2244 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { | 2246 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { |
2245 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2247 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
2246 rtc::CritScope lock(&receive_channels_cs_); | 2248 rtc::CritScope lock(&receive_channels_cs_); |
2247 | 2249 |
2248 if (!VERIFY(sp.ssrcs.size() == 1)) | 2250 if (!VERIFY(sp.ssrcs.size() == 1)) |
2249 return false; | 2251 return false; |
2250 uint32 ssrc = sp.first_ssrc(); | 2252 uint32_t ssrc = sp.first_ssrc(); |
2251 | 2253 |
2252 if (ssrc == 0) { | 2254 if (ssrc == 0) { |
2253 LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported."; | 2255 LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported."; |
2254 return false; | 2256 return false; |
2255 } | 2257 } |
2256 | 2258 |
2257 if (receive_channels_.find(ssrc) != receive_channels_.end()) { | 2259 if (receive_channels_.find(ssrc) != receive_channels_.end()) { |
2258 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; | 2260 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; |
2259 return false; | 2261 return false; |
2260 } | 2262 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 SetNack(channel, nack_enabled_); | 2366 SetNack(channel, nack_enabled_); |
2365 | 2367 |
2366 // Set RTP header extension for the new channel. | 2368 // Set RTP header extension for the new channel. |
2367 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { | 2369 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { |
2368 return false; | 2370 return false; |
2369 } | 2371 } |
2370 | 2372 |
2371 return SetPlayout(channel, playout_); | 2373 return SetPlayout(channel, playout_); |
2372 } | 2374 } |
2373 | 2375 |
2374 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { | 2376 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
2375 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2377 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
2376 rtc::CritScope lock(&receive_channels_cs_); | 2378 rtc::CritScope lock(&receive_channels_cs_); |
2377 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2379 ChannelMap::iterator it = receive_channels_.find(ssrc); |
2378 if (it == receive_channels_.end()) { | 2380 if (it == receive_channels_.end()) { |
2379 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 2381 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
2380 << " which doesn't exist."; | 2382 << " which doesn't exist."; |
2381 return false; | 2383 return false; |
2382 } | 2384 } |
2383 | 2385 |
2384 RemoveAudioReceiveStream(ssrc); | 2386 RemoveAudioReceiveStream(ssrc); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 enable_default_channel_playout = true; | 2424 enable_default_channel_playout = true; |
2423 } | 2425 } |
2424 if (enable_default_channel_playout && playout_) { | 2426 if (enable_default_channel_playout && playout_) { |
2425 LOG(LS_INFO) << "Enabling playback on the default voice channel"; | 2427 LOG(LS_INFO) << "Enabling playback on the default voice channel"; |
2426 SetPlayout(voe_channel(), true); | 2428 SetPlayout(voe_channel(), true); |
2427 } | 2429 } |
2428 | 2430 |
2429 return true; | 2431 return true; |
2430 } | 2432 } |
2431 | 2433 |
2432 bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32 ssrc, | 2434 bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32_t ssrc, |
2433 AudioRenderer* renderer) { | 2435 AudioRenderer* renderer) { |
2434 ChannelMap::iterator it = receive_channels_.find(ssrc); | 2436 ChannelMap::iterator it = receive_channels_.find(ssrc); |
2435 if (it == receive_channels_.end()) { | 2437 if (it == receive_channels_.end()) { |
2436 if (renderer) { | 2438 if (renderer) { |
2437 // Return an error if trying to set a valid renderer with an invalid ssrc. | 2439 // Return an error if trying to set a valid renderer with an invalid ssrc. |
2438 LOG(LS_ERROR) << "SetRemoteRenderer failed with ssrc "<< ssrc; | 2440 LOG(LS_ERROR) << "SetRemoteRenderer failed with ssrc "<< ssrc; |
2439 return false; | 2441 return false; |
2440 } | 2442 } |
2441 | 2443 |
2442 // The channel likely has gone away, do nothing. | 2444 // The channel likely has gone away, do nothing. |
2443 return true; | 2445 return true; |
2444 } | 2446 } |
2445 | 2447 |
2446 if (renderer) | 2448 if (renderer) |
2447 it->second->Start(renderer); | 2449 it->second->Start(renderer); |
2448 else | 2450 else |
2449 it->second->Stop(); | 2451 it->second->Stop(); |
2450 | 2452 |
2451 return true; | 2453 return true; |
2452 } | 2454 } |
2453 | 2455 |
2454 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32 ssrc, | 2456 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, |
2455 AudioRenderer* renderer) { | 2457 AudioRenderer* renderer) { |
2456 ChannelMap::iterator it = send_channels_.find(ssrc); | 2458 ChannelMap::iterator it = send_channels_.find(ssrc); |
2457 if (it == send_channels_.end()) { | 2459 if (it == send_channels_.end()) { |
2458 if (renderer) { | 2460 if (renderer) { |
2459 // Return an error if trying to set a valid renderer with an invalid ssrc. | 2461 // Return an error if trying to set a valid renderer with an invalid ssrc. |
2460 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; | 2462 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; |
2461 return false; | 2463 return false; |
2462 } | 2464 } |
2463 | 2465 |
2464 // The channel likely has gone away, do nothing. | 2466 // The channel likely has gone away, do nothing. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 if (engine()->voe()->processing()->SetTypingDetectionParameters( | 2517 if (engine()->voe()->processing()->SetTypingDetectionParameters( |
2516 time_window, cost_per_typing, | 2518 time_window, cost_per_typing, |
2517 reporting_threshold, penalty_decay, type_event_delay) == -1) { | 2519 reporting_threshold, penalty_decay, type_event_delay) == -1) { |
2518 // In case of error, log the info and continue | 2520 // In case of error, log the info and continue |
2519 LOG_RTCERR5(SetTypingDetectionParameters, time_window, | 2521 LOG_RTCERR5(SetTypingDetectionParameters, time_window, |
2520 cost_per_typing, reporting_threshold, penalty_decay, | 2522 cost_per_typing, reporting_threshold, penalty_decay, |
2521 type_event_delay); | 2523 type_event_delay); |
2522 } | 2524 } |
2523 } | 2525 } |
2524 | 2526 |
2525 bool WebRtcVoiceMediaChannel::SetOutputScaling( | 2527 bool WebRtcVoiceMediaChannel::SetOutputScaling(uint32_t ssrc, |
2526 uint32 ssrc, double left, double right) { | 2528 double left, |
| 2529 double right) { |
2527 rtc::CritScope lock(&receive_channels_cs_); | 2530 rtc::CritScope lock(&receive_channels_cs_); |
2528 // Collect the channels to scale the output volume. | 2531 // Collect the channels to scale the output volume. |
2529 std::vector<int> channels; | 2532 std::vector<int> channels; |
2530 if (0 == ssrc) { // Collect all channels, including the default one. | 2533 if (0 == ssrc) { // Collect all channels, including the default one. |
2531 // Default channel is not in receive_channels_ if it is not being used for | 2534 // Default channel is not in receive_channels_ if it is not being used for |
2532 // playout. | 2535 // playout. |
2533 if (default_receive_ssrc_ == 0) | 2536 if (default_receive_ssrc_ == 0) |
2534 channels.push_back(voe_channel()); | 2537 channels.push_back(voe_channel()); |
2535 for (const auto& ch : receive_channels_) { | 2538 for (const auto& ch : receive_channels_) { |
2536 channels.push_back(ch.second->channel()); | 2539 channels.push_back(ch.second->channel()); |
(...skipping 30 matching lines...) Expand all Loading... |
2567 << " right=" << right * scale | 2570 << " right=" << right * scale |
2568 << " for channel " << ch_id << " and ssrc " << ssrc; | 2571 << " for channel " << ch_id << " and ssrc " << ssrc; |
2569 } | 2572 } |
2570 return true; | 2573 return true; |
2571 } | 2574 } |
2572 | 2575 |
2573 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { | 2576 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { |
2574 return dtmf_allowed_; | 2577 return dtmf_allowed_; |
2575 } | 2578 } |
2576 | 2579 |
2577 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event, | 2580 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, |
2578 int duration, int flags) { | 2581 int event, |
| 2582 int duration, |
| 2583 int flags) { |
2579 if (!dtmf_allowed_) { | 2584 if (!dtmf_allowed_) { |
2580 return false; | 2585 return false; |
2581 } | 2586 } |
2582 | 2587 |
2583 // Send the event. | 2588 // Send the event. |
2584 if (flags & cricket::DF_SEND) { | 2589 if (flags & cricket::DF_SEND) { |
2585 int channel = -1; | 2590 int channel = -1; |
2586 if (ssrc == 0) { | 2591 if (ssrc == 0) { |
2587 bool default_channel_is_inuse = false; | 2592 bool default_channel_is_inuse = false; |
2588 for (const auto& ch : send_channels_) { | 2593 for (const auto& ch : send_channels_) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 // Make sure not sending the same packet to default channel more than once. | 2697 // Make sure not sending the same packet to default channel more than once. |
2693 if (IsDefaultChannel(ch.second->channel()) && | 2698 if (IsDefaultChannel(ch.second->channel()) && |
2694 has_sent_to_default_channel) | 2699 has_sent_to_default_channel) |
2695 continue; | 2700 continue; |
2696 | 2701 |
2697 engine()->voe()->network()->ReceivedRTCPPacket( | 2702 engine()->voe()->network()->ReceivedRTCPPacket( |
2698 ch.second->channel(), packet->data(), packet->size()); | 2703 ch.second->channel(), packet->data(), packet->size()); |
2699 } | 2704 } |
2700 } | 2705 } |
2701 | 2706 |
2702 bool WebRtcVoiceMediaChannel::MuteStream(uint32 ssrc, bool muted) { | 2707 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { |
2703 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelNum(ssrc); | 2708 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelNum(ssrc); |
2704 if (channel == -1) { | 2709 if (channel == -1) { |
2705 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; | 2710 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; |
2706 return false; | 2711 return false; |
2707 } | 2712 } |
2708 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { | 2713 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { |
2709 LOG_RTCERR2(SetInputMute, channel, muted); | 2714 LOG_RTCERR2(SetInputMute, channel, muted); |
2710 return false; | 2715 return false; |
2711 } | 2716 } |
2712 // We set the AGC to mute state only when all the channels are muted. | 2717 // We set the AGC to mute state only when all the channels are muted. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 // Get speech level. | 2968 // Get speech level. |
2964 rinfo.audio_level = (engine()->voe()->volume()-> | 2969 rinfo.audio_level = (engine()->voe()->volume()-> |
2965 GetSpeechOutputLevelFullRange(ch_id, level) != -1) ? level : -1; | 2970 GetSpeechOutputLevelFullRange(ch_id, level) != -1) ? level : -1; |
2966 info->receivers.push_back(rinfo); | 2971 info->receivers.push_back(rinfo); |
2967 } | 2972 } |
2968 } | 2973 } |
2969 | 2974 |
2970 return true; | 2975 return true; |
2971 } | 2976 } |
2972 | 2977 |
2973 bool WebRtcVoiceMediaChannel::FindSsrc(int channel_num, uint32* ssrc) { | 2978 bool WebRtcVoiceMediaChannel::FindSsrc(int channel_num, uint32_t* ssrc) { |
2974 rtc::CritScope lock(&receive_channels_cs_); | 2979 rtc::CritScope lock(&receive_channels_cs_); |
2975 RTC_DCHECK(ssrc != NULL); | 2980 RTC_DCHECK(ssrc != NULL); |
2976 if (channel_num == -1 && send_ != SEND_NOTHING) { | 2981 if (channel_num == -1 && send_ != SEND_NOTHING) { |
2977 // Sometimes the VoiceEngine core will throw error with channel_num = -1. | 2982 // Sometimes the VoiceEngine core will throw error with channel_num = -1. |
2978 // This means the error is not limited to a specific channel. Signal the | 2983 // This means the error is not limited to a specific channel. Signal the |
2979 // message using ssrc=0. If the current channel is sending, use this | 2984 // message using ssrc=0. If the current channel is sending, use this |
2980 // channel for sending the message. | 2985 // channel for sending the message. |
2981 *ssrc = 0; | 2986 *ssrc = 0; |
2982 return true; | 2987 return true; |
2983 } else { | 2988 } else { |
2984 // Check whether this is a sending channel. | 2989 // Check whether this is a sending channel. |
2985 for (const auto& ch : send_channels_) { | 2990 for (const auto& ch : send_channels_) { |
2986 if (ch.second->channel() == channel_num) { | 2991 if (ch.second->channel() == channel_num) { |
2987 // This is a sending channel. | 2992 // This is a sending channel. |
2988 uint32 local_ssrc = 0; | 2993 uint32_t local_ssrc = 0; |
2989 if (engine()->voe()->rtp()->GetLocalSSRC( | 2994 if (engine()->voe()->rtp()->GetLocalSSRC( |
2990 channel_num, local_ssrc) != -1) { | 2995 channel_num, local_ssrc) != -1) { |
2991 *ssrc = local_ssrc; | 2996 *ssrc = local_ssrc; |
2992 } | 2997 } |
2993 return true; | 2998 return true; |
2994 } | 2999 } |
2995 } | 3000 } |
2996 | 3001 |
2997 // Check whether this is a receiving channel. | 3002 // Check whether this is a receiving channel. |
2998 for (const auto& ch : receive_channels_) { | 3003 for (const auto& ch : receive_channels_) { |
2999 if (ch.second->channel() == channel_num) { | 3004 if (ch.second->channel() == channel_num) { |
3000 *ssrc = ch.first; | 3005 *ssrc = ch.first; |
3001 return true; | 3006 return true; |
3002 } | 3007 } |
3003 } | 3008 } |
3004 } | 3009 } |
3005 return false; | 3010 return false; |
3006 } | 3011 } |
3007 | 3012 |
3008 void WebRtcVoiceMediaChannel::OnError(uint32 ssrc, int error) { | 3013 void WebRtcVoiceMediaChannel::OnError(uint32_t ssrc, int error) { |
3009 if (error == VE_TYPING_NOISE_WARNING) { | 3014 if (error == VE_TYPING_NOISE_WARNING) { |
3010 typing_noise_detected_ = true; | 3015 typing_noise_detected_ = true; |
3011 } else if (error == VE_TYPING_NOISE_OFF_WARNING) { | 3016 } else if (error == VE_TYPING_NOISE_OFF_WARNING) { |
3012 typing_noise_detected_ = false; | 3017 typing_noise_detected_ = false; |
3013 } | 3018 } |
3014 } | 3019 } |
3015 | 3020 |
3016 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { | 3021 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { |
3017 unsigned int ulevel; | 3022 unsigned int ulevel; |
3018 int ret = | 3023 int ret = |
3019 engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); | 3024 engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); |
3020 return (ret == 0) ? static_cast<int>(ulevel) : -1; | 3025 return (ret == 0) ? static_cast<int>(ulevel) : -1; |
3021 } | 3026 } |
3022 | 3027 |
3023 int WebRtcVoiceMediaChannel::GetReceiveChannelNum(uint32 ssrc) const { | 3028 int WebRtcVoiceMediaChannel::GetReceiveChannelNum(uint32_t ssrc) const { |
3024 ChannelMap::const_iterator it = receive_channels_.find(ssrc); | 3029 ChannelMap::const_iterator it = receive_channels_.find(ssrc); |
3025 if (it != receive_channels_.end()) | 3030 if (it != receive_channels_.end()) |
3026 return it->second->channel(); | 3031 return it->second->channel(); |
3027 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; | 3032 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; |
3028 } | 3033 } |
3029 | 3034 |
3030 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { | 3035 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32_t ssrc) const { |
3031 ChannelMap::const_iterator it = send_channels_.find(ssrc); | 3036 ChannelMap::const_iterator it = send_channels_.find(ssrc); |
3032 if (it != send_channels_.end()) | 3037 if (it != send_channels_.end()) |
3033 return it->second->channel(); | 3038 return it->second->channel(); |
3034 | 3039 |
3035 return -1; | 3040 return -1; |
3036 } | 3041 } |
3037 | 3042 |
3038 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, | 3043 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, |
3039 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { | 3044 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { |
3040 // Get the RED encodings from the parameter with no name. This may | 3045 // Get the RED encodings from the parameter with no name. This may |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 LOG_RTCERR1(StartPlayout, channel); | 3119 LOG_RTCERR1(StartPlayout, channel); |
3115 return false; | 3120 return false; |
3116 } | 3121 } |
3117 } else { | 3122 } else { |
3118 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 3123 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
3119 engine()->voe()->base()->StopPlayout(channel); | 3124 engine()->voe()->base()->StopPlayout(channel); |
3120 } | 3125 } |
3121 return true; | 3126 return true; |
3122 } | 3127 } |
3123 | 3128 |
3124 uint32 WebRtcVoiceMediaChannel::ParseSsrc(const void* data, size_t len, | 3129 uint32_t WebRtcVoiceMediaChannel::ParseSsrc(const void* data, |
3125 bool rtcp) { | 3130 size_t len, |
| 3131 bool rtcp) { |
3126 size_t ssrc_pos = (!rtcp) ? 8 : 4; | 3132 size_t ssrc_pos = (!rtcp) ? 8 : 4; |
3127 uint32 ssrc = 0; | 3133 uint32_t ssrc = 0; |
3128 if (len >= (ssrc_pos + sizeof(ssrc))) { | 3134 if (len >= (ssrc_pos + sizeof(ssrc))) { |
3129 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos); | 3135 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos); |
3130 } | 3136 } |
3131 return ssrc; | 3137 return ssrc; |
3132 } | 3138 } |
3133 | 3139 |
3134 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum. | 3140 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum. |
3135 VoiceMediaChannel::Error | 3141 VoiceMediaChannel::Error |
3136 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) { | 3142 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) { |
3137 switch (err_code) { | 3143 switch (err_code) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3184 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { | 3190 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { |
3185 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 3191 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
3186 for (const auto& it : receive_channels_) { | 3192 for (const auto& it : receive_channels_) { |
3187 RemoveAudioReceiveStream(it.first); | 3193 RemoveAudioReceiveStream(it.first); |
3188 } | 3194 } |
3189 for (const auto& it : receive_channels_) { | 3195 for (const auto& it : receive_channels_) { |
3190 AddAudioReceiveStream(it.first); | 3196 AddAudioReceiveStream(it.first); |
3191 } | 3197 } |
3192 } | 3198 } |
3193 | 3199 |
3194 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { | 3200 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32_t ssrc) { |
3195 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 3201 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
3196 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; | 3202 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; |
3197 RTC_DCHECK(channel != nullptr); | 3203 RTC_DCHECK(channel != nullptr); |
3198 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); | 3204 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); |
3199 webrtc::AudioReceiveStream::Config config; | 3205 webrtc::AudioReceiveStream::Config config; |
3200 config.rtp.remote_ssrc = ssrc; | 3206 config.rtp.remote_ssrc = ssrc; |
3201 // Only add RTP extensions if we support combined A/V BWE. | 3207 // Only add RTP extensions if we support combined A/V BWE. |
3202 config.rtp.extensions = recv_rtp_extensions_; | 3208 config.rtp.extensions = recv_rtp_extensions_; |
3203 config.combined_audio_video_bwe = | 3209 config.combined_audio_video_bwe = |
3204 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); | 3210 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); |
3205 config.voe_channel_id = channel->channel(); | 3211 config.voe_channel_id = channel->channel(); |
3206 config.sync_group = receive_stream_params_[ssrc].sync_label; | 3212 config.sync_group = receive_stream_params_[ssrc].sync_label; |
3207 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); | 3213 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); |
3208 receive_streams_.insert(std::make_pair(ssrc, s)); | 3214 receive_streams_.insert(std::make_pair(ssrc, s)); |
3209 } | 3215 } |
3210 | 3216 |
3211 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) { | 3217 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32_t ssrc) { |
3212 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 3218 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
3213 auto stream_it = receive_streams_.find(ssrc); | 3219 auto stream_it = receive_streams_.find(ssrc); |
3214 if (stream_it != receive_streams_.end()) { | 3220 if (stream_it != receive_streams_.end()) { |
3215 call_->DestroyAudioReceiveStream(stream_it->second); | 3221 call_->DestroyAudioReceiveStream(stream_it->second); |
3216 receive_streams_.erase(stream_it); | 3222 receive_streams_.erase(stream_it); |
3217 } | 3223 } |
3218 } | 3224 } |
3219 | 3225 |
3220 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( | 3226 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( |
3221 const std::vector<AudioCodec>& new_codecs) { | 3227 const std::vector<AudioCodec>& new_codecs) { |
(...skipping 29 matching lines...) Expand all Loading... |
3251 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 3257 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
3252 return false; | 3258 return false; |
3253 } | 3259 } |
3254 } | 3260 } |
3255 return true; | 3261 return true; |
3256 } | 3262 } |
3257 | 3263 |
3258 } // namespace cricket | 3264 } // namespace cricket |
3259 | 3265 |
3260 #endif // HAVE_WEBRTC_VOICE | 3266 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |