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

Side by Side Diff: webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc

Issue 1322973004: Fold AudioEncoderMutable into AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: review fixes 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 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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
11 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" 11 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 AudioEncoderCopyRed::AudioEncoderCopyRed(const Config& config) 19 AudioEncoderCopyRed::AudioEncoderCopyRed(const Config& config)
20 : speech_encoder_(config.speech_encoder), 20 : speech_encoder_(config.speech_encoder),
21 red_payload_type_(config.payload_type) { 21 red_payload_type_(config.payload_type) {
22 CHECK(speech_encoder_) << "Speech encoder not provided."; 22 CHECK(speech_encoder_) << "Speech encoder not provided.";
23 } 23 }
24 24
25 AudioEncoderCopyRed::~AudioEncoderCopyRed() { 25 AudioEncoderCopyRed::~AudioEncoderCopyRed() = default;
26
27 size_t AudioEncoderCopyRed::MaxEncodedBytes() const {
28 return 2 * speech_encoder_->MaxEncodedBytes();
26 } 29 }
27 30
28 int AudioEncoderCopyRed::SampleRateHz() const { 31 int AudioEncoderCopyRed::SampleRateHz() const {
29 return speech_encoder_->SampleRateHz(); 32 return speech_encoder_->SampleRateHz();
30 } 33 }
31 34
35 int AudioEncoderCopyRed::NumChannels() const {
36 return speech_encoder_->NumChannels();
37 }
38
32 int AudioEncoderCopyRed::RtpTimestampRateHz() const { 39 int AudioEncoderCopyRed::RtpTimestampRateHz() const {
33 return speech_encoder_->RtpTimestampRateHz(); 40 return speech_encoder_->RtpTimestampRateHz();
34 } 41 }
35 42
36 int AudioEncoderCopyRed::NumChannels() const {
37 return speech_encoder_->NumChannels();
38 }
39
40 size_t AudioEncoderCopyRed::MaxEncodedBytes() const {
41 return 2 * speech_encoder_->MaxEncodedBytes();
42 }
43
44 size_t AudioEncoderCopyRed::Num10MsFramesInNextPacket() const { 43 size_t AudioEncoderCopyRed::Num10MsFramesInNextPacket() const {
45 return speech_encoder_->Num10MsFramesInNextPacket(); 44 return speech_encoder_->Num10MsFramesInNextPacket();
46 } 45 }
47 46
48 size_t AudioEncoderCopyRed::Max10MsFramesInAPacket() const { 47 size_t AudioEncoderCopyRed::Max10MsFramesInAPacket() const {
49 return speech_encoder_->Max10MsFramesInAPacket(); 48 return speech_encoder_->Max10MsFramesInAPacket();
50 } 49 }
51 50
52 int AudioEncoderCopyRed::GetTargetBitrate() const { 51 int AudioEncoderCopyRed::GetTargetBitrate() const {
53 return speech_encoder_->GetTargetBitrate(); 52 return speech_encoder_->GetTargetBitrate();
54 } 53 }
55 54
56 void AudioEncoderCopyRed::SetTargetBitrate(int bits_per_second) {
57 speech_encoder_->SetTargetBitrate(bits_per_second);
58 }
59
60 void AudioEncoderCopyRed::SetProjectedPacketLossRate(double fraction) {
61 DCHECK_GE(fraction, 0.0);
62 DCHECK_LE(fraction, 1.0);
63 speech_encoder_->SetProjectedPacketLossRate(fraction);
64 }
65
66 AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal( 55 AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal(
67 uint32_t rtp_timestamp, 56 uint32_t rtp_timestamp,
68 const int16_t* audio, 57 const int16_t* audio,
69 size_t max_encoded_bytes, 58 size_t max_encoded_bytes,
70 uint8_t* encoded) { 59 uint8_t* encoded) {
71 EncodedInfo info = speech_encoder_->Encode( 60 EncodedInfo info = speech_encoder_->Encode(
72 rtp_timestamp, audio, static_cast<size_t>(SampleRateHz() / 100), 61 rtp_timestamp, audio, static_cast<size_t>(SampleRateHz() / 100),
73 max_encoded_bytes, encoded); 62 max_encoded_bytes, encoded);
74 CHECK_GE(max_encoded_bytes, 63 CHECK_GE(max_encoded_bytes,
75 info.encoded_bytes + secondary_info_.encoded_bytes); 64 info.encoded_bytes + secondary_info_.encoded_bytes);
(...skipping 20 matching lines...) Expand all
96 // Update main EncodedInfo. 85 // Update main EncodedInfo.
97 info.payload_type = red_payload_type_; 86 info.payload_type = red_payload_type_;
98 info.encoded_bytes = 0; 87 info.encoded_bytes = 0;
99 for (std::vector<EncodedInfoLeaf>::const_iterator it = info.redundant.begin(); 88 for (std::vector<EncodedInfoLeaf>::const_iterator it = info.redundant.begin();
100 it != info.redundant.end(); ++it) { 89 it != info.redundant.end(); ++it) {
101 info.encoded_bytes += it->encoded_bytes; 90 info.encoded_bytes += it->encoded_bytes;
102 } 91 }
103 return info; 92 return info;
104 } 93 }
105 94
95 void AudioEncoderCopyRed::Reset() {
96 speech_encoder_->Reset();
97 secondary_encoded_.Clear();
98 secondary_info_.encoded_bytes = 0;
99 }
100
101 bool AudioEncoderCopyRed::SetFec(bool enable) {
102 return speech_encoder_->SetFec(enable);
103 }
104
105 bool AudioEncoderCopyRed::SetDtx(bool enable) {
106 return speech_encoder_->SetDtx(enable);
107 }
108
109 bool AudioEncoderCopyRed::SetApplication(Application application) {
110 return speech_encoder_->SetApplication(application);
111 }
112
113 bool AudioEncoderCopyRed::SetMaxPlaybackRate(int frequency_hz) {
114 return speech_encoder_->SetMaxPlaybackRate(frequency_hz);
115 }
116
117 void AudioEncoderCopyRed::SetProjectedPacketLossRate(double fraction) {
118 speech_encoder_->SetProjectedPacketLossRate(fraction);
119 }
120
121 void AudioEncoderCopyRed::SetTargetBitrate(int bits_per_second) {
122 speech_encoder_->SetTargetBitrate(bits_per_second);
123 }
124
125 void AudioEncoderCopyRed::SetMaxBitrate(int max_bps) {
126 speech_encoder_->SetMaxBitrate(max_bps);
127 }
128
129 void AudioEncoderCopyRed::SetMaxPayloadSize(int max_payload_size_bytes) {
130 speech_encoder_->SetMaxPayloadSize(max_payload_size_bytes);
131 }
132
106 } // namespace webrtc 133 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698