| 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/common_types.h" |
| 17 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/base/trace_event.h" | 19 #include "webrtc/base/trace_event.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy( | 22 RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy( |
| 22 RtpData* data_callback) { | 23 RtpData* data_callback) { |
| 23 return new RTPReceiverAudio(data_callback); | 24 return new RTPReceiverAudio(data_callback); |
| 24 } | 25 } |
| 25 | 26 |
| 26 RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback) | 27 RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // - G729 frame N/A 8,000 10 20 | 97 // - G729 frame N/A 8,000 10 20 |
| 97 // - G729D frame N/A 8,000 10 20 | 98 // - G729D frame N/A 8,000 10 20 |
| 98 // - G729E frame N/A 8,000 10 20 | 99 // - G729E frame N/A 8,000 10 20 |
| 99 // - GSM frame N/A 8,000 20 20 | 100 // - GSM frame N/A 8,000 20 20 |
| 100 // - GSM-EFR frame N/A 8,000 20 20 | 101 // - GSM-EFR frame N/A 8,000 20 20 |
| 101 // - LPC frame N/A 8,000 20 20 | 102 // - LPC frame N/A 8,000 20 20 |
| 102 // - MPA frame N/A var. var. | 103 // - MPA frame N/A var. var. |
| 103 // - | 104 // - |
| 104 // - G7221 frame N/A | 105 // - G7221 frame N/A |
| 105 int32_t RTPReceiverAudio::OnNewPayloadTypeCreated( | 106 int32_t RTPReceiverAudio::OnNewPayloadTypeCreated( |
| 106 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 107 const CodecInst& audio_codec) { |
| 107 int8_t payload_type, | |
| 108 uint32_t frequency) { | |
| 109 rtc::CritScope lock(&crit_sect_); | 108 rtc::CritScope lock(&crit_sect_); |
| 110 | 109 |
| 111 if (RtpUtility::StringCompare(payload_name, "telephone-event", 15)) { | 110 if (RtpUtility::StringCompare(audio_codec.plname, "telephone-event", 15)) { |
| 112 telephone_event_payload_type_ = payload_type; | 111 telephone_event_payload_type_ = audio_codec.pltype; |
| 113 } | 112 } |
| 114 if (RtpUtility::StringCompare(payload_name, "cn", 2)) { | 113 if (RtpUtility::StringCompare(audio_codec.plname, "cn", 2)) { |
| 115 // We support comfort noise at four different frequencies. | 114 // We support comfort noise at four different frequencies. |
| 116 if (frequency == 8000) { | 115 if (audio_codec.plfreq == 8000) { |
| 117 cng_nb_payload_type_ = payload_type; | 116 cng_nb_payload_type_ = audio_codec.pltype; |
| 118 } else if (frequency == 16000) { | 117 } else if (audio_codec.plfreq == 16000) { |
| 119 cng_wb_payload_type_ = payload_type; | 118 cng_wb_payload_type_ = audio_codec.pltype; |
| 120 } else if (frequency == 32000) { | 119 } else if (audio_codec.plfreq == 32000) { |
| 121 cng_swb_payload_type_ = payload_type; | 120 cng_swb_payload_type_ = audio_codec.pltype; |
| 122 } else if (frequency == 48000) { | 121 } else if (audio_codec.plfreq == 48000) { |
| 123 cng_fb_payload_type_ = payload_type; | 122 cng_fb_payload_type_ = audio_codec.pltype; |
| 124 } else { | 123 } else { |
| 125 assert(false); | 124 assert(false); |
| 126 return -1; | 125 return -1; |
| 127 } | 126 } |
| 128 } | 127 } |
| 129 return 0; | 128 return 0; |
| 130 } | 129 } |
| 131 | 130 |
| 132 int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, | 131 int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, |
| 133 const PayloadUnion& specific_payload, | 132 const PayloadUnion& specific_payload, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // only one frame in the RED strip the one byte to help NetEq | 298 // only one frame in the RED strip the one byte to help NetEq |
| 300 return data_callback_->OnReceivedPayloadData( | 299 return data_callback_->OnReceivedPayloadData( |
| 301 payload_data + 1, payload_length - 1, rtp_header); | 300 payload_data + 1, payload_length - 1, rtp_header); |
| 302 } | 301 } |
| 303 | 302 |
| 304 rtp_header->type.Audio.channel = audio_specific.channels; | 303 rtp_header->type.Audio.channel = audio_specific.channels; |
| 305 return data_callback_->OnReceivedPayloadData( | 304 return data_callback_->OnReceivedPayloadData( |
| 306 payload_data, payload_length, rtp_header); | 305 payload_data, payload_length, rtp_header); |
| 307 } | 306 } |
| 308 } // namespace webrtc | 307 } // namespace webrtc |
| OLD | NEW |