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

Side by Side Diff: content/renderer/media/android/media_player_renderer_client.h

Issue 2230583002: Add MediaPlayerRenderer/MediaPlayerRendererClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor comment changes Created 4 years, 4 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 CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_PLAYER_RENDERER_CLIENT_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_PLAYER_RENDERER_CLIENT_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h"
12 #include "media/base/android/stream_texture_wrapper.h"
13 #include "media/base/demuxer_stream_provider.h"
14 #include "media/base/renderer.h"
15 #include "media/base/renderer_client.h"
16 #include "media/base/video_renderer_sink.h"
17 #include "media/mojo/clients/mojo_renderer.h"
18
19 namespace content {
20
21 // MediaPlayerRendererClient lives in Renderer process and mirrors a
22 // MediaPlayerRenderer living in the Browser process.
23 //
24 // It is responsible for forwarding media::Renderer calls from WMPI to the
25 // MediaPlayerRenderer, using |mojo_renderer|. It also manages a StreamTexture,
26 // (via |stream_texture_wrapper_|) and notifies the VideoRendererSink when new
27 // frames are available.
28 //
29 // This class handles all calls on |media_task_runner_|, except for
30 // OnFrameAvailable(), which is called on |compositor_task_runner_|.
31 //
32 // N.B: This class implements media::RendererClient, in order to intercept
33 // OnVideoNaturalSizeChange() events, to update StreamTextureWrapper. All events
34 // (including OnVideoNaturalSizeChange()) are bubbled up to |client_|.
35 class CONTENT_EXPORT MediaPlayerRendererClient : public media::Renderer,
36 public media::RendererClient {
37 public:
38 MediaPlayerRendererClient(
39 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner,
40 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
41 media::MojoRenderer* mojo_renderer,
42 media::ScopedStreamTextureWrapper stream_texture_wrapper,
43 media::VideoRendererSink* sink);
44
45 virtual ~MediaPlayerRendererClient();
46
47 // media::Renderer implementation.
48 void Initialize(media::DemuxerStreamProvider* demuxer_stream_provider,
49 media::RendererClient* client,
50 const media::PipelineStatusCB& init_cb) override;
51 void SetCdm(media::CdmContext* cdm_context,
52 const media::CdmAttachedCB& cdm_attached_cb) override;
53 void Flush(const base::Closure& flush_cb) override;
54 void StartPlayingFrom(base::TimeDelta time) override;
55 void SetPlaybackRate(double playback_rate) override;
56 void SetVolume(float volume) override;
57 base::TimeDelta GetMediaTime() override;
58 bool HasAudio() override;
59 bool HasVideo() override;
60
61 // RendererClient implementation implementation.
watk 2016/08/09 21:39:58 buffalo buffalo buffalo.. media::RendererClient f
tguilbert 2016/08/09 22:38:34 Done.
62 void OnError(media::PipelineStatus status) override;
63 void OnEnded() override;
64 void OnStatisticsUpdate(const media::PipelineStatistics& stats) override;
65 void OnBufferingStateChange(media::BufferingState state) override;
66 void OnWaitingForDecryptionKey() override;
67 void OnVideoNaturalSizeChange(const gfx::Size& size) override;
68 void OnVideoOpacityChange(bool opaque) override;
69
70 // Called on |compositor_task_runner_| whenever |stream_texture_wrapper_| has
71 // a new frame.
72 void OnFrameAvailable();
73
74 private:
75 void InitializeRemoteRenderer(
76 media::DemuxerStreamProvider* demuxer_stream_provider);
77 void CompleteInitialization(media::PipelineStatus status);
78
79 // Used to forward calls to the MediaPlayerRenderer living in the Browser.
80 std::unique_ptr<media::MojoRenderer> mojo_renderer_;
81
82 // Owns the StreamTexture whose surface is used by MediaPlayerRenderer.
83 // Provides the VideoFrames to |sink_|.
84 media::ScopedStreamTextureWrapper stream_texture_wrapper_;
85
86 media::RendererClient* client_;
87
88 media::VideoRendererSink* sink_;
89
90 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
91
92 // Used by |stream_texture_wrapper_| to signal OnFrameAvailable() and to send
93 // VideoFrames to |sink_| on the right thread.
94 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
95
96 media::PipelineStatusCB init_cb_;
97
98 // NOTE: Weak pointers must be invalidated before all other member variables.
99 base::WeakPtrFactory<MediaPlayerRendererClient> weak_factory_;
100
101 DISALLOW_COPY_AND_ASSIGN(MediaPlayerRendererClient);
102 };
103
104 } // namespace content
105
106 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_PLAYER_RENDERER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698