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 // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. | 5 // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. |
6 // It contains Pipeline which is the actual media player pipeline, it glues | 6 // It contains Pipeline which is the actual media player pipeline, it glues |
7 // the media player pipeline, data source, audio renderer and renderer. | 7 // the media player pipeline, data source, audio renderer and renderer. |
8 // Pipeline would creates multiple threads and access some public methods | 8 // Pipeline would creates multiple threads and access some public methods |
9 // of this class, so we need to be extra careful about concurrent access of | 9 // of this class, so we need to be extra careful about concurrent access of |
10 // methods and members. | 10 // methods and members. |
11 // | 11 // |
12 // Other issues: | 12 // Other issues: |
13 // During tear down of the whole browser or a tab, the DOM tree may not be | 13 // During tear down of the whole browser or a tab, the DOM tree may not be |
14 // destructed nicely, and there will be some dangling media threads trying to | 14 // destructed nicely, and there will be some dangling media threads trying to |
15 // the main thread, so we need this class to listen to destruction event of the | 15 // the main thread, so we need this class to listen to destruction event of the |
16 // main thread and cleanup the media threads when the even is received. Also | 16 // main thread and cleanup the media threads when the even is received. Also |
17 // at destruction of this class we will need to unhook it from destruction event | 17 // at destruction of this class we will need to unhook it from destruction event |
18 // list of the main thread. | 18 // list of the main thread. |
19 | 19 |
20 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 20 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
21 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 21 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
22 | 22 |
23 #include <string> | 23 #include <string> |
24 | 24 |
25 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
26 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
27 #include "base/memory/weak_ptr.h" | 27 #include "base/memory/weak_ptr.h" |
28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
| 29 #include "cc/layers/video_frame_provider.h" |
29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
30 #include "media/base/audio_renderer_sink.h" | 31 #include "media/base/audio_renderer_sink.h" |
31 #include "media/base/decryptor.h" | 32 #include "media/base/decryptor.h" |
32 #include "media/base/pipeline.h" | 33 #include "media/base/pipeline.h" |
33 #include "media/filters/skcanvas_video_renderer.h" | 34 #include "media/filters/skcanvas_video_renderer.h" |
34 #include "skia/ext/platform_canvas.h" | 35 #include "skia/ext/platform_canvas.h" |
35 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 36 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
r.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
r.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.
h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.
h" |
39 #include "webkit/media/crypto/key_systems.h" | 40 #include "webkit/media/crypto/key_systems.h" |
40 #include "webkit/media/crypto/proxy_decryptor.h" | 41 #include "webkit/media/crypto/proxy_decryptor.h" |
41 | 42 |
42 class RenderAudioSourceProvider; | 43 class RenderAudioSourceProvider; |
43 | 44 |
44 namespace WebKit { | 45 namespace WebKit { |
45 class WebFrame; | 46 class WebFrame; |
46 } | 47 } |
47 | 48 |
48 namespace base { | 49 namespace base { |
49 class MessageLoopProxy; | 50 class MessageLoopProxy; |
50 } | 51 } |
51 | 52 |
52 namespace media { | 53 namespace media { |
53 class ChunkDemuxer; | 54 class ChunkDemuxer; |
54 class MediaLog; | 55 class MediaLog; |
55 } | 56 } |
56 | 57 |
| 58 namespace webkit { |
| 59 class WebLayerImpl; |
| 60 } |
| 61 |
57 namespace webkit_media { | 62 namespace webkit_media { |
58 | 63 |
59 class BufferedDataSource; | 64 class BufferedDataSource; |
60 class MediaStreamClient; | 65 class MediaStreamClient; |
61 class WebAudioSourceProviderImpl; | 66 class WebAudioSourceProviderImpl; |
62 class WebMediaPlayerDelegate; | 67 class WebMediaPlayerDelegate; |
63 class WebMediaPlayerParams; | 68 class WebMediaPlayerParams; |
64 | 69 |
65 class WebMediaPlayerImpl | 70 class WebMediaPlayerImpl |
66 : public WebKit::WebMediaPlayer, | 71 : public WebKit::WebMediaPlayer, |
| 72 #ifdef REMOVE_WEBVIDEOFRAME |
| 73 public cc::VideoFrameProvider, |
| 74 #endif |
67 public MessageLoop::DestructionObserver, | 75 public MessageLoop::DestructionObserver, |
68 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 76 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
69 public: | 77 public: |
70 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 78 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
71 // | 79 // |
72 // |delegate| may be null. | 80 // |delegate| may be null. |
73 WebMediaPlayerImpl( | 81 WebMediaPlayerImpl( |
74 WebKit::WebFrame* frame, | 82 WebKit::WebFrame* frame, |
75 WebKit::WebMediaPlayerClient* client, | 83 WebKit::WebMediaPlayerClient* client, |
76 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 84 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 virtual bool didPassCORSAccessCheck() const; | 142 virtual bool didPassCORSAccessCheck() const; |
135 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; | 143 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; |
136 | 144 |
137 virtual float mediaTimeForTimeValue(float timeValue) const; | 145 virtual float mediaTimeForTimeValue(float timeValue) const; |
138 | 146 |
139 virtual unsigned decodedFrameCount() const; | 147 virtual unsigned decodedFrameCount() const; |
140 virtual unsigned droppedFrameCount() const; | 148 virtual unsigned droppedFrameCount() const; |
141 virtual unsigned audioDecodedByteCount() const; | 149 virtual unsigned audioDecodedByteCount() const; |
142 virtual unsigned videoDecodedByteCount() const; | 150 virtual unsigned videoDecodedByteCount() const; |
143 | 151 |
| 152 #ifndef REMOVE_WEBVIDEOFRAME |
144 virtual WebKit::WebVideoFrame* getCurrentFrame(); | 153 virtual WebKit::WebVideoFrame* getCurrentFrame(); |
145 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame); | 154 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame); |
| 155 #else |
| 156 // cc::VideoFrameProvider implementation. |
| 157 virtual void SetVideoFrameProviderClient( |
| 158 cc::VideoFrameProvider::Client* client) OVERRIDE; |
| 159 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE; |
| 160 virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame) |
| 161 OVERRIDE; |
| 162 #endif |
146 | 163 |
147 virtual bool copyVideoTextureToPlatformTexture( | 164 virtual bool copyVideoTextureToPlatformTexture( |
148 WebKit::WebGraphicsContext3D* web_graphics_context, | 165 WebKit::WebGraphicsContext3D* web_graphics_context, |
149 unsigned int texture, | 166 unsigned int texture, |
150 unsigned int level, | 167 unsigned int level, |
151 unsigned int internal_format, | 168 unsigned int internal_format, |
152 bool premultiply_alpha, | 169 bool premultiply_alpha, |
153 bool flip_y); | 170 bool flip_y); |
154 | 171 |
155 virtual WebKit::WebAudioSourceProvider* audioSourceProvider(); | 172 virtual WebKit::WebAudioSourceProvider* audioSourceProvider(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // Video frame rendering members. | 351 // Video frame rendering members. |
335 // | 352 // |
336 // |lock_| protects |current_frame_| since new frames arrive on the video | 353 // |lock_| protects |current_frame_| since new frames arrive on the video |
337 // rendering thread, yet are accessed for rendering on either the main thread | 354 // rendering thread, yet are accessed for rendering on either the main thread |
338 // or compositing thread depending on whether accelerated compositing is used. | 355 // or compositing thread depending on whether accelerated compositing is used. |
339 base::Lock lock_; | 356 base::Lock lock_; |
340 media::SkCanvasVideoRenderer skcanvas_video_renderer_; | 357 media::SkCanvasVideoRenderer skcanvas_video_renderer_; |
341 scoped_refptr<media::VideoFrame> current_frame_; | 358 scoped_refptr<media::VideoFrame> current_frame_; |
342 bool pending_repaint_; | 359 bool pending_repaint_; |
343 | 360 |
| 361 // The compositor layer for displaying the video content when using composited |
| 362 // playback. |
| 363 scoped_ptr<webkit::WebLayerImpl> video_weblayer_; |
| 364 |
| 365 // A pointer back to the compositor to inform it about state changes. This is |
| 366 // not NULL while the compositor is actively using this webmediaplayer. |
| 367 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 368 |
344 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 369 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
345 }; | 370 }; |
346 | 371 |
347 } // namespace webkit_media | 372 } // namespace webkit_media |
348 | 373 |
349 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 374 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |