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

Unified Diff: media/cast/test/simulator.cc

Issue 433363002: Cast: cast_simulator to print more info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: shuffle a bit Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/simulator.cc
diff --git a/media/cast/test/simulator.cc b/media/cast/test/simulator.cc
index 135d44bb45c85c9193e08dd213b19c94dc8494f3..157a18fcc346ee2d45b43f5ae6273de918c337df 100644
--- a/media/cast/test/simulator.cc
+++ b/media/cast/test/simulator.cc
@@ -145,24 +145,20 @@ void GotAudioFrame(
base::Bind(&GotAudioFrame, counter, cast_receiver));
}
-void AppendLog(EncodingEventSubscriber* subscriber,
- const std::string& extra_data,
- const base::FilePath& output_path) {
- media::cast::proto::LogMetadata metadata;
- metadata.set_extra_data(extra_data);
-
- media::cast::FrameEventList frame_events;
- media::cast::PacketEventList packet_events;
- subscriber->GetEventsAndReset(
- &metadata, &frame_events, &packet_events);
+// Serialize |frame_events| and |packet_events| and append to the file
+// located at |output_path|.
+void AppendLogToFile(media::cast::proto::LogMetadata* metadata,
+ const media::cast::FrameEventList& frame_events,
+ const media::cast::PacketEventList& packet_events,
+ const base::FilePath& output_path) {
media::cast::proto::GeneralDescription* gen_desc =
- metadata.mutable_general_description();
+ metadata->mutable_general_description();
gen_desc->set_product("Cast Simulator");
gen_desc->set_product_version("0.1");
scoped_ptr<char[]> serialized_log(new char[media::cast::kMaxSerializedBytes]);
int output_bytes;
- bool success = media::cast::SerializeEvents(metadata,
+ bool success = media::cast::SerializeEvents(*metadata,
frame_events,
packet_events,
true,
@@ -330,8 +326,61 @@ void RunSimulation(const base::FilePath& source_path,
elapsed_time += step;
}
+ // Get event logs for audio and video.
+ media::cast::proto::LogMetadata audio_metadata, video_metadata;
+ media::cast::FrameEventList audio_frame_events, video_frame_events;
+ media::cast::PacketEventList audio_packet_events, video_packet_events;
+ audio_metadata.set_extra_data(extra_data);
+ video_metadata.set_extra_data(extra_data);
+ audio_event_subscriber.GetEventsAndReset(
+ &audio_metadata, &audio_frame_events, &audio_packet_events);
+ video_event_subscriber.GetEventsAndReset(
+ &video_metadata, &video_frame_events, &video_packet_events);
+
+ // Print simulation results.
+
+ // Compute and print statistics for video:
+ //
+ // * Total video frames captured.
+ // * Total video frames encoded.
+ // * Total video frames dropped.
+ // * Total video frames received late.
+ // * Average target bitrate.
+ // * Average encoded bitrate.
+ int total_video_frames = 0;
+ int encoded_video_frames = 0;
+ int dropped_video_frames = 0;
+ int late_video_frames = 0;
+ int64 encoded_size = 0;
+ int64 target_bitrate = 0;
+ for (size_t i = 0; i < video_frame_events.size(); ++i) {
+ const media::cast::proto::AggregatedFrameEvent& event =
+ *video_frame_events[i];
+ ++total_video_frames;
+ if (event.has_encoded_frame_size()) {
+ ++encoded_video_frames;
+ encoded_size += event.encoded_frame_size();
+ target_bitrate += event.target_bitrate();
+ } else {
+ ++dropped_video_frames;
+ }
+ if (event.has_delay_millis() && event.delay_millis() < 0)
+ ++late_video_frames;
+ }
+
+ double avg_encoded_bitrate =
+ !encoded_video_frames ? 0 :
+ 8.0 * encoded_size * video_sender_config.max_frame_rate /
+ encoded_video_frames / 1000;
+ double avg_target_bitrate =
+ !encoded_video_frames ? 0 : target_bitrate / encoded_video_frames / 1000;
+
LOG(INFO) << "Audio frame count: " << audio_frame_count;
- LOG(INFO) << "Video frame count: " << video_frame_count;
+ LOG(INFO) << "Total video frames: " << total_video_frames;
+ LOG(INFO) << "Dropped video frames " << dropped_video_frames;
+ LOG(INFO) << "Late video frames: " << late_video_frames;
+ LOG(INFO) << "Average encoded bitrate (kbps): " << avg_encoded_bitrate;
+ LOG(INFO) << "Average target bitrate (kbps): " << avg_target_bitrate;
LOG(INFO) << "Writing log: " << output_path.value();
// Truncate file and then write serialized log.
@@ -342,8 +391,10 @@ void RunSimulation(const base::FilePath& source_path,
return;
}
}
- AppendLog(&video_event_subscriber, extra_data, output_path);
- AppendLog(&audio_event_subscriber, extra_data, output_path);
+ AppendLogToFile(&video_metadata, video_frame_events, video_packet_events,
+ output_path);
+ AppendLogToFile(&audio_metadata, audio_frame_events, audio_packet_events,
+ output_path);
}
NetworkSimulationModel DefaultModel() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698