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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 _decodeTimestamp(0) | 22 _decodeTimestamp(0) |
23 { | 23 { |
24 _acm->InitializeReceiver(); | 24 _acm->InitializeReceiver(); |
25 _acm->RegisterTransportCallback(this); | 25 _acm->RegisterTransportCallback(this); |
26 } | 26 } |
27 | 27 |
28 AudioCoder::~AudioCoder() | 28 AudioCoder::~AudioCoder() |
29 { | 29 { |
30 } | 30 } |
31 | 31 |
32 int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst) | 32 int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst) { |
33 { | 33 const bool success = codec_manager_.RegisterEncoder(codecInst) && |
34 if(_acm->RegisterSendCodec((CodecInst&)codecInst) == -1) | 34 codec_manager_.MakeEncoder(&rent_a_codec_, _acm.get()); |
35 { | 35 return success ? 0 : -1; |
36 return -1; | |
37 } | |
38 return 0; | |
39 } | 36 } |
40 | 37 |
41 int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst) | 38 int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst) { |
42 { | 39 if (_acm->RegisterReceiveCodec( |
43 if(_acm->RegisterReceiveCodec((CodecInst&)codecInst) == -1) | 40 codecInst, [&] { return rent_a_codec_.RentIsacDecoder(); }) == -1) { |
44 { | 41 return -1; |
45 return -1; | 42 } |
46 } | 43 memcpy(&_receiveCodec, &codecInst, sizeof(CodecInst)); |
47 memcpy(&_receiveCodec,&codecInst,sizeof(CodecInst)); | 44 return 0; |
48 return 0; | |
49 } | 45 } |
50 | 46 |
51 int32_t AudioCoder::Decode(AudioFrame& decodedAudio, | 47 int32_t AudioCoder::Decode(AudioFrame& decodedAudio, |
52 uint32_t sampFreqHz, | 48 uint32_t sampFreqHz, |
53 const int8_t* incomingPayload, | 49 const int8_t* incomingPayload, |
54 size_t payloadLength) | 50 size_t payloadLength) |
55 { | 51 { |
56 if (payloadLength > 0) | 52 if (payloadLength > 0) |
57 { | 53 { |
58 const uint8_t payloadType = _receiveCodec.pltype; | 54 const uint8_t payloadType = _receiveCodec.pltype; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 uint32_t /* timeStamp */, | 99 uint32_t /* timeStamp */, |
104 const uint8_t* payloadData, | 100 const uint8_t* payloadData, |
105 size_t payloadSize, | 101 size_t payloadSize, |
106 const RTPFragmentationHeader* /* fragmentation*/) | 102 const RTPFragmentationHeader* /* fragmentation*/) |
107 { | 103 { |
108 memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize); | 104 memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize); |
109 _encodedLengthInBytes = payloadSize; | 105 _encodedLengthInBytes = payloadSize; |
110 return 0; | 106 return 0; |
111 } | 107 } |
112 } // namespace webrtc | 108 } // namespace webrtc |
OLD | NEW |