Chromium Code Reviews| Index: media/remoting/remoting_renderer_controller.h |
| diff --git a/media/remoting/remoting_renderer_controller.h b/media/remoting/remoting_renderer_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..47faea3e3c0f03864601c4931e2d7d0db81108bb |
| --- /dev/null |
| +++ b/media/remoting/remoting_renderer_controller.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
miu
2016/10/25 04:21:26
Since remoting_renderer_controller.h/.cc are modif
xjz
2016/10/26 22:00:26
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
| +#define MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "media/base/media_observer.h" |
| +#include "media/remoting/remoting_source_impl.h" |
| + |
| +namespace media { |
| +struct PipelineMetadata; |
| +} |
| + |
| +namespace media { |
| + |
| +// This class: |
| +// 1) Implements the RemotingSourceImpl::Client; |
| +// 2) Monitors player events as a MediaObserver; |
| +// 3) May trigger the switch of the media renderer between local playback |
| +// and remoting. |
| +class RemotingRendererController final : public RemotingSourceImpl::Client, |
| + public MediaObserver { |
| + public: |
| + explicit RemotingRendererController( |
| + scoped_refptr<RemotingSourceImpl> remoting_source); |
| + ~RemotingRendererController() override; |
| + |
| + // RemotingSourceImpl::Client implemenations. |
| + void OnStarted(bool success) override; |
| + void OnSessionStateChanged() override; |
| + |
| + // MediaObserver implementations. |
| + void OnEnteredFullscreen() override; |
| + void OnExitedFullscreen() override; |
| + void OnSetCdm(CdmContext* cdm_context) override; |
| + void OnMetadataChanged(const PipelineMetadata& metadata) override; |
| + |
| + using SwitchRendererCallback = base::Callback<void()>; |
|
miu
2016/10/25 04:21:26
This is the same as base::Closure, so consider rem
xjz
2016/10/26 22:00:26
Done.
|
| + void SetSwitchRendererCallback(const SwitchRendererCallback& cb); |
| + |
| + base::WeakPtr<RemotingRendererController> GetWeakPtr() { |
| + return weak_factory_.GetWeakPtr(); |
| + } |
| + |
| + // Used to query whether to create Media Remoting Renderer. |
|
miu
2016/10/25 04:21:26
To help those unfamiliar with this code: s/Used to
xjz
2016/10/26 22:00:26
Done.
|
| + bool IsRemoting() const; |
| + |
| + // Used to query whether the remoting session is permanently terminated. |
|
miu
2016/10/25 04:21:26
ditto: (Used by RemotingRendererFactory)
xjz
2016/10/26 22:00:26
Done.
|
| + bool IsTerminated() const; |
| + |
| + private: |
| + bool IsVideoCodecSupported(); |
| + bool IsAudioCodecSupported(); |
| + |
| + // Helper to decide whether to enter or leave Remoting mode. |
| + bool ShouldBeRemoting(); |
| + |
| + // Determines whether to enter or leave Remoting mode and switches if |
| + // necessary. |
| + void UpdateAndMaybeSwitch(); |
| + |
| + // Indicates if this media element or its ancestor enters full screen. |
|
miu
2016/10/25 04:21:26
s/if/whether/
and
s/enters/is in/
xjz
2016/10/26 22:00:26
Done.
|
| + bool is_fullscreen_ = false; |
| + |
| + // Indicates whether to switch to remoting. |
| + bool should_be_remoting_ = false; |
|
miu
2016/10/25 04:21:26
naming: Based on the way this variable is used, it
xjz
2016/10/26 22:00:26
Done.
|
| + |
| + // Indicates whether remoting session can be started. |
| + bool can_start_remoting_ = false; |
| + |
| + // Indicates whether audio or video is encrypted. |
| + bool is_encrypted_ = false; |
| + |
| + // Current audio/video config. |
| + VideoDecoderConfig video_decoder_config_; |
| + AudioDecoderConfig audio_decoder_config_; |
| + bool has_audio_ = false; |
| + bool has_video_ = false; |
| + |
| + // The callback to switch the media renderer. |
| + SwitchRendererCallback switch_renderer_cb_; |
| + |
| + // This will be replaced by the remoting source in RemotingCdmController |
|
miu
2016/10/25 04:21:26
For clarification: "This is initially the Remoting
xjz
2016/10/26 22:00:26
Done.
|
| + // when OnSetCdm() is called. |
| + scoped_refptr<RemotingSourceImpl> remoting_source_; |
| + |
| + // This is used to check all the methods are called on the current thread in |
| + // debug builds. |
| + base::ThreadChecker thread_checker_; |
| + |
| + base::WeakPtrFactory<RemotingRendererController> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |