Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: media/cast/test/sender.cc

Issue 1515023002: Simplify interface for media/cast: CastTransportSenderImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add changes on tests. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 *stats, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); 153 *stats, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
154 VLOG(0) << "Video stats: " << json; 154 VLOG(0) << "Video stats: " << json;
155 155
156 stats = audio_stats_subscriber->GetStats(); 156 stats = audio_stats_subscriber->GetStats();
157 json.clear(); 157 json.clear();
158 base::JSONWriter::WriteWithOptions( 158 base::JSONWriter::WriteWithOptions(
159 *stats, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); 159 *stats, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
160 VLOG(0) << "Audio stats: " << json; 160 VLOG(0) << "Audio stats: " << json;
161 } 161 }
162 162
163 class TransportClient : public media::cast::CastTransportSender::Client {
164 public:
165 TransportClient(media::cast::LogEventDispatcher* log_event_dispatcher)
166 : log_event_dispatcher_(log_event_dispatcher) {}
167
168 void OnStatusChanged(media::cast::CastTransportStatus status) final {
169 VLOG(1) << "Transport status: " << status;
170 };
171 void OnLoggingEventsReceived(
172 scoped_ptr<std::vector<media::cast::FrameEvent>> frame_events,
173 scoped_ptr<std::vector<media::cast::PacketEvent>> packet_events) final {
174 DCHECK(log_event_dispatcher_);
175 log_event_dispatcher_->DispatchBatchOfEvents(std::move(frame_events),
176 std::move(packet_events));
177 };
178 void ProcessRtpPacket(scoped_ptr<media::cast::Packet> packet) final{};
miu 2016/02/22 22:38:48 Please run `git cl format` to fix these kinds of w
xjz 2016/02/23 21:51:47 Done. This is what "git cl format" results with th
179
180 private:
181 media::cast::LogEventDispatcher* const
182 log_event_dispatcher_; // Not owned by this class.
183
184 DISALLOW_COPY_AND_ASSIGN(TransportClient);
185 };
186
163 } // namespace 187 } // namespace
164 188
165 int main(int argc, char** argv) { 189 int main(int argc, char** argv) {
166 base::AtExitManager at_exit; 190 base::AtExitManager at_exit;
167 base::CommandLine::Init(argc, argv); 191 base::CommandLine::Init(argc, argv);
168 InitLogging(logging::LoggingSettings()); 192 InitLogging(logging::LoggingSettings());
169 193
170 // Prepare media module for FFmpeg decoding. 194 // Prepare media module for FFmpeg decoding.
171 media::InitializeMediaLibrary(); 195 media::InitializeMediaLibrary();
172 196
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (!source_path.empty()) { 252 if (!source_path.empty()) {
229 LOG(INFO) << "Source: " << source_path.value(); 253 LOG(INFO) << "Source: " << source_path.value();
230 fake_media_source->SetSourceFile(source_path, final_fps); 254 fake_media_source->SetSourceFile(source_path, final_fps);
231 } 255 }
232 if (cmd->HasSwitch(kSwitchVaryFrameSizes)) 256 if (cmd->HasSwitch(kSwitchVaryFrameSizes))
233 fake_media_source->SetVariableFrameSizeMode(true); 257 fake_media_source->SetVariableFrameSizeMode(true);
234 258
235 // CastTransportSender initialization. 259 // CastTransportSender initialization.
236 scoped_ptr<media::cast::CastTransportSender> transport_sender = 260 scoped_ptr<media::cast::CastTransportSender> transport_sender =
237 media::cast::CastTransportSender::Create( 261 media::cast::CastTransportSender::Create(
238 nullptr, // net log. 262 cast_environment->Clock(), base::TimeDelta::FromSeconds(1),
239 cast_environment->Clock(), net::IPEndPoint(), remote_endpoint, 263 make_scoped_ptr(new TransportClient(cast_environment->logger())),
240 make_scoped_ptr(new base::DictionaryValue), // options 264 make_scoped_ptr(new media::cast::UdpTransport(
241 base::Bind(&UpdateCastTransportStatus), 265 nullptr, io_message_loop.task_runner(), net::IPEndPoint(),
242 base::Bind(&media::cast::LogEventDispatcher::DispatchBatchOfEvents, 266 remote_endpoint, base::Bind(&UpdateCastTransportStatus))),
243 base::Unretained(cast_environment->logger())), 267 io_message_loop.task_runner());
244 base::TimeDelta::FromSeconds(1),
245 media::cast::PacketReceiverCallback(), io_message_loop.task_runner());
246 268
247 // Set up event subscribers. 269 // Set up event subscribers.
248 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber; 270 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber;
249 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber; 271 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber;
250 std::string video_log_file_name("/tmp/video_events.log.gz"); 272 std::string video_log_file_name("/tmp/video_events.log.gz");
251 std::string audio_log_file_name("/tmp/audio_events.log.gz"); 273 std::string audio_log_file_name("/tmp/audio_events.log.gz");
252 LOG(INFO) << "Logging audio events to: " << audio_log_file_name; 274 LOG(INFO) << "Logging audio events to: " << audio_log_file_name;
253 LOG(INFO) << "Logging video events to: " << video_log_file_name; 275 LOG(INFO) << "Logging video events to: " << video_log_file_name;
254 video_event_subscriber.reset(new media::cast::EncodingEventSubscriber( 276 video_event_subscriber.reset(new media::cast::EncodingEventSubscriber(
255 media::cast::VIDEO_EVENT, 10000)); 277 media::cast::VIDEO_EVENT, 10000));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 base::Unretained(cast_sender.get()), 345 base::Unretained(cast_sender.get()),
324 audio_config, 346 audio_config,
325 base::Bind(&QuitLoopOnInitializationResult))); 347 base::Bind(&QuitLoopOnInitializationResult)));
326 io_message_loop.Run(); // Wait for audio initialization. 348 io_message_loop.Run(); // Wait for audio initialization.
327 349
328 fake_media_source->Start(cast_sender->audio_frame_input(), 350 fake_media_source->Start(cast_sender->audio_frame_input(),
329 cast_sender->video_frame_input()); 351 cast_sender->video_frame_input());
330 io_message_loop.Run(); 352 io_message_loop.Run();
331 return 0; 353 return 0;
332 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698