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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added more fixes for override hiding in AudioEncoder implementations. Created 4 years, 9 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
13 13
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/constructormagic.h" 16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" 17 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 struct CodecInst; 22 struct CodecInst;
23 23
24 class AudioEncoderOpus final : public AudioEncoder { 24 class AudioEncoderOpus final : public AudioEncoder {
25 public: 25 public:
26 using AudioEncoder::EncodeInternal;
27
26 enum ApplicationMode { 28 enum ApplicationMode {
27 kVoip = 0, 29 kVoip = 0,
28 kAudio = 1, 30 kAudio = 1,
29 }; 31 };
30 32
31 struct Config { 33 struct Config {
32 bool IsOk() const; 34 bool IsOk() const;
33 int frame_size_ms = 20; 35 int frame_size_ms = 20;
34 size_t num_channels = 1; 36 size_t num_channels = 1;
35 int payload_type = 120; 37 int payload_type = 120;
(...skipping 18 matching lines...) Expand all
54 explicit AudioEncoderOpus(const CodecInst& codec_inst); 56 explicit AudioEncoderOpus(const CodecInst& codec_inst);
55 ~AudioEncoderOpus() override; 57 ~AudioEncoderOpus() override;
56 58
57 size_t MaxEncodedBytes() const override; 59 size_t MaxEncodedBytes() const override;
58 int SampleRateHz() const override; 60 int SampleRateHz() const override;
59 size_t NumChannels() const override; 61 size_t NumChannels() const override;
60 size_t Num10MsFramesInNextPacket() const override; 62 size_t Num10MsFramesInNextPacket() const override;
61 size_t Max10MsFramesInAPacket() const override; 63 size_t Max10MsFramesInAPacket() const override;
62 int GetTargetBitrate() const override; 64 int GetTargetBitrate() const override;
63 65
64 EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
65 rtc::ArrayView<const int16_t> audio,
66 size_t max_encoded_bytes,
67 uint8_t* encoded) override;
68
69 void Reset() override; 66 void Reset() override;
70 bool SetFec(bool enable) override; 67 bool SetFec(bool enable) override;
71 68
72 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice 69 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice
73 // being inactive. During that, it still sends 2 packets (one for content, one 70 // being inactive. During that, it still sends 2 packets (one for content, one
74 // for signaling) about every 400 ms. 71 // for signaling) about every 400 ms.
75 bool SetDtx(bool enable) override; 72 bool SetDtx(bool enable) override;
76 73
77 bool SetApplication(Application application) override; 74 bool SetApplication(Application application) override;
78 void SetMaxPlaybackRate(int frequency_hz) override; 75 void SetMaxPlaybackRate(int frequency_hz) override;
79 void SetProjectedPacketLossRate(double fraction) override; 76 void SetProjectedPacketLossRate(double fraction) override;
80 void SetTargetBitrate(int target_bps) override; 77 void SetTargetBitrate(int target_bps) override;
81 78
82 // Getters for testing. 79 // Getters for testing.
83 double packet_loss_rate() const { return packet_loss_rate_; } 80 double packet_loss_rate() const { return packet_loss_rate_; }
84 ApplicationMode application() const { return config_.application; } 81 ApplicationMode application() const { return config_.application; }
85 bool dtx_enabled() const { return config_.dtx_enabled; } 82 bool dtx_enabled() const { return config_.dtx_enabled; }
86 83
84 protected:
85 EncodedInfo EncodeInternal(uint32_t rtp_timestamp,
86 rtc::ArrayView<const int16_t> audio,
87 rtc::Buffer* encoded) override;
88
87 private: 89 private:
88 size_t Num10msFramesPerPacket() const; 90 size_t Num10msFramesPerPacket() const;
89 size_t SamplesPer10msFrame() const; 91 size_t SamplesPer10msFrame() const;
90 bool RecreateEncoderInstance(const Config& config); 92 bool RecreateEncoderInstance(const Config& config);
91 93
92 Config config_; 94 Config config_;
93 double packet_loss_rate_; 95 double packet_loss_rate_;
94 std::vector<int16_t> input_buffer_; 96 std::vector<int16_t> input_buffer_;
95 OpusEncInst* inst_; 97 OpusEncInst* inst_;
96 uint32_t first_timestamp_in_buffer_; 98 uint32_t first_timestamp_in_buffer_;
97 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); 99 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
98 }; 100 };
99 101
100 } // namespace webrtc 102 } // namespace webrtc
101 103
102 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 104 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698