Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: media/remoting/remoting_controller.h

Issue 2389473002: Media Remoting: Add RemotingController. (Closed)
Patch Set: Fix bug on Android. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #ifndef MEDIA_REMOTING_REMOTING_CONTROLLER_H_
6 #define MEDIA_REMOTING_REMOTING_CONTROLLER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "media/base/media_observer.h"
11 #include "media/mojo/interfaces/remoting.mojom.h"
12 #include "mojo/public/cpp/bindings/binding.h"
13
14 // This class does the following:
15 // 1) Sends/Receives messages from/to Remoter;
16 // 2) Monitors player events as a MediaObserver;
17 // 3) May trigger the switch of the media renderer between local playback
18 // and remoting.
19 //
20 namespace media {
21
22 class RemotingController final : public MediaObserver,
23 public mojom::RemotingSource {
24 public:
25 explicit RemotingController(mojom::RemotingSourceRequest source_request,
26 mojom::RemoterPtr remoter);
xhwang 2016/10/04 06:30:30 no need for "explicit" now
xjz 2016/10/04 19:21:29 Done.
27 ~RemotingController() override;
28
29 // RemotingSource implementations.
30 void OnSinkAvailable() override;
31 void OnSinkGone() override;
32 void OnStarted() override;
33 void OnStartFailed(mojom::RemotingStartFailReason reason) override;
34 void OnMessageFromSink(const std::vector<uint8_t>& message) override;
35 void OnStopped(mojom::RemotingStopReason reason) override;
36
37 // MediaObserver implementation.
xhwang 2016/10/04 06:30:30 nit: You use "implementations" above but use "impl
xjz 2016/10/04 19:21:30 Done.
38 // This is called when the video element or its ancestor enters full screen.
39 // We currently use this as an indicator for immersive playback. May add other
40 // criteria (e.g. the actual display width/height of the video element) in
41 // future.
42 void OnEnteredFullscreen() override;
43 void OnExitedFullscreen() override;
44 void OnSetCdm(CdmContext* cdm_context) override;
45 void OnMetadata(const PipelineMetadata& metadata) override;
46
47 using SwitchRendererCallback = base::Callback<void()>;
48 void SetSwitchRenderCallback(const SwitchRendererCallback& cb);
xhwang 2016/10/04 06:30:30 nit: It should be SetSwitchRendererCallback
xjz 2016/10/04 19:21:29 Done.
49
50 // Tells which renderer should be used.
51 bool is_remoting() const {
52 DCHECK(task_runner_->BelongsToCurrentThread());
53 return is_remoting_;
54 }
55
56 base::WeakPtr<RemotingController> GetWeakPtr() {
57 return weak_factory_.GetWeakPtr();
58 }
59
60 private:
61 bool IsVideoConfigSupported();
62 bool IsAudioConfigSupported();
63
64 // Determines whether to enter or leave Remoting mode and switches if
65 // necessary.
66 void UpdateAndMaybeSwitch();
67
68 // Indicates if this media element or its ancestor enters full screen.
69 bool is_fullscreen_;
70
71 // Indicates the remoting sink availablity.
72 bool is_sink_available_;
73
74 // Indicates if remoting is started.
75 bool is_remoting_;
76
77 // Current audio/video config.
78 VideoDecoderConfig video_decoder_config_;
79 AudioDecoderConfig audio_decoder_config_;
80 bool has_audio_;
81 bool has_video_;
82
83 // The callback to switch the media renderer.
84 SwitchRendererCallback switch_renderer_cb_;
85
86 mojo::Binding<mojom::RemotingSource> binding_;
87 mojom::RemoterPtr remoter_;
88
89 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
xhwang 2016/10/04 06:30:30 forward declare base::SingleThreadTaskRunner?
xjz 2016/10/04 19:21:30 Done.
90
91 base::WeakPtrFactory<RemotingController> weak_factory_;
92
93 DISALLOW_COPY_AND_ASSIGN(RemotingController);
94 };
95
96 } // namespace media
97
98 #endif // MEDIA_REMOTING_REMOTING_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698