• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2014 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 "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h"
12 
13 #include <stdio.h>
14 #include <string>
15 
16 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
17 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
18 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
19 #include "webrtc/modules/video_coding/main/test/rtp_file_reader.h"
20 #include "webrtc/modules/video_coding/main/test/rtp_player.h"
21 
22 using webrtc::rtpplayer::RtpPacketSourceInterface;
23 
24 const int kMinBitrateBps = 30000;
25 
ParseArgsAndSetupEstimator(int argc,char ** argv,webrtc::Clock * clock,webrtc::RemoteBitrateObserver * observer,RtpPacketSourceInterface ** rtp_reader,webrtc::RtpHeaderParser ** parser,webrtc::RemoteBitrateEstimator ** estimator,std::string * estimator_used)26 bool ParseArgsAndSetupEstimator(int argc,
27                                 char** argv,
28                                 webrtc::Clock* clock,
29                                 webrtc::RemoteBitrateObserver* observer,
30                                 RtpPacketSourceInterface** rtp_reader,
31                                 webrtc::RtpHeaderParser** parser,
32                                 webrtc::RemoteBitrateEstimator** estimator,
33                                 std::string* estimator_used) {
34   *rtp_reader = webrtc::rtpplayer::CreateRtpFileReader(argv[3]);
35   if (!*rtp_reader) {
36     fprintf(stderr, "Cannot open input file %s\n", argv[3]);
37     return false;
38   }
39   fprintf(stderr, "Input file: %s\n\n", argv[3]);
40   webrtc::RTPExtensionType extension = webrtc::kRtpExtensionAbsoluteSendTime;
41 
42   if (strncmp("tsoffset", argv[1], 8) == 0) {
43     extension = webrtc::kRtpExtensionTransmissionTimeOffset;
44     fprintf(stderr, "Extension: toffset\n");
45   } else {
46     fprintf(stderr, "Extension: abs\n");
47   }
48   int id = atoi(argv[2]);
49 
50   // Setup the RTP header parser and the bitrate estimator.
51   *parser = webrtc::RtpHeaderParser::Create();
52   (*parser)->RegisterRtpHeaderExtension(extension, id);
53   if (estimator) {
54     switch (extension) {
55       case webrtc::kRtpExtensionAbsoluteSendTime: {
56           webrtc::AbsoluteSendTimeRemoteBitrateEstimatorFactory factory;
57           *estimator = factory.Create(observer, clock, webrtc::kAimdControl,
58                                       kMinBitrateBps);
59           *estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator";
60           break;
61         }
62       case webrtc::kRtpExtensionTransmissionTimeOffset: {
63           webrtc::RemoteBitrateEstimatorFactory factory;
64           *estimator = factory.Create(observer, clock, webrtc::kAimdControl,
65                                       kMinBitrateBps);
66           *estimator_used = "RemoteBitrateEstimator";
67           break;
68         }
69       default:
70         assert(false);
71     }
72   }
73   return true;
74 }
75