| Index: media/filters/remoting_controller.cc
|
| diff --git a/media/filters/remoting_controller.cc b/media/filters/remoting_controller.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d2bb6a8214e45cee4b7255ea48db01ae875f52fb
|
| --- /dev/null
|
| +++ b/media/filters/remoting_controller.cc
|
| @@ -0,0 +1,118 @@
|
| +// 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.
|
| +
|
| +#include "media/filters/remoting_controller.h"
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include "media/base/audio_codecs.h"
|
| +#include "media/base/video_codecs.h"
|
| +#include "media/filters/pipeline_controller.h"
|
| +
|
| +namespace media {
|
| +
|
| +RemotingController::RemotingController() : RemotingController(nullptr) {}
|
| +
|
| +RemotingController::RemotingController(PipelineController* pipeline_controller)
|
| + : is_fullscreen_(false),
|
| + is_encrypted_content_(false),
|
| + is_sink_available_(false),
|
| + use_remoting_renderer_(false),
|
| + pipeline_controller_(pipeline_controller) {}
|
| +
|
| +RemotingController::~RemotingController() {}
|
| +
|
| +void RemotingController::OnSinkAvailable() {
|
| + is_sink_available_ = true;
|
| + Update();
|
| +}
|
| +
|
| +void RemotingController::OnSinkGone() {
|
| + is_sink_available_ = false;
|
| + Update();
|
| +}
|
| +
|
| +void RemotingController::SetFullscreenMode(bool is_fullscreen) {
|
| + is_fullscreen_ = is_fullscreen;
|
| + Update();
|
| +}
|
| +
|
| +void RemotingController::SetIsEncryptedContent() {
|
| + is_encrypted_content_ = true;
|
| + Update();
|
| +}
|
| +
|
| +void RemotingController::SetPipelineController(
|
| + PipelineController* pipeline_controller) {
|
| + pipeline_controller_ = pipeline_controller;
|
| +}
|
| +
|
| +bool RemotingController::isVideoDecoderSupported() {
|
| + VideoDecoderConfig config = pipeline_controller_->GetVideoDecoderConfig();
|
| + switch (config.codec()) {
|
| + case VideoCodec::kCodecH264:
|
| + case VideoCodec::kCodecVP8:
|
| + return true;
|
| + default:
|
| + VLOG(2) << "Remoting does not support video codec: " << config.codec();
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +bool RemotingController::isAudioDecoderSupported() {
|
| + AudioDecoderConfig config = pipeline_controller_->GetAudioDecoderConfig();
|
| + switch (config.codec()) {
|
| + case AudioCodec::kCodecAAC:
|
| + case AudioCodec::kCodecMP3:
|
| + case AudioCodec::kCodecPCM:
|
| + case AudioCodec::kCodecVorbis:
|
| + case AudioCodec::kCodecFLAC:
|
| + case AudioCodec::kCodecAMR_NB:
|
| + case AudioCodec::kCodecAMR_WB:
|
| + case AudioCodec::kCodecPCM_MULAW:
|
| + case AudioCodec::kCodecGSM_MS:
|
| + case AudioCodec::kCodecPCM_S16BE:
|
| + case AudioCodec::kCodecPCM_S24BE:
|
| + case AudioCodec::kCodecOpus:
|
| + case AudioCodec::kCodecEAC3:
|
| + case AudioCodec::kCodecPCM_ALAW:
|
| + case AudioCodec::kCodecALAC:
|
| + case AudioCodec::kCodecAC3:
|
| + return true;
|
| + default:
|
| + VLOG(2) << "Remoting does not support audio codec: " << config.codec();
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +void RemotingController::Update() {
|
| + if (!pipeline_controller_)
|
| + return;
|
| +
|
| + // TODO(xjz): The swithcing logic for encrypted content will be added in a
|
| + // later CL.
|
| + if (is_encrypted_content_)
|
| + return;
|
| +
|
| + if (!use_remoting_renderer_) {
|
| + if (!is_sink_available_ || !is_fullscreen_ || !isVideoDecoderSupported() ||
|
| + !isAudioDecoderSupported())
|
| + return;
|
| + use_remoting_renderer_ = true;
|
| + } else {
|
| + if (!is_fullscreen_ || !is_sink_available_)
|
| + use_remoting_renderer_ = false;
|
| + else
|
| + return;
|
| + }
|
| + pipeline_controller_->ToggleRenderer();
|
| +}
|
| +
|
| +bool RemotingController::ShouldUseRemotingRenderer() {
|
| + // TODO(xjz): Try calling Mojo Remoter to start/stop remoting here.
|
| +
|
| + return use_remoting_renderer_;
|
| +}
|
| +
|
| +} // namespace media
|
|
|