blob: 4458ce0418a7e419f4e1f514a7d3e06a7ebfca4d [file] [log] [blame]
[email protected]a4dae8e2012-03-15 23:35:311// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]a2b5c472011-09-13 20:24:102// 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"
[email protected]236119c2011-12-16 17:14:259#include "base/time.h"
10#include "media/base/data_source.h"
[email protected]a2b5c472011-09-13 20:24:1011#include "media/base/demuxer_stream.h"
12#include "media/base/media_export.h"
[email protected]a2b5c472011-09-13 20:24:1013#include "media/base/pipeline_status.h"
14
15namespace media {
16
[email protected]236119c2011-12-16 17:14:2517class MEDIA_EXPORT DemuxerHost : public DataSourceHost {
18 public:
19 virtual ~DemuxerHost();
20
21 // Get the duration of the media in microseconds. If the duration has not
22 // been determined yet, then returns 0.
23 virtual void SetDuration(base::TimeDelta duration) = 0;
24
25 // Set the approximate amount of playable data buffered so far in micro-
26 // seconds.
27 virtual void SetBufferedTime(base::TimeDelta buffered_time) = 0;
28
29 // Sets the byte offset at which the client is requesting the video.
30 virtual void SetCurrentReadPosition(int64 offset) = 0;
31
32 // Stops execution of the pipeline due to a fatal error. Do not call this
33 // method with PIPELINE_OK.
34 virtual void OnDemuxerError(PipelineStatus error) = 0;
35};
[email protected]a2b5c472011-09-13 20:24:1036
[email protected]d09ef252012-04-05 04:31:3037class MEDIA_EXPORT Demuxer : public base::RefCountedThreadSafe<Demuxer> {
[email protected]a2b5c472011-09-13 20:24:1038 public:
[email protected]236119c2011-12-16 17:14:2539 Demuxer();
40
[email protected]9bfe9b82012-04-02 17:56:2741 // Completes initialization of the demuxer.
42 //
[email protected]d09ef252012-04-05 04:31:3043 // The demuxer does not own |host| as it is guaranteed to outlive the
44 // lifetime of the demuxer. Don't delete it!
45 virtual void Initialize(DemuxerHost* host,
46 const PipelineStatusCB& status_cb) = 0;
[email protected]9bfe9b82012-04-02 17:56:2747
[email protected]a2b5c472011-09-13 20:24:1048 // The pipeline playback rate has been changed. Demuxers may implement this
49 // method if they need to respond to this call.
50 virtual void SetPlaybackRate(float playback_rate);
51
52 // Carry out any actions required to seek to the given time, executing the
53 // callback upon completion.
[email protected]a4dae8e2012-03-15 23:35:3154 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb);
[email protected]a2b5c472011-09-13 20:24:1055
56 // The pipeline is being stopped either as a result of an error or because
57 // the client called Stop().
[email protected]adabb6272011-09-29 22:36:3858 virtual void Stop(const base::Closure& callback);
[email protected]a2b5c472011-09-13 20:24:1059
60 // This method is called from the pipeline when the audio renderer
61 // is disabled. Demuxers can ignore the notification if they do not
62 // need to react to this event.
63 //
64 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type).
65 virtual void OnAudioRendererDisabled();
66
67 // Returns the given stream type, or NULL if that type is not present.
68 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0;
69
[email protected]a2b5c472011-09-13 20:24:1070 // Returns the starting time for the media file.
71 virtual base::TimeDelta GetStartTime() const = 0;
72
[email protected]7b268b7a2011-11-18 19:52:0873 // Returns the content bitrate. May be obtained from container or
74 // approximated. Returns 0 if it is unknown.
75 virtual int GetBitrate() = 0;
76
[email protected]62fce1c2011-12-01 22:44:5577 // Returns true if the source is from a local file or stream (such as a
78 // webcam stream), false otherwise.
[email protected]9bfe9b82012-04-02 17:56:2779 //
80 // TODO(scherkus): See http://crbug.com/120426 on why we should remove this.
[email protected]62fce1c2011-12-01 22:44:5581 virtual bool IsLocalSource() = 0;
82
83 // Returns true if seeking is possible; false otherwise.
84 virtual bool IsSeekable() = 0;
85
[email protected]a2b5c472011-09-13 20:24:1086 protected:
[email protected]a2b5c472011-09-13 20:24:1087 friend class base::RefCountedThreadSafe<Demuxer>;
88 virtual ~Demuxer();
89
90 private:
[email protected]a2b5c472011-09-13 20:24:1091 DISALLOW_COPY_AND_ASSIGN(Demuxer);
92};
93
94} // namespace media
95
96#endif // MEDIA_BASE_DEMUXER_H_