| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // An extremely simple implementation of DataSource that downloads the entire | 5 // An extremely simple implementation of DataSource that downloads the entire |
| 6 // media resource into memory before signaling that initialization has finished. | 6 // media resource into memory before signaling that initialization has finished. |
| 7 // Primarily used to test <audio> and <video> with buffering/caching removed | 7 // Primarily used to test <audio> and <video> with buffering/caching removed |
| 8 // from the equation. | 8 // from the equation. |
| 9 | 9 |
| 10 #ifndef WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ | 10 #ifndef WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ |
| 11 #define WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ | 11 #define WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 18 #include "media/base/filter_factories.h" | 18 #include "media/base/filter_factories.h" |
| 19 #include "media/base/filters.h" | 19 #include "media/base/data_source.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
| 25 #include "webkit/media/web_data_source.h" | 25 #include "webkit/media/web_data_source.h" |
| 26 | 26 |
| 27 class MessageLoop; | 27 class MessageLoop; |
| 28 | 28 |
| 29 namespace media { | 29 namespace media { |
| 30 class MediaLog; | 30 class MediaLog; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace webkit_media { | 33 namespace webkit_media { |
| 34 | 34 |
| 35 class SimpleDataSource | 35 class SimpleDataSource |
| 36 : public WebDataSource, | 36 : public WebDataSource, |
| 37 public WebKit::WebURLLoaderClient { | 37 public WebKit::WebURLLoaderClient { |
| 38 public: | 38 public: |
| 39 // Creates a DataSourceFactory for building SimpleDataSource objects. | 39 // Creates a DataSourceFactory for building SimpleDataSource objects. |
| 40 static media::DataSourceFactory* CreateFactory( | 40 static media::DataSourceFactory* CreateFactory( |
| 41 MessageLoop* render_loop, | 41 MessageLoop* render_loop, |
| 42 WebKit::WebFrame* frame, | 42 WebKit::WebFrame* frame, |
| 43 media::MediaLog* media_log, | 43 media::MediaLog* media_log, |
| 44 const WebDataSourceBuildObserverHack& build_observer); | 44 const WebDataSourceBuildObserverHack& build_observer); |
| 45 | 45 |
| 46 SimpleDataSource(MessageLoop* render_loop, WebKit::WebFrame* frame); | 46 SimpleDataSource(MessageLoop* render_loop, WebKit::WebFrame* frame); |
| 47 virtual ~SimpleDataSource(); | 47 virtual ~SimpleDataSource(); |
| 48 | 48 |
| 49 // media::Filter implementation. | 49 // media::DataSource implementation. |
| 50 virtual void set_host(media::FilterHost* host) OVERRIDE; | 50 virtual void set_host(media::DataSourceHost* host) OVERRIDE; |
| 51 virtual void Stop(const base::Closure& callback) OVERRIDE; | 51 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 52 | |
| 53 // media::DataSource implementation. | |
| 54 virtual void Read(int64 position, | 52 virtual void Read(int64 position, |
| 55 size_t size, | 53 size_t size, |
| 56 uint8* data, | 54 uint8* data, |
| 57 const DataSource::ReadCallback& read_callback) OVERRIDE; | 55 const DataSource::ReadCallback& read_callback) OVERRIDE; |
| 58 virtual bool GetSize(int64* size_out) OVERRIDE; | 56 virtual bool GetSize(int64* size_out) OVERRIDE; |
| 59 virtual bool IsStreaming() OVERRIDE; | 57 virtual bool IsStreaming() OVERRIDE; |
| 60 virtual void SetPreload(media::Preload preload) OVERRIDE; | 58 virtual void SetPreload(media::Preload preload) OVERRIDE; |
| 61 virtual void SetBitrate(int bitrate) OVERRIDE; | 59 virtual void SetBitrate(int bitrate) OVERRIDE; |
| 62 | 60 |
| 63 // Used to inject a mock used for unittests. | 61 // Used to inject a mock used for unittests. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 142 |
| 145 // Used to ensure mocks for unittests are used instead of reset in Start(). | 143 // Used to ensure mocks for unittests are used instead of reset in Start(). |
| 146 bool keep_test_loader_; | 144 bool keep_test_loader_; |
| 147 | 145 |
| 148 DISALLOW_COPY_AND_ASSIGN(SimpleDataSource); | 146 DISALLOW_COPY_AND_ASSIGN(SimpleDataSource); |
| 149 }; | 147 }; |
| 150 | 148 |
| 151 } // namespace webkit_media | 149 } // namespace webkit_media |
| 152 | 150 |
| 153 #endif // WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ | 151 #endif // WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ |
| OLD | NEW |