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 = |
34 if(_acm->RegisterSendCodec((CodecInst&)codecInst) == -1) | 34 codec_manager_.RegisterEncoder(codecInst) && |
35 { | 35 codec_manager_.MakeEncoder(&rent_a_codec_, |
36 return -1; | 36 [&](std::unique_ptr<AudioEncoder> new_enc) { |
37 } | 37 _acm->SetEncoder(std::move(new_enc)); |
38 return 0; | 38 }); |
| 39 return success ? 0 : -1; |
39 } | 40 } |
40 | 41 |
41 int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst) | 42 int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst) { |
42 { | 43 if (_acm->RegisterReceiveCodec( |
43 if(_acm->RegisterReceiveCodec((CodecInst&)codecInst) == -1) | 44 codecInst, [&] { return rent_a_codec_.RentIsacDecoder(); }) == -1) { |
44 { | 45 return -1; |
45 return -1; | 46 } |
46 } | 47 memcpy(&_receiveCodec, &codecInst, sizeof(CodecInst)); |
47 memcpy(&_receiveCodec,&codecInst,sizeof(CodecInst)); | 48 return 0; |
48 return 0; | |
49 } | 49 } |
50 | 50 |
51 int32_t AudioCoder::Decode(AudioFrame& decodedAudio, | 51 int32_t AudioCoder::Decode(AudioFrame& decodedAudio, |
52 uint32_t sampFreqHz, | 52 uint32_t sampFreqHz, |
53 const int8_t* incomingPayload, | 53 const int8_t* incomingPayload, |
54 size_t payloadLength) | 54 size_t payloadLength) |
55 { | 55 { |
56 if (payloadLength > 0) | 56 if (payloadLength > 0) |
57 { | 57 { |
58 const uint8_t payloadType = _receiveCodec.pltype; | 58 const uint8_t payloadType = _receiveCodec.pltype; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 uint32_t /* timeStamp */, | 103 uint32_t /* timeStamp */, |
104 const uint8_t* payloadData, | 104 const uint8_t* payloadData, |
105 size_t payloadSize, | 105 size_t payloadSize, |
106 const RTPFragmentationHeader* /* fragmentation*/) | 106 const RTPFragmentationHeader* /* fragmentation*/) |
107 { | 107 { |
108 memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize); | 108 memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize); |
109 _encodedLengthInBytes = payloadSize; | 109 _encodedLengthInBytes = payloadSize; |
110 return 0; | 110 return 0; |
111 } | 111 } |
112 } // namespace webrtc | 112 } // namespace webrtc |
OLD | NEW |