OLD | NEW |
---|---|
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/base/array_view.h" |
18 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
19 #include "webrtc/base/deprecation.h" | 19 #include "webrtc/base/deprecation.h" |
20 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
21 | 21 |
22 namespace webrtc { | 22 namespace webrtc { |
23 | 23 |
24 // This is the interface class for encoders in AudioCoding module. Each codec | 24 // This is the interface class for encoders in AudioCoding module. Each codec |
25 // type must have an implementation of this class. | 25 // type must have an implementation of this class. |
26 class AudioEncoder { | 26 class AudioEncoder { |
27 public: | 27 public: |
28 // Used for UMA logging of codec usage. The same codecs in the same | |
29 // order must be listed in | |
kwiberg-webrtc
2016/05/15 02:06:14
"The same codecs, with the same values, must be...
aleloi
2016/05/16 08:02:23
Done.
| |
30 // src/tools/metrics/histograms/histograms.xml in chromium to log | |
31 // correct values. | |
32 enum class CodecType { | |
33 kOther = 0, // Codec not specified, and/or not listed in this enum | |
34 kOpus = 1, | |
35 kIsac = 2, | |
36 kPcmA = 3, | |
37 kPcmU = 4, | |
38 kG722 = 5, | |
39 kIlbc = 6, | |
40 | |
41 // Number of histogram bins in the UMA logging of codec types. The | |
42 // total number of different codecs that are logged cannot exceed this | |
43 // number. | |
44 kMaxLoggedAudioCodecTypes = 64 | |
45 }; | |
46 | |
28 struct EncodedInfoLeaf { | 47 struct EncodedInfoLeaf { |
29 size_t encoded_bytes = 0; | 48 size_t encoded_bytes = 0; |
30 uint32_t encoded_timestamp = 0; | 49 uint32_t encoded_timestamp = 0; |
31 int payload_type = 0; | 50 int payload_type = 0; |
32 bool send_even_if_empty = false; | 51 bool send_even_if_empty = false; |
33 bool speech = true; | 52 bool speech = true; |
53 CodecType encoder_type = CodecType::kOther; | |
34 }; | 54 }; |
35 | 55 |
36 // This is the main struct for auxiliary encoding information. Each encoded | 56 // This is the main struct for auxiliary encoding information. Each encoded |
37 // packet should be accompanied by one EncodedInfo struct, containing the | 57 // packet should be accompanied by one EncodedInfo struct, containing the |
38 // total number of |encoded_bytes|, the |encoded_timestamp| and the | 58 // total number of |encoded_bytes|, the |encoded_timestamp| and the |
39 // |payload_type|. If the packet contains redundant encodings, the |redundant| | 59 // |payload_type|. If the packet contains redundant encodings, the |redundant| |
40 // vector will be populated with EncodedInfoLeaf structs. Each struct in the | 60 // vector will be populated with EncodedInfoLeaf structs. Each struct in the |
41 // vector represents one encoding; the order of structs in the vector is the | 61 // vector represents one encoding; the order of structs in the vector is the |
42 // same as the order in which the actual payloads are written to the byte | 62 // same as the order in which the actual payloads are written to the byte |
43 // stream. When EncoderInfoLeaf structs are present in the vector, the main | 63 // stream. When EncoderInfoLeaf structs are present in the vector, the main |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 | 151 |
132 protected: | 152 protected: |
133 // Subclasses implement this to perform the actual encoding. Called by | 153 // Subclasses implement this to perform the actual encoding. Called by |
134 // Encode(). | 154 // Encode(). |
135 virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp, | 155 virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp, |
136 rtc::ArrayView<const int16_t> audio, | 156 rtc::ArrayView<const int16_t> audio, |
137 rtc::Buffer* encoded) = 0; | 157 rtc::Buffer* encoded) = 0; |
138 }; | 158 }; |
139 } // namespace webrtc | 159 } // namespace webrtc |
140 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ | 160 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ |
OLD | NEW |