summaryrefslogtreecommitdiff
path: root/media/base/android/demuxer_android.h
blob: 39dc30fe7e604a04f98c96e58a8d545ea727533c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_
#define MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_

#include "base/basictypes.h"
#include "base/time/time.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_export.h"

namespace media {

class DemuxerAndroidClient;
struct DemuxerConfigs;
struct DemuxerData;

// Defines a demuxer with asynchronous operations.
class MEDIA_EXPORT DemuxerAndroid {
 public:
  virtual ~DemuxerAndroid() {}

  // Initializes this demuxer with |client| as the callback handler.
  // Must be called prior to calling any other methods.
  virtual void Initialize(DemuxerAndroidClient* client) = 0;

  // Called to request the current audio/video decoder configurations.
  virtual void RequestDemuxerConfigs() = 0;

  // Called to request additional data from the demuxer.
  virtual void RequestDemuxerData(media::DemuxerStream::Type type) = 0;

  // Called to request the demuxer to seek to a particular media time.
  // |is_browser_seek| is true if the renderer is not previously expecting this
  // seek and must coordinate with other regular seeks. Browser seek existence
  // should be hidden as much as possible from the renderer player and web apps.
  // TODO(wolenetz): Instead of doing browser seek, replay cached data since
  // last keyframe. See http://crbug.com/304234.
  virtual void RequestDemuxerSeek(const base::TimeDelta& time_to_seek,
                                  bool is_browser_seek) = 0;
};

// Defines the client callback interface.
class MEDIA_EXPORT DemuxerAndroidClient {
 public:
  // Called in response to RequestDemuxerConfigs() and also when the demuxer has
  // initialized.
  //
  // TODO(scherkus): Perhaps clients should be required to call
  // RequestDemuxerConfigs() to initialize themselves instead of the demuxer
  // calling this method without being prompted.
  virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) = 0;

  // Called in response to RequestDemuxerData().
  virtual void OnDemuxerDataAvailable(const DemuxerData& params) = 0;

  // Called in response to RequestDemuxerSeek().
  // If this is in response to a request with |is_browser_seek| set to true,
  // then |actual_browser_seek_time| may differ from the requested
  // |time_to_seek|, and reflects the actual time seeked to by the demuxer.
  // For regular demuxer seeks, |actual_browser_seek_time| is kNoTimestamp() and
  // should be ignored by browser player.
  virtual void OnDemuxerSeekDone(
      base::TimeDelta actual_browser_seek_time) = 0;

  // Called whenever the demuxer has detected a duration change.
  virtual void OnDemuxerDurationChanged(base::TimeDelta duration) = 0;

 protected:
  virtual ~DemuxerAndroidClient() {}
};

}  // namespace media

#endif  // MEDIA_BASE_ANDROID_DEMUXER_ANDROID_H_