OLD | NEW |
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 public cc::VideoFrameProvider, |
50 public base::SupportsWeakPtr<WebMediaPlayerMS> { | 56 public base::SupportsWeakPtr<WebMediaPlayerMS> { |
51 public: | 57 public: |
52 // Construct a WebMediaPlayerMS with reference to the client, and | 58 // Construct a WebMediaPlayerMS with reference to the client, and |
53 // a MediaStreamClient which provides VideoFrameProvider. | 59 // a MediaStreamClient which provides VideoFrameProvider. |
54 WebMediaPlayerMS(WebKit::WebFrame* frame, | 60 WebMediaPlayerMS(WebKit::WebFrame* frame, |
55 WebKit::WebMediaPlayerClient* client, | 61 WebKit::WebMediaPlayerClient* client, |
56 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 62 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
57 MediaStreamClient* media_stream_client, | 63 MediaStreamClient* media_stream_client, |
58 media::MediaLog* media_log); | 64 media::MediaLog* media_log); |
59 virtual ~WebMediaPlayerMS(); | 65 virtual ~WebMediaPlayerMS(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 virtual bool didPassCORSAccessCheck() const OVERRIDE; | 119 virtual bool didPassCORSAccessCheck() const OVERRIDE; |
114 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const OVERRIDE; | 120 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const OVERRIDE; |
115 | 121 |
116 virtual float mediaTimeForTimeValue(float timeValue) const OVERRIDE; | 122 virtual float mediaTimeForTimeValue(float timeValue) const OVERRIDE; |
117 | 123 |
118 virtual unsigned decodedFrameCount() const OVERRIDE; | 124 virtual unsigned decodedFrameCount() const OVERRIDE; |
119 virtual unsigned droppedFrameCount() const OVERRIDE; | 125 virtual unsigned droppedFrameCount() const OVERRIDE; |
120 virtual unsigned audioDecodedByteCount() const OVERRIDE; | 126 virtual unsigned audioDecodedByteCount() const OVERRIDE; |
121 virtual unsigned videoDecodedByteCount() const OVERRIDE; | 127 virtual unsigned videoDecodedByteCount() const OVERRIDE; |
122 | 128 |
123 virtual WebKit::WebVideoFrame* getCurrentFrame() OVERRIDE; | 129 // VideoFrameProvider implementation. |
124 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame) OVERRIDE; | 130 virtual void SetVideoFrameProviderClient( |
| 131 cc::VideoFrameProvider::Client* client) OVERRIDE; |
| 132 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE; |
| 133 virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame) |
| 134 OVERRIDE; |
125 | 135 |
126 private: | 136 private: |
127 // The callback for VideoFrameProvider to signal a new frame is available. | 137 // The callback for VideoFrameProvider to signal a new frame is available. |
128 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); | 138 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); |
129 // Need repaint due to state change. | 139 // Need repaint due to state change. |
130 void RepaintInternal(); | 140 void RepaintInternal(); |
131 | 141 |
132 // The callback for source to report error. | 142 // The callback for source to report error. |
133 void OnSourceError(); | 143 void OnSourceError(); |
134 | 144 |
(...skipping 13 matching lines...) Expand all Loading... |
148 WebKit::WebTimeRanges buffered_; | 158 WebKit::WebTimeRanges buffered_; |
149 | 159 |
150 // Used for DCHECKs to ensure methods calls executed in the correct thread. | 160 // Used for DCHECKs to ensure methods calls executed in the correct thread. |
151 base::ThreadChecker thread_checker_; | 161 base::ThreadChecker thread_checker_; |
152 | 162 |
153 WebKit::WebMediaPlayerClient* client_; | 163 WebKit::WebMediaPlayerClient* client_; |
154 | 164 |
155 base::WeakPtr<WebMediaPlayerDelegate> delegate_; | 165 base::WeakPtr<WebMediaPlayerDelegate> delegate_; |
156 | 166 |
157 MediaStreamClient* media_stream_client_; | 167 MediaStreamClient* media_stream_client_; |
158 scoped_refptr<VideoFrameProvider> video_frame_provider_; | 168 scoped_refptr<webkit_media::VideoFrameProvider> video_frame_provider_; |
159 bool paused_; | 169 bool paused_; |
| 170 |
160 // |current_frame_| is updated only on main thread. | 171 // |current_frame_| is updated only on main thread. |
161 scoped_refptr<media::VideoFrame> current_frame_; | 172 scoped_refptr<media::VideoFrame> current_frame_; |
162 // |current_frame_used_| is updated on both main and compositing thread. | 173 // |current_frame_used_| is updated on both main and compositing thread. |
163 // It's used to track whether |current_frame_| was painted for detecting | 174 // It's used to track whether |current_frame_| was painted for detecting |
164 // when to increase |dropped_frame_count_|. | 175 // when to increase |dropped_frame_count_|. |
165 bool current_frame_used_; | 176 bool current_frame_used_; |
166 base::Lock current_frame_lock_; | 177 base::Lock current_frame_lock_; |
167 bool pending_repaint_; | 178 bool pending_repaint_; |
| 179 |
| 180 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
| 181 |
| 182 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 183 |
168 bool received_first_frame_; | 184 bool received_first_frame_; |
169 bool sequence_started_; | 185 bool sequence_started_; |
170 base::TimeDelta start_time_; | 186 base::TimeDelta start_time_; |
171 unsigned total_frame_count_; | 187 unsigned total_frame_count_; |
172 unsigned dropped_frame_count_; | 188 unsigned dropped_frame_count_; |
173 media::SkCanvasVideoRenderer video_renderer_; | 189 media::SkCanvasVideoRenderer video_renderer_; |
174 | 190 |
175 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; | 191 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; |
176 | 192 |
177 scoped_refptr<media::MediaLog> media_log_; | 193 scoped_refptr<media::MediaLog> media_log_; |
178 | 194 |
179 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 195 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); |
180 }; | 196 }; |
181 | 197 |
182 } // namespace webkit_media | 198 } // namespace webkit_media |
183 | 199 |
184 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_ | 200 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_ |
OLD | NEW |