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 #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/mediaplayer_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 MediaPlayerObserver; | |
17 // 3) May trigger the switch of the media renderer between local playback | |
18 // and remoting. | |
19 // | |
20 namespace media { | |
21 | |
22 class MEDIA_EXPORT RemotingController final : public MediaPlayerObserver, | |
xhwang
2016/10/01 07:12:15
You should NOT use MEDIA_EXPORT since this class d
xjz
2016/10/03 22:31:09
Done.
| |
23 public mojom::RemotingSource { | |
24 public: | |
25 // |remoter_factory| is just being used to create a Remoter and need not | |
26 // remain valid after the constructor returns. | |
xhwang
2016/10/01 07:12:15
It's a bit odd that you pass in a factory and use
xjz
2016/10/03 22:31:08
Done.
| |
27 explicit RemotingController(mojom::RemoterFactory* remoter_factory); | |
28 ~RemotingController() override; | |
29 | |
30 // RemotingSource implementations. | |
31 void OnSinkAvailable() override; | |
32 void OnSinkGone() override; | |
33 void OnStarted() override; | |
34 void OnStartFailed(mojom::RemotingStartFailReason reason) override; | |
35 void OnMessageFromSink(const std::vector<uint8_t>& message) override; | |
36 void OnStopped(mojom::RemotingStopReason reson) override; | |
xhwang
2016/10/01 07:12:15
s/reson/reason
xjz
2016/10/03 22:31:09
Done.
| |
37 | |
38 // MediaPlayerObserver implementation. | |
39 void OnEnteredFullscreen() override; | |
40 void OnExitedFullscreen() override; | |
41 void OnSetCdm(CdmContext* cdm_context) override; | |
42 void OnDecoderConfigChanged(const AudioDecoderConfig& audio_config, | |
43 const VideoDecoderConfig& video_config) override; | |
xhwang
2016/10/01 07:12:15
nit: empty line here
xjz
2016/10/03 22:31:09
Done.
| |
44 using SwitchRendererCallback = base::Callback<void()>; | |
45 void SetSwitchRenderCallback(const SwitchRendererCallback& cb); | |
46 | |
47 // Tells which renderer should be used. | |
48 bool is_remoting() const { | |
49 DCHECK(task_runner_->BelongsToCurrentThread()); | |
50 return is_remoting_; | |
51 } | |
52 | |
53 private: | |
54 bool isVideoConfigSupported(); | |
55 bool isAudioConfigSupported(); | |
xhwang
2016/10/01 07:12:15
nit: s/is/Is
xjz
2016/10/03 22:31:08
Done.
| |
56 | |
57 // Determines whether to enter or leave Remoting mode and switches if | |
58 // necessary. | |
59 void Update(); | |
xhwang
2016/10/01 07:12:15
nit: this function name seems too generic and does
xjz
2016/10/03 22:31:09
Renamed as UpdateAndMaybeSwitch.
| |
60 | |
61 // Indicates if this media element or its ancestor enters full screen. | |
62 bool is_fullscreen_; | |
xhwang
2016/10/01 07:12:15
nit: you can specify default value here, but diffe
xjz
2016/10/03 22:31:09
Leave it with the constructor. :)
| |
63 | |
64 // Indicates the remoting sink availablity. | |
65 bool is_sink_available_; | |
66 | |
67 // Indicates if remoting is started. | |
68 bool is_remoting_; | |
69 | |
70 // Current audio/video config. | |
71 VideoDecoderConfig video_decoder_config_; | |
72 AudioDecoderConfig audio_decoder_config_; | |
73 | |
74 // The callback to switch the media renderer. | |
75 SwitchRendererCallback switch_renderer_cb_; | |
76 | |
77 mojo::Binding<mojom::RemotingSource> binding_; | |
78 mojom::RemoterPtr remoter_; | |
79 | |
80 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
xhwang
2016/10/01 07:12:15
Looks like this class single threaded? If so, add
xjz
2016/10/03 22:31:09
In the up-coming changes, we may need to add media
xhwang
2016/10/04 06:30:29
Please still add a comment about the threading mod
xjz
2016/10/04 19:21:28
Added a TODO comment.
| |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(RemotingController); | |
83 }; | |
84 | |
85 } // namespace media | |
86 | |
87 #endif // MEDIA_REMOTING_REMOTING_CONTROLLER_H_ | |
OLD | NEW |