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 "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" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "media/base/decryptor.h" | 14 #include "media/base/decryptor.h" |
15 #include "media/base/demuxer.h" | 15 #include "media/base/demuxer.h" |
16 #include "media/base/media_keys.h" | 16 #include "media/base/media_keys.h" |
17 #include "media/base/pipeline_status.h" | 17 #include "media/base/pipeline_status.h" |
18 #include "media/base/ranges.h" | 18 #include "media/base/ranges.h" |
19 #include "media/base/text_track.h" | 19 #include "media/base/text_track.h" |
20 #include "third_party/WebKit/public/web/WebMediaPlayer.h" | 20 #include "third_party/WebKit/public/web/WebMediaPlayer.h" |
21 | 21 |
22 namespace media { | 22 namespace media { |
23 class ChunkDemuxer; | 23 class ChunkDemuxer; |
24 class DecoderBuffer; | 24 class DecoderBuffer; |
25 class DecryptingDemuxerStream; | 25 class DecryptingDemuxerStream; |
26 class DemuxerStream; | 26 class DemuxerStream; |
27 class MediaLog; | 27 class MediaLog; |
28 struct MediaPlayerHostMsg_DemuxerReady_Params; | 28 struct DemuxerConfigs; |
29 struct MediaPlayerHostMsg_ReadFromDemuxerAck_Params; | 29 struct DemuxerData; |
30 } | 30 } |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 | 33 |
34 class WebMediaPlayerProxyAndroid; | 34 class WebMediaPlayerProxyAndroid; |
35 | 35 |
36 class MediaSourceDelegate : public media::DemuxerHost { | 36 class MediaSourceDelegate : public media::DemuxerHost { |
37 public: | 37 public: |
38 typedef base::Callback<void(WebKit::WebMediaSource*)> | 38 typedef base::Callback<void(WebKit::WebMediaSource*)> |
39 MediaSourceOpenedCB; | 39 MediaSourceOpenedCB; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. | 86 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. |
87 void OnReadFromDemuxer(media::DemuxerStream::Type type); | 87 void OnReadFromDemuxer(media::DemuxerStream::Type type); |
88 | 88 |
89 // Called when the player needs the new config data from ChunkDemuxer. | 89 // Called when the player needs the new config data from ChunkDemuxer. |
90 void OnMediaConfigRequest(); | 90 void OnMediaConfigRequest(); |
91 | 91 |
92 // Called by the Destroyer to destroy an instance of this object. | 92 // Called by the Destroyer to destroy an instance of this object. |
93 void Destroy(); | 93 void Destroy(); |
94 | 94 |
95 private: | 95 private: |
96 typedef base::Callback<void( | 96 typedef base::Callback<void(scoped_ptr<media::DemuxerData> data)> |
97 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params)> | 97 ReadFromDemuxerAckCB; |
98 ReadFromDemuxerAckCB; | 98 typedef base::Callback<void(scoped_ptr<media::DemuxerConfigs> configs)> |
99 typedef base::Callback<void( | 99 DemuxerReadyCB; |
100 scoped_ptr<media::MediaPlayerHostMsg_DemuxerReady_Params> params)> | |
101 DemuxerReadyCB; | |
102 | 100 |
103 // This is private to enforce use of the Destroyer. | 101 // This is private to enforce use of the Destroyer. |
104 virtual ~MediaSourceDelegate(); | 102 virtual ~MediaSourceDelegate(); |
105 | 103 |
106 // Methods inherited from DemuxerHost. | 104 // Methods inherited from DemuxerHost. |
107 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | 105 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; |
108 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | 106 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; |
109 virtual void AddBufferedTimeRange(base::TimeDelta start, | 107 virtual void AddBufferedTimeRange(base::TimeDelta start, |
110 base::TimeDelta end) OVERRIDE; | 108 base::TimeDelta end) OVERRIDE; |
111 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | 109 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
(...skipping 29 matching lines...) Expand all Loading... |
141 void OnDemuxerStopDone(); | 139 void OnDemuxerStopDone(); |
142 void OnDemuxerOpened(); | 140 void OnDemuxerOpened(); |
143 void OnNeedKey(const std::string& type, | 141 void OnNeedKey(const std::string& type, |
144 const std::string& session_id, | 142 const std::string& session_id, |
145 const std::vector<uint8>& init_data); | 143 const std::vector<uint8>& init_data); |
146 scoped_ptr<media::TextTrack> OnAddTextTrack(media::TextKind kind, | 144 scoped_ptr<media::TextTrack> OnAddTextTrack(media::TextKind kind, |
147 const std::string& label, | 145 const std::string& label, |
148 const std::string& language); | 146 const std::string& language); |
149 void NotifyDemuxerReady(); | 147 void NotifyDemuxerReady(); |
150 bool CanNotifyDemuxerReady(); | 148 bool CanNotifyDemuxerReady(); |
151 void SendDemuxerReady( | 149 void SendDemuxerReady(scoped_ptr<media::DemuxerConfigs> configs); |
152 scoped_ptr<media::MediaPlayerHostMsg_DemuxerReady_Params> params); | |
153 | 150 |
154 void StopDemuxer(); | 151 void StopDemuxer(); |
155 void InitializeDemuxer(); | 152 void InitializeDemuxer(); |
156 void SeekInternal(base::TimeDelta time, unsigned seek_request_id); | 153 void SeekInternal(base::TimeDelta time, unsigned seek_request_id); |
157 void OnReadFromDemuxerInternal(media::DemuxerStream::Type type); | 154 void OnReadFromDemuxerInternal(media::DemuxerStream::Type type); |
158 // Reads an access unit from the demuxer stream |stream| and stores it in | 155 // Reads an access unit from the demuxer stream |stream| and stores it in |
159 // the |index|th access unit in |params|. | 156 // the |index|th access unit in |params|. |
160 void ReadFromDemuxerStream( | 157 void ReadFromDemuxerStream(media::DemuxerStream::Type type, |
161 media::DemuxerStream::Type type, | 158 scoped_ptr<media::DemuxerData> data, |
162 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params, | 159 size_t index); |
163 size_t index); | 160 void OnBufferReady(media::DemuxerStream::Type type, |
164 void OnBufferReady( | 161 scoped_ptr<media::DemuxerData> data, |
165 media::DemuxerStream::Type type, | 162 size_t index, |
166 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params, | 163 media::DemuxerStream::Status status, |
167 size_t index, | 164 const scoped_refptr<media::DecoderBuffer>& buffer); |
168 media::DemuxerStream::Status status, | |
169 const scoped_refptr<media::DecoderBuffer>& buffer); | |
170 | 165 |
171 void SendReadFromDemuxerAck( | 166 void SendReadFromDemuxerAck(scoped_ptr<media::DemuxerData> data); |
172 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params); | |
173 | 167 |
174 // Helper function for calculating duration. | 168 // Helper function for calculating duration. |
175 int GetDurationMs(); | 169 int GetDurationMs(); |
176 | 170 |
177 bool HasEncryptedStream(); | 171 bool HasEncryptedStream(); |
178 | 172 |
179 void SetSeeking(bool seeking); | 173 void SetSeeking(bool seeking); |
180 bool IsSeeking() const; | 174 bool IsSeeking() const; |
181 | 175 |
182 // Weak pointer must be dereferenced and invalidated on the same thread. | 176 // Weak pointer must be dereferenced and invalidated on the same thread. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 std::string key_system_; | 237 std::string key_system_; |
244 | 238 |
245 size_t access_unit_size_; | 239 size_t access_unit_size_; |
246 | 240 |
247 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); | 241 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); |
248 }; | 242 }; |
249 | 243 |
250 } // namespace content | 244 } // namespace content |
251 | 245 |
252 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 246 #endif // CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
OLD | NEW |