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

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

Issue 1397773002: Change SetOutputScaling to set a single level, not left/right levels. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase+rename Created 5 years, 2 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
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 if (engine()->voe()->processing()->SetTypingDetectionParameters( 2507 if (engine()->voe()->processing()->SetTypingDetectionParameters(
2508 time_window, cost_per_typing, 2508 time_window, cost_per_typing,
2509 reporting_threshold, penalty_decay, type_event_delay) == -1) { 2509 reporting_threshold, penalty_decay, type_event_delay) == -1) {
2510 // In case of error, log the info and continue 2510 // In case of error, log the info and continue
2511 LOG_RTCERR5(SetTypingDetectionParameters, time_window, 2511 LOG_RTCERR5(SetTypingDetectionParameters, time_window,
2512 cost_per_typing, reporting_threshold, penalty_decay, 2512 cost_per_typing, reporting_threshold, penalty_decay,
2513 type_event_delay); 2513 type_event_delay);
2514 } 2514 }
2515 } 2515 }
2516 2516
2517 bool WebRtcVoiceMediaChannel::SetOutputScaling(uint32_t ssrc, 2517 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
2518 double left,
2519 double right) {
2520 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 2518 RTC_DCHECK(thread_checker_.CalledOnValidThread());
2521 rtc::CritScope lock(&receive_channels_cs_); 2519 rtc::CritScope lock(&receive_channels_cs_);
2522 // Collect the channels to scale the output volume. 2520 // Collect the channels to scale the output volume.
2523 std::vector<int> channels; 2521 std::vector<int> channels;
2524 if (0 == ssrc) { // Collect all channels, including the default one. 2522 if (0 == ssrc) { // Collect all channels, including the default one.
2525 // Default channel is not in receive_channels_ if it is not being used for 2523 // Default channel is not in receive_channels_ if it is not being used for
2526 // playout. 2524 // playout.
2527 if (default_receive_ssrc_ == 0) 2525 if (default_receive_ssrc_ == 0)
2528 channels.push_back(voe_channel()); 2526 channels.push_back(voe_channel());
2529 for (const auto& ch : receive_channels_) { 2527 for (const auto& ch : receive_channels_) {
2530 channels.push_back(ch.second->channel()); 2528 channels.push_back(ch.second->channel());
2531 } 2529 }
2532 } else { // Collect only the channel of the specified ssrc. 2530 } else { // Collect only the channel of the specified ssrc.
2533 int channel = GetReceiveChannelId(ssrc); 2531 int channel = GetReceiveChannelId(ssrc);
2534 if (-1 == channel) { 2532 if (-1 == channel) {
2535 LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc; 2533 LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc;
2536 return false; 2534 return false;
2537 } 2535 }
2538 channels.push_back(channel); 2536 channels.push_back(channel);
2539 } 2537 }
2540 2538
2541 // Scale the output volume for the collected channels. We first normalize to
2542 // scale the volume and then set the left and right pan.
2543 float scale = static_cast<float>(std::max(left, right));
2544 if (scale > 0.0001f) {
2545 left /= scale;
2546 right /= scale;
2547 }
2548 for (int ch_id : channels) { 2539 for (int ch_id : channels) {
2549 if (-1 == engine()->voe()->volume()->SetChannelOutputVolumeScaling( 2540 if (-1 == engine()->voe()->volume()->SetChannelOutputVolumeScaling(
2550 ch_id, scale)) { 2541 ch_id, volume)) {
2551 LOG_RTCERR2(SetChannelOutputVolumeScaling, ch_id, scale); 2542 LOG_RTCERR2(SetChannelOutputVolumeScaling, ch_id, volume);
2552 return false; 2543 return false;
2553 } 2544 }
2554 if (-1 == engine()->voe()->volume()->SetOutputVolumePan( 2545 LOG(LS_INFO) << "SetOutputVolume to " << volume
2555 ch_id, static_cast<float>(left), static_cast<float>(right))) {
2556 LOG_RTCERR3(SetOutputVolumePan, ch_id, left, right);
2557 // Do not return if fails. SetOutputVolumePan is not available for all
2558 // pltforms.
2559 }
2560 LOG(LS_INFO) << "SetOutputScaling to left=" << left * scale
2561 << " right=" << right * scale
2562 << " for channel " << ch_id << " and ssrc " << ssrc; 2546 << " for channel " << ch_id << " and ssrc " << ssrc;
2563 } 2547 }
2564 return true; 2548 return true;
2565 } 2549 }
2566 2550
2567 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { 2551 bool WebRtcVoiceMediaChannel::CanInsertDtmf() {
2568 return dtmf_allowed_; 2552 return dtmf_allowed_;
2569 } 2553 }
2570 2554
2571 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, 2555 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc,
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 3204 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
3221 return false; 3205 return false;
3222 } 3206 }
3223 } 3207 }
3224 return true; 3208 return true;
3225 } 3209 }
3226 3210
3227 } // namespace cricket 3211 } // namespace cricket
3228 3212
3229 #endif // HAVE_WEBRTC_VOICE 3213 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698