summaryrefslogtreecommitdiffstats
path: root/media/base/demuxer_stream.h
blob: e81423e8069bd3f4abaf902138c167641177d4c2 (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
// Copyright (c) 2011 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_DEMUXER_STREAM_H_
#define MEDIA_BASE_DEMUXER_STREAM_H_

#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "media/base/media_export.h"

struct AVStream;

namespace media {

class AudioDecoderConfig;
class Buffer;

class MEDIA_EXPORT DemuxerStream
    : public base::RefCountedThreadSafe<DemuxerStream> {
 public:
  typedef base::Callback<void(Buffer*)> ReadCallback;

  enum Type {
    UNKNOWN,
    AUDIO,
    VIDEO,
    NUM_TYPES,  // Always keep this entry as the last one!
  };

  // Schedules a read.  When the |read_callback| is called, the downstream
  // object takes ownership of the buffer by AddRef()'ing the buffer.
  virtual void Read(const ReadCallback& read_callback) = 0;

  // Returns an |AVStream*| if supported, or NULL.
  virtual AVStream* GetAVStream();

  // Returns the audio decoder configuration. It is an error to call this method
  // if type() != AUDIO.
  virtual const AudioDecoderConfig& audio_decoder_config() = 0;

  // Returns the type of stream.
  virtual Type type() = 0;

  virtual void EnableBitstreamConverter() = 0;

 protected:
  friend class base::RefCountedThreadSafe<DemuxerStream>;
  virtual ~DemuxerStream();
};

}  // namespace media

#endif  // MEDIA_BASE_DEMUXER_STREAM_H_