• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
~DemuxerAndroid()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 the current audio/video decoder configurations.
29   virtual void RequestDemuxerConfigs() = 0;
30 
31   // Called to request additional data from the demuxer.
32   virtual void RequestDemuxerData(media::DemuxerStream::Type type) = 0;
33 
34   // Called to request the demuxer to seek to a particular media time.
35   // |is_browser_seek| is true if the renderer is not previously expecting this
36   // seek and must coordinate with other regular seeks. Browser seek existence
37   // should be hidden as much as possible from the renderer player and web apps.
38   // TODO(wolenetz): Instead of doing browser seek, replay cached data since
39   // last keyframe. See http://crbug.com/304234.
40   virtual void RequestDemuxerSeek(const base::TimeDelta& time_to_seek,
41                                   bool is_browser_seek) = 0;
42 };
43 
44 // Defines the client callback interface.
45 class MEDIA_EXPORT DemuxerAndroidClient {
46  public:
47   // Called in response to RequestDemuxerConfigs() and also when the demuxer has
48   // initialized.
49   //
50   // TODO(scherkus): Perhaps clients should be required to call
51   // RequestDemuxerConfigs() to initialize themselves instead of the demuxer
52   // calling this method without being prompted.
53   virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) = 0;
54 
55   // Called in response to RequestDemuxerData().
56   virtual void OnDemuxerDataAvailable(const DemuxerData& params) = 0;
57 
58   // Called in response to RequestDemuxerSeek().
59   // If this is in response to a request with |is_browser_seek| set to true,
60   // then |actual_browser_seek_time| may differ from the requested
61   // |time_to_seek|, and reflects the actual time seeked to by the demuxer.
62   // For regular demuxer seeks, |actual_browser_seek_time| is kNoTimestamp() and
63   // should be ignored by browser player.
64   virtual void OnDemuxerSeekDone(
65       const base::TimeDelta& actual_browser_seek_time) = 0;
66 
67   // Called whenever the demuxer has detected a duration change.
68   virtual void OnDemuxerDurationChanged(base::TimeDelta duration) = 0;
69 
70  protected:
~DemuxerAndroidClient()71   virtual ~DemuxerAndroidClient() {}
72 };
73 
74 }  // namespace media
75 
76 #endif  // MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_
77