OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 6 #define CONTENT_RENDERER_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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // | 51 // |
52 // blink::WebMediaPlayerClient | 52 // blink::WebMediaPlayerClient |
53 // WebKit client of this media player object. | 53 // WebKit client of this media player object. |
54 class WebMediaPlayerMS | 54 class WebMediaPlayerMS |
55 : public blink::WebMediaPlayer, | 55 : public blink::WebMediaPlayer, |
56 public cc::VideoFrameProvider, | 56 public cc::VideoFrameProvider, |
57 public base::SupportsWeakPtr<WebMediaPlayerMS> { | 57 public base::SupportsWeakPtr<WebMediaPlayerMS> { |
58 public: | 58 public: |
59 // Construct a WebMediaPlayerMS with reference to the client, and | 59 // Construct a WebMediaPlayerMS with reference to the client, and |
60 // a MediaStreamClient which provides VideoFrameProvider. | 60 // a MediaStreamClient which provides VideoFrameProvider. |
61 WebMediaPlayerMS(blink::WebFrame* frame, | 61 WebMediaPlayerMS( |
62 blink::WebMediaPlayerClient* client, | 62 blink::WebFrame* frame, |
63 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 63 blink::WebMediaPlayerClient* client, |
64 media::MediaLog* media_log, | 64 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
65 scoped_ptr<MediaStreamRendererFactory> factory); | 65 media::MediaLog* media_log, |
| 66 scoped_ptr<MediaStreamRendererFactory> factory, |
| 67 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread); |
| 68 |
66 virtual ~WebMediaPlayerMS(); | 69 virtual ~WebMediaPlayerMS(); |
67 | 70 |
68 virtual void load(LoadType load_type, | 71 virtual void load(LoadType load_type, |
69 const blink::WebURL& url, | 72 const blink::WebURL& url, |
70 CORSMode cors_mode); | 73 CORSMode cors_mode); |
71 | 74 |
72 // Playback controls. | 75 // Playback controls. |
73 virtual void play(); | 76 virtual void play(); |
74 virtual void pause(); | 77 virtual void pause(); |
75 virtual bool supportsSave() const; | 78 virtual bool supportsSave() const; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 void OnSourceError(); | 147 void OnSourceError(); |
145 | 148 |
146 // Helpers that set the network/ready state and notifies the client if | 149 // Helpers that set the network/ready state and notifies the client if |
147 // they've changed. | 150 // they've changed. |
148 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 151 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
149 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 152 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
150 | 153 |
151 // Getter method to |client_|. | 154 // Getter method to |client_|. |
152 blink::WebMediaPlayerClient* GetClient(); | 155 blink::WebMediaPlayerClient* GetClient(); |
153 | 156 |
| 157 static void StopVideoFrameProviderAndWakeUpHelper( |
| 158 cc::VideoFrameProvider::Client* client, |
| 159 base::WaitableEvent* event); |
| 160 static void StopVideoFrameProviderHelper( |
| 161 cc::VideoFrameProvider::Client* client); |
| 162 static void StartRenderingHelper(cc::VideoFrameProvider::Client* client); |
| 163 static void StopRenderingHelper(cc::VideoFrameProvider::Client* client); |
| 164 |
154 blink::WebFrame* frame_; | 165 blink::WebFrame* frame_; |
155 | 166 |
156 blink::WebMediaPlayer::NetworkState network_state_; | 167 blink::WebMediaPlayer::NetworkState network_state_; |
157 blink::WebMediaPlayer::ReadyState ready_state_; | 168 blink::WebMediaPlayer::ReadyState ready_state_; |
158 | 169 |
159 blink::WebTimeRanges buffered_; | 170 blink::WebTimeRanges buffered_; |
160 | 171 |
161 float volume_; | 172 float volume_; |
162 | 173 |
163 // Used for DCHECKs to ensure methods calls executed in the correct thread. | 174 // Used for DCHECKs to ensure methods calls executed in the correct thread. |
(...skipping 21 matching lines...) Expand all Loading... |
185 base::Lock current_frame_lock_; | 196 base::Lock current_frame_lock_; |
186 | 197 |
187 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; | 198 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; |
188 | 199 |
189 // A pointer back to the compositor to inform it about state changes. This is | 200 // A pointer back to the compositor to inform it about state changes. This is |
190 // not NULL while the compositor is actively using this webmediaplayer. | 201 // not NULL while the compositor is actively using this webmediaplayer. |
191 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 202 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
192 | 203 |
193 bool received_first_frame_; | 204 bool received_first_frame_; |
194 base::TimeDelta current_time_; | 205 base::TimeDelta current_time_; |
| 206 base::TimeTicks last_deadline_max_; |
195 unsigned total_frame_count_; | 207 unsigned total_frame_count_; |
196 unsigned dropped_frame_count_; | 208 unsigned dropped_frame_count_; |
197 media::SkCanvasVideoRenderer video_renderer_; | 209 media::SkCanvasVideoRenderer video_renderer_; |
198 | 210 |
199 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; | 211 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; |
200 | 212 |
201 scoped_refptr<media::MediaLog> media_log_; | 213 scoped_refptr<media::MediaLog> media_log_; |
202 | 214 |
203 scoped_ptr<MediaStreamRendererFactory> renderer_factory_; | 215 scoped_ptr<MediaStreamRendererFactory> renderer_factory_; |
204 | 216 |
| 217 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_; |
| 218 base::WaitableEvent wait_event_; |
| 219 |
205 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 220 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); |
206 }; | 221 }; |
207 | 222 |
208 } // namespace content | 223 } // namespace content |
209 | 224 |
210 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 225 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
OLD | NEW |