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 MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ | 5 #ifndef MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ |
6 #define MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ | 6 #define MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // preload=metadata, non-streaming resources that have not started playback. | 94 // preload=metadata, non-streaming resources that have not started playback. |
95 // If already deferred, connections will be immediately closed. | 95 // If already deferred, connections will be immediately closed. |
96 void OnBufferingHaveEnough() override; | 96 void OnBufferingHaveEnough() override; |
97 | 97 |
98 int64_t GetMemoryUsage() const override; | 98 int64_t GetMemoryUsage() const override; |
99 | 99 |
100 // DataSource implementation. | 100 // DataSource implementation. |
101 // Called from demuxer thread. | 101 // Called from demuxer thread. |
102 void Stop() override; | 102 void Stop() override; |
103 | 103 |
104 void Read(int64 position, | 104 void Read(int64_t position, |
105 int size, | 105 int size, |
106 uint8* data, | 106 uint8_t* data, |
107 const DataSource::ReadCB& read_cb) override; | 107 const DataSource::ReadCB& read_cb) override; |
108 bool GetSize(int64* size_out) override; | 108 bool GetSize(int64_t* size_out) override; |
109 bool IsStreaming() override; | 109 bool IsStreaming() override; |
110 void SetBitrate(int bitrate) override; | 110 void SetBitrate(int bitrate) override; |
111 | 111 |
112 protected: | 112 protected: |
113 void OnRedirect(const scoped_refptr<UrlData>& destination); | 113 void OnRedirect(const scoped_refptr<UrlData>& destination); |
114 | 114 |
115 // A factory method to create a BufferedResourceLoader based on the read | 115 // A factory method to create a BufferedResourceLoader based on the read |
116 // parameters. | 116 // parameters. |
117 void CreateResourceLoader(int64 first_byte_position, | 117 void CreateResourceLoader(int64_t first_byte_position, |
118 int64 last_byte_position); | 118 int64_t last_byte_position); |
119 | 119 |
120 friend class MultibufferDataSourceTest; | 120 friend class MultibufferDataSourceTest; |
121 | 121 |
122 // Task posted to perform actual reading on the render thread. | 122 // Task posted to perform actual reading on the render thread. |
123 void ReadTask(); | 123 void ReadTask(); |
124 | 124 |
125 // Cancels oustanding callbacks and sets |stop_signal_received_|. Safe to call | 125 // Cancels oustanding callbacks and sets |stop_signal_received_|. Safe to call |
126 // from any thread. | 126 // from any thread. |
127 void StopInternal_Locked(); | 127 void StopInternal_Locked(); |
128 | 128 |
129 // Stops |reader_| if present. Used by Abort() and Stop(). | 129 // Stops |reader_| if present. Used by Abort() and Stop(). |
130 void StopLoader(); | 130 void StopLoader(); |
131 | 131 |
132 // Tells |reader_| the bitrate of the media. | 132 // Tells |reader_| the bitrate of the media. |
133 void SetBitrateTask(int bitrate); | 133 void SetBitrateTask(int bitrate); |
134 | 134 |
135 // BufferedResourceLoader::Start() callback for initial load. | 135 // BufferedResourceLoader::Start() callback for initial load. |
136 void StartCallback(); | 136 void StartCallback(); |
137 | 137 |
138 // Check if we've moved to a new url and update has_signgle_origin_. | 138 // Check if we've moved to a new url and update has_signgle_origin_. |
139 void UpdateSingleOrigin(); | 139 void UpdateSingleOrigin(); |
140 | 140 |
141 // MultiBufferReader progress callback. | 141 // MultiBufferReader progress callback. |
142 void ProgressCallback(int64 begin, int64 end); | 142 void ProgressCallback(int64_t begin, int64_t end); |
143 | 143 |
144 // call downloading_cb_ if needed. | 144 // call downloading_cb_ if needed. |
145 // If |force_loading| is true, we call downloading_cb_ and tell it that | 145 // If |force_loading| is true, we call downloading_cb_ and tell it that |
146 // we are currently loading, regardless of what reader_->IsLoading() says. | 146 // we are currently loading, regardless of what reader_->IsLoading() says. |
147 void UpdateLoadingState(bool force_loading); | 147 void UpdateLoadingState(bool force_loading); |
148 | 148 |
149 // Update |reader_|'s preload and buffer settings. | 149 // Update |reader_|'s preload and buffer settings. |
150 void UpdateBufferSizes(); | 150 void UpdateBufferSizes(); |
151 | 151 |
152 // crossorigin attribute on the corresponding HTML media element, if any. | 152 // crossorigin attribute on the corresponding HTML media element, if any. |
153 UrlData::CORSMode cors_mode_; | 153 UrlData::CORSMode cors_mode_; |
154 | 154 |
155 // URL of the resource requested. | 155 // URL of the resource requested. |
156 scoped_refptr<UrlData> url_data_; | 156 scoped_refptr<UrlData> url_data_; |
157 | 157 |
158 // The total size of the resource. Set during StartCallback() if the size is | 158 // The total size of the resource. Set during StartCallback() if the size is |
159 // known, otherwise it will remain kPositionNotSpecified until the size is | 159 // known, otherwise it will remain kPositionNotSpecified until the size is |
160 // determined by reaching EOF. | 160 // determined by reaching EOF. |
161 int64 total_bytes_; | 161 int64_t total_bytes_; |
162 | 162 |
163 // This value will be true if this data source can only support streaming. | 163 // This value will be true if this data source can only support streaming. |
164 // i.e. range request is not supported. | 164 // i.e. range request is not supported. |
165 bool streaming_; | 165 bool streaming_; |
166 | 166 |
167 // This is the loading state that we last reported to our owner through | 167 // This is the loading state that we last reported to our owner through |
168 // |downloading_cb_|. | 168 // |downloading_cb_|. |
169 bool loading_; | 169 bool loading_; |
170 | 170 |
171 // The task runner of the render thread. | 171 // The task runner of the render thread. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // reaching into this class from multiple threads to attain a WeakPtr. | 238 // reaching into this class from multiple threads to attain a WeakPtr. |
239 base::WeakPtr<MultibufferDataSource> weak_ptr_; | 239 base::WeakPtr<MultibufferDataSource> weak_ptr_; |
240 base::WeakPtrFactory<MultibufferDataSource> weak_factory_; | 240 base::WeakPtrFactory<MultibufferDataSource> weak_factory_; |
241 | 241 |
242 DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource); | 242 DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource); |
243 }; | 243 }; |
244 | 244 |
245 } // namespace media | 245 } // namespace media |
246 | 246 |
247 #endif // MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ | 247 #endif // MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ |
OLD | NEW |