Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: webkit/media/android/media_source_delegate.h

Issue 15898002: Fix various MediaSource related crashes on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make Destroy() public and remove friend decl to make compiler happy Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 22 matching lines...) Expand all
33 namespace webkit_media { 33 namespace webkit_media {
34 34
35 class ProxyDecryptor; 35 class ProxyDecryptor;
36 class WebMediaPlayerProxyAndroid; 36 class WebMediaPlayerProxyAndroid;
37 37
38 class MediaSourceDelegate : public media::DemuxerHost { 38 class MediaSourceDelegate : public media::DemuxerHost {
39 public: 39 public:
40 typedef base::Callback<void(WebKit::WebMediaPlayer::NetworkState)> 40 typedef base::Callback<void(WebKit::WebMediaPlayer::NetworkState)>
41 UpdateNetworkStateCB; 41 UpdateNetworkStateCB;
42 42
43 // Helper class used by scoped_ptr to destroy an instance of
44 // MediaSourceDelegate.
45 class Destroyer {
46 public:
47 inline void operator()(void* media_source_delegate) const {
48 static_cast<MediaSourceDelegate*>(media_source_delegate)->Destroy();
49 }
50 };
51
43 MediaSourceDelegate(WebKit::WebFrame* frame, 52 MediaSourceDelegate(WebKit::WebFrame* frame,
44 WebKit::WebMediaPlayerClient* client, 53 WebKit::WebMediaPlayerClient* client,
45 WebMediaPlayerProxyAndroid* proxy, 54 WebMediaPlayerProxyAndroid* proxy,
46 int player_id, 55 int player_id,
47 media::MediaLog* media_log); 56 media::MediaLog* media_log);
48 virtual ~MediaSourceDelegate();
49
50 // Initialize the MediaSourceDelegate. |media_source| will be owned by 57 // Initialize the MediaSourceDelegate. |media_source| will be owned by
51 // this object after this call. 58 // this object after this call.
52 void Initialize(WebKit::WebMediaSource* media_source, 59 void Initialize(WebKit::WebMediaSource* media_source,
53 const UpdateNetworkStateCB& update_network_state_cb); 60 const UpdateNetworkStateCB& update_network_state_cb);
54 61
55 const WebKit::WebTimeRanges& Buffered(); 62 const WebKit::WebTimeRanges& Buffered();
56 size_t DecodedFrameCount() const; 63 size_t DecodedFrameCount() const;
57 size_t DroppedFrameCount() const; 64 size_t DroppedFrameCount() const;
58 size_t AudioDecodedByteCount() const; 65 size_t AudioDecodedByteCount() const;
59 size_t VideoDecodedByteCount() const; 66 size_t VideoDecodedByteCount() const;
(...skipping 12 matching lines...) Expand all
72 WebKit::WebMediaPlayer::MediaKeyException CancelKeyRequest( 79 WebKit::WebMediaPlayer::MediaKeyException CancelKeyRequest(
73 const WebKit::WebString& key_system, 80 const WebKit::WebString& key_system,
74 const WebKit::WebString& session_id); 81 const WebKit::WebString& session_id);
75 82
76 void Seek(base::TimeDelta time); 83 void Seek(base::TimeDelta time);
77 84
78 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer. 85 // Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer.
79 // 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.
80 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done); 87 void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done);
81 88
89 // Called by the Destroyer to destroy an instance of this object.
90 void Destroy();
91
82 private: 92 private:
93 // This is private to enforce use of the Destroyer.
94 virtual ~MediaSourceDelegate();
95
83 // Methods inherited from DemuxerHost. 96 // Methods inherited from DemuxerHost.
84 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; 97 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
85 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; 98 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE;
86 virtual void AddBufferedTimeRange(base::TimeDelta start, 99 virtual void AddBufferedTimeRange(base::TimeDelta start,
87 base::TimeDelta end) OVERRIDE; 100 base::TimeDelta end) OVERRIDE;
88 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; 101 virtual void SetDuration(base::TimeDelta duration) OVERRIDE;
89 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE; 102 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE;
90 103
91 // Callbacks for ChunkDemuxer & Decryptor. 104 // Callbacks for ChunkDemuxer & Decryptor.
92 void OnDemuxerInitDone(media::PipelineStatus status); 105 void OnDemuxerInitDone(media::PipelineStatus status);
106 void OnDemuxerStopDone();
93 void OnDemuxerOpened(); 107 void OnDemuxerOpened();
94 void OnKeyAdded(const std::string& key_system, const std::string& session_id); 108 void OnKeyAdded(const std::string& key_system, const std::string& session_id);
95 void OnKeyError(const std::string& key_system, 109 void OnKeyError(const std::string& key_system,
96 const std::string& session_id, 110 const std::string& session_id,
97 media::Decryptor::KeyError error_code, 111 media::Decryptor::KeyError error_code,
98 int system_code); 112 int system_code);
99 void OnKeyMessage(const std::string& key_system, 113 void OnKeyMessage(const std::string& key_system,
100 const std::string& session_id, 114 const std::string& session_id,
101 const std::string& message, 115 const std::string& message,
102 const std::string& default_url); 116 const std::string& default_url);
(...skipping 17 matching lines...) Expand all
120 media::DemuxerStream* stream, 134 media::DemuxerStream* stream,
121 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, 135 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params,
122 size_t index, 136 size_t index,
123 media::DemuxerStream::Status status, 137 media::DemuxerStream::Status status,
124 const scoped_refptr<media::DecoderBuffer>& buffer); 138 const scoped_refptr<media::DecoderBuffer>& buffer);
125 139
126 void NotifyDemuxerReady(const std::string& key_system); 140 void NotifyDemuxerReady(const std::string& key_system);
127 141
128 base::WeakPtrFactory<MediaSourceDelegate> weak_this_; 142 base::WeakPtrFactory<MediaSourceDelegate> weak_this_;
129 143
130 WebKit::WebMediaPlayerClient* const client_; 144 WebKit::WebMediaPlayerClient* client_;
131 WebMediaPlayerProxyAndroid* proxy_; 145 WebMediaPlayerProxyAndroid* proxy_;
132 int player_id_; 146 int player_id_;
133 147
134 scoped_refptr<media::MediaLog> media_log_; 148 scoped_refptr<media::MediaLog> media_log_;
135 UpdateNetworkStateCB update_network_state_cb_; 149 UpdateNetworkStateCB update_network_state_cb_;
136 150
137 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; 151 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_;
138 scoped_ptr<WebKit::WebMediaSource> media_source_; 152 scoped_ptr<WebKit::WebMediaSource> media_source_;
139 153
140 media::PipelineStatistics statistics_; 154 media::PipelineStatistics statistics_;
(...skipping 15 matching lines...) Expand all
156 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_; 170 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_;
157 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; 171 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_;
158 172
159 bool seeking_; 173 bool seeking_;
160 174
161 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); 175 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate);
162 }; 176 };
163 177
164 } // namespace webkit_media 178 } // namespace webkit_media
165 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ 179 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_
166
OLDNEW
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | webkit/media/android/media_source_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698