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

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

Issue 2024633002: AudioDecoder: New method SampleRateHz, + implementations for our codecs (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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_G711_AUDIO_DECODER_PCM_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_
13 13
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/base/constructormagic.h" 15 #include "webrtc/base/constructormagic.h"
16 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 16 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 19
20 class AudioDecoderPcmU final : public AudioDecoder { 20 class AudioDecoderPcmU final : public AudioDecoder {
21 public: 21 public:
22 explicit AudioDecoderPcmU(size_t num_channels) : num_channels_(num_channels) { 22 explicit AudioDecoderPcmU(int sample_rate_hz, size_t num_channels)
hlundin-webrtc 2016/05/30 14:10:17 Even though not a technical necessity, I think PCM
kwiberg-webrtc 2016/05/31 08:26:05 Done.
23 : sample_rate_hz_(sample_rate_hz), num_channels_(num_channels) {
23 RTC_DCHECK_GE(num_channels, 1u); 24 RTC_DCHECK_GE(num_channels, 1u);
24 } 25 }
25 void Reset() override; 26 void Reset() override;
26 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; 27 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
28 int SampleRateHz() const override;
27 size_t Channels() const override; 29 size_t Channels() const override;
28 30
29 protected: 31 protected:
30 int DecodeInternal(const uint8_t* encoded, 32 int DecodeInternal(const uint8_t* encoded,
31 size_t encoded_len, 33 size_t encoded_len,
32 int sample_rate_hz, 34 int sample_rate_hz,
33 int16_t* decoded, 35 int16_t* decoded,
34 SpeechType* speech_type) override; 36 SpeechType* speech_type) override;
35 37
36 private: 38 private:
39 const int sample_rate_hz_;
37 const size_t num_channels_; 40 const size_t num_channels_;
38 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmU); 41 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmU);
39 }; 42 };
40 43
41 class AudioDecoderPcmA final : public AudioDecoder { 44 class AudioDecoderPcmA final : public AudioDecoder {
42 public: 45 public:
43 explicit AudioDecoderPcmA(size_t num_channels) : num_channels_(num_channels) { 46 explicit AudioDecoderPcmA(int sample_rate_hz, size_t num_channels)
47 : sample_rate_hz_(sample_rate_hz), num_channels_(num_channels) {
44 RTC_DCHECK_GE(num_channels, 1u); 48 RTC_DCHECK_GE(num_channels, 1u);
45 } 49 }
46 void Reset() override; 50 void Reset() override;
47 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; 51 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
52 int SampleRateHz() const override;
48 size_t Channels() const override; 53 size_t Channels() const override;
49 54
50 protected: 55 protected:
51 int DecodeInternal(const uint8_t* encoded, 56 int DecodeInternal(const uint8_t* encoded,
52 size_t encoded_len, 57 size_t encoded_len,
53 int sample_rate_hz, 58 int sample_rate_hz,
54 int16_t* decoded, 59 int16_t* decoded,
55 SpeechType* speech_type) override; 60 SpeechType* speech_type) override;
56 61
57 private: 62 private:
63 const int sample_rate_hz_;
58 const size_t num_channels_; 64 const size_t num_channels_;
59 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmA); 65 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmA);
60 }; 66 };
61 67
62 } // namespace webrtc 68 } // namespace webrtc
63 69
64 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_ 70 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698