OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_NETEQ_DECODER_DATABASE_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/common_types.h" // NULL | 19 #include "webrtc/common_types.h" // NULL |
| 20 #include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h" |
| 21 #include "webrtc/modules/audio_coding/codecs/audio_format.h" |
20 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" | 22 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" |
21 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" | 23 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" |
22 #include "webrtc/modules/audio_coding/neteq/packet.h" | 24 #include "webrtc/modules/audio_coding/neteq/packet.h" |
23 #include "webrtc/typedefs.h" | 25 #include "webrtc/typedefs.h" |
24 | 26 |
25 namespace webrtc { | 27 namespace webrtc { |
26 | 28 |
27 class DecoderDatabase { | 29 class DecoderDatabase { |
28 public: | 30 public: |
29 enum DatabaseReturnCodes { | 31 enum DatabaseReturnCodes { |
(...skipping 10 matching lines...) Expand all Loading... |
40 class DecoderInfo { | 42 class DecoderInfo { |
41 public: | 43 public: |
42 DecoderInfo(NetEqDecoder ct, | 44 DecoderInfo(NetEqDecoder ct, |
43 const std::string& nm, | 45 const std::string& nm, |
44 int fs, | 46 int fs, |
45 AudioDecoder* ext_dec); | 47 AudioDecoder* ext_dec); |
46 DecoderInfo(DecoderInfo&&); | 48 DecoderInfo(DecoderInfo&&); |
47 ~DecoderInfo(); | 49 ~DecoderInfo(); |
48 | 50 |
49 // Get the AudioDecoder object, creating it first if necessary. | 51 // Get the AudioDecoder object, creating it first if necessary. |
50 AudioDecoder* GetDecoder(); | 52 AudioDecoder* GetDecoder(AudioDecoderFactory* factory); |
51 | 53 |
52 // Delete the AudioDecoder object, unless it's external. (This means we can | 54 // Delete the AudioDecoder object, unless it's external. (This means we can |
53 // always recreate it later if we need it.) | 55 // always recreate it later if we need it.) |
54 void DropDecoder() { decoder_.reset(); } | 56 void DropDecoder() { decoder_.reset(); } |
55 | 57 |
56 const NetEqDecoder codec_type; | 58 const NetEqDecoder codec_type; |
57 const std::string name; | 59 const std::string name; |
58 const int fs_hz; | 60 const int fs_hz; |
59 AudioDecoder* const external_decoder; | 61 AudioDecoder* const external_decoder; |
60 | 62 |
61 private: | 63 private: |
| 64 const rtc::Optional<SdpAudioFormat> audio_format_; |
62 std::unique_ptr<AudioDecoder> decoder_; | 65 std::unique_ptr<AudioDecoder> decoder_; |
63 }; | 66 }; |
64 | 67 |
65 // Maximum value for 8 bits, and an invalid RTP payload type (since it is | 68 // Maximum value for 8 bits, and an invalid RTP payload type (since it is |
66 // only 7 bits). | 69 // only 7 bits). |
67 static const uint8_t kRtpPayloadTypeError = 0xFF; | 70 static const uint8_t kRtpPayloadTypeError = 0xFF; |
68 | 71 |
69 DecoderDatabase(); | 72 DecoderDatabase(std::unique_ptr<AudioDecoderFactory> decoder_factory); |
70 | 73 |
71 virtual ~DecoderDatabase(); | 74 virtual ~DecoderDatabase(); |
72 | 75 |
73 // Returns true if the database is empty. | 76 // Returns true if the database is empty. |
74 virtual bool Empty() const; | 77 virtual bool Empty() const; |
75 | 78 |
76 // Returns the number of decoders registered in the database. | 79 // Returns the number of decoders registered in the database. |
77 virtual int Size() const; | 80 virtual int Size() const; |
78 | 81 |
79 // Resets the database, erasing all registered payload types, and deleting | 82 // Resets the database, erasing all registered payload types, and deleting |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // registered in the database. Otherwise, returns kDecoderNotFound. | 153 // registered in the database. Otherwise, returns kDecoderNotFound. |
151 virtual int CheckPayloadTypes(const PacketList& packet_list) const; | 154 virtual int CheckPayloadTypes(const PacketList& packet_list) const; |
152 | 155 |
153 private: | 156 private: |
154 typedef std::map<uint8_t, DecoderInfo> DecoderMap; | 157 typedef std::map<uint8_t, DecoderInfo> DecoderMap; |
155 | 158 |
156 DecoderMap decoders_; | 159 DecoderMap decoders_; |
157 int active_decoder_type_; | 160 int active_decoder_type_; |
158 int active_cng_decoder_type_; | 161 int active_cng_decoder_type_; |
159 std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; | 162 std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; |
| 163 const std::unique_ptr<AudioDecoderFactory> decoder_factory_; |
160 | 164 |
161 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); | 165 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); |
162 }; | 166 }; |
163 | 167 |
164 } // namespace webrtc | 168 } // namespace webrtc |
165 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ | 169 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ |
OLD | NEW |