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