| 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/pipeline.h" | 14 #include "media/base/pipeline.h" |
| 15 #include "media/crypto/decryptor_client.h" |
| 15 #include "media/filters/chunk_demuxer.h" | 16 #include "media/filters/chunk_demuxer.h" |
| 16 #include "media/filters/chunk_demuxer_client.h" | 17 #include "media/filters/chunk_demuxer_client.h" |
| 17 #include "media/filters/ffmpeg_video_decoder.h" | 18 #include "media/filters/ffmpeg_video_decoder.h" |
| 18 #include "webkit/media/buffered_data_source.h" | 19 #include "webkit/media/buffered_data_source.h" |
| 19 #include "webkit/media/skcanvas_video_renderer.h" | 20 #include "webkit/media/skcanvas_video_renderer.h" |
| 20 | 21 |
| 21 class SkCanvas; | 22 class SkCanvas; |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class MessageLoopProxy; | 25 class MessageLoopProxy; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace gfx { | 28 namespace gfx { |
| 28 class Rect; | 29 class Rect; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace media { | 32 namespace media { |
| 32 class VideoFrame; | 33 class VideoFrame; |
| 33 class VideoRendererBase; | 34 class VideoRendererBase; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace webkit_media { | 37 namespace webkit_media { |
| 37 | 38 |
| 38 class WebMediaPlayerImpl; | 39 class WebMediaPlayerImpl; |
| 39 | 40 |
| 40 // Acts as a thread proxy between the various threads used for multimedia and | 41 // Acts as a thread proxy between the various threads used for multimedia and |
| 41 // the render thread that WebMediaPlayerImpl is running on. | 42 // the render thread that WebMediaPlayerImpl is running on. |
| 42 class WebMediaPlayerProxy | 43 class WebMediaPlayerProxy |
| 43 : public base::RefCountedThreadSafe<WebMediaPlayerProxy>, | 44 : public base::RefCountedThreadSafe<WebMediaPlayerProxy>, |
| 44 public media::ChunkDemuxerClient { | 45 public media::ChunkDemuxerClient, |
| 46 public media::DecryptorClient { |
| 45 public: | 47 public: |
| 46 WebMediaPlayerProxy(const scoped_refptr<base::MessageLoopProxy>& render_loop, | 48 WebMediaPlayerProxy(const scoped_refptr<base::MessageLoopProxy>& render_loop, |
| 47 WebMediaPlayerImpl* webmediaplayer); | 49 WebMediaPlayerImpl* webmediaplayer); |
| 48 const scoped_refptr<BufferedDataSource>& data_source() { | 50 const scoped_refptr<BufferedDataSource>& data_source() { |
| 49 return data_source_; | 51 return data_source_; |
| 50 } | 52 } |
| 51 void set_data_source(const scoped_refptr<BufferedDataSource>& data_source) { | 53 void set_data_source(const scoped_refptr<BufferedDataSource>& data_source) { |
| 52 data_source_ = data_source; | 54 data_source_ = data_source; |
| 53 } | 55 } |
| 54 | 56 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 83 // Methods for Pipeline -> WebMediaPlayerImpl communication. | 85 // Methods for Pipeline -> WebMediaPlayerImpl communication. |
| 84 void PipelineInitializationCallback(media::PipelineStatus status); | 86 void PipelineInitializationCallback(media::PipelineStatus status); |
| 85 void PipelineSeekCallback(media::PipelineStatus status); | 87 void PipelineSeekCallback(media::PipelineStatus status); |
| 86 void PipelineEndedCallback(media::PipelineStatus status); | 88 void PipelineEndedCallback(media::PipelineStatus status); |
| 87 void PipelineErrorCallback(media::PipelineStatus error); | 89 void PipelineErrorCallback(media::PipelineStatus error); |
| 88 void NetworkEventCallback(media::NetworkEvent type); | 90 void NetworkEventCallback(media::NetworkEvent type); |
| 89 | 91 |
| 90 // ChunkDemuxerClient implementation. | 92 // ChunkDemuxerClient implementation. |
| 91 virtual void DemuxerOpened(media::ChunkDemuxer* demuxer) OVERRIDE; | 93 virtual void DemuxerOpened(media::ChunkDemuxer* demuxer) OVERRIDE; |
| 92 virtual void DemuxerClosed() OVERRIDE; | 94 virtual void DemuxerClosed() OVERRIDE; |
| 93 virtual void KeyNeeded(scoped_array<uint8> init_data, | 95 virtual void DemuxerNeedKey(scoped_array<uint8> init_data, |
| 94 int init_data_size) OVERRIDE; | 96 int init_data_size) OVERRIDE; |
| 95 | 97 |
| 96 // Methods for Demuxer communication. | 98 // Methods for Demuxer communication. |
| 97 void DemuxerStartWaitingForSeek(); | 99 void DemuxerStartWaitingForSeek(); |
| 98 media::ChunkDemuxer::Status DemuxerAddId(const std::string& id, | 100 media::ChunkDemuxer::Status DemuxerAddId(const std::string& id, |
| 99 const std::string& type, | 101 const std::string& type, |
| 100 std::vector<std::string>& codecs); | 102 std::vector<std::string>& codecs); |
| 101 void DemuxerRemoveId(const std::string& id); | 103 void DemuxerRemoveId(const std::string& id); |
| 102 bool DemuxerBufferedRange(const std::string& id, | 104 bool DemuxerBufferedRange(const std::string& id, |
| 103 media::ChunkDemuxer::Ranges* ranges_out); | 105 media::ChunkDemuxer::Ranges* ranges_out); |
| 104 bool DemuxerAppend(const std::string& id, const uint8* data, size_t length); | 106 bool DemuxerAppend(const std::string& id, const uint8* data, size_t length); |
| 105 void DemuxerAbort(const std::string& id); | 107 void DemuxerAbort(const std::string& id); |
| 106 void DemuxerEndOfStream(media::PipelineStatus status); | 108 void DemuxerEndOfStream(media::PipelineStatus status); |
| 107 void DemuxerShutdown(); | 109 void DemuxerShutdown(); |
| 108 | 110 |
| 109 void DemuxerOpenedTask(const scoped_refptr<media::ChunkDemuxer>& demuxer); | 111 // DecryptorClient implementation. |
| 110 void DemuxerClosedTask(); | 112 virtual void KeyAdded(const std::string& key_system, |
| 111 void KeyNeededTask(scoped_array<uint8> init_data, int init_data_size); | 113 const std::string& session_id) OVERRIDE; |
| 114 virtual void KeyError(const std::string& key_system, |
| 115 const std::string& session_id, |
| 116 media::AesDecryptor::KeyError error_code, |
| 117 int system_code) OVERRIDE; |
| 118 virtual void KeyMessage(const std::string& key_system, |
| 119 const std::string& session_id, |
| 120 scoped_array<uint8> message, |
| 121 int message_length, |
| 122 const std::string& default_url) OVERRIDE; |
| 123 virtual void NeedKey(const std::string& key_system, |
| 124 const std::string& session_id, |
| 125 scoped_array<uint8> init_data, |
| 126 int init_data_size) OVERRIDE; |
| 112 | 127 |
| 113 private: | 128 private: |
| 114 friend class base::RefCountedThreadSafe<WebMediaPlayerProxy>; | 129 friend class base::RefCountedThreadSafe<WebMediaPlayerProxy>; |
| 115 virtual ~WebMediaPlayerProxy(); | 130 virtual ~WebMediaPlayerProxy(); |
| 116 | 131 |
| 117 // Invoke |webmediaplayer_| to perform a repaint. | 132 // Invoke |webmediaplayer_| to perform a repaint. |
| 118 void RepaintTask(); | 133 void RepaintTask(); |
| 119 | 134 |
| 120 // Notify |webmediaplayer_| that initialization has finished. | 135 // Notify |webmediaplayer_| that initialization has finished. |
| 121 void PipelineInitializationTask(media::PipelineStatus status); | 136 void PipelineInitializationTask(media::PipelineStatus status); |
| 122 | 137 |
| 123 // Notify |webmediaplayer_| that a seek has finished. | 138 // Notify |webmediaplayer_| that a seek has finished. |
| 124 void PipelineSeekTask(media::PipelineStatus status); | 139 void PipelineSeekTask(media::PipelineStatus status); |
| 125 | 140 |
| 126 // Notify |webmediaplayer_| that the media has ended. | 141 // Notify |webmediaplayer_| that the media has ended. |
| 127 void PipelineEndedTask(media::PipelineStatus status); | 142 void PipelineEndedTask(media::PipelineStatus status); |
| 128 | 143 |
| 129 // Notify |webmediaplayer_| that a pipeline error has occurred during | 144 // Notify |webmediaplayer_| that a pipeline error has occurred during |
| 130 // playback. | 145 // playback. |
| 131 void PipelineErrorTask(media::PipelineStatus error); | 146 void PipelineErrorTask(media::PipelineStatus error); |
| 132 | 147 |
| 133 // Notify |webmediaplayer_| that there's a network event. | 148 // Notify |webmediaplayer_| that there's a network event. |
| 134 void NetworkEventTask(media::NetworkEvent type); | 149 void NetworkEventTask(media::NetworkEvent type); |
| 135 | 150 |
| 136 // Inform |webmediaplayer_| whether the video content is opaque. | 151 // Inform |webmediaplayer_| whether the video content is opaque. |
| 137 void SetOpaqueTask(bool opaque); | 152 void SetOpaqueTask(bool opaque); |
| 138 | 153 |
| 154 void DemuxerOpenedTask(const scoped_refptr<media::ChunkDemuxer>& demuxer); |
| 155 void DemuxerClosedTask(); |
| 156 |
| 157 // Notify |webmediaplayer_| that a key has been added. |
| 158 void KeyAddedTask(const std::string& key_system, |
| 159 const std::string& session_id); |
| 160 |
| 161 // Notify |webmediaplayer_| that a key error has occurred. |
| 162 void KeyErrorTask(const std::string& key_system, |
| 163 const std::string& session_id, |
| 164 media::AesDecryptor::KeyError error_code, |
| 165 int system_code); |
| 166 |
| 167 // Notify |webmediaplayer_| that a key message has been generated. |
| 168 void KeyMessageTask(const std::string& key_system, |
| 169 const std::string& session_id, |
| 170 scoped_array<uint8> message, |
| 171 int message_length, |
| 172 const std::string& default_url); |
| 173 |
| 174 // Notify |webmediaplayer_| that a key is needed for decryption. |
| 175 void NeedKeyTask(const std::string& key_system, |
| 176 const std::string& session_id, |
| 177 scoped_array<uint8> init_data, |
| 178 int init_data_size); |
| 179 |
| 139 // The render message loop where WebKit lives. | 180 // The render message loop where WebKit lives. |
| 140 scoped_refptr<base::MessageLoopProxy> render_loop_; | 181 scoped_refptr<base::MessageLoopProxy> render_loop_; |
| 141 WebMediaPlayerImpl* webmediaplayer_; | 182 WebMediaPlayerImpl* webmediaplayer_; |
| 142 | 183 |
| 143 scoped_refptr<BufferedDataSource> data_source_; | 184 scoped_refptr<BufferedDataSource> data_source_; |
| 144 scoped_refptr<media::VideoRendererBase> frame_provider_; | 185 scoped_refptr<media::VideoRendererBase> frame_provider_; |
| 145 SkCanvasVideoRenderer video_renderer_; | 186 SkCanvasVideoRenderer video_renderer_; |
| 146 scoped_refptr<media::FFmpegVideoDecoder> video_decoder_; | 187 scoped_refptr<media::FFmpegVideoDecoder> video_decoder_; |
| 147 | 188 |
| 148 base::Lock lock_; | 189 base::Lock lock_; |
| 149 int outstanding_repaints_; | 190 int outstanding_repaints_; |
| 150 | 191 |
| 151 scoped_refptr<media::ChunkDemuxer> chunk_demuxer_; | 192 scoped_refptr<media::ChunkDemuxer> chunk_demuxer_; |
| 152 | 193 |
| 153 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxy); | 194 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxy); |
| 154 }; | 195 }; |
| 155 | 196 |
| 156 } // namespace webkit_media | 197 } // namespace webkit_media |
| 157 | 198 |
| 158 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ | 199 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_PROXY_H_ |
| OLD | NEW |