Chromium Code Reviews| 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 d5133b61cc0259899b38a5d422f96ca694b321a3..da3a45636769d03a39a444460950dd93f576ebd0 100644 |
| --- a/chrome/renderer/media/cast_session_delegate.cc |
| +++ b/chrome/renderer/media/cast_session_delegate.cc |
| @@ -12,6 +12,7 @@ |
| #include "media/cast/cast_config.h" |
| #include "media/cast/cast_environment.h" |
| #include "media/cast/cast_sender.h" |
| +#include "media/cast/logging/encoding_event_subscriber.h" |
| #include "media/cast/logging/logging_defines.h" |
| #include "media/cast/transport/cast_transport_config.h" |
| #include "media/cast/transport/cast_transport_sender.h" |
| @@ -21,6 +22,18 @@ using media::cast::CastEnvironment; |
| using media::cast::CastSender; |
| using media::cast::VideoSenderConfig; |
| +namespace { |
| + |
| +// Allow about 9MB for video event logs. Assume serialized log data for |
| +// each frame will take up to 150 bytes. |
| +const int kMaxVideoEventEntries = 9000000 / 150; |
| + |
| +// Allow about 9MB for audio event logs. Assume serialized log data for |
| +// each frame will take up to 75 bytes. |
| +const int kMaxAudioEventEntries = 9000000 / 75; |
| + |
| +} // namespace |
| + |
| CastSessionDelegate::CastSessionDelegate() |
| : audio_encode_thread_("CastAudioEncodeThread"), |
| video_encode_thread_("CastVideoEncodeThread"), |
| @@ -32,6 +45,15 @@ CastSessionDelegate::CastSessionDelegate() |
| CastSessionDelegate::~CastSessionDelegate() { |
| DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| + |
| + if (audio_event_subscriber_.get()) { |
| + cast_environment_->Logging()->RemoveRawEventSubscriber( |
| + audio_event_subscriber_.get()); |
| + } |
| + if (video_event_subscriber_.get()) { |
| + cast_environment_->Logging()->RemoveRawEventSubscriber( |
| + video_event_subscriber_.get()); |
| + } |
| } |
| void CastSessionDelegate::Initialize() { |
| @@ -86,6 +108,16 @@ void CastSessionDelegate::StartUDP( |
| StartSendingInternal(); |
| } |
| +void CastSessionDelegate::GetEventLogsAndReset( |
| + const EventLogsCallback& callback) { |
| + if (!cast_sender_.get()) |
| + return; |
| + |
| + // TODO(imcheng): Get data from event subscribers. |
| + scoped_ptr<std::string> result(new std::string); |
| + callback.Run(result.Pass()); |
| +} |
| + |
| void CastSessionDelegate::StatusNotificationCB( |
| media::cast::transport::CastTransportStatus unused_status) { |
| DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| @@ -116,11 +148,24 @@ void CastSessionDelegate::StartSendingInternal() { |
| config.audio_rtp_config = audio_config_->rtp_config; |
| config.audio_frequency = audio_config_->frequency; |
| config.audio_channels = audio_config_->channels; |
| + audio_event_subscriber_.reset(new media::cast::EncodingEventSubscriber( |
| + media::cast::AUDIO_EVENT, kMaxAudioEventEntries)); |
| + |
| + // Currently on main thread, can call logging directly. |
|
Alpha Left Google
2014/02/21 01:59:19
This comment is not necessary.
imcheng
2014/02/21 03:17:25
I suppose... it helps to remind me this is making
|
| + cast_environment_->Logging()->AddRawEventSubscriber( |
| + audio_event_subscriber_.get()); |
| } |
| if (video_config_) { |
| config.video_ssrc = video_config_->sender_ssrc; |
| config.video_codec = video_config_->codec; |
| config.video_rtp_config = video_config_->rtp_config; |
| + |
| + video_event_subscriber_.reset(new media::cast::EncodingEventSubscriber( |
| + media::cast::VIDEO_EVENT, kMaxVideoEventEntries)); |
| + |
| + // Currently on main thread, can call logging directly. |
|
Alpha Left Google
2014/02/21 01:59:19
This comment is not necessary.
imcheng
2014/02/21 03:17:25
Done.
imcheng
2014/02/21 03:17:25
Done.
|
| + cast_environment_->Logging()->AddRawEventSubscriber( |
| + video_event_subscriber_.get()); |
| } |
| cast_transport_.reset(new CastTransportSenderIPC( |