Home | History | Annotate | Download | only in android
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_
      6 #define MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/time/time.h"
     10 #include "media/base/demuxer_stream.h"
     11 #include "media/base/media_export.h"
     12 
     13 namespace media {
     14 
     15 class DemuxerAndroidClient;
     16 struct DemuxerConfigs;
     17 struct DemuxerData;
     18 
     19 // Defines a demuxer with asynchronous operations.
     20 class MEDIA_EXPORT DemuxerAndroid {
     21  public:
     22   virtual ~DemuxerAndroid() {}
     23 
     24   // Initializes this demuxer with |client| as the callback handler.
     25   // Must be called prior to calling any other methods.
     26   virtual void Initialize(DemuxerAndroidClient* client) = 0;
     27 
     28   // Called to request additional data from the demuxer.
     29   virtual void RequestDemuxerData(media::DemuxerStream::Type type) = 0;
     30 
     31   // Called to request the demuxer to seek to a particular media time.
     32   // |is_browser_seek| is true if the renderer is not previously expecting this
     33   // seek and must coordinate with other regular seeks. Browser seek existence
     34   // should be hidden as much as possible from the renderer player and web apps.
     35   // TODO(wolenetz): Instead of doing browser seek, replay cached data since
     36   // last keyframe. See http://crbug.com/304234.
     37   virtual void RequestDemuxerSeek(const base::TimeDelta& time_to_seek,
     38                                   bool is_browser_seek) = 0;
     39 };
     40 
     41 // Defines the client callback interface.
     42 class MEDIA_EXPORT DemuxerAndroidClient {
     43  public:
     44   // Called when the demuxer has initialized.
     45   virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) = 0;
     46 
     47   // Called in response to RequestDemuxerData().
     48   virtual void OnDemuxerDataAvailable(const DemuxerData& params) = 0;
     49 
     50   // Called in response to RequestDemuxerSeek().
     51   // If this is in response to a request with |is_browser_seek| set to true,
     52   // then |actual_browser_seek_time| may differ from the requested
     53   // |time_to_seek|, and reflects the actual time seeked to by the demuxer.
     54   // For regular demuxer seeks, |actual_browser_seek_time| is kNoTimestamp() and
     55   // should be ignored by browser player.
     56   virtual void OnDemuxerSeekDone(
     57       base::TimeDelta actual_browser_seek_time) = 0;
     58 
     59   // Called whenever the demuxer has detected a duration change.
     60   virtual void OnDemuxerDurationChanged(base::TimeDelta duration) = 0;
     61 
     62  protected:
     63   virtual ~DemuxerAndroidClient() {}
     64 };
     65 
     66 }  // namespace media
     67 
     68 #endif  // MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_
     69