1e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org/* 2e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * 4e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * Use of this source code is governed by a BSD-style license 5e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * that can be found in the LICENSE file in the root of the source 6e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * tree. An additional intellectual property rights grant can be found 7e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * in the file PATENTS. All contributing project authors may 8e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org * be found in the AUTHORS file in the root of the source tree. 9e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org */ 10e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 11e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org#include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h" 12e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 13e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org#include <stdio.h> 14e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org#include <string> 15e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 16e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" 17e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" 18e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" 19ac772a43f023d08fc0222473e669924113274bddpbos@webrtc.org#include "webrtc/test/rtp_file_reader.h" 20e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 21e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.orgconst int kMinBitrateBps = 30000; 22e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 23e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.orgbool ParseArgsAndSetupEstimator(int argc, 24e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org char** argv, 25e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::Clock* clock, 26e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::RemoteBitrateObserver* observer, 27ac772a43f023d08fc0222473e669924113274bddpbos@webrtc.org webrtc::test::RtpFileReader** rtp_reader, 28e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::RtpHeaderParser** parser, 29e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::RemoteBitrateEstimator** estimator, 30e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org std::string* estimator_used) { 31ac772a43f023d08fc0222473e669924113274bddpbos@webrtc.org *rtp_reader = webrtc::test::RtpFileReader::Create( 32ac772a43f023d08fc0222473e669924113274bddpbos@webrtc.org webrtc::test::RtpFileReader::kRtpDump, argv[3]); 33e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org if (!*rtp_reader) { 34dc0759049c98729d1902682ec14d53da74b1cdd2stefan@webrtc.org fprintf(stderr, "Cannot open input file %s\n", argv[3]); 35e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org return false; 36e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } 37dc0759049c98729d1902682ec14d53da74b1cdd2stefan@webrtc.org fprintf(stderr, "Input file: %s\n\n", argv[3]); 38e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::RTPExtensionType extension = webrtc::kRtpExtensionAbsoluteSendTime; 39e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 40e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org if (strncmp("tsoffset", argv[1], 8) == 0) { 41e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org extension = webrtc::kRtpExtensionTransmissionTimeOffset; 42dc0759049c98729d1902682ec14d53da74b1cdd2stefan@webrtc.org fprintf(stderr, "Extension: toffset\n"); 43e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } else { 44dc0759049c98729d1902682ec14d53da74b1cdd2stefan@webrtc.org fprintf(stderr, "Extension: abs\n"); 45e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } 46e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org int id = atoi(argv[2]); 47e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org 48e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org // Setup the RTP header parser and the bitrate estimator. 49e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org *parser = webrtc::RtpHeaderParser::Create(); 50e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org (*parser)->RegisterRtpHeaderExtension(extension, id); 51e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org if (estimator) { 52e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org switch (extension) { 53e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org case webrtc::kRtpExtensionAbsoluteSendTime: { 54e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::AbsoluteSendTimeRemoteBitrateEstimatorFactory factory; 55b9d0acb4017586521b5a11d8b73ad8c733958a53stefan@webrtc.org *estimator = factory.Create(observer, clock, webrtc::kAimdControl, 56b9d0acb4017586521b5a11d8b73ad8c733958a53stefan@webrtc.org kMinBitrateBps); 57e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org *estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator"; 58e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org break; 59e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } 60e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org case webrtc::kRtpExtensionTransmissionTimeOffset: { 61e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org webrtc::RemoteBitrateEstimatorFactory factory; 62b9d0acb4017586521b5a11d8b73ad8c733958a53stefan@webrtc.org *estimator = factory.Create(observer, clock, webrtc::kAimdControl, 63b9d0acb4017586521b5a11d8b73ad8c733958a53stefan@webrtc.org kMinBitrateBps); 64e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org *estimator_used = "RemoteBitrateEstimator"; 65e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org break; 66e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } 67e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org default: 68e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org assert(false); 69e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } 70e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org } 71e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org return true; 72e1c99022cc666e440e9fc74dc7cf8414987a47a5stefan@webrtc.org} 73