henrik.lundin@webrtc.org d94659dc27 Initial upload of NetEq4
This is the first public upload of the new NetEq, version 4.

It has been through extensive internal review during the course of
the project.

TEST=trybots

Review URL: https://webrtc-codereview.appspot.com/1073005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3425 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-01-29 12:09:21 +00:00

98 lines
2.5 KiB
C++

/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <algorithm>
#include <stdio.h>
#include <vector>
#include "NETEQTEST_RTPpacket.h"
#include "gtest/gtest.h"
/*********************/
/* Misc. definitions */
/*********************/
#define FIRSTLINELEN 40
int main(int argc, char* argv[])
{
if(argc < 4 || argc > 6)
{
printf("Usage: RTPtimeshift in.rtp out.rtp newStartTS [newStartSN [newStartArrTime]]\n");
exit(1);
}
FILE *inFile=fopen(argv[1],"rb");
if (!inFile)
{
printf("Cannot open input file %s\n", argv[1]);
return(-1);
}
printf("Input RTP file: %s\n",argv[1]);
FILE *outFile=fopen(argv[2],"wb");
if (!outFile)
{
printf("Cannot open output file %s\n", argv[2]);
return(-1);
}
printf("Output RTP file: %s\n\n",argv[2]);
// read file header and write directly to output file
const unsigned int kRtpDumpHeaderSize = 4 + 4 + 4 + 2 + 2;
char firstline[FIRSTLINELEN];
EXPECT_TRUE(fgets(firstline, FIRSTLINELEN, inFile) != NULL);
EXPECT_GT(fputs(firstline, outFile), 0);
EXPECT_EQ(kRtpDumpHeaderSize,
fread(firstline, 1, kRtpDumpHeaderSize, inFile));
EXPECT_EQ(kRtpDumpHeaderSize,
fwrite(firstline, 1, kRtpDumpHeaderSize, outFile));
NETEQTEST_RTPpacket packet;
int packLen = packet.readFromFile(inFile);
if (packLen < 0)
{
exit(1);
}
// get new start TS and start SeqNo from arguments
WebRtc_UWord32 TSdiff = atoi(argv[3]) - packet.timeStamp();
WebRtc_UWord16 SNdiff = 0;
WebRtc_UWord32 ATdiff = 0;
if (argc > 4)
{
if (argv[4] >= 0)
SNdiff = atoi(argv[4]) - packet.sequenceNumber();
if (argc > 5)
{
if (argv[5] >= 0)
ATdiff = atoi(argv[5]) - packet.time();
}
}
while (packLen >= 0)
{
packet.setTimeStamp(packet.timeStamp() + TSdiff);
packet.setSequenceNumber(packet.sequenceNumber() + SNdiff);
packet.setTime(packet.time() + ATdiff);
packet.writeToFile(outFile);
packLen = packet.readFromFile(inFile);
}
fclose(inFile);
fclose(outFile);
return 0;
}