OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/filters/remoting_controller.h" |
| 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include "media/base/audio_codecs.h" |
| 10 #include "media/base/video_codecs.h" |
| 11 #include "media/filters/pipeline_controller.h" |
| 12 |
| 13 namespace media { |
| 14 |
| 15 RemotingController::RemotingController() : RemotingController(nullptr) {} |
| 16 |
| 17 RemotingController::RemotingController(PipelineController* pipeline_controller) |
| 18 : is_fullscreen_(false), |
| 19 is_encrypted_content_(false), |
| 20 is_sink_available_(false), |
| 21 use_remoting_renderer_(false), |
| 22 pipeline_controller_(pipeline_controller) {} |
| 23 |
| 24 RemotingController::~RemotingController() {} |
| 25 |
| 26 void RemotingController::OnSinkAvailable() { |
| 27 is_sink_available_ = true; |
| 28 Update(); |
| 29 } |
| 30 |
| 31 void RemotingController::OnSinkGone() { |
| 32 is_sink_available_ = false; |
| 33 Update(); |
| 34 } |
| 35 |
| 36 void RemotingController::SetFullscreenMode(bool is_fullscreen) { |
| 37 is_fullscreen_ = is_fullscreen; |
| 38 Update(); |
| 39 } |
| 40 |
| 41 void RemotingController::SetIsEncryptedContent() { |
| 42 is_encrypted_content_ = true; |
| 43 Update(); |
| 44 } |
| 45 |
| 46 void RemotingController::SetPipelineController( |
| 47 PipelineController* pipeline_controller) { |
| 48 pipeline_controller_ = pipeline_controller; |
| 49 } |
| 50 |
| 51 bool RemotingController::isVideoDecoderSupported() { |
| 52 VideoDecoderConfig config = pipeline_controller_->GetVideoDecoderConfig(); |
| 53 switch (config.codec()) { |
| 54 case VideoCodec::kCodecH264: |
| 55 case VideoCodec::kCodecVP8: |
| 56 return true; |
| 57 default: |
| 58 VLOG(2) << "Remoting does not support video codec: " << config.codec(); |
| 59 return false; |
| 60 } |
| 61 } |
| 62 |
| 63 bool RemotingController::isAudioDecoderSupported() { |
| 64 AudioDecoderConfig config = pipeline_controller_->GetAudioDecoderConfig(); |
| 65 switch (config.codec()) { |
| 66 case AudioCodec::kCodecAAC: |
| 67 case AudioCodec::kCodecMP3: |
| 68 case AudioCodec::kCodecPCM: |
| 69 case AudioCodec::kCodecVorbis: |
| 70 case AudioCodec::kCodecFLAC: |
| 71 case AudioCodec::kCodecAMR_NB: |
| 72 case AudioCodec::kCodecAMR_WB: |
| 73 case AudioCodec::kCodecPCM_MULAW: |
| 74 case AudioCodec::kCodecGSM_MS: |
| 75 case AudioCodec::kCodecPCM_S16BE: |
| 76 case AudioCodec::kCodecPCM_S24BE: |
| 77 case AudioCodec::kCodecOpus: |
| 78 case AudioCodec::kCodecEAC3: |
| 79 case AudioCodec::kCodecPCM_ALAW: |
| 80 case AudioCodec::kCodecALAC: |
| 81 case AudioCodec::kCodecAC3: |
| 82 return true; |
| 83 default: |
| 84 VLOG(2) << "Remoting does not support audio codec: " << config.codec(); |
| 85 return false; |
| 86 } |
| 87 } |
| 88 |
| 89 void RemotingController::Update() { |
| 90 if (!pipeline_controller_) |
| 91 return; |
| 92 |
| 93 // TODO(xjz): The swithcing logic for encrypted content will be added in a |
| 94 // later CL. |
| 95 if (is_encrypted_content_) |
| 96 return; |
| 97 |
| 98 if (!use_remoting_renderer_) { |
| 99 if (!is_sink_available_ || !is_fullscreen_ || !isVideoDecoderSupported() || |
| 100 !isAudioDecoderSupported()) |
| 101 return; |
| 102 use_remoting_renderer_ = true; |
| 103 } else { |
| 104 if (!is_fullscreen_ || !is_sink_available_) |
| 105 use_remoting_renderer_ = false; |
| 106 else |
| 107 return; |
| 108 } |
| 109 pipeline_controller_->ToggleRenderer(); |
| 110 } |
| 111 |
| 112 bool RemotingController::ShouldUseRemotingRenderer() { |
| 113 // TODO(xjz): Try calling Mojo Remoter to start/stop remoting here. |
| 114 |
| 115 return use_remoting_renderer_; |
| 116 } |
| 117 |
| 118 } // namespace media |
OLD | NEW |