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

Side by Side Diff: webkit/media/webmediaplayer_ms.h

Issue 12676004: Move ownership of cc:VideoLayer to webkit/media (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « webkit/media/webmediaplayer_impl.cc ('k') | webkit/media/webmediaplayer_ms.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_ 5 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_
6 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_ 6 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "cc/layers/video_frame_provider.h"
12 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
13 #include "media/filters/skcanvas_video_renderer.h" 14 #include "media/filters/skcanvas_video_renderer.h"
14 #include "skia/ext/platform_canvas.h" 15 #include "skia/ext/platform_canvas.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
16 17
17 namespace WebKit { 18 namespace WebKit {
18 class WebFrame; 19 class WebFrame;
19 class WebMediaPlayerClient; 20 class WebMediaPlayerClient;
20 class WebVideoFrame; 21 class WebVideoFrame;
21 } 22 }
22 23
23 namespace media { 24 namespace media {
24 class MediaLog; 25 class MediaLog;
25 } 26 }
26 27
28 namespace webkit {
29 class WebLayerImpl;
30 }
31
27 namespace webkit_media { 32 namespace webkit_media {
28 33
29 class MediaStreamAudioRenderer; 34 class MediaStreamAudioRenderer;
30 class MediaStreamClient; 35 class MediaStreamClient;
31 class VideoFrameProvider; 36 class VideoFrameProvider;
32 class WebMediaPlayerDelegate; 37 class WebMediaPlayerDelegate;
33 38
34 // WebMediaPlayerMS delegates calls from WebCore::MediaPlayerPrivate to 39 // WebMediaPlayerMS delegates calls from WebCore::MediaPlayerPrivate to
35 // Chrome's media player when "src" is from media stream. 40 // Chrome's media player when "src" is from media stream.
36 // 41 //
37 // WebMediaPlayerMS works with multiple objects, the most important ones are: 42 // WebMediaPlayerMS works with multiple objects, the most important ones are:
38 // 43 //
39 // VideoFrameProvider 44 // VideoFrameProvider
40 // provides video frames for rendering. 45 // provides video frames for rendering.
41 // 46 //
42 // TODO(wjia): add AudioPlayer. 47 // TODO(wjia): add AudioPlayer.
43 // AudioPlayer 48 // AudioPlayer
44 // plays audio streams. 49 // plays audio streams.
45 // 50 //
46 // WebKit::WebMediaPlayerClient 51 // WebKit::WebMediaPlayerClient
47 // WebKit client of this media player object. 52 // WebKit client of this media player object.
48 class WebMediaPlayerMS 53 class WebMediaPlayerMS
49 : public WebKit::WebMediaPlayer, 54 : public WebKit::WebMediaPlayer,
55 #ifdef REMOVE_WEBVIDEOFRAME
56 public cc::VideoFrameProvider,
57 #endif
50 public base::SupportsWeakPtr<WebMediaPlayerMS> { 58 public base::SupportsWeakPtr<WebMediaPlayerMS> {
51 public: 59 public:
52 // Construct a WebMediaPlayerMS with reference to the client, and 60 // Construct a WebMediaPlayerMS with reference to the client, and
53 // a MediaStreamClient which provides VideoFrameProvider. 61 // a MediaStreamClient which provides VideoFrameProvider.
54 WebMediaPlayerMS(WebKit::WebFrame* frame, 62 WebMediaPlayerMS(WebKit::WebFrame* frame,
55 WebKit::WebMediaPlayerClient* client, 63 WebKit::WebMediaPlayerClient* client,
56 base::WeakPtr<WebMediaPlayerDelegate> delegate, 64 base::WeakPtr<WebMediaPlayerDelegate> delegate,
57 MediaStreamClient* media_stream_client, 65 MediaStreamClient* media_stream_client,
58 media::MediaLog* media_log); 66 media::MediaLog* media_log);
59 virtual ~WebMediaPlayerMS(); 67 virtual ~WebMediaPlayerMS();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 virtual bool didPassCORSAccessCheck() const OVERRIDE; 121 virtual bool didPassCORSAccessCheck() const OVERRIDE;
114 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const OVERRIDE; 122 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const OVERRIDE;
115 123
116 virtual float mediaTimeForTimeValue(float timeValue) const OVERRIDE; 124 virtual float mediaTimeForTimeValue(float timeValue) const OVERRIDE;
117 125
118 virtual unsigned decodedFrameCount() const OVERRIDE; 126 virtual unsigned decodedFrameCount() const OVERRIDE;
119 virtual unsigned droppedFrameCount() const OVERRIDE; 127 virtual unsigned droppedFrameCount() const OVERRIDE;
120 virtual unsigned audioDecodedByteCount() const OVERRIDE; 128 virtual unsigned audioDecodedByteCount() const OVERRIDE;
121 virtual unsigned videoDecodedByteCount() const OVERRIDE; 129 virtual unsigned videoDecodedByteCount() const OVERRIDE;
122 130
131 #ifndef REMOVE_WEBVIDEOFRAME
123 virtual WebKit::WebVideoFrame* getCurrentFrame() OVERRIDE; 132 virtual WebKit::WebVideoFrame* getCurrentFrame() OVERRIDE;
124 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame) OVERRIDE; 133 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame) OVERRIDE;
134 #else
135 // VideoFrameProvider implementation.
136 virtual void SetVideoFrameProviderClient(
137 cc::VideoFrameProvider::Client* client) OVERRIDE;
138 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE;
139 virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame)
140 OVERRIDE;
141 #endif
125 142
126 private: 143 private:
127 // The callback for VideoFrameProvider to signal a new frame is available. 144 // The callback for VideoFrameProvider to signal a new frame is available.
128 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); 145 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame);
129 // Need repaint due to state change. 146 // Need repaint due to state change.
130 void RepaintInternal(); 147 void RepaintInternal();
131 148
132 // The callback for source to report error. 149 // The callback for source to report error.
133 void OnSourceError(); 150 void OnSourceError();
134 151
(...skipping 13 matching lines...) Expand all
148 WebKit::WebTimeRanges buffered_; 165 WebKit::WebTimeRanges buffered_;
149 166
150 // Used for DCHECKs to ensure methods calls executed in the correct thread. 167 // Used for DCHECKs to ensure methods calls executed in the correct thread.
151 base::ThreadChecker thread_checker_; 168 base::ThreadChecker thread_checker_;
152 169
153 WebKit::WebMediaPlayerClient* client_; 170 WebKit::WebMediaPlayerClient* client_;
154 171
155 base::WeakPtr<WebMediaPlayerDelegate> delegate_; 172 base::WeakPtr<WebMediaPlayerDelegate> delegate_;
156 173
157 MediaStreamClient* media_stream_client_; 174 MediaStreamClient* media_stream_client_;
158 scoped_refptr<VideoFrameProvider> video_frame_provider_; 175 scoped_refptr<webkit_media::VideoFrameProvider> video_frame_provider_;
159 bool paused_; 176 bool paused_;
160 // |current_frame_| is updated only on main thread. 177
178 // |current_frame_| is updated only on main thread. The object it holds
179 // can be freed on the compositor thread if it is the last to hold a
180 // reference but media::VideoFrame is a thread-safe ref-pointer.
161 scoped_refptr<media::VideoFrame> current_frame_; 181 scoped_refptr<media::VideoFrame> current_frame_;
162 // |current_frame_used_| is updated on both main and compositing thread. 182 // |current_frame_used_| is updated on both main and compositing thread.
163 // It's used to track whether |current_frame_| was painted for detecting 183 // It's used to track whether |current_frame_| was painted for detecting
164 // when to increase |dropped_frame_count_|. 184 // when to increase |dropped_frame_count_|.
165 bool current_frame_used_; 185 bool current_frame_used_;
166 base::Lock current_frame_lock_; 186 base::Lock current_frame_lock_;
167 bool pending_repaint_; 187 bool pending_repaint_;
188
189 scoped_ptr<webkit::WebLayerImpl> video_weblayer_;
190
191 // A pointer back to the compositor to inform it about state changes. This is
192 // not NULL while the compositor is actively using this webmediaplayer.
193 cc::VideoFrameProvider::Client* video_frame_provider_client_;
194
168 bool received_first_frame_; 195 bool received_first_frame_;
169 bool sequence_started_; 196 bool sequence_started_;
170 base::TimeDelta start_time_; 197 base::TimeDelta start_time_;
171 unsigned total_frame_count_; 198 unsigned total_frame_count_;
172 unsigned dropped_frame_count_; 199 unsigned dropped_frame_count_;
173 media::SkCanvasVideoRenderer video_renderer_; 200 media::SkCanvasVideoRenderer video_renderer_;
174 201
175 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; 202 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_;
176 203
177 scoped_refptr<media::MediaLog> media_log_; 204 scoped_refptr<media::MediaLog> media_log_;
178 205
179 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); 206 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS);
180 }; 207 };
181 208
182 } // namespace webkit_media 209 } // namespace webkit_media
183 210
184 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_ 211 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_
OLDNEW
« no previous file with comments | « webkit/media/webmediaplayer_impl.cc ('k') | webkit/media/webmediaplayer_ms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698