• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
12 #define WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
13 
14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/common_types.h"
16 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
17 #include "webrtc/typedefs.h"
18 
19 namespace webrtc {
20 class AudioFrame;
21 
22 class AudioCoder : public AudioPacketizationCallback
23 {
24 public:
25     AudioCoder(uint32_t instanceID);
26     ~AudioCoder();
27 
28     int32_t SetEncodeCodec(const CodecInst& codecInst);
29 
30     int32_t SetDecodeCodec(const CodecInst& codecInst);
31 
32     int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
33                    const int8_t* incomingPayload, size_t payloadLength);
34 
35     int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
36 
37     int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
38                    size_t& encodedLengthInBytes);
39 
40 protected:
41  int32_t SendData(FrameType frameType,
42                   uint8_t payloadType,
43                   uint32_t timeStamp,
44                   const uint8_t* payloadData,
45                   size_t payloadSize,
46                   const RTPFragmentationHeader* fragmentation) override;
47 
48 private:
49  rtc::scoped_ptr<AudioCodingModule> _acm;
50 
51     CodecInst _receiveCodec;
52 
53     uint32_t _encodeTimestamp;
54     int8_t*  _encodedData;
55     size_t _encodedLengthInBytes;
56 
57     uint32_t _decodeTimestamp;
58 };
59 }  // namespace webrtc
60 
61 #endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
62