| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This program benchmarks the theoretical throughput of the cast library. | 5 // This program benchmarks the theoretical throughput of the cast library. |
| 6 // It runs using a fake clock, simulated network and fake codecs. This allows | 6 // It runs using a fake clock, simulated network and fake codecs. This allows |
| 7 // tests to run much faster than real time. | 7 // tests to run much faster than real time. |
| 8 // To run the program, run: | 8 // To run the program, run: |
| 9 // $ ./out/Release/cast_benchmarks | tee benchmarkoutput.asc | 9 // $ ./out/Release/cast_benchmarks | tee benchmarkoutput.asc |
| 10 // This may take a while, when it is done, you can view the data with | 10 // This may take a while, when it is done, you can view the data with |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void Init(CastTransportSender* transport, | 89 void Init(CastTransportSender* transport, |
| 90 uint64_t* encoded_video_bytes, | 90 uint64_t* encoded_video_bytes, |
| 91 uint64_t* encoded_audio_bytes) { | 91 uint64_t* encoded_audio_bytes) { |
| 92 transport_.reset(transport); | 92 transport_.reset(transport); |
| 93 encoded_video_bytes_ = encoded_video_bytes; | 93 encoded_video_bytes_ = encoded_video_bytes; |
| 94 encoded_audio_bytes_ = encoded_audio_bytes; | 94 encoded_audio_bytes_ = encoded_audio_bytes; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void InitializeAudio(const CastTransportRtpConfig& config, | 97 void InitializeAudio(const CastTransportRtpConfig& config, |
| 98 const RtcpCastMessageCallback& cast_message_cb, | 98 const RtcpCastMessageCallback& cast_message_cb, |
| 99 const RtcpRttCallback& rtt_cb) final { | 99 const RtcpRttCallback& rtt_cb, |
| 100 const RtcpPliCallback& key_frame_cb) final { |
| 100 audio_ssrc_ = config.ssrc; | 101 audio_ssrc_ = config.ssrc; |
| 101 transport_->InitializeAudio(config, cast_message_cb, rtt_cb); | 102 transport_->InitializeAudio(config, cast_message_cb, rtt_cb, key_frame_cb); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void InitializeVideo(const CastTransportRtpConfig& config, | 105 void InitializeVideo(const CastTransportRtpConfig& config, |
| 105 const RtcpCastMessageCallback& cast_message_cb, | 106 const RtcpCastMessageCallback& cast_message_cb, |
| 106 const RtcpRttCallback& rtt_cb) final { | 107 const RtcpRttCallback& rtt_cb, |
| 108 const RtcpPliCallback& key_frame_cb) final { |
| 107 video_ssrc_ = config.ssrc; | 109 video_ssrc_ = config.ssrc; |
| 108 transport_->InitializeVideo(config, cast_message_cb, rtt_cb); | 110 transport_->InitializeVideo(config, cast_message_cb, rtt_cb, key_frame_cb); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final { | 113 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final { |
| 112 if (ssrc == audio_ssrc_) { | 114 if (ssrc == audio_ssrc_) { |
| 113 *encoded_audio_bytes_ += frame.data.size(); | 115 *encoded_audio_bytes_ += frame.data.size(); |
| 114 } else if (ssrc == video_ssrc_) { | 116 } else if (ssrc == video_ssrc_) { |
| 115 *encoded_video_bytes_ += frame.data.size(); | 117 *encoded_video_bytes_ += frame.data.size(); |
| 116 } | 118 } |
| 117 transport_->InsertFrame(ssrc, frame); | 119 transport_->InsertFrame(ssrc, frame); |
| 118 } | 120 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 140 | 142 |
| 141 void AddValidSsrc(uint32_t ssrc) final { | 143 void AddValidSsrc(uint32_t ssrc) final { |
| 142 return transport_->AddValidSsrc(ssrc); | 144 return transport_->AddValidSsrc(ssrc); |
| 143 } | 145 } |
| 144 | 146 |
| 145 void SendRtcpFromRtpReceiver( | 147 void SendRtcpFromRtpReceiver( |
| 146 uint32_t ssrc, | 148 uint32_t ssrc, |
| 147 uint32_t sender_ssrc, | 149 uint32_t sender_ssrc, |
| 148 const RtcpTimeData& time_data, | 150 const RtcpTimeData& time_data, |
| 149 const RtcpCastMessage* cast_message, | 151 const RtcpCastMessage* cast_message, |
| 152 const RtcpPliMessage* pli_message, |
| 150 base::TimeDelta target_delay, | 153 base::TimeDelta target_delay, |
| 151 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, | 154 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
| 152 const RtpReceiverStatistics* rtp_receiver_statistics) final { | 155 const RtpReceiverStatistics* rtp_receiver_statistics) final { |
| 153 return transport_->SendRtcpFromRtpReceiver(ssrc, | 156 return transport_->SendRtcpFromRtpReceiver( |
| 154 sender_ssrc, | 157 ssrc, sender_ssrc, time_data, cast_message, pli_message, target_delay, |
| 155 time_data, | 158 rtcp_events, rtp_receiver_statistics); |
| 156 cast_message, | |
| 157 target_delay, | |
| 158 rtcp_events, | |
| 159 rtp_receiver_statistics); | |
| 160 } | 159 } |
| 161 | 160 |
| 162 void SetOptions(const base::DictionaryValue& options) final {} | 161 void SetOptions(const base::DictionaryValue& options) final {} |
| 163 | 162 |
| 164 private: | 163 private: |
| 165 scoped_ptr<CastTransportSender> transport_; | 164 scoped_ptr<CastTransportSender> transport_; |
| 166 uint32_t audio_ssrc_, video_ssrc_; | 165 uint32_t audio_ssrc_, video_ssrc_; |
| 167 uint64_t* encoded_video_bytes_; | 166 uint64_t* encoded_video_bytes_; |
| 168 uint64_t* encoded_audio_bytes_; | 167 uint64_t* encoded_audio_bytes_; |
| 169 }; | 168 }; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 media::cast::CastBenchmark benchmark; | 717 media::cast::CastBenchmark benchmark; |
| 719 if (getenv("PROFILE_FILE")) { | 718 if (getenv("PROFILE_FILE")) { |
| 720 std::string profile_file(getenv("PROFILE_FILE")); | 719 std::string profile_file(getenv("PROFILE_FILE")); |
| 721 base::debug::StartProfiling(profile_file); | 720 base::debug::StartProfiling(profile_file); |
| 722 benchmark.Run(); | 721 benchmark.Run(); |
| 723 base::debug::StopProfiling(); | 722 base::debug::StopProfiling(); |
| 724 } else { | 723 } else { |
| 725 benchmark.Run(); | 724 benchmark.Run(); |
| 726 } | 725 } |
| 727 } | 726 } |
| OLD | NEW |