henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 <stdio.h> |
| 12 | |
kwiberg | 2d0c332 | 2016-02-14 09:28:33 -0800 | [diff] [blame] | 13 | #include <memory> |
| 14 | |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame^] | 15 | #include "webrtc/rtc_base/checks.h" |
henrik.lundin@webrtc.org | 8331714 | 2014-12-01 11:25:04 +0000 | [diff] [blame] | 16 | #include "webrtc/test/rtp_file_reader.h" |
| 17 | #include "webrtc/test/rtp_file_writer.h" |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 18 | |
henrik.lundin@webrtc.org | 8331714 | 2014-12-01 11:25:04 +0000 | [diff] [blame] | 19 | using webrtc::test::RtpFileReader; |
| 20 | using webrtc::test::RtpFileWriter; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 21 | |
| 22 | int main(int argc, char* argv[]) { |
| 23 | if (argc < 3) { |
henrik.lundin@webrtc.org | 20446e7 | 2014-12-01 14:23:01 +0000 | [diff] [blame] | 24 | printf("Concatenates multiple rtpdump files into one.\n"); |
| 25 | printf("Usage: rtpcat in1.rtp int2.rtp [...] out.rtp\n"); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 26 | exit(1); |
| 27 | } |
| 28 | |
kwiberg | 2d0c332 | 2016-02-14 09:28:33 -0800 | [diff] [blame] | 29 | std::unique_ptr<RtpFileWriter> output( |
henrik.lundin@webrtc.org | 8331714 | 2014-12-01 11:25:04 +0000 | [diff] [blame] | 30 | RtpFileWriter::Create(RtpFileWriter::kRtpDump, argv[argc - 1])); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 31 | RTC_CHECK(output.get() != NULL) << "Cannot open output file."; |
henrik.lundin@webrtc.org | 8331714 | 2014-12-01 11:25:04 +0000 | [diff] [blame] | 32 | printf("Output RTP file: %s\n", argv[argc - 1]); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 33 | |
| 34 | for (int i = 1; i < argc - 1; i++) { |
kwiberg | 2d0c332 | 2016-02-14 09:28:33 -0800 | [diff] [blame] | 35 | std::unique_ptr<RtpFileReader> input( |
henrik.lundin@webrtc.org | 8331714 | 2014-12-01 11:25:04 +0000 | [diff] [blame] | 36 | RtpFileReader::Create(RtpFileReader::kRtpDump, argv[i])); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 37 | RTC_CHECK(input.get() != NULL) << "Cannot open input file " << argv[i]; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 38 | printf("Input RTP file: %s\n", argv[i]); |
| 39 | |
henrik.lundin@webrtc.org | 8331714 | 2014-12-01 11:25:04 +0000 | [diff] [blame] | 40 | webrtc::test::RtpPacket packet; |
| 41 | while (input->NextPacket(&packet)) |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 42 | RTC_CHECK(output->WritePacket(&packet)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 43 | } |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 44 | return 0; |
| 45 | } |