| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 6 #define CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Initialize the MediaSourceDelegate. |media_source| will be owned by | 61 // Initialize the MediaSourceDelegate. |media_source| will be owned by |
| 62 // this object after this call. | 62 // this object after this call. |
| 63 void InitializeMediaSource( | 63 void InitializeMediaSource( |
| 64 const MediaSourceOpenedCB& media_source_opened_cb, | 64 const MediaSourceOpenedCB& media_source_opened_cb, |
| 65 const media::Demuxer::NeedKeyCB& need_key_cb, | 65 const media::Demuxer::NeedKeyCB& need_key_cb, |
| 66 const media::SetDecryptorReadyCB& set_decryptor_ready_cb, | 66 const media::SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 67 const UpdateNetworkStateCB& update_network_state_cb, | 67 const UpdateNetworkStateCB& update_network_state_cb, |
| 68 const DurationChangeCB& duration_change_cb); | 68 const DurationChangeCB& duration_change_cb); |
| 69 | 69 |
| 70 #if defined(GOOGLE_TV) | |
| 71 void InitializeMediaStream( | |
| 72 media::Demuxer* demuxer, | |
| 73 const UpdateNetworkStateCB& update_network_state_cb); | |
| 74 #endif | |
| 75 | |
| 76 const blink::WebTimeRanges& Buffered(); | 70 const blink::WebTimeRanges& Buffered(); |
| 77 size_t DecodedFrameCount() const; | 71 size_t DecodedFrameCount() const; |
| 78 size_t DroppedFrameCount() const; | 72 size_t DroppedFrameCount() const; |
| 79 size_t AudioDecodedByteCount() const; | 73 size_t AudioDecodedByteCount() const; |
| 80 size_t VideoDecodedByteCount() const; | 74 size_t VideoDecodedByteCount() const; |
| 81 | 75 |
| 82 // In MSE case, calls ChunkDemuxer::CancelPendingSeek(). Also sets the | 76 // In MSE case, calls ChunkDemuxer::CancelPendingSeek(). Also sets the |
| 83 // expectation that a regular seek will be arriving and to trivially finish | 77 // expectation that a regular seek will be arriving and to trivially finish |
| 84 // any browser seeks that may be requested prior to the regular seek. | 78 // any browser seeks that may be requested prior to the regular seek. |
| 85 void CancelPendingSeek(const base::TimeDelta& seek_time); | 79 void CancelPendingSeek(const base::TimeDelta& seek_time); |
| 86 | 80 |
| 87 // In MSE case, calls ChunkDemuxer::StartWaitingForSeek(), first calling | 81 // In MSE case, calls ChunkDemuxer::StartWaitingForSeek(), first calling |
| 88 // ChunkDemuxer::CancelPendingSeek() if a browser seek is in progress. | 82 // ChunkDemuxer::CancelPendingSeek() if a browser seek is in progress. |
| 89 // Also sets the expectation that a regular seek will be arriving and to | 83 // Also sets the expectation that a regular seek will be arriving and to |
| 90 // trivially finish any browser seeks that may be requested prior to the | 84 // trivially finish any browser seeks that may be requested prior to the |
| 91 // regular seek. | 85 // regular seek. |
| 92 void StartWaitingForSeek(const base::TimeDelta& seek_time); | 86 void StartWaitingForSeek(const base::TimeDelta& seek_time); |
| 93 | 87 |
| 94 // Seeks the demuxer and later calls OnDemuxerSeekDone() after the seek has | 88 // Seeks the demuxer and later calls OnDemuxerSeekDone() after the seek has |
| 95 // been completed. There must be no other seek of the demuxer currently in | 89 // been completed. There must be no other seek of the demuxer currently in |
| 96 // process when this method is called. | 90 // process when this method is called. |
| 97 // If |is_browser_seek| is true, then this is a short-term hack browser | 91 // If |is_browser_seek| is true, then this is a short-term hack browser |
| 98 // seek. | 92 // seek. |
| 99 // TODO(wolenetz): Instead of doing browser seek, browser player should replay | 93 // TODO(wolenetz): Instead of doing browser seek, browser player should replay |
| 100 // cached data since last keyframe. See http://crbug.com/304234. | 94 // cached data since last keyframe. See http://crbug.com/304234. |
| 101 void Seek(const base::TimeDelta& seek_time, bool is_browser_seek); | 95 void Seek(const base::TimeDelta& seek_time, bool is_browser_seek); |
| 102 | 96 |
| 103 void NotifyKeyAdded(const std::string& key_system); | |
| 104 | |
| 105 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. | 97 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. |
| 106 void OnReadFromDemuxer(media::DemuxerStream::Type type); | 98 void OnReadFromDemuxer(media::DemuxerStream::Type type); |
| 107 | 99 |
| 108 // Called when the player needs the new config data from ChunkDemuxer. | 100 // Called when the player needs the new config data from ChunkDemuxer. |
| 109 void OnMediaConfigRequest(); | 101 void OnMediaConfigRequest(); |
| 110 | 102 |
| 111 // Called by the Destroyer to destroy an instance of this object. | 103 // Called by the Destroyer to destroy an instance of this object. |
| 112 void Destroy(); | 104 void Destroy(); |
| 113 | 105 |
| 114 private: | 106 private: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 base::WeakPtrFactory<MediaSourceDelegate> media_weak_factory_; | 196 base::WeakPtrFactory<MediaSourceDelegate> media_weak_factory_; |
| 205 | 197 |
| 206 RendererDemuxerAndroid* demuxer_client_; | 198 RendererDemuxerAndroid* demuxer_client_; |
| 207 int demuxer_client_id_; | 199 int demuxer_client_id_; |
| 208 | 200 |
| 209 scoped_refptr<media::MediaLog> media_log_; | 201 scoped_refptr<media::MediaLog> media_log_; |
| 210 UpdateNetworkStateCB update_network_state_cb_; | 202 UpdateNetworkStateCB update_network_state_cb_; |
| 211 DurationChangeCB duration_change_cb_; | 203 DurationChangeCB duration_change_cb_; |
| 212 | 204 |
| 213 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; | 205 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; |
| 214 media::Demuxer* demuxer_; | |
| 215 bool is_demuxer_ready_; | 206 bool is_demuxer_ready_; |
| 216 | 207 |
| 217 media::SetDecryptorReadyCB set_decryptor_ready_cb_; | 208 media::SetDecryptorReadyCB set_decryptor_ready_cb_; |
| 218 | 209 |
| 219 scoped_ptr<media::DecryptingDemuxerStream> audio_decrypting_demuxer_stream_; | 210 scoped_ptr<media::DecryptingDemuxerStream> audio_decrypting_demuxer_stream_; |
| 220 scoped_ptr<media::DecryptingDemuxerStream> video_decrypting_demuxer_stream_; | 211 scoped_ptr<media::DecryptingDemuxerStream> video_decrypting_demuxer_stream_; |
| 221 | 212 |
| 222 media::DemuxerStream* audio_stream_; | 213 media::DemuxerStream* audio_stream_; |
| 223 media::DemuxerStream* video_stream_; | 214 media::DemuxerStream* video_stream_; |
| 224 | 215 |
| 225 media::PipelineStatistics statistics_; | 216 media::PipelineStatistics statistics_; |
| 226 media::Ranges<base::TimeDelta> buffered_time_ranges_; | 217 media::Ranges<base::TimeDelta> buffered_time_ranges_; |
| 227 // Keep a list of buffered time ranges. | 218 // Keep a list of buffered time ranges. |
| 228 blink::WebTimeRanges buffered_web_time_ranges_; | 219 blink::WebTimeRanges buffered_web_time_ranges_; |
| 229 | 220 |
| 230 MediaSourceOpenedCB media_source_opened_cb_; | 221 MediaSourceOpenedCB media_source_opened_cb_; |
| 231 media::Demuxer::NeedKeyCB need_key_cb_; | 222 media::Demuxer::NeedKeyCB need_key_cb_; |
| 232 | 223 |
| 233 // The currently selected key system. Empty string means that no key system | |
| 234 // has been selected. | |
| 235 blink::WebString current_key_system_; | |
| 236 | |
| 237 // Temporary for EME v0.1. In the future the init data type should be passed | 224 // Temporary for EME v0.1. In the future the init data type should be passed |
| 238 // through GenerateKeyRequest() directly from WebKit. | 225 // through GenerateKeyRequest() directly from WebKit. |
| 239 std::string init_data_type_; | 226 std::string init_data_type_; |
| 240 | 227 |
| 241 // Lock used to serialize access for |seeking_|. | 228 // Lock used to serialize access for |seeking_|. |
| 242 mutable base::Lock seeking_lock_; | 229 mutable base::Lock seeking_lock_; |
| 243 bool seeking_; | 230 bool seeking_; |
| 244 | 231 |
| 245 // Track if we are currently performing a browser seek, and track whether or | 232 // Track if we are currently performing a browser seek, and track whether or |
| 246 // not a regular seek is expected soon. If a regular seek is expected soon, | 233 // not a regular seek is expected soon. If a regular seek is expected soon, |
| 247 // then any in-progress browser seek will be canceled pending the | 234 // then any in-progress browser seek will be canceled pending the |
| 248 // regular seek, if using |chunk_demuxer_|, and any requested browser seek | 235 // regular seek, if using |chunk_demuxer_|, and any requested browser seek |
| 249 // will be trivially finished. Access is serialized by |seeking_lock_|. | 236 // will be trivially finished. Access is serialized by |seeking_lock_|. |
| 250 bool doing_browser_seek_; | 237 bool doing_browser_seek_; |
| 251 base::TimeDelta browser_seek_time_; | 238 base::TimeDelta browser_seek_time_; |
| 252 bool expecting_regular_seek_; | 239 bool expecting_regular_seek_; |
| 253 | 240 |
| 254 #if defined(GOOGLE_TV) | |
| 255 bool key_added_; | |
| 256 std::string key_system_; | |
| 257 #endif // defined(GOOGLE_TV) | |
| 258 | |
| 259 size_t access_unit_size_; | 241 size_t access_unit_size_; |
| 260 | 242 |
| 261 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); | 243 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); |
| 262 }; | 244 }; |
| 263 | 245 |
| 264 } // namespace content | 246 } // namespace content |
| 265 | 247 |
| 266 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 248 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
| OLD | NEW |