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

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

Issue 2772773002: Adding cbr support for Opus (Closed)
Patch Set: Created 3 years, 9 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 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 << bitrate; 248 << bitrate;
249 } 249 }
250 return bitrate; 250 return bitrate;
251 } 251 }
252 252
253 void GetOpusConfig(const AudioCodec& codec, 253 void GetOpusConfig(const AudioCodec& codec,
254 webrtc::CodecInst* voe_codec, 254 webrtc::CodecInst* voe_codec,
255 bool* enable_codec_fec, 255 bool* enable_codec_fec,
256 int* max_playback_rate, 256 int* max_playback_rate,
257 bool* enable_codec_dtx, 257 bool* enable_codec_dtx,
258 bool* enable_codec_cbr,
258 int* min_ptime_ms, 259 int* min_ptime_ms,
259 int* max_ptime_ms) { 260 int* max_ptime_ms) {
260 *enable_codec_fec = IsCodecFeatureEnabled(codec, kCodecParamUseInbandFec); 261 *enable_codec_fec = IsCodecFeatureEnabled(codec, kCodecParamUseInbandFec);
261 *enable_codec_dtx = IsCodecFeatureEnabled(codec, kCodecParamUseDtx); 262 *enable_codec_dtx = IsCodecFeatureEnabled(codec, kCodecParamUseDtx);
263 *enable_codec_cbr = IsCodecFeatureEnabled(codec, kCodecParamUseCbr);
262 *max_playback_rate = GetCodecFeatureInt(codec, kCodecParamMaxPlaybackRate, 264 *max_playback_rate = GetCodecFeatureInt(codec, kCodecParamMaxPlaybackRate,
263 kOpusDefaultMaxPlaybackRate); 265 kOpusDefaultMaxPlaybackRate);
264 *max_ptime_ms = 266 *max_ptime_ms =
265 GetCodecFeatureInt(codec, kCodecParamMaxPTime, kOpusDefaultMaxPTime); 267 GetCodecFeatureInt(codec, kCodecParamMaxPTime, kOpusDefaultMaxPTime);
266 *min_ptime_ms = 268 *min_ptime_ms =
267 GetCodecFeatureInt(codec, kCodecParamMinPTime, kOpusDefaultMinPTime); 269 GetCodecFeatureInt(codec, kCodecParamMinPTime, kOpusDefaultMinPTime);
268 if (*max_ptime_ms < *min_ptime_ms) { 270 if (*max_ptime_ms < *min_ptime_ms) {
269 // If min ptime or max ptime defined by codec parameter is wrong, we use 271 // If min ptime or max ptime defined by codec parameter is wrong, we use
270 // the default values. 272 // the default values.
271 *max_ptime_ms = kOpusDefaultMaxPTime; 273 *max_ptime_ms = kOpusDefaultMaxPTime;
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 send_codec_spec.nack_enabled = HasNack(*codec); 1973 send_codec_spec.nack_enabled = HasNack(*codec);
1972 bitrate_config_ = GetBitrateConfigForCodec(*codec); 1974 bitrate_config_ = GetBitrateConfigForCodec(*codec);
1973 1975
1974 // For Opus as the send codec, we are to determine inband FEC, maximum 1976 // For Opus as the send codec, we are to determine inband FEC, maximum
1975 // playback rate, and opus internal dtx. 1977 // playback rate, and opus internal dtx.
1976 if (IsCodec(*codec, kOpusCodecName)) { 1978 if (IsCodec(*codec, kOpusCodecName)) {
1977 GetOpusConfig(*codec, &send_codec_spec.codec_inst, 1979 GetOpusConfig(*codec, &send_codec_spec.codec_inst,
1978 &send_codec_spec.enable_codec_fec, 1980 &send_codec_spec.enable_codec_fec,
1979 &send_codec_spec.opus_max_playback_rate, 1981 &send_codec_spec.opus_max_playback_rate,
1980 &send_codec_spec.enable_opus_dtx, 1982 &send_codec_spec.enable_opus_dtx,
1983 &send_codec_spec.enable_opus_cbr,
1981 &send_codec_spec.min_ptime_ms, 1984 &send_codec_spec.min_ptime_ms,
1982 &send_codec_spec.max_ptime_ms); 1985 &send_codec_spec.max_ptime_ms);
1983 } 1986 }
1984 1987
1985 // Set packet size if the AudioCodec param kCodecParamPTime is set. 1988 // Set packet size if the AudioCodec param kCodecParamPTime is set.
1986 int ptime_ms = 0; 1989 int ptime_ms = 0;
1987 if (codec->GetParam(kCodecParamPTime, &ptime_ms)) { 1990 if (codec->GetParam(kCodecParamPTime, &ptime_ms)) {
1988 if (!WebRtcVoiceCodecs::SetPTimeAsPacketSize( 1991 if (!WebRtcVoiceCodecs::SetPTimeAsPacketSize(
1989 &send_codec_spec.codec_inst, ptime_ms)) { 1992 &send_codec_spec.codec_inst, ptime_ms)) {
1990 LOG(LS_WARNING) << "Failed to set packet size for codec " 1993 LOG(LS_WARNING) << "Failed to set packet size for codec "
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 ssrc); 2696 ssrc);
2694 if (it != unsignaled_recv_ssrcs_.end()) { 2697 if (it != unsignaled_recv_ssrcs_.end()) {
2695 unsignaled_recv_ssrcs_.erase(it); 2698 unsignaled_recv_ssrcs_.erase(it);
2696 return true; 2699 return true;
2697 } 2700 }
2698 return false; 2701 return false;
2699 } 2702 }
2700 } // namespace cricket 2703 } // namespace cricket
2701 2704
2702 #endif // HAVE_WEBRTC_VOICE 2705 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698