Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1311533009: - Rename VoiceChannel::MuteStream() -> SetAudioSend() (incl. media channel) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@lj_remove_typingmonitor_files
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 DCHECK(send == SEND_NOTHING); 2367 DCHECK(send == SEND_NOTHING);
2368 if (engine()->voe()->base()->StopSend(channel) == -1) { 2368 if (engine()->voe()->base()->StopSend(channel) == -1) {
2369 LOG_RTCERR1(StopSend, channel); 2369 LOG_RTCERR1(StopSend, channel);
2370 return false; 2370 return false;
2371 } 2371 }
2372 } 2372 }
2373 2373
2374 return true; 2374 return true;
2375 } 2375 }
2376 2376
2377 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32 ssrc, bool mute,
2378 const AudioOptions* options,
2379 AudioRenderer* renderer) {
2380 // SetLocalRenderer
2381 {
2382 ChannelMap::iterator it = send_channels_.find(ssrc);
2383 if (it == send_channels_.end()) {
2384 if (renderer) {
2385 // Return error if trying to set a valid renderer with an invalid ssrc.
2386 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc;
2387 return false;
2388 }
2389 // The channel likely has gone away, do nothing.
2390 } else {
2391 if (renderer) {
2392 it->second->Start(renderer);
2393 } else {
2394 it->second->Stop();
2395 }
2396 }
2397 }
2398
2399 // MuteStream
2400 {
2401 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelNum(ssrc);
2402 if (channel == -1) {
2403 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use.";
2404 return false;
2405 }
2406 if (engine()->voe()->volume()->SetInputMute(channel, mute) == -1) {
2407 LOG_RTCERR2(SetInputMute, channel, mute);
2408 return false;
2409 }
2410 // We set the AGC to mute state only when all the channels are muted.
2411 // This implementation is not ideal, instead we should signal the AGC when
2412 // the mic channel is muted/unmuted. We can't do it today because there
2413 // is no good way to know which stream is mapping to the mic channel.
2414 bool all_muted = mute;
2415 for (const auto& ch : send_channels_) {
2416 if (!all_muted) {
2417 break;
2418 }
2419 if (engine()->voe()->volume()->GetInputMute(ch.second->channel(),
2420 all_muted)) {
2421 LOG_RTCERR1(GetInputMute, ch.second->channel());
2422 return false;
2423 }
2424 }
2425
2426 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing();
2427 if (ap)
2428 ap->set_output_will_be_muted(all_muted);
2429
2430 if (!mute && options) {
2431 return SetOptions(*options);
2432 }
2433 }
2434
2435 return true;
pthatcher1 2015/09/09 07:16:12 Similarly, would it make more sense for this CL to
the sun 2015/09/09 09:50:50 Done.
2436 }
2437
2377 // TODO(ronghuawu): Change this method to return bool. 2438 // TODO(ronghuawu): Change this method to return bool.
2378 void WebRtcVoiceMediaChannel::ConfigureSendChannel(int channel) { 2439 void WebRtcVoiceMediaChannel::ConfigureSendChannel(int channel) {
2379 if (engine()->voe()->network()->RegisterExternalTransport( 2440 if (engine()->voe()->network()->RegisterExternalTransport(
2380 channel, *this) == -1) { 2441 channel, *this) == -1) {
2381 LOG_RTCERR2(RegisterExternalTransport, channel, this); 2442 LOG_RTCERR2(RegisterExternalTransport, channel, this);
2382 } 2443 }
2383 2444
2384 // Enable RTCP (for quality stats and feedback messages) 2445 // Enable RTCP (for quality stats and feedback messages)
2385 EnableRtcp(channel); 2446 EnableRtcp(channel);
2386 2447
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 } 2777 }
2717 2778
2718 if (renderer) 2779 if (renderer)
2719 it->second->Start(renderer); 2780 it->second->Start(renderer);
2720 else 2781 else
2721 it->second->Stop(); 2782 it->second->Stop();
2722 2783
2723 return true; 2784 return true;
2724 } 2785 }
2725 2786
2726 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32 ssrc,
2727 AudioRenderer* renderer) {
2728 ChannelMap::iterator it = send_channels_.find(ssrc);
2729 if (it == send_channels_.end()) {
2730 if (renderer) {
2731 // Return an error if trying to set a valid renderer with an invalid ssrc.
2732 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc;
2733 return false;
2734 }
2735
2736 // The channel likely has gone away, do nothing.
2737 return true;
2738 }
2739
2740 if (renderer)
2741 it->second->Start(renderer);
2742 else
2743 it->second->Stop();
2744
2745 return true;
2746 }
2747
2748 bool WebRtcVoiceMediaChannel::GetActiveStreams( 2787 bool WebRtcVoiceMediaChannel::GetActiveStreams(
2749 AudioInfo::StreamList* actives) { 2788 AudioInfo::StreamList* actives) {
2750 // In conference mode, the default channel should not be in 2789 // In conference mode, the default channel should not be in
2751 // |receive_channels_|. 2790 // |receive_channels_|.
2752 actives->clear(); 2791 actives->clear();
2753 for (const auto& ch : receive_channels_) { 2792 for (const auto& ch : receive_channels_) {
2754 int level = GetOutputLevel(ch.second->channel()); 2793 int level = GetOutputLevel(ch.second->channel());
2755 if (level > 0) { 2794 if (level > 0) {
2756 actives->push_back(std::make_pair(ch.first, level)); 2795 actives->push_back(std::make_pair(ch.first, level));
2757 } 2796 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 // Make sure not sending the same packet to default channel more than once. 3064 // Make sure not sending the same packet to default channel more than once.
3026 if (IsDefaultChannel(ch.second->channel()) && 3065 if (IsDefaultChannel(ch.second->channel()) &&
3027 has_sent_to_default_channel) 3066 has_sent_to_default_channel)
3028 continue; 3067 continue;
3029 3068
3030 engine()->voe()->network()->ReceivedRTCPPacket( 3069 engine()->voe()->network()->ReceivedRTCPPacket(
3031 ch.second->channel(), packet->data(), packet->size()); 3070 ch.second->channel(), packet->data(), packet->size());
3032 } 3071 }
3033 } 3072 }
3034 3073
3035 bool WebRtcVoiceMediaChannel::MuteStream(uint32 ssrc, bool muted) {
3036 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelNum(ssrc);
3037 if (channel == -1) {
3038 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use.";
3039 return false;
3040 }
3041 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) {
3042 LOG_RTCERR2(SetInputMute, channel, muted);
3043 return false;
3044 }
3045 // We set the AGC to mute state only when all the channels are muted.
3046 // This implementation is not ideal, instead we should signal the AGC when
3047 // the mic channel is muted/unmuted. We can't do it today because there
3048 // is no good way to know which stream is mapping to the mic channel.
3049 bool all_muted = muted;
3050 for (const auto& ch : send_channels_) {
3051 if (!all_muted) {
3052 break;
3053 }
3054 if (engine()->voe()->volume()->GetInputMute(ch.second->channel(),
3055 all_muted)) {
3056 LOG_RTCERR1(GetInputMute, ch.second->channel());
3057 return false;
3058 }
3059 }
3060
3061 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing();
3062 if (ap)
3063 ap->set_output_will_be_muted(all_muted);
3064 return true;
3065 }
3066
3067 // TODO(minyue): SetMaxSendBandwidth() is subject to be renamed to 3074 // TODO(minyue): SetMaxSendBandwidth() is subject to be renamed to
3068 // SetMaxSendBitrate() in future. 3075 // SetMaxSendBitrate() in future.
3069 bool WebRtcVoiceMediaChannel::SetMaxSendBandwidth(int bps) { 3076 bool WebRtcVoiceMediaChannel::SetMaxSendBandwidth(int bps) {
3070 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth."; 3077 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth.";
3071 3078
3072 return SetSendBitrateInternal(bps); 3079 return SetSendBitrateInternal(bps);
3073 } 3080 }
3074 3081
3075 bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(int bps) { 3082 bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(int bps) {
3076 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal."; 3083 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal.";
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 3621
3615 int WebRtcSoundclipStream::Rewind() { 3622 int WebRtcSoundclipStream::Rewind() {
3616 mem_.Rewind(); 3623 mem_.Rewind();
3617 // Return -1 to keep VoiceEngine from looping. 3624 // Return -1 to keep VoiceEngine from looping.
3618 return (loop_) ? 0 : -1; 3625 return (loop_) ? 0 : -1;
3619 } 3626 }
3620 3627
3621 } // namespace cricket 3628 } // namespace cricket
3622 3629
3623 #endif // HAVE_WEBRTC_VOICE 3630 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698