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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 AudioDecoder* decoder = decoder_database->GetDecoder(payload_type); | 145 AudioDecoder* decoder = decoder_database->GetDecoder(payload_type); |
146 // decoder should not return NULL. | 146 // decoder should not return NULL. |
147 assert(decoder != NULL); | 147 assert(decoder != NULL); |
148 if (!decoder || | 148 if (!decoder || |
149 !decoder->PacketHasFec(packet->payload, packet->payload_length)) { | 149 !decoder->PacketHasFec(packet->payload, packet->payload_length)) { |
150 ++it; | 150 ++it; |
151 continue; | 151 continue; |
152 } | 152 } |
153 | 153 |
154 switch (info->codec_type) { | 154 switch (info->codec_type) { |
155 case kDecoderOpus: | 155 case NetEqDecoder::kDecoderOpus: |
156 case kDecoderOpus_2ch: { | 156 case NetEqDecoder::kDecoderOpus_2ch: { |
157 // The main payload of this packet should be decoded as a primary | 157 // The main payload of this packet should be decoded as a primary |
158 // payload, even if it comes as a secondary payload in a RED packet. | 158 // payload, even if it comes as a secondary payload in a RED packet. |
159 packet->primary = true; | 159 packet->primary = true; |
160 | 160 |
161 Packet* new_packet = new Packet; | 161 Packet* new_packet = new Packet; |
162 new_packet->header = packet->header; | 162 new_packet->header = packet->header; |
163 int duration = decoder-> | 163 int duration = decoder-> |
164 PacketDurationRedundant(packet->payload, packet->payload_length); | 164 PacketDurationRedundant(packet->payload, packet->payload_length); |
165 new_packet->header.timestamp -= duration; | 165 new_packet->header.timestamp -= duration; |
166 new_packet->payload = new uint8_t[packet->payload_length]; | 166 new_packet->payload = new uint8_t[packet->payload_length]; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 LOG(LS_WARNING) << "SplitAudio unknown payload type"; | 229 LOG(LS_WARNING) << "SplitAudio unknown payload type"; |
230 return kUnknownPayloadType; | 230 return kUnknownPayloadType; |
231 } | 231 } |
232 // No splitting for a sync-packet. | 232 // No splitting for a sync-packet. |
233 if (packet->sync_packet) { | 233 if (packet->sync_packet) { |
234 ++it; | 234 ++it; |
235 continue; | 235 continue; |
236 } | 236 } |
237 PacketList new_packets; | 237 PacketList new_packets; |
238 switch (info->codec_type) { | 238 switch (info->codec_type) { |
239 case kDecoderPCMu: | 239 case NetEqDecoder::kDecoderPCMu: |
240 case kDecoderPCMa: { | 240 case NetEqDecoder::kDecoderPCMa: { |
241 // 8 bytes per ms; 8 timestamps per ms. | 241 // 8 bytes per ms; 8 timestamps per ms. |
242 SplitBySamples(packet, 8, 8, &new_packets); | 242 SplitBySamples(packet, 8, 8, &new_packets); |
243 break; | 243 break; |
244 } | 244 } |
245 case kDecoderPCMu_2ch: | 245 case NetEqDecoder::kDecoderPCMu_2ch: |
246 case kDecoderPCMa_2ch: { | 246 case NetEqDecoder::kDecoderPCMa_2ch: { |
247 // 2 * 8 bytes per ms; 8 timestamps per ms. | 247 // 2 * 8 bytes per ms; 8 timestamps per ms. |
248 SplitBySamples(packet, 2 * 8, 8, &new_packets); | 248 SplitBySamples(packet, 2 * 8, 8, &new_packets); |
249 break; | 249 break; |
250 } | 250 } |
251 case kDecoderG722: { | 251 case NetEqDecoder::kDecoderG722: { |
252 // 8 bytes per ms; 16 timestamps per ms. | 252 // 8 bytes per ms; 16 timestamps per ms. |
253 SplitBySamples(packet, 8, 16, &new_packets); | 253 SplitBySamples(packet, 8, 16, &new_packets); |
254 break; | 254 break; |
255 } | 255 } |
256 case kDecoderPCM16B: { | 256 case NetEqDecoder::kDecoderPCM16B: { |
257 // 16 bytes per ms; 8 timestamps per ms. | 257 // 16 bytes per ms; 8 timestamps per ms. |
258 SplitBySamples(packet, 16, 8, &new_packets); | 258 SplitBySamples(packet, 16, 8, &new_packets); |
259 break; | 259 break; |
260 } | 260 } |
261 case kDecoderPCM16Bwb: { | 261 case NetEqDecoder::kDecoderPCM16Bwb: { |
262 // 32 bytes per ms; 16 timestamps per ms. | 262 // 32 bytes per ms; 16 timestamps per ms. |
263 SplitBySamples(packet, 32, 16, &new_packets); | 263 SplitBySamples(packet, 32, 16, &new_packets); |
264 break; | 264 break; |
265 } | 265 } |
266 case kDecoderPCM16Bswb32kHz: { | 266 case NetEqDecoder::kDecoderPCM16Bswb32kHz: { |
267 // 64 bytes per ms; 32 timestamps per ms. | 267 // 64 bytes per ms; 32 timestamps per ms. |
268 SplitBySamples(packet, 64, 32, &new_packets); | 268 SplitBySamples(packet, 64, 32, &new_packets); |
269 break; | 269 break; |
270 } | 270 } |
271 case kDecoderPCM16Bswb48kHz: { | 271 case NetEqDecoder::kDecoderPCM16Bswb48kHz: { |
272 // 96 bytes per ms; 48 timestamps per ms. | 272 // 96 bytes per ms; 48 timestamps per ms. |
273 SplitBySamples(packet, 96, 48, &new_packets); | 273 SplitBySamples(packet, 96, 48, &new_packets); |
274 break; | 274 break; |
275 } | 275 } |
276 case kDecoderPCM16B_2ch: { | 276 case NetEqDecoder::kDecoderPCM16B_2ch: { |
277 // 2 * 16 bytes per ms; 8 timestamps per ms. | 277 // 2 * 16 bytes per ms; 8 timestamps per ms. |
278 SplitBySamples(packet, 2 * 16, 8, &new_packets); | 278 SplitBySamples(packet, 2 * 16, 8, &new_packets); |
279 break; | 279 break; |
280 } | 280 } |
281 case kDecoderPCM16Bwb_2ch: { | 281 case NetEqDecoder::kDecoderPCM16Bwb_2ch: { |
282 // 2 * 32 bytes per ms; 16 timestamps per ms. | 282 // 2 * 32 bytes per ms; 16 timestamps per ms. |
283 SplitBySamples(packet, 2 * 32, 16, &new_packets); | 283 SplitBySamples(packet, 2 * 32, 16, &new_packets); |
284 break; | 284 break; |
285 } | 285 } |
286 case kDecoderPCM16Bswb32kHz_2ch: { | 286 case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch: { |
287 // 2 * 64 bytes per ms; 32 timestamps per ms. | 287 // 2 * 64 bytes per ms; 32 timestamps per ms. |
288 SplitBySamples(packet, 2 * 64, 32, &new_packets); | 288 SplitBySamples(packet, 2 * 64, 32, &new_packets); |
289 break; | 289 break; |
290 } | 290 } |
291 case kDecoderPCM16Bswb48kHz_2ch: { | 291 case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch: { |
292 // 2 * 96 bytes per ms; 48 timestamps per ms. | 292 // 2 * 96 bytes per ms; 48 timestamps per ms. |
293 SplitBySamples(packet, 2 * 96, 48, &new_packets); | 293 SplitBySamples(packet, 2 * 96, 48, &new_packets); |
294 break; | 294 break; |
295 } | 295 } |
296 case kDecoderPCM16B_5ch: { | 296 case NetEqDecoder::kDecoderPCM16B_5ch: { |
297 // 5 * 16 bytes per ms; 8 timestamps per ms. | 297 // 5 * 16 bytes per ms; 8 timestamps per ms. |
298 SplitBySamples(packet, 5 * 16, 8, &new_packets); | 298 SplitBySamples(packet, 5 * 16, 8, &new_packets); |
299 break; | 299 break; |
300 } | 300 } |
301 case kDecoderILBC: { | 301 case NetEqDecoder::kDecoderILBC: { |
302 size_t bytes_per_frame; | 302 size_t bytes_per_frame; |
303 int timestamps_per_frame; | 303 int timestamps_per_frame; |
304 if (packet->payload_length >= 950) { | 304 if (packet->payload_length >= 950) { |
305 LOG(LS_WARNING) << "SplitAudio too large iLBC payload"; | 305 LOG(LS_WARNING) << "SplitAudio too large iLBC payload"; |
306 return kTooLargePayload; | 306 return kTooLargePayload; |
307 } | 307 } |
308 if (packet->payload_length % 38 == 0) { | 308 if (packet->payload_length % 38 == 0) { |
309 // 20 ms frames. | 309 // 20 ms frames. |
310 bytes_per_frame = 38; | 310 bytes_per_frame = 38; |
311 timestamps_per_frame = 160; | 311 timestamps_per_frame = 160; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 new_packet->payload = new uint8_t[bytes_per_frame]; | 432 new_packet->payload = new uint8_t[bytes_per_frame]; |
433 memcpy(new_packet->payload, payload_ptr, bytes_per_frame); | 433 memcpy(new_packet->payload, payload_ptr, bytes_per_frame); |
434 payload_ptr += bytes_per_frame; | 434 payload_ptr += bytes_per_frame; |
435 new_packets->push_back(new_packet); | 435 new_packets->push_back(new_packet); |
436 len -= bytes_per_frame; | 436 len -= bytes_per_frame; |
437 } | 437 } |
438 return kOK; | 438 return kOK; |
439 } | 439 } |
440 | 440 |
441 } // namespace webrtc | 441 } // namespace webrtc |
OLD | NEW |