Chromium Code Reviews| 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_PROXY_H_ | 5 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ |
| 6 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ | 6 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ |
| 7 | 7 |
| 8 #include <list> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 13 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 14 #include "media/base/decryptor_client.h" | |
| 15 #include "media/base/pipeline.h" | 10 #include "media/base/pipeline.h" |
| 16 #include "media/filters/chunk_demuxer.h" | 11 #include "media/filters/chunk_demuxer.h" |
| 17 #include "media/filters/ffmpeg_video_decoder.h" | 12 #include "media/filters/ffmpeg_video_decoder.h" |
| 18 #include "webkit/media/buffered_data_source.h" | 13 #include "webkit/media/buffered_data_source.h" |
| 19 #include "webkit/media/skcanvas_video_renderer.h" | 14 #include "webkit/media/skcanvas_video_renderer.h" |
| 20 | 15 |
| 21 class SkCanvas; | 16 class SkCanvas; |
| 22 | 17 |
| 23 namespace base { | 18 namespace base { |
| 24 class MessageLoopProxy; | 19 class MessageLoopProxy; |
| 25 } | 20 } |
| 26 | 21 |
| 27 namespace gfx { | 22 namespace gfx { |
| 28 class Rect; | 23 class Rect; |
| 29 } | 24 } |
| 30 | 25 |
| 31 namespace media { | 26 namespace media { |
| 32 class VideoFrame; | 27 class VideoFrame; |
| 33 class VideoRendererBase; | 28 class VideoRendererBase; |
| 34 } | 29 } |
| 35 | 30 |
| 36 namespace webkit_media { | 31 namespace webkit_media { |
| 37 | 32 |
| 38 class WebMediaPlayerImpl; | 33 class WebMediaPlayerImpl; |
| 39 | 34 |
| 40 // Acts as a thread proxy between the various threads used for multimedia and | 35 // Acts as a thread proxy between the various threads used for multimedia and |
| 41 // the render thread that WebMediaPlayerImpl is running on. | 36 // the render thread that WebMediaPlayerImpl is running on. |
| 42 class WebMediaPlayerProxy | 37 class WebMediaPlayerProxy |
| 43 : public base::RefCountedThreadSafe<WebMediaPlayerProxy>, | 38 : public base::RefCountedThreadSafe<WebMediaPlayerProxy> { |
| 44 public media::DecryptorClient { | |
|
Ami GONE FROM CHROMIUM
2012/10/23 06:52:22
I <3 THIS SO HARD!
scherkus (not reviewing)
2012/10/23 21:10:40
+1
| |
| 45 public: | 39 public: |
| 46 WebMediaPlayerProxy(const scoped_refptr<base::MessageLoopProxy>& render_loop, | 40 WebMediaPlayerProxy(const scoped_refptr<base::MessageLoopProxy>& render_loop, |
| 47 WebMediaPlayerImpl* webmediaplayer); | 41 WebMediaPlayerImpl* webmediaplayer); |
| 48 const scoped_refptr<BufferedDataSource>& data_source() { | 42 const scoped_refptr<BufferedDataSource>& data_source() { |
| 49 return data_source_; | 43 return data_source_; |
| 50 } | 44 } |
| 51 void set_data_source(const scoped_refptr<BufferedDataSource>& data_source) { | 45 void set_data_source(const scoped_refptr<BufferedDataSource>& data_source) { |
| 52 data_source_ = data_source; | 46 data_source_ = data_source; |
| 53 } | 47 } |
| 54 | 48 |
| 55 // TODO(scherkus): remove this once VideoRendererBase::PaintCB passes | 49 // TODO(scherkus): remove this once VideoRendererBase::PaintCB passes |
| 56 // ownership of the VideoFrame http://crbug.com/108435 | 50 // ownership of the VideoFrame http://crbug.com/108435 |
| 57 void set_frame_provider(media::VideoRendererBase* frame_provider) { | 51 void set_frame_provider(media::VideoRendererBase* frame_provider) { |
| 58 frame_provider_ = frame_provider; | 52 frame_provider_ = frame_provider; |
| 59 } | 53 } |
| 60 | 54 |
| 61 // Methods for Filter -> WebMediaPlayerImpl communication. | 55 // Methods for Filter -> WebMediaPlayerImpl communication. |
| 62 void Repaint(); | 56 void Repaint(); |
| 63 | 57 |
| 64 // Methods for WebMediaPlayerImpl -> Filter communication. | 58 // Methods for WebMediaPlayerImpl -> Filter communication. |
| 65 void Paint(SkCanvas* canvas, const gfx::Rect& dest_rect, uint8_t alpha); | 59 void Paint(SkCanvas* canvas, const gfx::Rect& dest_rect, uint8_t alpha); |
| 66 void Detach(); | 60 void Detach(); |
| 67 void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out); | 61 void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out); |
| 68 void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame); | 62 void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame); |
| 69 bool HasSingleOrigin(); | 63 bool HasSingleOrigin(); |
| 70 bool DidPassCORSAccessCheck() const; | 64 bool DidPassCORSAccessCheck() const; |
| 71 | 65 |
| 72 void AbortDataSource(); | 66 void AbortDataSource(); |
| 73 | 67 |
| 74 // DecryptorClient implementation. | |
| 75 virtual void KeyAdded(const std::string& key_system, | |
| 76 const std::string& session_id) OVERRIDE; | |
| 77 virtual void KeyError(const std::string& key_system, | |
| 78 const std::string& session_id, | |
| 79 media::Decryptor::KeyError error_code, | |
| 80 int system_code) OVERRIDE; | |
| 81 virtual void KeyMessage(const std::string& key_system, | |
| 82 const std::string& session_id, | |
| 83 scoped_array<uint8> message, | |
| 84 int message_length, | |
| 85 const std::string& default_url) OVERRIDE; | |
| 86 virtual void NeedKey(const std::string& key_system, | |
| 87 const std::string& session_id, | |
| 88 scoped_array<uint8> init_data, | |
| 89 int init_data_size) OVERRIDE; | |
| 90 | |
| 91 private: | 68 private: |
| 92 friend class base::RefCountedThreadSafe<WebMediaPlayerProxy>; | 69 friend class base::RefCountedThreadSafe<WebMediaPlayerProxy>; |
| 93 virtual ~WebMediaPlayerProxy(); | 70 virtual ~WebMediaPlayerProxy(); |
| 94 | 71 |
| 95 // Invoke |webmediaplayer_| to perform a repaint. | 72 // Invoke |webmediaplayer_| to perform a repaint. |
| 96 void RepaintTask(); | 73 void RepaintTask(); |
| 97 | 74 |
| 98 // Notify |webmediaplayer_| that a key has been added. | |
| 99 void KeyAddedTask(const std::string& key_system, | |
| 100 const std::string& session_id); | |
| 101 | |
| 102 // Notify |webmediaplayer_| that a key error occurred. | |
| 103 void KeyErrorTask(const std::string& key_system, | |
| 104 const std::string& session_id, | |
| 105 media::Decryptor::KeyError error_code, | |
| 106 int system_code); | |
| 107 | |
| 108 // Notify |webmediaplayer_| that a key message has been generated. | |
| 109 void KeyMessageTask(const std::string& key_system, | |
| 110 const std::string& session_id, | |
| 111 scoped_array<uint8> message, | |
| 112 int message_length, | |
| 113 const std::string& default_url); | |
| 114 | |
| 115 // Notify |webmediaplayer_| that a key is needed for decryption. | |
| 116 void NeedKeyTask(const std::string& key_system, | |
| 117 const std::string& session_id, | |
| 118 scoped_array<uint8> init_data, | |
| 119 int init_data_size); | |
| 120 | |
| 121 // The render message loop where WebKit lives. | 75 // The render message loop where WebKit lives. |
| 122 scoped_refptr<base::MessageLoopProxy> render_loop_; | 76 scoped_refptr<base::MessageLoopProxy> render_loop_; |
| 123 WebMediaPlayerImpl* webmediaplayer_; | 77 WebMediaPlayerImpl* webmediaplayer_; |
| 124 | 78 |
| 125 scoped_refptr<BufferedDataSource> data_source_; | 79 scoped_refptr<BufferedDataSource> data_source_; |
| 126 scoped_refptr<media::VideoRendererBase> frame_provider_; | 80 scoped_refptr<media::VideoRendererBase> frame_provider_; |
| 127 SkCanvasVideoRenderer video_renderer_; | 81 SkCanvasVideoRenderer video_renderer_; |
| 128 | 82 |
| 129 base::Lock lock_; | 83 base::Lock lock_; |
| 130 int outstanding_repaints_; | 84 int outstanding_repaints_; |
| 131 | 85 |
| 132 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxy); | 86 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxy); |
| 133 }; | 87 }; |
| 134 | 88 |
| 135 } // namespace webkit_media | 89 } // namespace webkit_media |
| 136 | 90 |
| 137 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ | 91 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ |
| OLD | NEW |