1 // Copyright (c) 2012 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.
5 #ifndef MEDIA_BASE_DEMUXER_H_
6 #define MEDIA_BASE_DEMUXER_H_
10 #include "base/time/time.h"
11 #include "media/base/data_source.h"
12 #include "media/base/demuxer_stream.h"
13 #include "media/base/media_export.h"
14 #include "media/base/pipeline_status.h"
18 class TextTrackConfig
;
20 class MEDIA_EXPORT DemuxerHost
{
22 // Notify the host that time range [start,end] has been buffered.
23 virtual void AddBufferedTimeRange(base::TimeDelta start
,
24 base::TimeDelta end
) = 0;
26 // Sets the duration of the media in microseconds.
27 // Duration may be kInfiniteDuration() if the duration is not known.
28 virtual void SetDuration(base::TimeDelta duration
) = 0;
30 // Stops execution of the pipeline due to a fatal error. Do not call this
31 // method with PIPELINE_OK.
32 virtual void OnDemuxerError(PipelineStatus error
) = 0;
34 // Add |text_stream| to the collection managed by the text renderer.
35 virtual void AddTextStream(DemuxerStream
* text_stream
,
36 const TextTrackConfig
& config
) = 0;
38 // Remove |text_stream| from the presentation.
39 virtual void RemoveTextStream(DemuxerStream
* text_stream
) = 0;
42 virtual ~DemuxerHost();
45 class MEDIA_EXPORT Demuxer
{
53 // A new potentially encrypted stream has been parsed.
54 // First parameter - The type of initialization data.
55 // Second parameter - The initialization data associated with the stream.
56 typedef base::Callback
<void(const std::string
& type
,
57 const std::vector
<uint8
>& init_data
)> NeedKeyCB
;
62 // Completes initialization of the demuxer.
64 // The demuxer does not own |host| as it is guaranteed to outlive the
65 // lifetime of the demuxer. Don't delete it!
66 virtual void Initialize(DemuxerHost
* host
,
67 const PipelineStatusCB
& status_cb
,
68 bool enable_text_tracks
) = 0;
70 // Carry out any actions required to seek to the given time, executing the
71 // callback upon completion.
72 virtual void Seek(base::TimeDelta time
,
73 const PipelineStatusCB
& status_cb
) = 0;
75 // Starts stopping this demuxer, executing the callback upon completion.
77 // After the callback completes the demuxer may be destroyed. It is illegal to
78 // call any method (including Stop()) after a demuxer has stopped.
79 virtual void Stop(const base::Closure
& callback
) = 0;
81 // Returns the first stream of the given stream type (which is not allowed
82 // to be DemuxerStream::TEXT), or NULL if that type of stream is not present.
83 virtual DemuxerStream
* GetStream(DemuxerStream::Type type
) = 0;
85 // Returns Time represented by presentation timestamp 0.
86 // If the timstamps are not associated with a Time, then
87 // a null Time is returned.
88 virtual base::Time
GetTimelineOffset() const = 0;
90 // Returns liveness of the stream, i.e. whether it is recorded or live.
91 virtual Liveness
GetLiveness() const = 0;
94 DISALLOW_COPY_AND_ASSIGN(Demuxer
);
99 #endif // MEDIA_BASE_DEMUXER_H_