blob: 5bdb4463205947b1a50c20621176042b891a374d [file] [log] [blame]
[email protected]a2b5c472011-09-13 20:24:101// Copyright (c) 2011 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_DEMUXER_H_
6#define MEDIA_BASE_DEMUXER_H_
7
8#include "base/memory/ref_counted.h"
9#include "media/base/demuxer_stream.h"
10#include "media/base/media_export.h"
11
12// TODO(acolwell): Remove include once DataSource & Preload are moved
13// out of "media/base/filters.h" and Stop() is converted to use new callbacks.
14#include "media/base/filters.h"
15#include "media/base/pipeline_status.h"
16
17namespace media {
18
19class FilterHost;
20
21class MEDIA_EXPORT Demuxer
22 : public base::RefCountedThreadSafe<Demuxer> {
23 public:
24 // Sets the private member |host_|. This is the first method called by
25 // the FilterHost after a demuxer is created. The host holds a strong
26 // reference to the demuxer. The reference held by the host is guaranteed
27 // to be released before the host object is destroyed by the pipeline.
28 //
29 // TODO(acolwell): Change this to a narrow DemuxerHost interface.
30 virtual void set_host(FilterHost* host);
31
32 // The pipeline playback rate has been changed. Demuxers may implement this
33 // method if they need to respond to this call.
34 virtual void SetPlaybackRate(float playback_rate);
35
36 // Carry out any actions required to seek to the given time, executing the
37 // callback upon completion.
38 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback);
39
40 // The pipeline is being stopped either as a result of an error or because
41 // the client called Stop().
42 //
43 // TODO(acolwell): Convert to base::Closure.
44 virtual void Stop(FilterCallback* callback);
45
46 // This method is called from the pipeline when the audio renderer
47 // is disabled. Demuxers can ignore the notification if they do not
48 // need to react to this event.
49 //
50 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type).
51 virtual void OnAudioRendererDisabled();
52
53 // Returns the given stream type, or NULL if that type is not present.
54 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0;
55
56 // Alert the Demuxer that the video preload value has been changed.
57 virtual void SetPreload(Preload preload) = 0;
58
59 // Returns the starting time for the media file.
60 virtual base::TimeDelta GetStartTime() const = 0;
61
62 protected:
63 Demuxer();
64 FilterHost* host() { return host_; }
65
66 friend class base::RefCountedThreadSafe<Demuxer>;
67 virtual ~Demuxer();
68
69 private:
70 FilterHost* host_;
71
72 DISALLOW_COPY_AND_ASSIGN(Demuxer);
73};
74
75} // namespace media
76
77#endif // MEDIA_BASE_DEMUXER_H_