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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 public: | 90 public: |
91 // Takes ownership of |transport|. | 91 // Takes ownership of |transport|. |
92 void Init(CastTransport* transport, | 92 void Init(CastTransport* transport, |
93 uint64_t* encoded_video_bytes, | 93 uint64_t* encoded_video_bytes, |
94 uint64_t* encoded_audio_bytes) { | 94 uint64_t* encoded_audio_bytes) { |
95 transport_.reset(transport); | 95 transport_.reset(transport); |
96 encoded_video_bytes_ = encoded_video_bytes; | 96 encoded_video_bytes_ = encoded_video_bytes; |
97 encoded_audio_bytes_ = encoded_audio_bytes; | 97 encoded_audio_bytes_ = encoded_audio_bytes; |
98 } | 98 } |
99 | 99 |
100 void InitializeAudio(const CastTransportRtpConfig& config, | 100 void InitializeStream(const CastTransportRtpConfig& config, |
101 std::unique_ptr<RtcpObserver> rtcp_observer) final { | 101 std::unique_ptr<RtcpObserver> rtcp_observer) final { |
102 audio_ssrc_ = config.ssrc; | 102 audio_ssrc_ = config.ssrc; |
miu
2016/07/06 21:45:42
Need to set video_ssrc_ instead, if this is video.
xjz
2016/07/13 20:31:17
Done.
| |
103 transport_->InitializeAudio(config, std::move(rtcp_observer)); | 103 transport_->InitializeStream(config, std::move(rtcp_observer)); |
104 } | |
105 | |
106 void InitializeVideo(const CastTransportRtpConfig& config, | |
107 std::unique_ptr<RtcpObserver> rtcp_observer) final { | |
108 video_ssrc_ = config.ssrc; | |
109 transport_->InitializeVideo(config, std::move(rtcp_observer)); | |
110 } | 104 } |
111 | 105 |
112 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final { | 106 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final { |
113 if (ssrc == audio_ssrc_) { | 107 if (ssrc == audio_ssrc_) { |
114 *encoded_audio_bytes_ += frame.data.size(); | 108 *encoded_audio_bytes_ += frame.data.size(); |
115 } else if (ssrc == video_ssrc_) { | 109 } else if (ssrc == video_ssrc_) { |
116 *encoded_video_bytes_ += frame.data.size(); | 110 *encoded_video_bytes_ += frame.data.size(); |
117 } | 111 } |
118 transport_->InsertFrame(ssrc, frame); | 112 transport_->InsertFrame(ssrc, frame); |
119 } | 113 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 }; | 442 }; |
449 | 443 |
450 namespace { | 444 namespace { |
451 | 445 |
452 class TransportClient : public CastTransport::Client { | 446 class TransportClient : public CastTransport::Client { |
453 public: | 447 public: |
454 explicit TransportClient(RunOneBenchmark* run_one_benchmark) | 448 explicit TransportClient(RunOneBenchmark* run_one_benchmark) |
455 : run_one_benchmark_(run_one_benchmark) {} | 449 : run_one_benchmark_(run_one_benchmark) {} |
456 | 450 |
457 void OnStatusChanged(CastTransportStatus status) final { | 451 void OnStatusChanged(CastTransportStatus status) final { |
458 bool result = (status == TRANSPORT_AUDIO_INITIALIZED || | 452 EXPECT_EQ(TRANSPORT_STREAM_INITIALIZED, status); |
459 status == TRANSPORT_VIDEO_INITIALIZED); | |
460 EXPECT_TRUE(result); | |
461 }; | 453 }; |
462 void OnLoggingEventsReceived( | 454 void OnLoggingEventsReceived( |
463 std::unique_ptr<std::vector<FrameEvent>> frame_events, | 455 std::unique_ptr<std::vector<FrameEvent>> frame_events, |
464 std::unique_ptr<std::vector<PacketEvent>> packet_events) final{}; | 456 std::unique_ptr<std::vector<PacketEvent>> packet_events) final{}; |
465 void ProcessRtpPacket(std::unique_ptr<Packet> packet) final { | 457 void ProcessRtpPacket(std::unique_ptr<Packet> packet) final { |
466 if (run_one_benchmark_) | 458 if (run_one_benchmark_) |
467 run_one_benchmark_->ReceivePacket(std::move(packet)); | 459 run_one_benchmark_->ReceivePacket(std::move(packet)); |
468 }; | 460 }; |
469 | 461 |
470 private: | 462 private: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 media::cast::CastBenchmark benchmark; | 719 media::cast::CastBenchmark benchmark; |
728 if (getenv("PROFILE_FILE")) { | 720 if (getenv("PROFILE_FILE")) { |
729 std::string profile_file(getenv("PROFILE_FILE")); | 721 std::string profile_file(getenv("PROFILE_FILE")); |
730 base::debug::StartProfiling(profile_file); | 722 base::debug::StartProfiling(profile_file); |
731 benchmark.Run(); | 723 benchmark.Run(); |
732 base::debug::StopProfiling(); | 724 base::debug::StopProfiling(); |
733 } else { | 725 } else { |
734 benchmark.Run(); | 726 benchmark.Run(); |
735 } | 727 } |
736 } | 728 } |
OLD | NEW |