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_ISAC_AUDIO_ENCODER_ISAC_T_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 16 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
17 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 17 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
18 #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" | 18 #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 struct CodecInst; | |
23 | |
22 template <typename T> | 24 template <typename T> |
23 class AudioEncoderIsacT final : public AudioEncoder { | 25 class AudioEncoderIsacT final : public AudioEncoder { |
24 public: | 26 public: |
25 // Allowed combinations of sample rate, frame size, and bit rate are | 27 // Allowed combinations of sample rate, frame size, and bit rate are |
26 // - 16000 Hz, 30 ms, 10000-32000 bps | 28 // - 16000 Hz, 30 ms, 10000-32000 bps |
27 // - 16000 Hz, 60 ms, 10000-32000 bps | 29 // - 16000 Hz, 60 ms, 10000-32000 bps |
28 // - 32000 Hz, 30 ms, 10000-56000 bps (if T has super-wideband support) | 30 // - 32000 Hz, 30 ms, 10000-56000 bps (if T has super-wideband support) |
29 // - 48000 Hz, 30 ms, 10000-56000 bps (if T has super-wideband support) | 31 // - 48000 Hz, 30 ms, 10000-56000 bps (if T has super-wideband support) |
30 struct Config { | 32 struct Config { |
31 Config(); | 33 Config(); |
hlundin-webrtc
2015/09/07 20:00:01
Do you still need this one? In audio_encoder_cng.h
kwiberg-webrtc
2015/09/08 10:47:45
No, it seems not. Removing.
| |
32 bool IsOk() const; | 34 bool IsOk() const; |
33 | 35 |
34 LockedIsacBandwidthInfo* bwinfo; | 36 LockedIsacBandwidthInfo* bwinfo = nullptr; |
35 | 37 |
36 int payload_type; | 38 int payload_type = 103; |
37 int sample_rate_hz; | 39 int sample_rate_hz = 16000; |
38 int frame_size_ms; | 40 int frame_size_ms = 30; |
39 int bit_rate; // Limit on the short-term average bit rate, in bits/s. | 41 int bit_rate = kDefaultBitRate; // Limit on the short-term average bit |
40 int max_payload_size_bytes; | 42 // rate, in bits/s. |
41 int max_bit_rate; | 43 int max_payload_size_bytes = -1; |
44 int max_bit_rate = -1; | |
42 | 45 |
43 // If true, the encoder will dynamically adjust frame size and bit rate; | 46 // If true, the encoder will dynamically adjust frame size and bit rate; |
44 // the configured values are then merely the starting point. | 47 // the configured values are then merely the starting point. |
45 bool adaptive_mode; | 48 bool adaptive_mode = false; |
46 | 49 |
47 // In adaptive mode, prevent adaptive changes to the frame size. (Not used | 50 // In adaptive mode, prevent adaptive changes to the frame size. (Not used |
48 // in nonadaptive mode.) | 51 // in nonadaptive mode.) |
49 bool enforce_frame_size; | 52 bool enforce_frame_size = false; |
50 }; | 53 }; |
51 | 54 |
52 explicit AudioEncoderIsacT(const Config& config); | 55 explicit AudioEncoderIsacT(const Config& config); |
56 explicit AudioEncoderIsacT(const CodecInst& codec_inst, | |
57 LockedIsacBandwidthInfo* bwinfo); | |
53 ~AudioEncoderIsacT() override; | 58 ~AudioEncoderIsacT() override; |
54 | 59 |
60 size_t MaxEncodedBytes() const override; | |
55 int SampleRateHz() const override; | 61 int SampleRateHz() const override; |
56 int NumChannels() const override; | 62 int NumChannels() const override; |
57 size_t MaxEncodedBytes() const override; | |
58 size_t Num10MsFramesInNextPacket() const override; | 63 size_t Num10MsFramesInNextPacket() const override; |
59 size_t Max10MsFramesInAPacket() const override; | 64 size_t Max10MsFramesInAPacket() const override; |
60 int GetTargetBitrate() const override; | 65 int GetTargetBitrate() const override; |
61 EncodedInfo EncodeInternal(uint32_t rtp_timestamp, | 66 EncodedInfo EncodeInternal(uint32_t rtp_timestamp, |
62 const int16_t* audio, | 67 const int16_t* audio, |
63 size_t max_encoded_bytes, | 68 size_t max_encoded_bytes, |
64 uint8_t* encoded) override; | 69 uint8_t* encoded) override; |
70 void Reset() override; | |
71 void SetMaxPayloadSize(int max_payload_size_bytes) override; | |
72 void SetMaxBitrate(int max_rate_bps) override; | |
65 | 73 |
66 private: | 74 private: |
67 // This value is taken from STREAM_SIZE_MAX_60 for iSAC float (60 ms) and | 75 // This value is taken from STREAM_SIZE_MAX_60 for iSAC float (60 ms) and |
68 // STREAM_MAXW16_60MS for iSAC fix (60 ms). | 76 // STREAM_MAXW16_60MS for iSAC fix (60 ms). |
69 static const size_t kSufficientEncodeBufferSizeBytes = 400; | 77 static const size_t kSufficientEncodeBufferSizeBytes = 400; |
70 | 78 |
71 const int payload_type_; | 79 static const int kDefaultBitRate = 32000; |
72 typename T::instance_type* isac_state_; | 80 |
73 LockedIsacBandwidthInfo* bwinfo_; | 81 void RecreateEncoderInstance(const Config& config); |
82 | |
83 Config config_; | |
84 typename T::instance_type* isac_state_ = nullptr; | |
85 LockedIsacBandwidthInfo* bwinfo_ = nullptr; | |
74 | 86 |
75 // Have we accepted input but not yet emitted it in a packet? | 87 // Have we accepted input but not yet emitted it in a packet? |
76 bool packet_in_progress_; | 88 bool packet_in_progress_ = false; |
77 | 89 |
78 // Timestamp of the first input of the currently in-progress packet. | 90 // Timestamp of the first input of the currently in-progress packet. |
79 uint32_t packet_timestamp_; | 91 uint32_t packet_timestamp_; |
80 | 92 |
81 // Timestamp of the previously encoded packet. | 93 // Timestamp of the previously encoded packet. |
82 uint32_t last_encoded_timestamp_; | 94 uint32_t last_encoded_timestamp_; |
83 | 95 |
84 const int target_bitrate_bps_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(AudioEncoderIsacT); | 96 DISALLOW_COPY_AND_ASSIGN(AudioEncoderIsacT); |
87 }; | 97 }; |
88 | 98 |
89 template <typename T> | 99 template <typename T> |
90 class AudioDecoderIsacT final : public AudioDecoder { | 100 class AudioDecoderIsacT final : public AudioDecoder { |
91 public: | 101 public: |
92 AudioDecoderIsacT(); | 102 AudioDecoderIsacT(); |
93 explicit AudioDecoderIsacT(LockedIsacBandwidthInfo* bwinfo); | 103 explicit AudioDecoderIsacT(LockedIsacBandwidthInfo* bwinfo); |
94 ~AudioDecoderIsacT() override; | 104 ~AudioDecoderIsacT() override; |
95 | 105 |
(...skipping 16 matching lines...) Expand all Loading... | |
112 private: | 122 private: |
113 typename T::instance_type* isac_state_; | 123 typename T::instance_type* isac_state_; |
114 LockedIsacBandwidthInfo* bwinfo_; | 124 LockedIsacBandwidthInfo* bwinfo_; |
115 int decoder_sample_rate_hz_; | 125 int decoder_sample_rate_hz_; |
116 | 126 |
117 DISALLOW_COPY_AND_ASSIGN(AudioDecoderIsacT); | 127 DISALLOW_COPY_AND_ASSIGN(AudioDecoderIsacT); |
118 }; | 128 }; |
119 | 129 |
120 } // namespace webrtc | 130 } // namespace webrtc |
121 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_H_ | 131 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_H_ |
OLD | NEW |