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 13 matching lines...) Expand all Loading... | |
24 struct MediaPlayerHostMsg_ReadFromDemuxerAck_Params; | 24 struct MediaPlayerHostMsg_ReadFromDemuxerAck_Params; |
25 } | 25 } |
26 | 26 |
27 namespace WebKit { | 27 namespace WebKit { |
28 class WebFrame; | 28 class WebFrame; |
29 class WebMediaSource; | 29 class WebMediaSource; |
30 } | 30 } |
31 | 31 |
32 namespace webkit_media { | 32 namespace webkit_media { |
33 | 33 |
34 class KeyHandlingDemuxer; | |
34 class ProxyDecryptor; | 35 class ProxyDecryptor; |
35 class WebMediaPlayerProxyAndroid; | 36 class WebMediaPlayerProxyAndroid; |
36 | 37 |
37 class MediaSourceDelegate : public media::DemuxerHost { | 38 class MediaSourceDelegate : public media::DemuxerHost { |
38 public: | 39 public: |
39 typedef base::Callback<void(WebKit::WebMediaPlayer::NetworkState)> | 40 typedef base::Callback<void(WebKit::WebMediaPlayer::NetworkState)> |
40 UpdateNetworkStateCB; | 41 UpdateNetworkStateCB; |
42 typedef base::Callback<void(const media::Demuxer*)> DestroyDemuxerCB; | |
41 | 43 |
42 MediaSourceDelegate(WebKit::WebFrame* frame, | 44 MediaSourceDelegate(WebMediaPlayerProxyAndroid* proxy, |
43 WebKit::WebMediaPlayerClient* client, | |
44 WebMediaPlayerProxyAndroid* proxy, | |
45 int player_id, | 45 int player_id, |
46 media::MediaLog* media_log); | 46 const UpdateNetworkStateCB& update_network_state_cb); |
47 virtual ~MediaSourceDelegate(); | 47 virtual ~MediaSourceDelegate(); |
48 | 48 |
49 void Initialize(scoped_ptr<WebKit::WebMediaSource> media_source, | 49 void InitializeMediaSource(WebKit::WebFrame* frame, |
50 const UpdateNetworkStateCB& update_network_state_cb); | 50 WebKit::WebMediaPlayerClient* client, |
51 WebKit::WebMediaSource* media_source, | |
52 media::MediaLog* media_log); | |
53 | |
54 void InitializeMediaStream(media::Demuxer* demuxer, | |
Ami GONE FROM CHROMIUM
2013/05/08 20:26:44
Is it easy to see why this variant wouldn't want a
| |
55 const DestroyDemuxerCB& destroy_demuxer_cb); | |
51 | 56 |
52 const WebKit::WebTimeRanges& Buffered(); | 57 const WebKit::WebTimeRanges& Buffered(); |
53 size_t DecodedFrameCount() const; | 58 size_t DecodedFrameCount() const; |
54 size_t DroppedFrameCount() const; | 59 size_t DroppedFrameCount() const; |
55 size_t AudioDecodedByteCount() const; | 60 size_t AudioDecodedByteCount() const; |
56 size_t VideoDecodedByteCount() const; | 61 size_t VideoDecodedByteCount() const; |
57 | 62 |
58 WebKit::WebMediaPlayer::MediaKeyException GenerateKeyRequest( | 63 WebKit::WebMediaPlayer::MediaKeyException GenerateKeyRequest( |
59 const WebKit::WebString& key_system, | 64 const WebKit::WebString& key_system, |
60 const unsigned char* init_data, | 65 const unsigned char* init_data, |
(...skipping 17 matching lines...) Expand all Loading... | |
78 | 83 |
79 private: | 84 private: |
80 // Methods inherited from DemuxerHost. | 85 // Methods inherited from DemuxerHost. |
81 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | 86 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; |
82 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | 87 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; |
83 virtual void AddBufferedTimeRange(base::TimeDelta start, | 88 virtual void AddBufferedTimeRange(base::TimeDelta start, |
84 base::TimeDelta end) OVERRIDE; | 89 base::TimeDelta end) OVERRIDE; |
85 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | 90 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
86 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE; | 91 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE; |
87 | 92 |
88 // Callbacks for ChunkDemuxer & Decryptor. | 93 // Callbacks for Demuxer |
89 void OnDemuxerInitDone(media::PipelineStatus status); | 94 void OnDemuxerInitDone(media::PipelineStatus status); |
90 void OnDemuxerOpened(); | |
91 void OnKeyAdded(const std::string& key_system, const std::string& session_id); | |
92 void OnKeyError(const std::string& key_system, | |
93 const std::string& session_id, | |
94 media::Decryptor::KeyError error_code, | |
95 int system_code); | |
96 void OnKeyMessage(const std::string& key_system, | |
97 const std::string& session_id, | |
98 const std::string& message, | |
99 const std::string& default_url); | |
100 void OnNeedKey(const std::string& key_system, | |
101 const std::string& type, | |
102 const std::string& session_id, | |
103 scoped_ptr<uint8[]> init_data, | |
104 int init_data_size); | |
105 void OnDecryptorReady(media::Decryptor*); | |
106 | 95 |
107 // Reads an access unit from the demuxer stream |stream| and stores it in | 96 // Reads an access unit from the demuxer stream |stream| and stores it in |
108 // the |index|th access unit in |params|. | 97 // the |index|th access unit in |params|. |
109 void ReadFromDemuxerStream( | 98 void ReadFromDemuxerStream( |
110 media::DemuxerStream* stream, | 99 media::DemuxerStream* stream, |
111 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, | 100 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, |
112 size_t index); | 101 size_t index); |
113 void OnBufferReady( | 102 void OnBufferReady( |
114 media::DemuxerStream* stream, | 103 media::DemuxerStream* stream, |
115 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, | 104 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, |
116 size_t index, | 105 size_t index, |
117 media::DemuxerStream::Status status, | 106 media::DemuxerStream::Status status, |
118 const scoped_refptr<media::DecoderBuffer>& buffer); | 107 const scoped_refptr<media::DecoderBuffer>& buffer); |
119 | 108 |
120 void NotifyDemuxerReady(const std::string& key_system); | 109 void NotifyDemuxerReady(const std::string& key_system); |
121 | 110 |
122 base::WeakPtrFactory<MediaSourceDelegate> weak_this_; | 111 base::WeakPtrFactory<MediaSourceDelegate> weak_this_; |
123 | 112 |
124 WebKit::WebMediaPlayerClient* const client_; | |
125 WebMediaPlayerProxyAndroid* proxy_; | 113 WebMediaPlayerProxyAndroid* proxy_; |
126 int player_id_; | 114 int player_id_; |
127 | 115 |
128 scoped_refptr<media::MediaLog> media_log_; | |
129 UpdateNetworkStateCB update_network_state_cb_; | 116 UpdateNetworkStateCB update_network_state_cb_; |
117 DestroyDemuxerCB destroy_demuxer_cb_; | |
130 | 118 |
131 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; | 119 scoped_ptr<KeyHandlingDemuxer> demuxer_; |
132 scoped_ptr<WebKit::WebMediaSource> media_source_; | |
133 | 120 |
134 media::PipelineStatistics statistics_; | 121 media::PipelineStatistics statistics_; |
135 media::Ranges<base::TimeDelta> buffered_time_ranges_; | 122 media::Ranges<base::TimeDelta> buffered_time_ranges_; |
136 // Keep a list of buffered time ranges. | 123 // Keep a list of buffered time ranges. |
137 WebKit::WebTimeRanges buffered_web_time_ranges_; | 124 WebKit::WebTimeRanges buffered_web_time_ranges_; |
138 | 125 |
139 // The decryptor that manages decryption keys and decrypts encrypted frames. | |
140 scoped_ptr<ProxyDecryptor> decryptor_; | |
141 | |
142 // The currently selected key system. Empty string means that no key system | |
143 // has been selected. | |
144 WebKit::WebString current_key_system_; | |
145 | |
146 // Temporary for EME v0.1. In the future the init data type should be passed | |
147 // through GenerateKeyRequest() directly from WebKit. | |
148 std::string init_data_type_; | |
149 | |
150 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_; | 126 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_; |
151 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; | 127 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; |
152 | 128 |
153 bool seeking_; | 129 bool seeking_; |
130 bool is_media_stream_; | |
Ami GONE FROM CHROMIUM
2013/05/08 20:26:44
Should this not be a MediaSourceType?
In fact sin
wonsik
2013/05/13 14:03:48
Done.
| |
154 | 131 |
155 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); |
156 }; | 133 }; |
157 | 134 |
158 } // namespace webkit_media | 135 } // namespace webkit_media |
159 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ | 136 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ |
160 | 137 |
OLD | NEW |