| 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> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "media/base/decryptor_client.h" | 14 #include "media/base/decryptor_client.h" |
| 15 #include "media/base/pipeline.h" | 15 #include "media/base/pipeline.h" |
| 16 #include "media/filters/chunk_demuxer.h" | 16 #include "media/filters/chunk_demuxer.h" |
| 17 #include "media/filters/chunk_demuxer_client.h" | |
| 18 #include "media/filters/ffmpeg_video_decoder.h" | 17 #include "media/filters/ffmpeg_video_decoder.h" |
| 19 #include "webkit/media/buffered_data_source.h" | 18 #include "webkit/media/buffered_data_source.h" |
| 20 #include "webkit/media/skcanvas_video_renderer.h" | 19 #include "webkit/media/skcanvas_video_renderer.h" |
| 21 | 20 |
| 22 class SkCanvas; | 21 class SkCanvas; |
| 23 | 22 |
| 24 namespace base { | 23 namespace base { |
| 25 class MessageLoopProxy; | 24 class MessageLoopProxy; |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace gfx { | 27 namespace gfx { |
| 29 class Rect; | 28 class Rect; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace media { | 31 namespace media { |
| 33 class VideoFrame; | 32 class VideoFrame; |
| 34 class VideoRendererBase; | 33 class VideoRendererBase; |
| 35 } | 34 } |
| 36 | 35 |
| 37 namespace webkit_media { | 36 namespace webkit_media { |
| 38 | 37 |
| 39 class WebMediaPlayerImpl; | 38 class WebMediaPlayerImpl; |
| 40 | 39 |
| 41 // Acts as a thread proxy between the various threads used for multimedia and | 40 // Acts as a thread proxy between the various threads used for multimedia and |
| 42 // the render thread that WebMediaPlayerImpl is running on. | 41 // the render thread that WebMediaPlayerImpl is running on. |
| 43 class WebMediaPlayerProxy | 42 class WebMediaPlayerProxy |
| 44 : public base::RefCountedThreadSafe<WebMediaPlayerProxy>, | 43 : public base::RefCountedThreadSafe<WebMediaPlayerProxy>, |
| 45 public media::ChunkDemuxerClient, | |
| 46 public media::DecryptorClient { | 44 public media::DecryptorClient { |
| 47 public: | 45 public: |
| 48 WebMediaPlayerProxy(const scoped_refptr<base::MessageLoopProxy>& render_loop, | 46 WebMediaPlayerProxy(const scoped_refptr<base::MessageLoopProxy>& render_loop, |
| 49 WebMediaPlayerImpl* webmediaplayer); | 47 WebMediaPlayerImpl* webmediaplayer); |
| 50 const scoped_refptr<BufferedDataSource>& data_source() { | 48 const scoped_refptr<BufferedDataSource>& data_source() { |
| 51 return data_source_; | 49 return data_source_; |
| 52 } | 50 } |
| 53 void set_data_source(const scoped_refptr<BufferedDataSource>& data_source) { | 51 void set_data_source(const scoped_refptr<BufferedDataSource>& data_source) { |
| 54 data_source_ = data_source; | 52 data_source_ = data_source; |
| 55 } | 53 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 66 // Methods for WebMediaPlayerImpl -> Filter communication. | 64 // Methods for WebMediaPlayerImpl -> Filter communication. |
| 67 void Paint(SkCanvas* canvas, const gfx::Rect& dest_rect, uint8_t alpha); | 65 void Paint(SkCanvas* canvas, const gfx::Rect& dest_rect, uint8_t alpha); |
| 68 void Detach(); | 66 void Detach(); |
| 69 void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out); | 67 void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out); |
| 70 void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame); | 68 void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame); |
| 71 bool HasSingleOrigin(); | 69 bool HasSingleOrigin(); |
| 72 bool DidPassCORSAccessCheck() const; | 70 bool DidPassCORSAccessCheck() const; |
| 73 | 71 |
| 74 void AbortDataSource(); | 72 void AbortDataSource(); |
| 75 | 73 |
| 76 // ChunkDemuxerClient implementation. | |
| 77 virtual void DemuxerOpened(media::ChunkDemuxer* demuxer) OVERRIDE; | |
| 78 virtual void DemuxerClosed() OVERRIDE; | |
| 79 virtual void DemuxerNeedKey(scoped_array<uint8> init_data, | |
| 80 int init_data_size) OVERRIDE; | |
| 81 | |
| 82 // Methods for Demuxer communication. | |
| 83 void DemuxerStartWaitingForSeek(); | |
| 84 void DemuxerCancelPendingSeek(); | |
| 85 media::ChunkDemuxer::Status DemuxerAddId(const std::string& id, | |
| 86 const std::string& type, | |
| 87 std::vector<std::string>& codecs); | |
| 88 void DemuxerRemoveId(const std::string& id); | |
| 89 media::Ranges<base::TimeDelta> DemuxerBufferedRange(const std::string& id); | |
| 90 bool DemuxerAppend(const std::string& id, const uint8* data, size_t length); | |
| 91 void DemuxerAbort(const std::string& id); | |
| 92 void DemuxerSetDuration(base::TimeDelta duration); | |
| 93 void DemuxerEndOfStream(media::PipelineStatus status); | |
| 94 void DemuxerShutdown(); | |
| 95 bool DemuxerSetTimestampOffset(const std::string& id, base::TimeDelta offset); | |
| 96 | |
| 97 // DecryptorClient implementation. | 74 // DecryptorClient implementation. |
| 98 virtual void KeyAdded(const std::string& key_system, | 75 virtual void KeyAdded(const std::string& key_system, |
| 99 const std::string& session_id) OVERRIDE; | 76 const std::string& session_id) OVERRIDE; |
| 100 virtual void KeyError(const std::string& key_system, | 77 virtual void KeyError(const std::string& key_system, |
| 101 const std::string& session_id, | 78 const std::string& session_id, |
| 102 media::Decryptor::KeyError error_code, | 79 media::Decryptor::KeyError error_code, |
| 103 int system_code) OVERRIDE; | 80 int system_code) OVERRIDE; |
| 104 virtual void KeyMessage(const std::string& key_system, | 81 virtual void KeyMessage(const std::string& key_system, |
| 105 const std::string& session_id, | 82 const std::string& session_id, |
| 106 scoped_array<uint8> message, | 83 scoped_array<uint8> message, |
| 107 int message_length, | 84 int message_length, |
| 108 const std::string& default_url) OVERRIDE; | 85 const std::string& default_url) OVERRIDE; |
| 109 virtual void NeedKey(const std::string& key_system, | 86 virtual void NeedKey(const std::string& key_system, |
| 110 const std::string& session_id, | 87 const std::string& session_id, |
| 111 scoped_array<uint8> init_data, | 88 scoped_array<uint8> init_data, |
| 112 int init_data_size) OVERRIDE; | 89 int init_data_size) OVERRIDE; |
| 113 | 90 |
| 114 private: | 91 private: |
| 115 friend class base::RefCountedThreadSafe<WebMediaPlayerProxy>; | 92 friend class base::RefCountedThreadSafe<WebMediaPlayerProxy>; |
| 116 virtual ~WebMediaPlayerProxy(); | 93 virtual ~WebMediaPlayerProxy(); |
| 117 | 94 |
| 118 // Invoke |webmediaplayer_| to perform a repaint. | 95 // Invoke |webmediaplayer_| to perform a repaint. |
| 119 void RepaintTask(); | 96 void RepaintTask(); |
| 120 | 97 |
| 121 void DemuxerOpenedTask(const scoped_refptr<media::ChunkDemuxer>& demuxer); | |
| 122 void DemuxerClosedTask(); | |
| 123 | |
| 124 // Notify |webmediaplayer_| that a key has been added. | 98 // Notify |webmediaplayer_| that a key has been added. |
| 125 void KeyAddedTask(const std::string& key_system, | 99 void KeyAddedTask(const std::string& key_system, |
| 126 const std::string& session_id); | 100 const std::string& session_id); |
| 127 | 101 |
| 128 // Notify |webmediaplayer_| that a key error occurred. | 102 // Notify |webmediaplayer_| that a key error occurred. |
| 129 void KeyErrorTask(const std::string& key_system, | 103 void KeyErrorTask(const std::string& key_system, |
| 130 const std::string& session_id, | 104 const std::string& session_id, |
| 131 media::Decryptor::KeyError error_code, | 105 media::Decryptor::KeyError error_code, |
| 132 int system_code); | 106 int system_code); |
| 133 | 107 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 148 scoped_refptr<base::MessageLoopProxy> render_loop_; | 122 scoped_refptr<base::MessageLoopProxy> render_loop_; |
| 149 WebMediaPlayerImpl* webmediaplayer_; | 123 WebMediaPlayerImpl* webmediaplayer_; |
| 150 | 124 |
| 151 scoped_refptr<BufferedDataSource> data_source_; | 125 scoped_refptr<BufferedDataSource> data_source_; |
| 152 scoped_refptr<media::VideoRendererBase> frame_provider_; | 126 scoped_refptr<media::VideoRendererBase> frame_provider_; |
| 153 SkCanvasVideoRenderer video_renderer_; | 127 SkCanvasVideoRenderer video_renderer_; |
| 154 | 128 |
| 155 base::Lock lock_; | 129 base::Lock lock_; |
| 156 int outstanding_repaints_; | 130 int outstanding_repaints_; |
| 157 | 131 |
| 158 scoped_refptr<media::ChunkDemuxer> chunk_demuxer_; | |
| 159 | |
| 160 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxy); | 132 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxy); |
| 161 }; | 133 }; |
| 162 | 134 |
| 163 } // namespace webkit_media | 135 } // namespace webkit_media |
| 164 | 136 |
| 165 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ | 137 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ |
| OLD | NEW |