Reformatting RTPtimeshift.cc file.
BUG=2692 R=henrik.lundin@webrtc.org, kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45239004 Cr-Commit-Position: refs/heads/master@{#9052}
This commit is contained in:
parent
ac69016b0f
commit
5a3178042b
@ -8,92 +8,79 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "NETEQTEST_RTPpacket.h"
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
#include "webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h"
|
||||||
/*********************/
|
|
||||||
/* Misc. definitions */
|
|
||||||
/*********************/
|
|
||||||
|
|
||||||
#define FIRSTLINELEN 40
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
FILE* inFile = fopen(argv[1], "rb");
|
||||||
{
|
if (!inFile) {
|
||||||
if(argc < 4 || argc > 6)
|
printf("Cannot open input file %s\n", argv[1]);
|
||||||
{
|
return (-1);
|
||||||
printf("Usage: RTPtimeshift in.rtp out.rtp newStartTS [newStartSN [newStartArrTime]]\n");
|
}
|
||||||
exit(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.
|
||||||
|
uint32_t TSdiff = atoi(argv[3]) - packet.timeStamp();
|
||||||
|
uint16_t SNdiff = 0;
|
||||||
|
uint32_t ATdiff = 0;
|
||||||
|
if (argc > 4) {
|
||||||
|
int startSN = atoi(argv[4]);
|
||||||
|
if (startSN >= 0)
|
||||||
|
SNdiff = startSN - packet.sequenceNumber();
|
||||||
|
if (argc > 5) {
|
||||||
|
int startTS = atoi(argv[5]);
|
||||||
|
if (startTS >= 0)
|
||||||
|
ATdiff = startTS - packet.time();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FILE *inFile=fopen(argv[1],"rb");
|
while (packLen >= 0) {
|
||||||
if (!inFile)
|
packet.setTimeStamp(packet.timeStamp() + TSdiff);
|
||||||
{
|
packet.setSequenceNumber(packet.sequenceNumber() + SNdiff);
|
||||||
printf("Cannot open input file %s\n", argv[1]);
|
packet.setTime(packet.time() + ATdiff);
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
printf("Input RTP file: %s\n",argv[1]);
|
|
||||||
|
|
||||||
FILE *outFile=fopen(argv[2],"wb");
|
packet.writeToFile(outFile);
|
||||||
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
|
packLen = packet.readFromFile(inFile);
|
||||||
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
|
fclose(inFile);
|
||||||
uint32_t TSdiff = atoi(argv[3]) - packet.timeStamp();
|
fclose(outFile);
|
||||||
uint16_t SNdiff = 0;
|
|
||||||
uint32_t ATdiff = 0;
|
|
||||||
if (argc > 4)
|
|
||||||
{
|
|
||||||
int startSN = atoi(argv[4]);
|
|
||||||
if (startSN >= 0)
|
|
||||||
SNdiff = startSN - packet.sequenceNumber();
|
|
||||||
if (argc > 5)
|
|
||||||
{
|
|
||||||
int startTS = atoi(argv[5]);
|
|
||||||
if (startTS >= 0)
|
|
||||||
ATdiff = startTS - packet.time();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (packLen >= 0)
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user