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

Unified Diff: chrome/renderer/media/cast_session_delegate.cc

Issue 184853003: Cast: Add GetStats() extensions API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/media/cast_session_delegate.cc
diff --git a/chrome/renderer/media/cast_session_delegate.cc b/chrome/renderer/media/cast_session_delegate.cc
index a1432770ced56074c98a2dc79e6588059b264360..08fcf27e6e62e70a6dc139165eb55d79863a0ff8 100644
--- a/chrome/renderer/media/cast_session_delegate.cc
+++ b/chrome/renderer/media/cast_session_delegate.cc
@@ -16,6 +16,7 @@
#include "media/cast/logging/encoding_event_subscriber.h"
#include "media/cast/logging/log_serializer.h"
#include "media/cast/logging/logging_defines.h"
+#include "media/cast/logging/stats_serializer.h"
#include "media/cast/transport/cast_transport_config.h"
#include "media/cast/transport/cast_transport_sender.h"
@@ -182,6 +183,26 @@ void CastSessionDelegate::GetEventLogsAndReset(
callback.Run(serialized_log.Pass());
}
+void CastSessionDelegate::GetStatsAndReset(bool is_audio,
+ const StatsCallback& callback) {
+ media::cast::FrameStatsMap frame_stats =
+ cast_environment_->Logging()->GetFrameStatsData(
+ is_audio ? media::cast::AUDIO_EVENT : media::cast::VIDEO_EVENT);
+ media::cast::PacketStatsMap packet_stats =
+ cast_environment_->Logging()->GetPacketStatsData(
+ is_audio ? media::cast::AUDIO_EVENT : media::cast::VIDEO_EVENT);
+ scoped_ptr<std::string> result(new std::string);
+ bool success =
+ media::cast::SerializeStats(frame_stats, packet_stats, result.get());
+ if (!success) {
+ VLOG(2) << "Failed to serialized stats.";
+ callback.Run(make_scoped_ptr(new std::string).Pass());
+ return;
+ }
+
+ callback.Run(result.Pass());
+}
+
void CastSessionDelegate::StatusNotificationCB(
media::cast::transport::CastTransportStatus unused_status) {
DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698