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

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

Issue 2406483002: WIP - Add EME (Closed)
Patch Set: Rebase. Split RemotingSourceImpl. Addressed comments. 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.
miu 2016/10/25 04:21:26 Since remoting_renderer_controller.h/.cc are modif
xjz 2016/10/26 22:00:26 Done.
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_RENDERER_CONTROLLER_H_
6 #define MEDIA_REMOTING_REMOTING_RENDERER_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/remoting/remoting_source_impl.h"
12
13 namespace media {
14 struct PipelineMetadata;
15 }
16
17 namespace media {
18
19 // This class:
20 // 1) Implements the RemotingSourceImpl::Client;
21 // 2) Monitors player events as a MediaObserver;
22 // 3) May trigger the switch of the media renderer between local playback
23 // and remoting.
24 class RemotingRendererController final : public RemotingSourceImpl::Client,
25 public MediaObserver {
26 public:
27 explicit RemotingRendererController(
28 scoped_refptr<RemotingSourceImpl> remoting_source);
29 ~RemotingRendererController() override;
30
31 // RemotingSourceImpl::Client implemenations.
32 void OnStarted(bool success) override;
33 void OnSessionStateChanged() override;
34
35 // MediaObserver implementations.
36 void OnEnteredFullscreen() override;
37 void OnExitedFullscreen() override;
38 void OnSetCdm(CdmContext* cdm_context) override;
39 void OnMetadataChanged(const PipelineMetadata& metadata) override;
40
41 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.
42 void SetSwitchRendererCallback(const SwitchRendererCallback& cb);
43
44 base::WeakPtr<RemotingRendererController> GetWeakPtr() {
45 return weak_factory_.GetWeakPtr();
46 }
47
48 // 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.
49 bool IsRemoting() const;
50
51 // 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.
52 bool IsTerminated() const;
53
54 private:
55 bool IsVideoCodecSupported();
56 bool IsAudioCodecSupported();
57
58 // Helper to decide whether to enter or leave Remoting mode.
59 bool ShouldBeRemoting();
60
61 // Determines whether to enter or leave Remoting mode and switches if
62 // necessary.
63 void UpdateAndMaybeSwitch();
64
65 // 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.
66 bool is_fullscreen_ = false;
67
68 // Indicates whether to switch to remoting.
69 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.
70
71 // Indicates whether remoting session can be started.
72 bool can_start_remoting_ = false;
73
74 // Indicates whether audio or video is encrypted.
75 bool is_encrypted_ = false;
76
77 // Current audio/video config.
78 VideoDecoderConfig video_decoder_config_;
79 AudioDecoderConfig audio_decoder_config_;
80 bool has_audio_ = false;
81 bool has_video_ = false;
82
83 // The callback to switch the media renderer.
84 SwitchRendererCallback switch_renderer_cb_;
85
86 // 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.
87 // when OnSetCdm() is called.
88 scoped_refptr<RemotingSourceImpl> remoting_source_;
89
90 // This is used to check all the methods are called on the current thread in
91 // debug builds.
92 base::ThreadChecker thread_checker_;
93
94 base::WeakPtrFactory<RemotingRendererController> weak_factory_;
95
96 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController);
97 };
98
99 } // namespace media
100
101 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698