blob: 6a4c6b119010ac73acefcfea251caa62f378d027 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
andrew@webrtc.orgf589dfe2012-03-27 17:05:44 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.orgbc91d5a2011-11-15 10:16:01 +000011#include <assert.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000012#include <stdio.h>
13#include <vector>
14
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000015#include "modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h"
andrew@webrtc.orgf589dfe2012-03-27 17:05:44 +000016#include "modules/audio_coding/neteq/test/NETEQTEST_DummyRTPpacket.h"
17
18//#define WEBRTC_DUMMY_RTP
niklase@google.com470e71d2011-07-07 08:21:25 +000019
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000020enum {
21 kRedPayloadType = 127
22};
niklase@google.com470e71d2011-07-07 08:21:25 +000023
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000024int 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.com470e71d2011-07-07 08:21:25 +000031
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000032 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.com470e71d2011-07-07 08:21:25 +000038
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000039 // Print file header.
henrik.lundin@webrtc.org25fadd72012-10-05 08:34:37 +000040 fprintf(out_file, "SeqNo TimeStamp SendTime Size PT M SSRC\n");
niklase@google.com470e71d2011-07-07 08:21:25 +000041
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000042 // Read file header.
43 NETEQTEST_RTPpacket::skipFileHeader(in_file);
andrew@webrtc.orgf589dfe2012-03-27 17:05:44 +000044#ifdef WEBRTC_DUMMY_RTP
45 NETEQTEST_DummyRTPpacket packet;
46#else
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000047 NETEQTEST_RTPpacket packet;
andrew@webrtc.orgf589dfe2012-03-27 17:05:44 +000048#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000049
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000050 while (packet.readFromFile(in_file) >= 0) {
51 // Write packet data to file.
henrik.lundin@webrtc.org25fadd72012-10-05 08:34:37 +000052 fprintf(out_file, "%5u %10u %10u %5i %5i %2i %#08X\n",
henrik.lundin@webrtc.org29fd9a52011-09-15 08:25:45 +000053 packet.sequenceNumber(), packet.timeStamp(), packet.time(),
henrik.lundin@webrtc.org25fadd72012-10-05 08:34:37 +000054 packet.dataLen(), packet.payloadType(), packet.markerBit(),
55 packet.SSRC());
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000056 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.com470e71d2011-07-07 08:21:25 +000066 }
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000067 }
niklase@google.com470e71d2011-07-07 08:21:25 +000068
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000069 fclose(in_file);
70 fclose(out_file);
niklase@google.com470e71d2011-07-07 08:21:25 +000071
henrik.lundin@webrtc.org6c877362012-01-03 10:03:19 +000072 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000073}