Index: media/cast/test/sender.cc |
diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc |
index fa2120e138f37289357bfdbdc22809a2f7407893..74352beae84a064ba4ec5df980a06f719b4ac2b1 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" |
@@ -383,7 +387,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)) { |
@@ -434,6 +438,30 @@ void WriteLogsToFileAndStopSubscribing( |
audio_log_file.Pass()); |
} |
+void WriteStats( |
miu
2014/04/17 02:14:14
naming: This method does more than just write the
imcheng
2014/04/17 19:19:06
Done. Also renamed the method above.
|
+ 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) { |
@@ -520,8 +548,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( |
@@ -559,6 +603,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( |