Commit 267e4634 authored by slan's avatar slan Committed by Commit bot

Plumb callbacks from mojo media service to client.

Add OnStatisticsUpdate and OnWaitingForDecryptionKey to
mojom::RendererClient, and call these callbacks from
MojoRendererService. These are needed for Cast Apps like Netflix that
depend on decoding statistics from the media pipeline.

BUG=585287
BUG= internal b/29390639

Review-Url: https://codereview.chromium.org/2101043003
Cr-Commit-Position: refs/heads/master@{#404486}
parent d75fb6b6
......@@ -17,7 +17,9 @@
#include "chromecast/public/media/media_pipeline_device_params.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/demuxer_stream.h"
#include "media/base/demuxer_stream_provider.h"
#include "media/base/media_log.h"
#include "media/base/renderer_client.h"
namespace chromecast {
namespace media {
......
......@@ -11,6 +11,7 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "media/base/demuxer_stream_provider.h"
#include "media/base/pipeline_status.h"
#include "media/base/renderer_client.h"
#include "media/base/video_renderer_sink.h"
#include "media/mojo/clients/mojo_demuxer_stream_impl.h"
......@@ -239,6 +240,18 @@ void MojoRenderer::OnVideoOpacityChange(bool opaque) {
client_->OnVideoOpacityChange(opaque);
}
void MojoRenderer::OnStatisticsUpdate(const PipelineStatistics& stats) {
DVLOG(3) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
client_->OnStatisticsUpdate(stats);
}
void MojoRenderer::OnWaitingForDecryptionKey() {
DVLOG(1) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
client_->OnWaitingForDecryptionKey();
}
void MojoRenderer::OnConnectionError() {
DVLOG(1) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
......
......@@ -65,6 +65,8 @@ class MojoRenderer : public Renderer, public mojom::RendererClient {
void OnError() override;
void OnVideoNaturalSizeChange(const gfx::Size& size) override;
void OnVideoOpacityChange(bool opaque) override;
void OnWaitingForDecryptionKey() override;
void OnStatisticsUpdate(const PipelineStatistics& stats) override;
// Binds |remote_renderer_| to the mojo message pipe. Can be called multiple
// times. If an error occurs during connection, OnConnectionError will be
......
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
per-file *_type_converter*.*=set noparent
per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_MOJO_COMMON_PIPELINE_STATISTICS_STRUCT_TRAITS_H_
#define MEDIA_MOJO_COMMON_PIPELINE_STATISTICS_STRUCT_TRAITS_H_
#include "media/base/pipeline_status.h"
#include "media/mojo/interfaces/media_types.mojom.h"
namespace mojo {
template <>
struct StructTraits<media::mojom::PipelineStatistics,
media::PipelineStatistics> {
static uint64_t audio_bytes_decoded(const media::PipelineStatistics& input) {
return input.audio_bytes_decoded;
}
static uint64_t video_bytes_decoded(const media::PipelineStatistics& input) {
return input.video_bytes_decoded;
}
static uint32_t video_frames_decoded(const media::PipelineStatistics& input) {
return input.video_frames_decoded;
}
static uint32_t video_frames_dropped(const media::PipelineStatistics& input) {
return input.video_frames_dropped;
}
static int64_t audio_memory_usage(const media::PipelineStatistics& input) {
return input.audio_memory_usage;
}
static int64_t video_memory_usage(const media::PipelineStatistics& input) {
return input.video_memory_usage;
}
static bool Read(media::mojom::PipelineStatisticsDataView data,
media::PipelineStatistics* output) {
output->audio_bytes_decoded = data.audio_bytes_decoded();
output->video_bytes_decoded = data.video_bytes_decoded();
output->video_frames_decoded = data.video_frames_decoded();
output->video_frames_dropped = data.video_frames_dropped();
output->audio_memory_usage = data.audio_memory_usage();
output->video_memory_usage = data.video_memory_usage();
return true;
}
};
} // namespace mojo
#endif // MEDIA_MOJO_COMMON_PIPELINE_STATISTICS_STRUCT_TRAITS_H_
\ No newline at end of file
......@@ -336,3 +336,12 @@ struct VideoFrame {
uint64 u_offset;
uint64 v_offset;
};
struct PipelineStatistics {
uint64 audio_bytes_decoded;
uint64 video_bytes_decoded;
uint32 video_frames_decoded;
uint32 video_frames_dropped;
int64 audio_memory_usage;
int64 video_memory_usage;
};
\ No newline at end of file
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
mojom = "//media/mojo/interfaces/media_types.mojom"
public_headers = [ "//media/base/pipeline_status.h" ]
traits_headers = [ "//media/mojo/common/pipeline_statistics_struct_traits.h" ]
type_mappings = [ "media.mojom.PipelineStatistics=media::PipelineStatistics" ]
......@@ -59,4 +59,12 @@ interface RendererClient {
// Executed for the first video frame and whenever opacity changes.
OnVideoOpacityChange(bool opaque);
// Called periodically to pass statistics to the web player. See
// media_types.mojom.
OnStatisticsUpdate(PipelineStatistics stats);
// Called when the remote renderering service is waiting on the decryption
// key.
OnWaitingForDecryptionKey();
};
......@@ -2,4 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
typemaps = [ "//media/mojo/interfaces/audio_parameters.typemap" ]
typemaps = [
"//media/mojo/interfaces/audio_parameters.typemap",
"//media/mojo/interfaces/pipeline_statistics.typemap",
]
......@@ -49,6 +49,9 @@ class MockRendererClient : public mojom::RendererClient {
MOCK_METHOD0(OnError, void());
MOCK_METHOD1(OnVideoOpacityChange, void(bool opaque));
MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size& size));
MOCK_METHOD1(OnStatisticsUpdate,
void(const media::PipelineStatistics& stats));
MOCK_METHOD0(OnWaitingForDecryptionKey, void());
private:
DISALLOW_COPY_AND_ASSIGN(MockRendererClient);
......
......@@ -115,7 +115,8 @@ void MojoRendererService::OnEnded() {
}
void MojoRendererService::OnStatisticsUpdate(const PipelineStatistics& stats) {
// TODO(alokp): Plumb the event to mojom::RendererClient. crbug/585287
DVLOG(3) << __FUNCTION__;
client_->OnStatisticsUpdate(stats);
}
void MojoRendererService::OnBufferingStateChange(BufferingState state) {
......@@ -124,7 +125,8 @@ void MojoRendererService::OnBufferingStateChange(BufferingState state) {
}
void MojoRendererService::OnWaitingForDecryptionKey() {
// TODO(alokp): Plumb the event to mojom::RendererClient. crbug/585287
DVLOG(1) << __FUNCTION__;
client_->OnWaitingForDecryptionKey();
}
void MojoRendererService::OnVideoNaturalSizeChange(const gfx::Size& size) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment