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

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

Issue 236123003: Cast: Provide more meaningful stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
Index: media/cast/test/sender.cc
diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc
index 1accf4b728a4c1b6093971c6091fb02a3f3ebafe..430d99049cb7ec6b54a732aad67cd05c0a919c23 100644
--- a/media/cast/test/sender.cc
+++ b/media/cast/test/sender.cc
@@ -9,10 +9,12 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/scoped_file.h"
+#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread.h"
#include "base/time/default_tick_clock.h"
+#include "base/values.h"
#include "media/base/video_frame.h"
#include "media/cast/cast_config.h"
#include "media/cast/cast_environment.h"
@@ -21,6 +23,8 @@
#include "media/cast/logging/log_serializer.h"
#include "media/cast/logging/logging_defines.h"
#include "media/cast/logging/proto/raw_events.pb.h"
+#include "media/cast/logging/receiver_time_offset_estimator_impl.h"
+#include "media/cast/logging/stats_event_subscriber.h"
#include "media/cast/test/utility/audio_utility.h"
#include "media/cast/test/utility/default_config.h"
#include "media/cast/test/utility/input_builder.h"
@@ -384,7 +388,7 @@ void DumpLoggingData(const media::cast::proto::LogMetadata& log_metadata,
if (!media::cast::SerializeEvents(log_metadata,
frame_events,
packet_events,
- compress,
+ true,
media::cast::kMaxSerializedLogBytes,
event_log.get(),
&event_log_bytes)) {
@@ -435,6 +439,30 @@ void WriteLogsToFileAndStopSubscribing(
audio_log_file.Pass());
}
+void WriteStats(
+ const scoped_refptr<media::cast::CastEnvironment>& cast_environment,
+ scoped_ptr<media::cast::StatsEventSubscriber> video_event_subscriber,
+ scoped_ptr<media::cast::StatsEventSubscriber> audio_event_subscriber,
+ scoped_ptr<media::cast::ReceiverTimeOffsetEstimatorImpl> estimator) {
+ cast_environment->Logging()->RemoveRawEventSubscriber(
+ video_event_subscriber.get());
+ cast_environment->Logging()->RemoveRawEventSubscriber(
+ audio_event_subscriber.get());
+ cast_environment->Logging()->RemoveRawEventSubscriber(estimator.get());
+
+ scoped_ptr<base::DictionaryValue> stats = video_event_subscriber->GetStats();
+ std::string json;
+ base::JSONWriter::WriteWithOptions(
+ stats.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
+ VLOG(0) << "Video stats: " << json;
+
+ stats = audio_event_subscriber->GetStats();
+ json.clear();
+ base::JSONWriter::WriteWithOptions(
+ stats.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
+ VLOG(0) << "Audio stats: " << json;
+}
+
} // namespace
int main(int argc, char** argv) {
@@ -521,8 +549,24 @@ int main(int argc, char** argv) {
// Set up event subscribers.
int logging_duration = media::cast::GetLoggingDuration();
+ scoped_ptr<media::cast::ReceiverTimeOffsetEstimatorImpl> offset_estimator(
+ new media::cast::ReceiverTimeOffsetEstimatorImpl);
+ cast_environment->Logging()->AddRawEventSubscriber(offset_estimator.get());
+
scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber;
scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber;
+ scoped_ptr<media::cast::StatsEventSubscriber> video_stats_subscriber(
+ new media::cast::StatsEventSubscriber(media::cast::VIDEO_EVENT,
+ cast_environment->Clock(),
+ offset_estimator.get()));
+ scoped_ptr<media::cast::StatsEventSubscriber> audio_stats_subscriber(
+ new media::cast::StatsEventSubscriber(media::cast::AUDIO_EVENT,
+ cast_environment->Clock(),
+ offset_estimator.get()));
+ cast_environment->Logging()->AddRawEventSubscriber(
+ video_stats_subscriber.get());
+ cast_environment->Logging()->AddRawEventSubscriber(
+ audio_stats_subscriber.get());
if (logging_duration > 0) {
bool compress = media::cast::CompressLogs();
std::string video_log_file_name(
@@ -560,6 +604,15 @@ int main(int argc, char** argv) {
base::Passed(&audio_log_file),
compress),
base::TimeDelta::FromSeconds(logging_duration));
+
+ io_message_loop.message_loop_proxy()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&WriteStats,
+ cast_environment,
+ base::Passed(&video_stats_subscriber),
+ base::Passed(&audio_stats_subscriber),
+ base::Passed(&offset_estimator)),
+ base::TimeDelta::FromSeconds(logging_duration));
}
test_thread.message_loop_proxy()->PostTask(

Powered by Google App Engine
This is Rietveld 408576698