blob: 3075b595765162b2003735c3791ec0b2bcc8e39c [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
[email protected]322d22c2013-08-26 18:50:418#include <vector>
9
[email protected]7e72e7b2013-06-28 05:40:1010#include "base/time/time.h"
[email protected]236119c2011-12-16 17:14:2511#include "media/base/data_source.h"
[email protected]a2b5c472011-09-13 20:24:1012#include "media/base/demuxer_stream.h"
xhwang1c5668e2014-09-10 02:42:0413#include "media/base/demuxer_stream_provider.h"
jrummellcf78967c2015-04-03 05:03:5814#include "media/base/eme_constants.h"
[email protected]a2b5c472011-09-13 20:24:1015#include "media/base/media_export.h"
[email protected]a2b5c472011-09-13 20:24:1016#include "media/base/pipeline_status.h"
17
18namespace media {
19
[email protected]8a561062013-11-22 01:19:3120class TextTrackConfig;
21
[email protected]a61ce5a92014-04-03 18:54:3922class MEDIA_EXPORT DemuxerHost {
[email protected]236119c2011-12-16 17:14:2523 public:
[email protected]a61ce5a92014-04-03 18:54:3924 // Notify the host that time range [start,end] has been buffered.
25 virtual void AddBufferedTimeRange(base::TimeDelta start,
26 base::TimeDelta end) = 0;
27
[email protected]60bf9222012-05-26 00:31:3428 // Sets the duration of the media in microseconds.
29 // Duration may be kInfiniteDuration() if the duration is not known.
[email protected]236119c2011-12-16 17:14:2530 virtual void SetDuration(base::TimeDelta duration) = 0;
31
[email protected]236119c2011-12-16 17:14:2532 // 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;
[email protected]512d03f2012-06-26 01:06:0635
[email protected]8a561062013-11-22 01:19:3136 // Add |text_stream| to the collection managed by the text renderer.
37 virtual void AddTextStream(DemuxerStream* text_stream,
38 const TextTrackConfig& config) = 0;
39
40 // Remove |text_stream| from the presentation.
41 virtual void RemoveTextStream(DemuxerStream* text_stream) = 0;
42
[email protected]512d03f2012-06-26 01:06:0643 protected:
44 virtual ~DemuxerHost();
[email protected]236119c2011-12-16 17:14:2545};
[email protected]a2b5c472011-09-13 20:24:1046
xhwang1c5668e2014-09-10 02:42:0447class MEDIA_EXPORT Demuxer : public DemuxerStreamProvider {
[email protected]a2b5c472011-09-13 20:24:1048 public:
[email protected]322d22c2013-08-26 18:50:4149 // A new potentially encrypted stream has been parsed.
50 // First parameter - The type of initialization data.
51 // Second parameter - The initialization data associated with the stream.
jrummellcf78967c2015-04-03 05:03:5852 typedef base::Callback<void(EmeInitDataType type,
xhwange8c4181a2014-12-06 08:10:0153 const std::vector<uint8>& init_data)>
54 EncryptedMediaInitDataCB;
[email protected]322d22c2013-08-26 18:50:4155
[email protected]236119c2011-12-16 17:14:2556 Demuxer();
dchengc24565478f2014-10-21 12:23:2757 ~Demuxer() override;
[email protected]236119c2011-12-16 17:14:2558
[email protected]9bfe9b82012-04-02 17:56:2759 // Completes initialization of the demuxer.
60 //
[email protected]d09ef252012-04-05 04:31:3061 // The demuxer does not own |host| as it is guaranteed to outlive the
dalecurtis21b128292015-01-21 11:09:2462 // lifetime of the demuxer. Don't delete it! |status_cb| must only be run
63 // after this method has returned.
[email protected]d09ef252012-04-05 04:31:3064 virtual void Initialize(DemuxerHost* host,
[email protected]8a561062013-11-22 01:19:3165 const PipelineStatusCB& status_cb,
66 bool enable_text_tracks) = 0;
[email protected]9bfe9b82012-04-02 17:56:2767
[email protected]a2b5c472011-09-13 20:24:1068 // Carry out any actions required to seek to the given time, executing the
69 // callback upon completion.
[email protected]7c63c2e2013-10-10 20:00:4570 virtual void Seek(base::TimeDelta time,
71 const PipelineStatusCB& status_cb) = 0;
[email protected]a2b5c472011-09-13 20:24:1072
xhwangfcdacaf2014-09-02 18:08:3573 // Stops this demuxer.
[email protected]8b754552013-08-22 00:31:0574 //
xhwangfcdacaf2014-09-02 18:08:3575 // After this call the demuxer may be destroyed. It is illegal to call any
76 // method (including Stop()) after a demuxer has stopped.
77 virtual void Stop() = 0;
[email protected]a2b5c472011-09-13 20:24:1078
dalecurtisb9ec078cf2014-09-16 22:23:2179 // Returns the starting time for the media file; it's always positive.
80 virtual base::TimeDelta GetStartTime() const = 0;
81
[email protected]db66d0092014-04-16 07:15:1282 // Returns Time represented by presentation timestamp 0.
83 // If the timstamps are not associated with a Time, then
84 // a null Time is returned.
85 virtual base::Time GetTimelineOffset() const = 0;
86
[email protected]a2b5c472011-09-13 20:24:1087 private:
[email protected]a2b5c472011-09-13 20:24:1088 DISALLOW_COPY_AND_ASSIGN(Demuxer);
89};
90
91} // namespace media
92
93#endif // MEDIA_BASE_DEMUXER_H_