Chromium Code Reviews

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_encoder.h

Issue 1418423010: Pass audio to AudioEncoder::Encode() in an ArrayView (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « webrtc/base/array_view_unittest.cc ('k') | webrtc/modules/audio_coding/codecs/audio_encoder.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 * 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_
13 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/array_view.h"
17 #include "webrtc/typedefs.h" 18 #include "webrtc/typedefs.h"
18 19
19 namespace webrtc { 20 namespace webrtc {
20 21
21 // This is the interface class for encoders in AudioCoding module. Each codec 22 // This is the interface class for encoders in AudioCoding module. Each codec
22 // type must have an implementation of this class. 23 // type must have an implementation of this class.
23 class AudioEncoder { 24 class AudioEncoder {
24 public: 25 public:
25 struct EncodedInfoLeaf { 26 struct EncodedInfoLeaf {
26 size_t encoded_bytes = 0; 27 size_t encoded_bytes = 0;
(...skipping 57 matching lines...)
84 85
85 // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 * 86 // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 *
86 // NumChannels() samples). Multi-channel audio must be sample-interleaved. 87 // NumChannels() samples). Multi-channel audio must be sample-interleaved.
87 // The encoder produces zero or more bytes of output in |encoded| and 88 // The encoder produces zero or more bytes of output in |encoded| and
88 // returns additional encoding information. 89 // returns additional encoding information.
89 // The caller is responsible for making sure that |max_encoded_bytes| is 90 // The caller is responsible for making sure that |max_encoded_bytes| is
90 // not smaller than the number of bytes actually produced by the encoder. 91 // not smaller than the number of bytes actually produced by the encoder.
91 // Encode() checks some preconditions, calls EncodeInternal() which does the 92 // Encode() checks some preconditions, calls EncodeInternal() which does the
92 // actual work, and then checks some postconditions. 93 // actual work, and then checks some postconditions.
93 EncodedInfo Encode(uint32_t rtp_timestamp, 94 EncodedInfo Encode(uint32_t rtp_timestamp,
94 const int16_t* audio, 95 rtc::ArrayView<const int16_t> audio,
95 size_t num_samples_per_channel,
96 size_t max_encoded_bytes, 96 size_t max_encoded_bytes,
97 uint8_t* encoded); 97 uint8_t* encoded);
98 98
99 virtual EncodedInfo EncodeInternal(uint32_t rtp_timestamp, 99 virtual EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
100 const int16_t* audio, 100 rtc::ArrayView<const int16_t> audio,
101 size_t max_encoded_bytes, 101 size_t max_encoded_bytes,
102 uint8_t* encoded) = 0; 102 uint8_t* encoded) = 0;
103 103
104 // Resets the encoder to its starting state, discarding any input that has 104 // Resets the encoder to its starting state, discarding any input that has
105 // been fed to the encoder but not yet emitted in a packet. 105 // been fed to the encoder but not yet emitted in a packet.
106 virtual void Reset() = 0; 106 virtual void Reset() = 0;
107 107
108 // Enables or disables codec-internal FEC (forward error correction). Returns 108 // Enables or disables codec-internal FEC (forward error correction). Returns
109 // true if the codec was able to comply. The default implementation returns 109 // true if the codec was able to comply. The default implementation returns
110 // true when asked to disable FEC and false when asked to enable it (meaning 110 // true when asked to disable FEC and false when asked to enable it (meaning
(...skipping 23 matching lines...)
134 // does nothing. 134 // does nothing.
135 virtual void SetProjectedPacketLossRate(double fraction); 135 virtual void SetProjectedPacketLossRate(double fraction);
136 136
137 // Tells the encoder what average bitrate we'd like it to produce. The 137 // Tells the encoder what average bitrate we'd like it to produce. The
138 // encoder is free to adjust or disregard the given bitrate (the default 138 // encoder is free to adjust or disregard the given bitrate (the default
139 // implementation does the latter). 139 // implementation does the latter).
140 virtual void SetTargetBitrate(int target_bps); 140 virtual void SetTargetBitrate(int target_bps);
141 }; 141 };
142 } // namespace webrtc 142 } // namespace webrtc
143 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 143 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/base/array_view_unittest.cc ('k') | webrtc/modules/audio_coding/codecs/audio_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine