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" |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStreamTextureClien
t.h" |
39 #include "webkit/media/crypto/key_systems.h" | 41 #include "webkit/media/crypto/key_systems.h" |
40 #include "webkit/media/crypto/proxy_decryptor.h" | 42 #include "webkit/media/crypto/proxy_decryptor.h" |
41 | 43 |
42 class RenderAudioSourceProvider; | 44 class RenderAudioSourceProvider; |
43 | 45 |
44 namespace WebKit { | 46 namespace WebKit { |
45 class WebFrame; | 47 class WebFrame; |
46 } | 48 } |
47 | 49 |
48 namespace base { | 50 namespace base { |
49 class MessageLoopProxy; | 51 class MessageLoopProxy; |
50 } | 52 } |
51 | 53 |
52 namespace media { | 54 namespace media { |
53 class ChunkDemuxer; | 55 class ChunkDemuxer; |
54 class MediaLog; | 56 class MediaLog; |
55 } | 57 } |
56 | 58 |
57 namespace webkit_media { | 59 namespace webkit_media { |
58 | 60 |
59 class BufferedDataSource; | 61 class BufferedDataSource; |
60 class MediaStreamClient; | 62 class MediaStreamClient; |
61 class WebAudioSourceProviderImpl; | 63 class WebAudioSourceProviderImpl; |
62 class WebMediaPlayerDelegate; | 64 class WebMediaPlayerDelegate; |
63 class WebMediaPlayerParams; | 65 class WebMediaPlayerParams; |
64 | 66 |
65 class WebMediaPlayerImpl | 67 class WebMediaPlayerImpl |
66 : public WebKit::WebMediaPlayer, | 68 : public WebKit::WebMediaPlayer, |
| 69 public cc::VideoFrameProvider, |
| 70 public WebKit::WebStreamTextureClient, |
67 public MessageLoop::DestructionObserver, | 71 public MessageLoop::DestructionObserver, |
68 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 72 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
69 public: | 73 public: |
70 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 74 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
71 // | 75 // |
72 // |delegate| may be null. | 76 // |delegate| may be null. |
73 WebMediaPlayerImpl( | 77 WebMediaPlayerImpl( |
74 WebKit::WebFrame* frame, | 78 WebKit::WebFrame* frame, |
75 WebKit::WebMediaPlayerClient* client, | 79 WebKit::WebMediaPlayerClient* client, |
76 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 80 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 virtual bool didPassCORSAccessCheck() const; | 138 virtual bool didPassCORSAccessCheck() const; |
135 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; | 139 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const; |
136 | 140 |
137 virtual float mediaTimeForTimeValue(float timeValue) const; | 141 virtual float mediaTimeForTimeValue(float timeValue) const; |
138 | 142 |
139 virtual unsigned decodedFrameCount() const; | 143 virtual unsigned decodedFrameCount() const; |
140 virtual unsigned droppedFrameCount() const; | 144 virtual unsigned droppedFrameCount() const; |
141 virtual unsigned audioDecodedByteCount() const; | 145 virtual unsigned audioDecodedByteCount() const; |
142 virtual unsigned videoDecodedByteCount() const; | 146 virtual unsigned videoDecodedByteCount() const; |
143 | 147 |
144 virtual WebKit::WebVideoFrame* getCurrentFrame(); | 148 virtual WebKit::WebLayer* createCompositingLayer(); |
145 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame); | 149 |
| 150 // cc::VideoFrameProvider imlpementation. |
| 151 virtual void SetVideoFrameProviderClient( |
| 152 cc::VideoFrameProvider::Client* client) OVERRIDE; |
| 153 virtual scoped_refptr<media::VideoFrame> GetCurrentFrame() OVERRIDE; |
| 154 virtual void PutCurrentFrame(const scoped_refptr<media::VideoFrame>& frame) |
| 155 OVERRIDE; |
| 156 |
| 157 // WebStreamTextureClient implementation. |
| 158 virtual void didReceiveFrame(); |
| 159 virtual void didUpdateMatrix(const float* matrix); |
146 | 160 |
147 virtual bool copyVideoTextureToPlatformTexture( | 161 virtual bool copyVideoTextureToPlatformTexture( |
148 WebKit::WebGraphicsContext3D* web_graphics_context, | 162 WebKit::WebGraphicsContext3D* web_graphics_context, |
149 unsigned int texture, | 163 unsigned int texture, |
150 unsigned int level, | 164 unsigned int level, |
151 unsigned int internal_format, | 165 unsigned int internal_format, |
152 bool premultiply_alpha, | 166 bool premultiply_alpha, |
153 bool flip_y); | 167 bool flip_y); |
154 | 168 |
155 virtual WebKit::WebAudioSourceProvider* audioSourceProvider(); | 169 virtual WebKit::WebAudioSourceProvider* audioSourceProvider(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // Video frame rendering members. | 348 // Video frame rendering members. |
335 // | 349 // |
336 // |lock_| protects |current_frame_| since new frames arrive on the video | 350 // |lock_| protects |current_frame_| since new frames arrive on the video |
337 // rendering thread, yet are accessed for rendering on either the main thread | 351 // rendering thread, yet are accessed for rendering on either the main thread |
338 // or compositing thread depending on whether accelerated compositing is used. | 352 // or compositing thread depending on whether accelerated compositing is used. |
339 base::Lock lock_; | 353 base::Lock lock_; |
340 media::SkCanvasVideoRenderer skcanvas_video_renderer_; | 354 media::SkCanvasVideoRenderer skcanvas_video_renderer_; |
341 scoped_refptr<media::VideoFrame> current_frame_; | 355 scoped_refptr<media::VideoFrame> current_frame_; |
342 bool pending_repaint_; | 356 bool pending_repaint_; |
343 | 357 |
| 358 base::Lock provider_lock_; |
| 359 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
| 360 |
344 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 361 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
345 }; | 362 }; |
346 | 363 |
347 } // namespace webkit_media | 364 } // namespace webkit_media |
348 | 365 |
349 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 366 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |