| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 5 #ifndef WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
| 6 #define WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 6 #define WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 namespace webkit_media { | 32 namespace webkit_media { |
| 33 | 33 |
| 34 class ProxyDecryptor; | 34 class ProxyDecryptor; |
| 35 class WebMediaPlayerProxyAndroid; | 35 class WebMediaPlayerProxyAndroid; |
| 36 | 36 |
| 37 class MediaSourceDelegate : public media::DemuxerHost { | 37 class MediaSourceDelegate : public media::DemuxerHost { |
| 38 public: | 38 public: |
| 39 typedef base::Callback<void(WebKit::WebMediaPlayer::NetworkState)> | 39 typedef base::Callback<void(WebKit::WebMediaPlayer::NetworkState)> |
| 40 UpdateNetworkStateCB; | 40 UpdateNetworkStateCB; |
| 41 | 41 |
| 42 // Helper class used by scoped_ptr to destroy an instance of |
| 43 // MediaSourceDelegate. |
| 44 class Destroyer { |
| 45 public: |
| 46 inline void operator()(void* media_source_delegate) const { |
| 47 static_cast<MediaSourceDelegate*>(media_source_delegate)->Destroy(); |
| 48 } |
| 49 }; |
| 50 |
| 42 MediaSourceDelegate(WebKit::WebFrame* frame, | 51 MediaSourceDelegate(WebKit::WebFrame* frame, |
| 43 WebKit::WebMediaPlayerClient* client, | 52 WebKit::WebMediaPlayerClient* client, |
| 44 WebMediaPlayerProxyAndroid* proxy, | 53 WebMediaPlayerProxyAndroid* proxy, |
| 45 int player_id, | 54 int player_id, |
| 46 media::MediaLog* media_log); | 55 media::MediaLog* media_log); |
| 47 virtual ~MediaSourceDelegate(); | |
| 48 | |
| 49 // Initialize the MediaSourceDelegate. |media_source| will be owned by | 56 // Initialize the MediaSourceDelegate. |media_source| will be owned by |
| 50 // this object after this call. | 57 // this object after this call. |
| 51 void Initialize(WebKit::WebMediaSource* media_source, | 58 void Initialize(WebKit::WebMediaSource* media_source, |
| 52 const UpdateNetworkStateCB& update_network_state_cb); | 59 const UpdateNetworkStateCB& update_network_state_cb); |
| 53 | 60 |
| 54 const WebKit::WebTimeRanges& Buffered(); | 61 const WebKit::WebTimeRanges& Buffered(); |
| 55 size_t DecodedFrameCount() const; | 62 size_t DecodedFrameCount() const; |
| 56 size_t DroppedFrameCount() const; | 63 size_t DroppedFrameCount() const; |
| 57 size_t AudioDecodedByteCount() const; | 64 size_t AudioDecodedByteCount() const; |
| 58 size_t VideoDecodedByteCount() const; | 65 size_t VideoDecodedByteCount() const; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 72 const WebKit::WebString& key_system, | 79 const WebKit::WebString& key_system, |
| 73 const WebKit::WebString& session_id); | 80 const WebKit::WebString& session_id); |
| 74 | 81 |
| 75 void Seek(base::TimeDelta time); | 82 void Seek(base::TimeDelta time); |
| 76 | 83 |
| 77 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. | 84 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. |
| 78 // If it's the first request after the seek, |seek_done| will be true. | 85 // If it's the first request after the seek, |seek_done| will be true. |
| 79 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); | 86 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); |
| 80 | 87 |
| 81 private: | 88 private: |
| 89 friend MediaSourceDelegate::Destroyer; |
| 90 |
| 91 // This is private to enforce use of the Destroyer. |
| 92 virtual ~MediaSourceDelegate(); |
| 93 |
| 94 // Called by the Destroyer to destroy an instance of this object. |
| 95 void Destroy(); |
| 96 |
| 82 // Methods inherited from DemuxerHost. | 97 // Methods inherited from DemuxerHost. |
| 83 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | 98 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; |
| 84 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | 99 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; |
| 85 virtual void AddBufferedTimeRange(base::TimeDelta start, | 100 virtual void AddBufferedTimeRange(base::TimeDelta start, |
| 86 base::TimeDelta end) OVERRIDE; | 101 base::TimeDelta end) OVERRIDE; |
| 87 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | 102 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
| 88 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE; | 103 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE; |
| 89 | 104 |
| 90 // Callbacks for ChunkDemuxer & Decryptor. | 105 // Callbacks for ChunkDemuxer & Decryptor. |
| 91 void OnDemuxerInitDone(media::PipelineStatus status); | 106 void OnDemuxerInitDone(media::PipelineStatus status); |
| 107 void OnDemuxerStopDone(); |
| 92 void OnDemuxerOpened(); | 108 void OnDemuxerOpened(); |
| 93 void OnKeyAdded(const std::string& key_system, const std::string& session_id); | 109 void OnKeyAdded(const std::string& key_system, const std::string& session_id); |
| 94 void OnKeyError(const std::string& key_system, | 110 void OnKeyError(const std::string& key_system, |
| 95 const std::string& session_id, | 111 const std::string& session_id, |
| 96 media::Decryptor::KeyError error_code, | 112 media::Decryptor::KeyError error_code, |
| 97 int system_code); | 113 int system_code); |
| 98 void OnKeyMessage(const std::string& key_system, | 114 void OnKeyMessage(const std::string& key_system, |
| 99 const std::string& session_id, | 115 const std::string& session_id, |
| 100 const std::string& message, | 116 const std::string& message, |
| 101 const std::string& default_url); | 117 const std::string& default_url); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 116 media::DemuxerStream* stream, | 132 media::DemuxerStream* stream, |
| 117 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, | 133 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, |
| 118 size_t index, | 134 size_t index, |
| 119 media::DemuxerStream::Status status, | 135 media::DemuxerStream::Status status, |
| 120 const scoped_refptr<media::DecoderBuffer>& buffer); | 136 const scoped_refptr<media::DecoderBuffer>& buffer); |
| 121 | 137 |
| 122 void NotifyDemuxerReady(const std::string& key_system); | 138 void NotifyDemuxerReady(const std::string& key_system); |
| 123 | 139 |
| 124 base::WeakPtrFactory<MediaSourceDelegate> weak_this_; | 140 base::WeakPtrFactory<MediaSourceDelegate> weak_this_; |
| 125 | 141 |
| 126 WebKit::WebMediaPlayerClient* const client_; | 142 WebKit::WebMediaPlayerClient* client_; |
| 127 WebMediaPlayerProxyAndroid* proxy_; | 143 WebMediaPlayerProxyAndroid* proxy_; |
| 128 int player_id_; | 144 int player_id_; |
| 129 | 145 |
| 130 scoped_refptr<media::MediaLog> media_log_; | 146 scoped_refptr<media::MediaLog> media_log_; |
| 131 UpdateNetworkStateCB update_network_state_cb_; | 147 UpdateNetworkStateCB update_network_state_cb_; |
| 132 | 148 |
| 133 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; | 149 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; |
| 134 scoped_ptr<WebKit::WebMediaSource> media_source_; | 150 scoped_ptr<WebKit::WebMediaSource> media_source_; |
| 135 | 151 |
| 136 media::PipelineStatistics statistics_; | 152 media::PipelineStatistics statistics_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 152 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_; | 168 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_; |
| 153 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; | 169 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; |
| 154 | 170 |
| 155 bool seeking_; | 171 bool seeking_; |
| 156 | 172 |
| 157 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); | 173 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); |
| 158 }; | 174 }; |
| 159 | 175 |
| 160 } // namespace webkit_media | 176 } // namespace webkit_media |
| 161 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 177 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
| 162 | |
| OLD | NEW |