OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Test application that simulates a cast sender - Data can be either generated | 5 // Test application that simulates a cast sender - Data can be either generated |
6 // or read from a file. | 6 // or read from a file. |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return video_config; | 116 return video_config; |
117 } | 117 } |
118 | 118 |
119 void UpdateCastTransportStatus( | 119 void UpdateCastTransportStatus( |
120 media::cast::CastTransportStatus status) { | 120 media::cast::CastTransportStatus status) { |
121 VLOG(1) << "Transport status: " << status; | 121 VLOG(1) << "Transport status: " << status; |
122 } | 122 } |
123 | 123 |
124 void LogRawEvents( | 124 void LogRawEvents( |
125 const scoped_refptr<media::cast::CastEnvironment>& cast_environment, | 125 const scoped_refptr<media::cast::CastEnvironment>& cast_environment, |
126 const std::vector<media::cast::PacketEvent>& packet_events) { | 126 const std::vector<media::cast::PacketEvent>& packet_events, |
| 127 const std::vector<media::cast::FrameEvent>& frame_events) { |
127 VLOG(1) << "Got packet events from transport, size: " << packet_events.size(); | 128 VLOG(1) << "Got packet events from transport, size: " << packet_events.size(); |
128 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 129 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
129 packet_events.begin(); | 130 packet_events.begin(); |
130 it != packet_events.end(); | 131 it != packet_events.end(); |
131 ++it) { | 132 ++it) { |
132 cast_environment->Logging()->InsertPacketEvent(it->timestamp, | 133 cast_environment->Logging()->InsertPacketEvent(it->timestamp, |
133 it->type, | 134 it->type, |
134 it->media_type, | 135 it->media_type, |
135 it->rtp_timestamp, | 136 it->rtp_timestamp, |
136 it->frame_id, | 137 it->frame_id, |
137 it->packet_id, | 138 it->packet_id, |
138 it->max_packet_id, | 139 it->max_packet_id, |
139 it->size); | 140 it->size); |
140 } | 141 } |
| 142 VLOG(1) << "Got frame events from transport, size: " << frame_events.size(); |
| 143 for (std::vector<media::cast::FrameEvent>::const_iterator it = |
| 144 frame_events.begin(); |
| 145 it != frame_events.end(); |
| 146 ++it) { |
| 147 cast_environment->Logging()->InsertFrameEvent(it->timestamp, |
| 148 it->type, |
| 149 it->media_type, |
| 150 it->rtp_timestamp, |
| 151 it->frame_id); |
| 152 } |
141 } | 153 } |
142 | 154 |
143 void InitializationResult(media::cast::CastInitializationStatus result) { | 155 void InitializationResult(media::cast::CastInitializationStatus result) { |
144 bool end_result = result == media::cast::STATUS_AUDIO_INITIALIZED || | 156 bool end_result = result == media::cast::STATUS_AUDIO_INITIALIZED || |
145 result == media::cast::STATUS_VIDEO_INITIALIZED; | 157 result == media::cast::STATUS_VIDEO_INITIALIZED; |
146 CHECK(end_result) << "Cast sender uninitialized"; | 158 CHECK(end_result) << "Cast sender uninitialized"; |
147 } | 159 } |
148 | 160 |
149 net::IPEndPoint CreateUDPAddress(std::string ip_str, int port) { | 161 net::IPEndPoint CreateUDPAddress(std::string ip_str, int port) { |
150 net::IPAddressNumber ip_number; | 162 net::IPAddressNumber ip_number; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 332 |
321 // CastSender initialization. | 333 // CastSender initialization. |
322 scoped_ptr<media::cast::CastSender> cast_sender = | 334 scoped_ptr<media::cast::CastSender> cast_sender = |
323 media::cast::CastSender::Create(cast_environment, transport_sender.get()); | 335 media::cast::CastSender::Create(cast_environment, transport_sender.get()); |
324 cast_sender->InitializeVideo( | 336 cast_sender->InitializeVideo( |
325 fake_media_source->get_video_config(), | 337 fake_media_source->get_video_config(), |
326 base::Bind(&InitializationResult), | 338 base::Bind(&InitializationResult), |
327 media::cast::CreateDefaultVideoEncodeAcceleratorCallback(), | 339 media::cast::CreateDefaultVideoEncodeAcceleratorCallback(), |
328 media::cast::CreateDefaultVideoEncodeMemoryCallback()); | 340 media::cast::CreateDefaultVideoEncodeMemoryCallback()); |
329 cast_sender->InitializeAudio(audio_config, base::Bind(&InitializationResult)); | 341 cast_sender->InitializeAudio(audio_config, base::Bind(&InitializationResult)); |
330 transport_sender->SetPacketReceiver(cast_sender->packet_receiver()); | |
331 | 342 |
332 // Set up event subscribers. | 343 // Set up event subscribers. |
333 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber; | 344 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber; |
334 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber; | 345 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber; |
335 std::string video_log_file_name("/tmp/video_events.log.gz"); | 346 std::string video_log_file_name("/tmp/video_events.log.gz"); |
336 std::string audio_log_file_name("/tmp/audio_events.log.gz"); | 347 std::string audio_log_file_name("/tmp/audio_events.log.gz"); |
337 LOG(INFO) << "Logging audio events to: " << audio_log_file_name; | 348 LOG(INFO) << "Logging audio events to: " << audio_log_file_name; |
338 LOG(INFO) << "Logging video events to: " << video_log_file_name; | 349 LOG(INFO) << "Logging video events to: " << video_log_file_name; |
339 video_event_subscriber.reset(new media::cast::EncodingEventSubscriber( | 350 video_event_subscriber.reset(new media::cast::EncodingEventSubscriber( |
340 media::cast::VIDEO_EVENT, 10000)); | 351 media::cast::VIDEO_EVENT, 10000)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 base::Passed(&audio_stats_subscriber), | 404 base::Passed(&audio_stats_subscriber), |
394 base::Passed(&offset_estimator)), | 405 base::Passed(&offset_estimator)), |
395 base::TimeDelta::FromSeconds(logging_duration_seconds)); | 406 base::TimeDelta::FromSeconds(logging_duration_seconds)); |
396 | 407 |
397 fake_media_source->Start(cast_sender->audio_frame_input(), | 408 fake_media_source->Start(cast_sender->audio_frame_input(), |
398 cast_sender->video_frame_input()); | 409 cast_sender->video_frame_input()); |
399 | 410 |
400 io_message_loop.Run(); | 411 io_message_loop.Run(); |
401 return 0; | 412 return 0; |
402 } | 413 } |
OLD | NEW |