| 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 // Simulate end to end streaming. | 5 // Simulate end to end streaming. |
| 6 // | 6 // |
| 7 // Input: | 7 // Input: |
| 8 // --source= | 8 // --source= |
| 9 // WebM used as the source of video and audio frames. | 9 // WebM used as the source of video and audio frames. |
| 10 // --output= | 10 // --output= |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 void AudioInitializationStatus(CastInitializationStatus status) { | 79 void AudioInitializationStatus(CastInitializationStatus status) { |
| 80 LOG(INFO) << "Audio status: " << status; | 80 LOG(INFO) << "Audio status: " << status; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void VideoInitializationStatus(CastInitializationStatus status) { | 83 void VideoInitializationStatus(CastInitializationStatus status) { |
| 84 LOG(INFO) << "Video status: " << status; | 84 LOG(INFO) << "Video status: " << status; |
| 85 } | 85 } |
| 86 | 86 |
| 87 void LogTransportEvents(const scoped_refptr<CastEnvironment>& env, | 87 void LogTransportEvents(const scoped_refptr<CastEnvironment>& env, |
| 88 const std::vector<PacketEvent>& packet_events) { | 88 const std::vector<PacketEvent>& packet_events, |
| 89 const std::vector<FrameEvent>& frame_events) { |
| 89 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 90 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
| 90 packet_events.begin(); | 91 packet_events.begin(); |
| 91 it != packet_events.end(); | 92 it != packet_events.end(); |
| 92 ++it) { | 93 ++it) { |
| 93 env->Logging()->InsertPacketEvent(it->timestamp, | 94 env->Logging()->InsertPacketEvent(it->timestamp, |
| 94 it->type, | 95 it->type, |
| 95 it->media_type, | 96 it->media_type, |
| 96 it->rtp_timestamp, | 97 it->rtp_timestamp, |
| 97 it->frame_id, | 98 it->frame_id, |
| 98 it->packet_id, | 99 it->packet_id, |
| 99 it->max_packet_id, | 100 it->max_packet_id, |
| 100 it->size); | 101 it->size); |
| 101 } | 102 } |
| 103 for (std::vector<media::cast::FrameEvent>::const_iterator it = |
| 104 frame_events.begin(); |
| 105 it != frame_events.end(); |
| 106 ++it) { |
| 107 env->Logging()->InsertFrameEvent(it->timestamp, |
| 108 it->type, |
| 109 it->media_type, |
| 110 it->rtp_timestamp, |
| 111 it->frame_id); |
| 112 } |
| 102 } | 113 } |
| 103 | 114 |
| 104 void GotVideoFrame( | 115 void GotVideoFrame( |
| 105 int* counter, | 116 int* counter, |
| 106 CastReceiver* cast_receiver, | 117 CastReceiver* cast_receiver, |
| 107 const scoped_refptr<media::VideoFrame>& video_frame, | 118 const scoped_refptr<media::VideoFrame>& video_frame, |
| 108 const base::TimeTicks& render_time, | 119 const base::TimeTicks& render_time, |
| 109 bool continuous) { | 120 bool continuous) { |
| 110 ++*counter; | 121 ++*counter; |
| 111 cast_receiver->RequestDecodedVideoFrame( | 122 cast_receiver->RequestDecodedVideoFrame( |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 const IPPModel& ipp_model = model.ipp(); | 269 const IPPModel& ipp_model = model.ipp(); |
| 259 | 270 |
| 260 std::vector<double> average_rates(ipp_model.average_rate_size()); | 271 std::vector<double> average_rates(ipp_model.average_rate_size()); |
| 261 std::copy(ipp_model.average_rate().begin(), ipp_model.average_rate().end(), | 272 std::copy(ipp_model.average_rate().begin(), ipp_model.average_rate().end(), |
| 262 average_rates.begin()); | 273 average_rates.begin()); |
| 263 test::InterruptedPoissonProcess ipp(average_rates, | 274 test::InterruptedPoissonProcess ipp(average_rates, |
| 264 ipp_model.coef_burstiness(), ipp_model.coef_variance(), 0); | 275 ipp_model.coef_burstiness(), ipp_model.coef_variance(), 0); |
| 265 | 276 |
| 266 // Connect sender to receiver. This initializes the pipe. | 277 // Connect sender to receiver. This initializes the pipe. |
| 267 receiver_to_sender.Initialize( | 278 receiver_to_sender.Initialize( |
| 268 ipp.NewBuffer(128 * 1024), cast_sender->packet_receiver(), task_runner, | 279 ipp.NewBuffer(128 * 1024), transport_sender->PacketReceiverForTesting(), |
| 269 &testing_clock); | 280 task_runner, &testing_clock); |
| 270 sender_to_receiver.Initialize( | 281 sender_to_receiver.Initialize( |
| 271 ipp.NewBuffer(128 * 1024), cast_receiver->packet_receiver(), task_runner, | 282 ipp.NewBuffer(128 * 1024), cast_receiver->packet_receiver(), task_runner, |
| 272 &testing_clock); | 283 &testing_clock); |
| 273 | 284 |
| 274 // Start receiver. | 285 // Start receiver. |
| 275 int audio_frame_count = 0; | 286 int audio_frame_count = 0; |
| 276 int video_frame_count = 0; | 287 int video_frame_count = 0; |
| 277 cast_receiver->RequestDecodedVideoFrame( | 288 cast_receiver->RequestDecodedVideoFrame( |
| 278 base::Bind(&GotVideoFrame, &video_frame_count, cast_receiver.get())); | 289 base::Bind(&GotVideoFrame, &video_frame_count, cast_receiver.get())); |
| 279 cast_receiver->RequestDecodedAudioFrame( | 290 cast_receiver->RequestDecodedAudioFrame( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 values.SetBoolean("sim", true); | 447 values.SetBoolean("sim", true); |
| 437 values.SetString("sim-id", sim_id); | 448 values.SetString("sim-id", sim_id); |
| 438 | 449 |
| 439 std::string extra_data; | 450 std::string extra_data; |
| 440 base::JSONWriter::Write(&values, &extra_data); | 451 base::JSONWriter::Write(&values, &extra_data); |
| 441 | 452 |
| 442 // Run. | 453 // Run. |
| 443 media::cast::RunSimulation(source_path, output_path, extra_data, model); | 454 media::cast::RunSimulation(source_path, output_path, extra_data, model); |
| 444 return 0; | 455 return 0; |
| 445 } | 456 } |
| OLD | NEW |