niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | f589dfe | 2012-03-27 17:05:44 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
henrik.lundin@webrtc.org | bc91d5a | 2011-11-15 10:16:01 +0000 | [diff] [blame] | 11 | #include <assert.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | #include <stdio.h> |
| 13 | #include <vector> |
| 14 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 15 | #include "modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h" |
andrew@webrtc.org | f589dfe | 2012-03-27 17:05:44 +0000 | [diff] [blame] | 16 | #include "modules/audio_coding/neteq/test/NETEQTEST_DummyRTPpacket.h" |
| 17 | |
| 18 | //#define WEBRTC_DUMMY_RTP |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 20 | enum { |
| 21 | kRedPayloadType = 127 |
| 22 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 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]); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 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]); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 39 | // Print file header. |
henrik.lundin@webrtc.org | 25fadd7 | 2012-10-05 08:34:37 +0000 | [diff] [blame] | 40 | fprintf(out_file, "SeqNo TimeStamp SendTime Size PT M SSRC\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 42 | // Read file header. |
| 43 | NETEQTEST_RTPpacket::skipFileHeader(in_file); |
andrew@webrtc.org | f589dfe | 2012-03-27 17:05:44 +0000 | [diff] [blame] | 44 | #ifdef WEBRTC_DUMMY_RTP |
| 45 | NETEQTEST_DummyRTPpacket packet; |
| 46 | #else |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 47 | NETEQTEST_RTPpacket packet; |
andrew@webrtc.org | f589dfe | 2012-03-27 17:05:44 +0000 | [diff] [blame] | 48 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 50 | while (packet.readFromFile(in_file) >= 0) { |
| 51 | // Write packet data to file. |
henrik.lundin@webrtc.org | 25fadd7 | 2012-10-05 08:34:37 +0000 | [diff] [blame] | 52 | fprintf(out_file, "%5u %10u %10u %5i %5i %2i %#08X\n", |
henrik.lundin@webrtc.org | 29fd9a5 | 2011-09-15 08:25:45 +0000 | [diff] [blame] | 53 | packet.sequenceNumber(), packet.timeStamp(), packet.time(), |
henrik.lundin@webrtc.org | 25fadd7 | 2012-10-05 08:34:37 +0000 | [diff] [blame] | 54 | packet.dataLen(), packet.payloadType(), packet.markerBit(), |
| 55 | packet.SSRC()); |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 56 | if (packet.payloadType() == kRedPayloadType) { |
| 57 | WebRtcNetEQ_RTPInfo red_header; |
| 58 | int len; |
| 59 | int red_index = 0; |
| 60 | while ((len = packet.extractRED(red_index++, red_header)) >= 0) { |
| 61 | fprintf(out_file, "* %5u %10u %10u %5i %5i\n", |
| 62 | red_header.sequenceNumber, red_header.timeStamp, |
| 63 | packet.time(), len, red_header.payloadType); |
| 64 | } |
| 65 | assert(red_index > 1); // We must get at least one payload. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | } |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 67 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 69 | fclose(in_file); |
| 70 | fclose(out_file); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
henrik.lundin@webrtc.org | 6c87736 | 2012-01-03 10:03:19 +0000 | [diff] [blame] | 72 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | } |