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 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 static const int kDefaultComplexity = 5; | 47 static const int kDefaultComplexity = 5; |
48 #else | 48 #else |
49 static const int kDefaultComplexity = 9; | 49 static const int kDefaultComplexity = 9; |
50 #endif | 50 #endif |
51 }; | 51 }; |
52 | 52 |
53 explicit AudioEncoderOpus(const Config& config); | 53 explicit AudioEncoderOpus(const Config& config); |
54 explicit AudioEncoderOpus(const CodecInst& codec_inst); | 54 explicit AudioEncoderOpus(const CodecInst& codec_inst); |
55 ~AudioEncoderOpus() override; | 55 ~AudioEncoderOpus() override; |
56 | 56 |
57 size_t MaxEncodedBytes() const override; | |
58 int SampleRateHz() const override; | 57 int SampleRateHz() const override; |
59 size_t NumChannels() const override; | 58 size_t NumChannels() const override; |
60 size_t Num10MsFramesInNextPacket() const override; | 59 size_t Num10MsFramesInNextPacket() const override; |
61 size_t Max10MsFramesInAPacket() const override; | 60 size_t Max10MsFramesInAPacket() const override; |
62 int GetTargetBitrate() const override; | 61 int GetTargetBitrate() const override; |
63 | 62 |
64 void Reset() override; | 63 void Reset() override; |
65 bool SetFec(bool enable) override; | 64 bool SetFec(bool enable) override; |
66 | 65 |
67 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice | 66 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice |
68 // being inactive. During that, it still sends 2 packets (one for content, one | 67 // being inactive. During that, it still sends 2 packets (one for content, one |
69 // for signaling) about every 400 ms. | 68 // for signaling) about every 400 ms. |
70 bool SetDtx(bool enable) override; | 69 bool SetDtx(bool enable) override; |
71 | 70 |
72 bool SetApplication(Application application) override; | 71 bool SetApplication(Application application) override; |
73 void SetMaxPlaybackRate(int frequency_hz) override; | 72 void SetMaxPlaybackRate(int frequency_hz) override; |
74 void SetProjectedPacketLossRate(double fraction) override; | 73 void SetProjectedPacketLossRate(double fraction) override; |
75 void SetTargetBitrate(int target_bps) override; | 74 void SetTargetBitrate(int target_bps) override; |
76 | 75 |
77 // Getters for testing. | 76 // Getters for testing. |
78 double packet_loss_rate() const { return packet_loss_rate_; } | 77 double packet_loss_rate() const { return packet_loss_rate_; } |
79 ApplicationMode application() const { return config_.application; } | 78 ApplicationMode application() const { return config_.application; } |
80 bool dtx_enabled() const { return config_.dtx_enabled; } | 79 bool dtx_enabled() const { return config_.dtx_enabled; } |
81 | 80 |
82 protected: | 81 protected: |
83 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, | 82 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, |
84 rtc::ArrayView<const int16_t> audio, | 83 rtc::ArrayView<const int16_t> audio, |
85 rtc::Buffer* encoded) override; | 84 rtc::Buffer* encoded) override; |
86 | 85 |
87 private: | 86 private: |
88 size_t Num10msFramesPerPacket() const; | 87 size_t Num10msFramesPerPacket() const; |
89 size_t SamplesPer10msFrame() const; | 88 size_t SamplesPer10msFrame() const; |
| 89 size_t SufficientOutputBufferSize() const; |
90 bool RecreateEncoderInstance(const Config& config); | 90 bool RecreateEncoderInstance(const Config& config); |
91 | 91 |
92 Config config_; | 92 Config config_; |
93 double packet_loss_rate_; | 93 double packet_loss_rate_; |
94 std::vector<int16_t> input_buffer_; | 94 std::vector<int16_t> input_buffer_; |
95 OpusEncInst* inst_; | 95 OpusEncInst* inst_; |
96 uint32_t first_timestamp_in_buffer_; | 96 uint32_t first_timestamp_in_buffer_; |
97 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); | 97 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace webrtc | 100 } // namespace webrtc |
101 | 101 |
102 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 102 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
OLD | NEW |