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 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" |
12 | 12 |
13 #include <assert.h> // assert | 13 #include <assert.h> // assert |
14 #include <math.h> // pow() | 14 #include <math.h> // pow() |
15 #include <string.h> // memcpy() | 15 #include <string.h> // memcpy() |
16 | 16 |
17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
18 #include "webrtc/system_wrappers/interface/logging.h" | 18 #include "webrtc/system_wrappers/interface/logging.h" |
19 #include "webrtc/system_wrappers/interface/trace_event.h" | 19 #include "webrtc/system_wrappers/interface/trace_event.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy( | 22 RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy( |
23 int32_t id, RtpData* data_callback, | 23 RtpData* data_callback, |
24 RtpAudioFeedback* incoming_messages_callback) { | 24 RtpAudioFeedback* incoming_messages_callback) { |
25 return new RTPReceiverAudio(id, data_callback, incoming_messages_callback); | 25 return new RTPReceiverAudio(data_callback, incoming_messages_callback); |
26 } | 26 } |
27 | 27 |
28 RTPReceiverAudio::RTPReceiverAudio(const int32_t id, | 28 RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback, |
29 RtpData* data_callback, | |
30 RtpAudioFeedback* incoming_messages_callback) | 29 RtpAudioFeedback* incoming_messages_callback) |
31 : RTPReceiverStrategy(data_callback), | 30 : RTPReceiverStrategy(data_callback), |
32 TelephoneEventHandler(), | 31 TelephoneEventHandler(), |
33 id_(id), | |
34 last_received_frequency_(8000), | 32 last_received_frequency_(8000), |
35 telephone_event_forward_to_decoder_(false), | 33 telephone_event_forward_to_decoder_(false), |
36 telephone_event_payload_type_(-1), | 34 telephone_event_payload_type_(-1), |
37 cng_nb_payload_type_(-1), | 35 cng_nb_payload_type_(-1), |
38 cng_wb_payload_type_(-1), | 36 cng_wb_payload_type_(-1), |
39 cng_swb_payload_type_(-1), | 37 cng_swb_payload_type_(-1), |
40 cng_fb_payload_type_(-1), | 38 cng_fb_payload_type_(-1), |
41 cng_payload_type_(-1), | 39 cng_payload_type_(-1), |
42 g722_payload_type_(-1), | 40 g722_payload_type_(-1), |
43 last_received_g722_(false), | 41 last_received_g722_(false), |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 254 |
257 if (num_energy_ > 0) { | 255 if (num_energy_ > 0) { |
258 memcpy(array_of_energy, current_remote_energy_, | 256 memcpy(array_of_energy, current_remote_energy_, |
259 sizeof(uint8_t) * num_energy_); | 257 sizeof(uint8_t) * num_energy_); |
260 } | 258 } |
261 return num_energy_; | 259 return num_energy_; |
262 } | 260 } |
263 | 261 |
264 int32_t RTPReceiverAudio::InvokeOnInitializeDecoder( | 262 int32_t RTPReceiverAudio::InvokeOnInitializeDecoder( |
265 RtpFeedback* callback, | 263 RtpFeedback* callback, |
266 int32_t id, | |
267 int8_t payload_type, | 264 int8_t payload_type, |
268 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 265 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
269 const PayloadUnion& specific_payload) const { | 266 const PayloadUnion& specific_payload) const { |
270 if (-1 == callback->OnInitializeDecoder(id, | 267 if (-1 == |
271 payload_type, | 268 callback->OnInitializeDecoder( |
272 payload_name, | 269 payload_type, payload_name, specific_payload.Audio.frequency, |
273 specific_payload.Audio.frequency, | 270 specific_payload.Audio.channels, specific_payload.Audio.rate)) { |
274 specific_payload.Audio.channels, | |
275 specific_payload.Audio.rate)) { | |
276 LOG(LS_ERROR) << "Failed to create decoder for payload type: " | 271 LOG(LS_ERROR) << "Failed to create decoder for payload type: " |
277 << payload_name << "/" << static_cast<int>(payload_type); | 272 << payload_name << "/" << static_cast<int>(payload_type); |
278 return -1; | 273 return -1; |
279 } | 274 } |
280 return 0; | 275 return 0; |
281 } | 276 } |
282 | 277 |
283 // We are not allowed to have any critsects when calling data_callback. | 278 // We are not allowed to have any critsects when calling data_callback. |
284 int32_t RTPReceiverAudio::ParseAudioCodecSpecific( | 279 int32_t RTPReceiverAudio::ParseAudioCodecSpecific( |
285 WebRtcRTPHeader* rtp_header, | 280 WebRtcRTPHeader* rtp_header, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // only one frame in the RED strip the one byte to help NetEq | 376 // only one frame in the RED strip the one byte to help NetEq |
382 return data_callback_->OnReceivedPayloadData( | 377 return data_callback_->OnReceivedPayloadData( |
383 payload_data + 1, payload_length - 1, rtp_header); | 378 payload_data + 1, payload_length - 1, rtp_header); |
384 } | 379 } |
385 | 380 |
386 rtp_header->type.Audio.channel = audio_specific.channels; | 381 rtp_header->type.Audio.channel = audio_specific.channels; |
387 return data_callback_->OnReceivedPayloadData( | 382 return data_callback_->OnReceivedPayloadData( |
388 payload_data, payload_length, rtp_header); | 383 payload_data, payload_length, rtp_header); |
389 } | 384 } |
390 } // namespace webrtc | 385 } // namespace webrtc |
OLD | NEW |