| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 uint64* encoded_audio_bytes) { | 105 uint64* encoded_audio_bytes) { |
| 106 transport_.reset(transport); | 106 transport_.reset(transport); |
| 107 encoded_video_bytes_ = encoded_video_bytes; | 107 encoded_video_bytes_ = encoded_video_bytes; |
| 108 encoded_audio_bytes_ = encoded_audio_bytes; | 108 encoded_audio_bytes_ = encoded_audio_bytes; |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual void InitializeAudio( | 111 virtual void InitializeAudio( |
| 112 const CastTransportRtpConfig& config, | 112 const CastTransportRtpConfig& config, |
| 113 const RtcpCastMessageCallback& cast_message_cb, | 113 const RtcpCastMessageCallback& cast_message_cb, |
| 114 const RtcpRttCallback& rtt_cb) OVERRIDE { | 114 const RtcpRttCallback& rtt_cb) OVERRIDE { |
| 115 audio_ssrc_ = config.ssrc; |
| 115 transport_->InitializeAudio(config, cast_message_cb, rtt_cb); | 116 transport_->InitializeAudio(config, cast_message_cb, rtt_cb); |
| 116 } | 117 } |
| 117 | 118 |
| 118 virtual void InitializeVideo( | 119 virtual void InitializeVideo( |
| 119 const CastTransportRtpConfig& config, | 120 const CastTransportRtpConfig& config, |
| 120 const RtcpCastMessageCallback& cast_message_cb, | 121 const RtcpCastMessageCallback& cast_message_cb, |
| 121 const RtcpRttCallback& rtt_cb) OVERRIDE { | 122 const RtcpRttCallback& rtt_cb) OVERRIDE { |
| 123 video_ssrc_ = config.ssrc; |
| 122 transport_->InitializeVideo(config, cast_message_cb, rtt_cb); | 124 transport_->InitializeVideo(config, cast_message_cb, rtt_cb); |
| 123 } | 125 } |
| 124 | 126 |
| 125 virtual void InsertCodedAudioFrame( | 127 virtual void InsertFrame(uint32 ssrc, |
| 126 const EncodedFrame& audio_frame) OVERRIDE { | 128 const EncodedFrame& frame) OVERRIDE { |
| 127 *encoded_audio_bytes_ += audio_frame.data.size(); | 129 if (ssrc == audio_ssrc_) { |
| 128 transport_->InsertCodedAudioFrame(audio_frame); | 130 *encoded_audio_bytes_ += frame.data.size(); |
| 129 } | 131 } else if (ssrc == video_ssrc_) { |
| 130 | 132 *encoded_video_bytes_ += frame.data.size(); |
| 131 virtual void InsertCodedVideoFrame( | 133 } |
| 132 const EncodedFrame& video_frame) OVERRIDE { | 134 transport_->InsertFrame(ssrc, frame); |
| 133 *encoded_video_bytes_ += video_frame.data.size(); | |
| 134 transport_->InsertCodedVideoFrame(video_frame); | |
| 135 } | 135 } |
| 136 | 136 |
| 137 virtual void SendSenderReport( | 137 virtual void SendSenderReport( |
| 138 uint32 ssrc, | 138 uint32 ssrc, |
| 139 base::TimeTicks current_time, | 139 base::TimeTicks current_time, |
| 140 uint32 current_time_as_rtp_timestamp) OVERRIDE { | 140 uint32 current_time_as_rtp_timestamp) OVERRIDE { |
| 141 transport_->SendSenderReport(ssrc, | 141 transport_->SendSenderReport(ssrc, |
| 142 current_time, | 142 current_time, |
| 143 current_time_as_rtp_timestamp); | 143 current_time_as_rtp_timestamp); |
| 144 } | 144 } |
| 145 | 145 |
| 146 virtual void CancelSendingFrames( | 146 virtual void CancelSendingFrames( |
| 147 uint32 ssrc, | 147 uint32 ssrc, |
| 148 const std::vector<uint32>& frame_ids) OVERRIDE { | 148 const std::vector<uint32>& frame_ids) OVERRIDE { |
| 149 transport_->CancelSendingFrames(ssrc, frame_ids); | 149 transport_->CancelSendingFrames(ssrc, frame_ids); |
| 150 } | 150 } |
| 151 | 151 |
| 152 virtual void ResendFrameForKickstart(uint32 ssrc, | 152 virtual void ResendFrameForKickstart(uint32 ssrc, |
| 153 uint32 frame_id) OVERRIDE { | 153 uint32 frame_id) OVERRIDE { |
| 154 transport_->ResendFrameForKickstart(ssrc, frame_id); | 154 transport_->ResendFrameForKickstart(ssrc, frame_id); |
| 155 } | 155 } |
| 156 | 156 |
| 157 virtual PacketReceiverCallback PacketReceiverForTesting() OVERRIDE { | 157 virtual PacketReceiverCallback PacketReceiverForTesting() OVERRIDE { |
| 158 return transport_->PacketReceiverForTesting(); | 158 return transport_->PacketReceiverForTesting(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 scoped_ptr<CastTransportSender> transport_; | 162 scoped_ptr<CastTransportSender> transport_; |
| 163 uint32 audio_ssrc_, video_ssrc_; |
| 163 uint64* encoded_video_bytes_; | 164 uint64* encoded_video_bytes_; |
| 164 uint64* encoded_audio_bytes_; | 165 uint64* encoded_audio_bytes_; |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 struct MeasuringPoint { | 168 struct MeasuringPoint { |
| 168 MeasuringPoint(double bitrate_, double latency_, double percent_packet_drop_) | 169 MeasuringPoint(double bitrate_, double latency_, double percent_packet_drop_) |
| 169 : bitrate(bitrate_), | 170 : bitrate(bitrate_), |
| 170 latency(latency_), | 171 latency(latency_), |
| 171 percent_packet_drop(percent_packet_drop_) {} | 172 percent_packet_drop(percent_packet_drop_) {} |
| 172 bool operator<=(const MeasuringPoint& other) const { | 173 bool operator<=(const MeasuringPoint& other) const { |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 media::cast::CastBenchmark benchmark; | 708 media::cast::CastBenchmark benchmark; |
| 708 if (getenv("PROFILE_FILE")) { | 709 if (getenv("PROFILE_FILE")) { |
| 709 std::string profile_file(getenv("PROFILE_FILE")); | 710 std::string profile_file(getenv("PROFILE_FILE")); |
| 710 base::debug::StartProfiling(profile_file); | 711 base::debug::StartProfiling(profile_file); |
| 711 benchmark.Run(); | 712 benchmark.Run(); |
| 712 base::debug::StopProfiling(); | 713 base::debug::StopProfiling(); |
| 713 } else { | 714 } else { |
| 714 benchmark.Run(); | 715 benchmark.Run(); |
| 715 } | 716 } |
| 716 } | 717 } |
| OLD | NEW |