12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef MEDIA_BASE_ANDROID_MEDIA_RESOURCE_GETTER_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MEDIA_BASE_ANDROID_MEDIA_RESOURCE_GETTER_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/callback.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "base/strings/string16.h"
13eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "media/base/media_export.h"
157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace media {
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Class for asynchronously retrieving resources for a media URL. All callbacks
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// are executed on the caller's thread.
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class MEDIA_EXPORT MediaResourceGetter {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Callback to get the cookies. Args: cookies string.
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef base::Callback<void(const std::string&)> GetCookieCB;
255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Callback to get the platform path. Args: platform path.
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef base::Callback<void(const std::string&)> GetPlatformPathCB;
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Callback to get the auth credentials. Args: username and password.
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  typedef base::Callback<void(const base::string16&, const base::string16&)>
315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      GetAuthCredentialsCB;
325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Callback to get the media metadata. Args: duration, width, height, and
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // whether the information is retrieved successfully.
35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  typedef base::Callback<void(base::TimeDelta, int, int, bool)>
36c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      ExtractMediaMetadataCB;
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~MediaResourceGetter();
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Method for getting the auth credentials for a URL.
405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual void GetAuthCredentials(const GURL& url,
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                                  const GetAuthCredentialsCB& callback) = 0;
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Method for getting the cookies for a given URL.
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void GetCookies(const GURL& url,
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          const GURL& first_party_for_cookies,
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          const GetCookieCB& callback) = 0;
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Method for getting the platform path from a file system or blob URL.
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void GetPlatformPathFromURL(
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const GURL& url,
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const GetPlatformPathCB& callback) = 0;
52c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Extracts the metadata from a media URL. Once completed, the provided
54c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // callback function will be run.
55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void ExtractMediaMetadata(
56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const std::string& url,
57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const std::string& cookies,
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::string& user_agent,
59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const ExtractMediaMetadataCB& callback) = 0;
605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Extracts the metadata from a file descriptor. Once completed, the
625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // provided callback function will be run.
635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual void ExtractMediaMetadata(
645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      const int fd,
655f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      const int64 offset,
665f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      const int64 size,
675f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      const ExtractMediaMetadataCB& callback) = 0;
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace media
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // MEDIA_BASE_ANDROID_MEDIA_RESOURCE_GETTER_H_
73