| Index: media/remoting/remoting_controller.h
|
| diff --git a/media/remoting/remoting_controller.h b/media/remoting/remoting_controller.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5120d3dc59caaa6b71d51504b976a8d450157865
|
| --- /dev/null
|
| +++ b/media/remoting/remoting_controller.h
|
| @@ -0,0 +1,87 @@
|
| +// 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_REMOTING_REMOTING_CONTROLLER_H_
|
| +#define MEDIA_REMOTING_REMOTING_CONTROLLER_H_
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "media/base/mediaplayer_observer.h"
|
| +#include "media/mojo/interfaces/remoting.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +
|
| +// This class does the following:
|
| +// 1) Sends/Receives messages from/to Remoter;
|
| +// 2) Monitors player events as a MediaPlayerObserver;
|
| +// 3) May trigger the switch of the media renderer between local playback
|
| +// and remoting.
|
| +//
|
| +namespace media {
|
| +
|
| +class MEDIA_EXPORT RemotingController final : public MediaPlayerObserver,
|
| + public mojom::RemotingSource {
|
| + public:
|
| + // |remoter_factory| is just being used to create a Remoter and need not
|
| + // remain valid after the constructor returns.
|
| + explicit RemotingController(mojom::RemoterFactory* remoter_factory);
|
| + ~RemotingController() override;
|
| +
|
| + // RemotingSource implementations.
|
| + void OnSinkAvailable() override;
|
| + void OnSinkGone() override;
|
| + void OnStarted() override;
|
| + void OnStartFailed(mojom::RemotingStartFailReason reason) override;
|
| + void OnMessageFromSink(const std::vector<uint8_t>& message) override;
|
| + void OnStopped(mojom::RemotingStopReason reson) override;
|
| +
|
| + // MediaPlayerObserver implementation.
|
| + void OnEnteredFullscreen() override;
|
| + void OnExitedFullscreen() override;
|
| + void OnSetCdm(CdmContext* cdm_context) override;
|
| + void OnDecoderConfigChanged(const AudioDecoderConfig& audio_config,
|
| + const VideoDecoderConfig& video_config) override;
|
| + using SwitchRendererCallback = base::Callback<void()>;
|
| + void SetSwitchRenderCallback(const SwitchRendererCallback& cb);
|
| +
|
| + // Tells which renderer should be used.
|
| + bool is_remoting() const {
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| + return is_remoting_;
|
| + }
|
| +
|
| + private:
|
| + bool isVideoConfigSupported();
|
| + bool isAudioConfigSupported();
|
| +
|
| + // Determines whether to enter or leave Remoting mode and switches if
|
| + // necessary.
|
| + void Update();
|
| +
|
| + // Indicates if this media element or its ancestor enters full screen.
|
| + bool is_fullscreen_;
|
| +
|
| + // Indicates the remoting sink availablity.
|
| + bool is_sink_available_;
|
| +
|
| + // Indicates if remoting is started.
|
| + bool is_remoting_;
|
| +
|
| + // Current audio/video config.
|
| + VideoDecoderConfig video_decoder_config_;
|
| + AudioDecoderConfig audio_decoder_config_;
|
| +
|
| + // The callback to switch the media renderer.
|
| + SwitchRendererCallback switch_renderer_cb_;
|
| +
|
| + mojo::Binding<mojom::RemotingSource> binding_;
|
| + mojom::RemoterPtr remoter_;
|
| +
|
| + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RemotingController);
|
| +};
|
| +
|
| +} // namespace media
|
| +
|
| +#endif // MEDIA_REMOTING_REMOTING_CONTROLLER_H_
|
|
|