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 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_RESOURCE_GETTER_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_RESOURCE_GETTER_H_ 7 8 #include <string> 9 10 #include "base/callback.h" 11 #include "base/files/file_path.h" 12 #include "base/strings/string16.h" 13 #include "base/time/time.h" 14 #include "media/base/media_export.h" 15 #include "url/gurl.h" 16 17 namespace media { 18 19 // Class for asynchronously retrieving resources for a media URL. All callbacks 20 // are executed on the caller's thread. 21 class MEDIA_EXPORT MediaResourceGetter { 22 public: 23 // Callback to get the cookies. Args: cookies string. 24 typedef base::Callback<void(const std::string&)> GetCookieCB; 25 26 // Callback to get the platform path. Args: platform path. 27 typedef base::Callback<void(const std::string&)> GetPlatformPathCB; 28 29 // Callback to get the auth credentials. Args: username and password. 30 typedef base::Callback<void(const base::string16&, const base::string16&)> 31 GetAuthCredentialsCB; 32 33 // Callback to get the media metadata. Args: duration, width, height, and 34 // whether the information is retrieved successfully. 35 typedef base::Callback<void(base::TimeDelta, int, int, bool)> 36 ExtractMediaMetadataCB; 37 virtual ~MediaResourceGetter(); 38 39 // Method for getting the auth credentials for a URL. 40 virtual void GetAuthCredentials(const GURL& url, 41 const GetAuthCredentialsCB& callback) = 0; 42 43 // Method for getting the cookies for a given URL. 44 virtual void GetCookies(const GURL& url, 45 const GURL& first_party_for_cookies, 46 const GetCookieCB& callback) = 0; 47 48 // Method for getting the platform path from a file system or blob URL. 49 virtual void GetPlatformPathFromURL( 50 const GURL& url, 51 const GetPlatformPathCB& callback) = 0; 52 53 // Extracts the metadata from a media URL. Once completed, the provided 54 // callback function will be run. 55 virtual void ExtractMediaMetadata( 56 const std::string& url, 57 const std::string& cookies, 58 const std::string& user_agent, 59 const ExtractMediaMetadataCB& callback) = 0; 60 61 // Extracts the metadata from a file descriptor. Once completed, the 62 // provided callback function will be run. 63 virtual void ExtractMediaMetadata( 64 const int fd, 65 const int64 offset, 66 const int64 size, 67 const ExtractMediaMetadataCB& callback) = 0; 68 }; 69 70 } // namespace media 71 72 #endif // MEDIA_BASE_ANDROID_MEDIA_RESOURCE_GETTER_H_ 73