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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/message_loop/message_loop.h" | |
16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
17 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
18 #include "media/base/demuxer.h" | 17 #include "media/base/demuxer.h" |
19 #include "media/base/media_keys.h" | 18 #include "media/base/media_keys.h" |
20 #include "media/base/pipeline_status.h" | 19 #include "media/base/pipeline_status.h" |
21 #include "media/base/ranges.h" | 20 #include "media/base/ranges.h" |
22 #include "media/base/text_track.h" | 21 #include "media/base/text_track.h" |
23 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 22 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
24 | 23 |
| 24 namespace base { |
| 25 class SingleThreadTaskRunner; |
| 26 } |
| 27 |
25 namespace media { | 28 namespace media { |
26 class ChunkDemuxer; | 29 class ChunkDemuxer; |
27 class DecoderBuffer; | 30 class DecoderBuffer; |
28 class DecryptingDemuxerStream; | 31 class DecryptingDemuxerStream; |
29 class DemuxerStream; | 32 class DemuxerStream; |
30 class MediaLog; | 33 class MediaLog; |
31 struct DemuxerConfigs; | 34 struct DemuxerConfigs; |
32 struct DemuxerData; | 35 struct DemuxerData; |
33 } | 36 } |
34 | 37 |
(...skipping 11 matching lines...) Expand all Loading... |
46 | 49 |
47 // Helper class used by scoped_ptr to destroy an instance of | 50 // Helper class used by scoped_ptr to destroy an instance of |
48 // MediaSourceDelegate. | 51 // MediaSourceDelegate. |
49 class Destroyer { | 52 class Destroyer { |
50 public: | 53 public: |
51 inline void operator()(void* media_source_delegate) const { | 54 inline void operator()(void* media_source_delegate) const { |
52 static_cast<MediaSourceDelegate*>(media_source_delegate)->Destroy(); | 55 static_cast<MediaSourceDelegate*>(media_source_delegate)->Destroy(); |
53 } | 56 } |
54 }; | 57 }; |
55 | 58 |
56 MediaSourceDelegate(RendererDemuxerAndroid* demuxer_client, | 59 MediaSourceDelegate( |
57 int demuxer_client_id, | 60 RendererDemuxerAndroid* demuxer_client, |
58 const scoped_refptr<base::MessageLoopProxy>& media_loop, | 61 int demuxer_client_id, |
59 const scoped_refptr<media::MediaLog> media_log); | 62 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 63 const scoped_refptr<media::MediaLog> media_log); |
60 | 64 |
61 // Initialize the MediaSourceDelegate. |media_source| will be owned by | 65 // Initialize the MediaSourceDelegate. |media_source| will be owned by |
62 // this object after this call. | 66 // this object after this call. |
63 void InitializeMediaSource( | 67 void InitializeMediaSource( |
64 const MediaSourceOpenedCB& media_source_opened_cb, | 68 const MediaSourceOpenedCB& media_source_opened_cb, |
65 const media::Demuxer::NeedKeyCB& need_key_cb, | 69 const media::Demuxer::NeedKeyCB& need_key_cb, |
66 const media::SetDecryptorReadyCB& set_decryptor_ready_cb, | 70 const media::SetDecryptorReadyCB& set_decryptor_ready_cb, |
67 const UpdateNetworkStateCB& update_network_state_cb, | 71 const UpdateNetworkStateCB& update_network_state_cb, |
68 const DurationChangeCB& duration_change_cb); | 72 const DurationChangeCB& duration_change_cb); |
69 | 73 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // not a regular seek is expected soon. If a regular seek is expected soon, | 228 // not a regular seek is expected soon. If a regular seek is expected soon, |
225 // then any in-progress browser seek will be canceled pending the | 229 // then any in-progress browser seek will be canceled pending the |
226 // regular seek, if using |chunk_demuxer_|, and any requested browser seek | 230 // regular seek, if using |chunk_demuxer_|, and any requested browser seek |
227 // will be trivially finished. Access is serialized by |seeking_lock_|. | 231 // will be trivially finished. Access is serialized by |seeking_lock_|. |
228 bool doing_browser_seek_; | 232 bool doing_browser_seek_; |
229 base::TimeDelta browser_seek_time_; | 233 base::TimeDelta browser_seek_time_; |
230 bool expecting_regular_seek_; | 234 bool expecting_regular_seek_; |
231 | 235 |
232 size_t access_unit_size_; | 236 size_t access_unit_size_; |
233 | 237 |
234 // Message loop for main renderer and media threads. | 238 // Task runner for main renderer and media threads. |
235 const scoped_refptr<base::MessageLoopProxy> main_loop_; | 239 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
236 const scoped_refptr<base::MessageLoopProxy> media_loop_; | 240 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
237 | 241 |
238 // NOTE: Weak pointers must be invalidated before all other member variables. | 242 // NOTE: Weak pointers must be invalidated before all other member variables. |
239 base::WeakPtrFactory<MediaSourceDelegate> main_weak_factory_; | 243 base::WeakPtrFactory<MediaSourceDelegate> main_weak_factory_; |
240 base::WeakPtrFactory<MediaSourceDelegate> media_weak_factory_; | 244 base::WeakPtrFactory<MediaSourceDelegate> media_weak_factory_; |
241 base::WeakPtr<MediaSourceDelegate> main_weak_this_; | 245 base::WeakPtr<MediaSourceDelegate> main_weak_this_; |
242 | 246 |
243 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); | 247 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); |
244 }; | 248 }; |
245 | 249 |
246 } // namespace content | 250 } // namespace content |
247 | 251 |
248 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 252 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
OLD | NEW |