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 3 // found in the LICENSE file. 4 5 #ifndef WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_ 6 #define WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_ 7 8 #include "media/base/filters.h" 9 #include "media/base/pipeline_status.h" 10 11 namespace webkit_glue { 12 13 // An interface that allows WebMediaPlayerImpl::Proxy to communicate with the 14 // DataSource in the pipeline. 15 class WebDataSource : public media::DataSource { 16 public: 17 WebDataSource(); 18 virtual ~WebDataSource(); 19 20 // Initialize this object using |url|. This object calls |callback| when 21 // initialization has completed. 22 virtual void Initialize(const std::string& url, 23 media::PipelineStatusCallback* callback) = 0; 24 25 // Called to cancel initialization. The callback passed in Initialize() will 26 // be destroyed and will not be called after this method returns. Once this 27 // method returns, the object will be in an uninitialized state and 28 // Initialize() cannot be called again. The caller is expected to release 29 // its handle to this object and never call it again. 30 virtual void CancelInitialize() = 0; 31 32 // Returns true if the media resource has a single origin, false otherwise. 33 // 34 // Method called on the render thread. 35 virtual bool HasSingleOrigin() = 0; 36 37 // This method is used to unblock any read calls that would cause the 38 // media pipeline to stall. 39 // 40 // Method called on the render thread. 41 virtual void Abort() = 0; 42 43 private: 44 DISALLOW_COPY_AND_ASSIGN(WebDataSource); 45 }; 46 47 // Temporary hack to allow WebMediaPlayerImpl::Proxy::AddDataSource() to 48 // be called when WebDataSource objects are created. This can be removed 49 // once WebMediaPlayerImpl::Proxy is fixed so it doesn't have to track 50 // WebDataSources. Proxy only has to track WebDataSources so it can call Abort() 51 // on them at shutdown. Once cancellation is added to DataSource and pause 52 // support in Demuxers cancel pending reads, Proxy shouldn't have to keep 53 // a WebDataSource list or call Abort(). 54 typedef Callback1<WebDataSource*>::Type WebDataSourceBuildObserverHack; 55 56 } // namespace webkit_glue 57 58 #endif // WEBKIT_GLUE_MEDIA_WEB_DATA_SOURCE_H_ 59