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

Side by Side Diff: webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h

Issue 1967503002: Audio codec usage statistics (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Minor fixes + counting bugfix Created 4 years, 7 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
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, 48 EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
49 rtc::ArrayView<const int16_t> audio, 49 rtc::ArrayView<const int16_t> audio,
50 rtc::Buffer* encoded) override; 50 rtc::Buffer* encoded) override;
51 51
52 virtual size_t EncodeCall(const int16_t* audio, 52 virtual size_t EncodeCall(const int16_t* audio,
53 size_t input_len, 53 size_t input_len,
54 uint8_t* encoded) = 0; 54 uint8_t* encoded) = 0;
55 55
56 virtual size_t BytesPerSample() const = 0; 56 virtual size_t BytesPerSample() const = 0;
57 57
58 // The default implementation returns kOther, which means no name,
59 // other or unknown codec. Used to set EncodedInfoLeaf::encoder_type
60 // in AudioEncoderPcm::EncodeImpl
61 virtual AudioEncoder::CodecType GetCodecType() const;
kwiberg-webrtc 2016/05/12 23:30:21 Again, it's probably much simpler to =0 here and j
aleloi 2016/05/13 09:02:27 To clarify: you suggest changing this to =0, make
kwiberg-webrtc 2016/05/15 02:06:13 Exactly.
aleloi 2016/05/16 08:02:23 Done.
62
58 private: 63 private:
59 const int sample_rate_hz_; 64 const int sample_rate_hz_;
60 const size_t num_channels_; 65 const size_t num_channels_;
61 const int payload_type_; 66 const int payload_type_;
62 const size_t num_10ms_frames_per_packet_; 67 const size_t num_10ms_frames_per_packet_;
63 const size_t full_frame_samples_; 68 const size_t full_frame_samples_;
64 std::vector<int16_t> speech_buffer_; 69 std::vector<int16_t> speech_buffer_;
65 uint32_t first_timestamp_in_buffer_; 70 uint32_t first_timestamp_in_buffer_;
66 }; 71 };
67 72
68 struct CodecInst; 73 struct CodecInst;
69 74
70 class AudioEncoderPcmA final : public AudioEncoderPcm { 75 class AudioEncoderPcmA final : public AudioEncoderPcm {
71 public: 76 public:
72 struct Config : public AudioEncoderPcm::Config { 77 struct Config : public AudioEncoderPcm::Config {
73 Config() : AudioEncoderPcm::Config(8) {} 78 Config() : AudioEncoderPcm::Config(8) {}
74 }; 79 };
75 80
76 explicit AudioEncoderPcmA(const Config& config) 81 explicit AudioEncoderPcmA(const Config& config)
77 : AudioEncoderPcm(config, kSampleRateHz) {} 82 : AudioEncoderPcm(config, kSampleRateHz) {}
78 explicit AudioEncoderPcmA(const CodecInst& codec_inst); 83 explicit AudioEncoderPcmA(const CodecInst& codec_inst);
79 84
80 protected: 85 protected:
81 size_t EncodeCall(const int16_t* audio, 86 size_t EncodeCall(const int16_t* audio,
82 size_t input_len, 87 size_t input_len,
83 uint8_t* encoded) override; 88 uint8_t* encoded) override;
84 89
85 size_t BytesPerSample() const override; 90 size_t BytesPerSample() const override;
86 91
92 AudioEncoder::CodecType GetCodecType() const override;
93
87 private: 94 private:
88 static const int kSampleRateHz = 8000; 95 static const int kSampleRateHz = 8000;
89 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); 96 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA);
90 }; 97 };
91 98
92 class AudioEncoderPcmU final : public AudioEncoderPcm { 99 class AudioEncoderPcmU final : public AudioEncoderPcm {
93 public: 100 public:
94 struct Config : public AudioEncoderPcm::Config { 101 struct Config : public AudioEncoderPcm::Config {
95 Config() : AudioEncoderPcm::Config(0) {} 102 Config() : AudioEncoderPcm::Config(0) {}
96 }; 103 };
97 104
98 explicit AudioEncoderPcmU(const Config& config) 105 explicit AudioEncoderPcmU(const Config& config)
99 : AudioEncoderPcm(config, kSampleRateHz) {} 106 : AudioEncoderPcm(config, kSampleRateHz) {}
100 explicit AudioEncoderPcmU(const CodecInst& codec_inst); 107 explicit AudioEncoderPcmU(const CodecInst& codec_inst);
101 108
102 protected: 109 protected:
103 size_t EncodeCall(const int16_t* audio, 110 size_t EncodeCall(const int16_t* audio,
104 size_t input_len, 111 size_t input_len,
105 uint8_t* encoded) override; 112 uint8_t* encoded) override;
106 113
107 size_t BytesPerSample() const override; 114 size_t BytesPerSample() const override;
108 115
116 AudioEncoder::CodecType GetCodecType() const override;
117
109 private: 118 private:
110 static const int kSampleRateHz = 8000; 119 static const int kSampleRateHz = 8000;
111 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); 120 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU);
112 }; 121 };
113 122
114 } // namespace webrtc 123 } // namespace webrtc
115 124
116 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ 125 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698