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

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

Issue 14247018: Implement WebRTC in Chrome for TV (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: refactored according to Ami's suggestion 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 13 matching lines...) Expand all
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);
51 55
52 const WebKit::WebTimeRanges& Buffered(); 56 const WebKit::WebTimeRanges& Buffered();
53 size_t DecodedFrameCount() const; 57 size_t DecodedFrameCount() const;
54 size_t DroppedFrameCount() const; 58 size_t DroppedFrameCount() const;
55 size_t AudioDecodedByteCount() const; 59 size_t AudioDecodedByteCount() const;
56 size_t VideoDecodedByteCount() const; 60 size_t VideoDecodedByteCount() const;
57 61
58 WebKit::WebMediaPlayer::MediaKeyException GenerateKeyRequest( 62 WebKit::WebMediaPlayer::MediaKeyException GenerateKeyRequest(
59 const WebKit::WebString& key_system, 63 const WebKit::WebString& key_system,
60 const unsigned char* init_data, 64 const unsigned char* init_data,
(...skipping 17 matching lines...) Expand all
78 82
79 private: 83 private:
80 // Methods inherited from DemuxerHost. 84 // Methods inherited from DemuxerHost.
81 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; 85 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
82 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; 86 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE;
83 virtual void AddBufferedTimeRange(base::TimeDelta start, 87 virtual void AddBufferedTimeRange(base::TimeDelta start,
84 base::TimeDelta end) OVERRIDE; 88 base::TimeDelta end) OVERRIDE;
85 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; 89 virtual void SetDuration(base::TimeDelta duration) OVERRIDE;
86 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE; 90 virtual void OnDemuxerError(media::PipelineStatus status) OVERRIDE;
87 91
88 // Callbacks for ChunkDemuxer & Decryptor. 92 // Callbacks for Demuxer
89 void OnDemuxerInitDone(media::PipelineStatus status); 93 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 94
107 // Reads an access unit from the demuxer stream |stream| and stores it in 95 // Reads an access unit from the demuxer stream |stream| and stores it in
108 // the |index|th access unit in |params|. 96 // the |index|th access unit in |params|.
109 void ReadFromDemuxerStream( 97 void ReadFromDemuxerStream(
110 media::DemuxerStream* stream, 98 media::DemuxerStream* stream,
111 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, 99 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params,
112 size_t index); 100 size_t index);
113 void OnBufferReady( 101 void OnBufferReady(
114 media::DemuxerStream* stream, 102 media::DemuxerStream* stream,
115 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params, 103 media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params,
116 size_t index, 104 size_t index,
117 media::DemuxerStream::Status status, 105 media::DemuxerStream::Status status,
118 const scoped_refptr<media::DecoderBuffer>& buffer); 106 const scoped_refptr<media::DecoderBuffer>& buffer);
119 107
120 void NotifyDemuxerReady(const std::string& key_system); 108 void NotifyDemuxerReady(const std::string& key_system);
121 109
122 base::WeakPtrFactory<MediaSourceDelegate> weak_this_; 110 base::WeakPtrFactory<MediaSourceDelegate> weak_this_;
123 111
124 WebKit::WebMediaPlayerClient* const client_;
125 WebMediaPlayerProxyAndroid* proxy_; 112 WebMediaPlayerProxyAndroid* proxy_;
126 int player_id_; 113 int player_id_;
127 114
128 scoped_refptr<media::MediaLog> media_log_;
129 UpdateNetworkStateCB update_network_state_cb_; 115 UpdateNetworkStateCB update_network_state_cb_;
116 DestroyDemuxerCB destroy_demuxer_cb_;
130 117
131 scoped_ptr<media::ChunkDemuxer> chunk_demuxer_; 118 scoped_ptr<KeyHandlingDemuxer> demuxer_;
132 scoped_ptr<WebKit::WebMediaSource> media_source_;
133 119
134 media::PipelineStatistics statistics_; 120 media::PipelineStatistics statistics_;
135 media::Ranges<base::TimeDelta> buffered_time_ranges_; 121 media::Ranges<base::TimeDelta> buffered_time_ranges_;
136 // Keep a list of buffered time ranges. 122 // Keep a list of buffered time ranges.
137 WebKit::WebTimeRanges buffered_web_time_ranges_; 123 WebKit::WebTimeRanges buffered_web_time_ranges_;
138 124
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_; 125 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> audio_params_;
151 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_; 126 scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> video_params_;
152 127
153 bool seeking_; 128 bool seeking_;
129 size_t access_unit_size_;
154 130
155 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate); 131 DISALLOW_COPY_AND_ASSIGN(MediaSourceDelegate);
156 }; 132 };
157 133
158 } // namespace webkit_media 134 } // namespace webkit_media
159 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_ 135 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_SOURCE_DELEGATE_H_
160 136
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698