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

Side by Side Diff: webrtc/modules/utility/source/coder.cc

Issue 1968853002: Modernize variable names (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « webrtc/modules/utility/source/coder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "webrtc/common_types.h" 11 #include "webrtc/common_types.h"
12 #include "webrtc/modules/include/module_common_types.h" 12 #include "webrtc/modules/include/module_common_types.h"
13 #include "webrtc/modules/utility/source/coder.h" 13 #include "webrtc/modules/utility/source/coder.h"
14 14
15 namespace webrtc { 15 namespace webrtc {
16 16
17 AudioCoder::AudioCoder(uint32_t instanceID) 17 AudioCoder::AudioCoder(uint32_t instance_id)
18 : _acm(AudioCodingModule::Create(instanceID)), 18 : acm_(AudioCodingModule::Create(instance_id)),
19 _receiveCodec(), 19 receive_codec_(),
20 _encodeTimestamp(0), 20 encode_timestamp_(0),
21 _encodedData(NULL), 21 encoded_data_(nullptr),
22 _encodedLengthInBytes(0), 22 encoded_length_in_bytes_(0),
23 _decodeTimestamp(0) { 23 decode_timestamp_(0) {
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 int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst) { 30 int32_t AudioCoder::SetEncodeCodec(const CodecInst& codec_inst) {
31 const bool success = codec_manager_.RegisterEncoder(codecInst) && 31 const bool success = codec_manager_.RegisterEncoder(codec_inst) &&
32 codec_manager_.MakeEncoder(&rent_a_codec_, _acm.get()); 32 codec_manager_.MakeEncoder(&rent_a_codec_, acm_.get());
33 return success ? 0 : -1; 33 return success ? 0 : -1;
34 } 34 }
35 35
36 int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst) { 36 int32_t AudioCoder::SetDecodeCodec(const CodecInst& codec_inst) {
37 if (_acm->RegisterReceiveCodec( 37 if (acm_->RegisterReceiveCodec(
38 codecInst, [&] { return rent_a_codec_.RentIsacDecoder(); }) == -1) { 38 codec_inst, [&] { return rent_a_codec_.RentIsacDecoder(); }) == -1) {
39 return -1; 39 return -1;
40 } 40 }
41 memcpy(&_receiveCodec, &codecInst, sizeof(CodecInst)); 41 memcpy(&receive_codec_, &codec_inst, sizeof(CodecInst));
42 return 0; 42 return 0;
43 } 43 }
44 44
45 int32_t AudioCoder::Decode(AudioFrame& decodedAudio, 45 int32_t AudioCoder::Decode(AudioFrame& decoded_audio,
46 uint32_t sampFreqHz, 46 uint32_t samp_freq_hz,
47 const int8_t* incomingPayload, 47 const int8_t* incoming_payload,
48 size_t payloadLength) { 48 size_t payload_length) {
49 if (payloadLength > 0) { 49 if (payload_length > 0) {
50 const uint8_t payloadType = _receiveCodec.pltype; 50 const uint8_t payload_type = receive_codec_.pltype;
51 _decodeTimestamp += _receiveCodec.pacsize; 51 decode_timestamp_ += receive_codec_.pacsize;
52 if (_acm->IncomingPayload((const uint8_t*)incomingPayload, payloadLength, 52 if (acm_->IncomingPayload((const uint8_t*)incoming_payload, payload_length,
53 payloadType, _decodeTimestamp) == -1) { 53 payload_type, decode_timestamp_) == -1) {
54 return -1; 54 return -1;
55 } 55 }
56 } 56 }
57 return _acm->PlayoutData10Ms((uint16_t)sampFreqHz, &decodedAudio); 57 return acm_->PlayoutData10Ms((uint16_t)samp_freq_hz, &decoded_audio);
58 } 58 }
59 59
60 int32_t AudioCoder::PlayoutData(AudioFrame& decodedAudio, 60 int32_t AudioCoder::PlayoutData(AudioFrame& decoded_audio,
61 uint16_t& sampFreqHz) { 61 uint16_t& samp_freq_hz) {
62 return _acm->PlayoutData10Ms(sampFreqHz, &decodedAudio); 62 return acm_->PlayoutData10Ms(samp_freq_hz, &decoded_audio);
63 } 63 }
64 64
65 int32_t AudioCoder::Encode(const AudioFrame& audio, 65 int32_t AudioCoder::Encode(const AudioFrame& audio,
66 int8_t* encodedData, 66 int8_t* encoded_data,
67 size_t& encodedLengthInBytes) { 67 size_t& encoded_length_in_bytes) {
68 // Fake a timestamp in case audio doesn't contain a correct timestamp. 68 // Fake a timestamp in case audio doesn't contain a correct timestamp.
69 // Make a local copy of the audio frame since audio is const 69 // Make a local copy of the audio frame since audio is const
70 AudioFrame audioFrame; 70 AudioFrame audio_frame;
71 audioFrame.CopyFrom(audio); 71 audio_frame.CopyFrom(audio);
72 audioFrame.timestamp_ = _encodeTimestamp; 72 audio_frame.timestamp_ = encode_timestamp_;
73 _encodeTimestamp += static_cast<uint32_t>(audioFrame.samples_per_channel_); 73 encode_timestamp_ += static_cast<uint32_t>(audio_frame.samples_per_channel_);
74 74
75 // For any codec with a frame size that is longer than 10 ms the encoded 75 // For any codec with a frame size that is longer than 10 ms the encoded
76 // length in bytes should be zero until a a full frame has been encoded. 76 // length in bytes should be zero until a a full frame has been encoded.
77 _encodedLengthInBytes = 0; 77 encoded_length_in_bytes_ = 0;
78 if (_acm->Add10MsData((AudioFrame&)audioFrame) == -1) { 78 if (acm_->Add10MsData((AudioFrame&)audio_frame) == -1) {
79 return -1; 79 return -1;
80 } 80 }
81 _encodedData = encodedData; 81 encoded_data_ = encoded_data;
82 encodedLengthInBytes = _encodedLengthInBytes; 82 encoded_length_in_bytes = encoded_length_in_bytes_;
83 return 0; 83 return 0;
84 } 84 }
85 85
86 int32_t AudioCoder::SendData(FrameType /* frameType */, 86 int32_t AudioCoder::SendData(FrameType /* frame_type */,
87 uint8_t /* payloadType */, 87 uint8_t /* payload_type */,
88 uint32_t /* timeStamp */, 88 uint32_t /* time_stamp */,
89 const uint8_t* payloadData, 89 const uint8_t* payload_data,
90 size_t payloadSize, 90 size_t payload_size,
91 const RTPFragmentationHeader* /* fragmentation*/) { 91 const RTPFragmentationHeader* /* fragmentation*/) {
92 memcpy(_encodedData, payloadData, sizeof(uint8_t) * payloadSize); 92 memcpy(encoded_data_, payload_data, sizeof(uint8_t) * payload_size);
93 _encodedLengthInBytes = payloadSize; 93 encoded_length_in_bytes_ = payload_size;
94 return 0; 94 return 0;
95 } 95 }
96 96
97 } // namespace webrtc 97 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/utility/source/coder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698