henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include <assert.h> |
| 12 | #include <stdio.h> |
| 13 | #include <vector> |
| 14 | |
| 15 | #include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_DummyRTPpacket.h" |
| 16 | #include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_RTPpacket.h" |
| 17 | |
| 18 | //#define WEBRTC_DUMMY_RTP |
| 19 | |
| 20 | enum { |
| 21 | kRedPayloadType = 127 |
| 22 | }; |
| 23 | |
| 24 | int main(int argc, char* argv[]) { |
| 25 | FILE* in_file = fopen(argv[1], "rb"); |
| 26 | if (!in_file) { |
| 27 | printf("Cannot open input file %s\n", argv[1]); |
| 28 | return -1; |
| 29 | } |
| 30 | printf("Input file: %s\n", argv[1]); |
| 31 | |
| 32 | FILE* out_file = fopen(argv[2], "wt"); |
| 33 | if (!out_file) { |
| 34 | printf("Cannot open output file %s\n", argv[2]); |
| 35 | return -1; |
| 36 | } |
| 37 | printf("Output file: %s\n\n", argv[2]); |
| 38 | |
| 39 | // Print file header. |
| 40 | fprintf(out_file, "SeqNo TimeStamp SendTime Size PT M\n"); |
| 41 | |
| 42 | // Read file header. |
| 43 | NETEQTEST_RTPpacket::skipFileHeader(in_file); |
| 44 | #ifdef WEBRTC_DUMMY_RTP |
| 45 | NETEQTEST_DummyRTPpacket packet; |
| 46 | #else |
| 47 | NETEQTEST_RTPpacket packet; |
| 48 | #endif |
| 49 | |
| 50 | while (packet.readFromFile(in_file) >= 0) { |
| 51 | // Write packet data to file. |
| 52 | fprintf(out_file, "%5u %10u %10u %5i %5i %2i\n", |
| 53 | packet.sequenceNumber(), packet.timeStamp(), packet.time(), |
| 54 | packet.dataLen(), packet.payloadType(), packet.markerBit()); |
| 55 | if (packet.payloadType() == kRedPayloadType) { |
| 56 | webrtc::WebRtcRTPHeader red_header; |
| 57 | int len; |
| 58 | int red_index = 0; |
| 59 | while ((len = packet.extractRED(red_index++, red_header)) >= 0) { |
| 60 | fprintf(out_file, "* %5u %10u %10u %5i %5i\n", |
| 61 | red_header.header.sequenceNumber, red_header.header.timestamp, |
| 62 | packet.time(), len, red_header.header.payloadType); |
| 63 | } |
| 64 | assert(red_index > 1); // We must get at least one payload. |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | fclose(in_file); |
| 69 | fclose(out_file); |
| 70 | |
| 71 | return 0; |
| 72 | } |