blob: 4658107b88e998805f5f4ed1e447d83a674da8ad [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"
[email protected]a2b5c472011-09-13 20:24:1014#include "media/base/media_export.h"
[email protected]a2b5c472011-09-13 20:24:1015#include "media/base/pipeline_status.h"
16
17namespace media {
18
[email protected]8a561062013-11-22 01:19:3119class TextTrackConfig;
20
[email protected]a61ce5a92014-04-03 18:54:3921class MEDIA_EXPORT DemuxerHost {
[email protected]236119c2011-12-16 17:14:2522 public:
[email protected]a61ce5a92014-04-03 18:54:3923 // Notify the host that time range [start,end] has been buffered.
24 virtual void AddBufferedTimeRange(base::TimeDelta start,
25 base::TimeDelta end) = 0;
26
[email protected]60bf9222012-05-26 00:31:3427 // Sets the duration of the media in microseconds.
28 // Duration may be kInfiniteDuration() if the duration is not known.
[email protected]236119c2011-12-16 17:14:2529 virtual void SetDuration(base::TimeDelta duration) = 0;
30
[email protected]236119c2011-12-16 17:14:2531 // Stops execution of the pipeline due to a fatal error. Do not call this
32 // method with PIPELINE_OK.
33 virtual void OnDemuxerError(PipelineStatus error) = 0;
[email protected]512d03f2012-06-26 01:06:0634
[email protected]8a561062013-11-22 01:19:3135 // Add |text_stream| to the collection managed by the text renderer.
36 virtual void AddTextStream(DemuxerStream* text_stream,
37 const TextTrackConfig& config) = 0;
38
39 // Remove |text_stream| from the presentation.
40 virtual void RemoveTextStream(DemuxerStream* text_stream) = 0;
41
[email protected]512d03f2012-06-26 01:06:0642 protected:
43 virtual ~DemuxerHost();
[email protected]236119c2011-12-16 17:14:2544};
[email protected]a2b5c472011-09-13 20:24:1045
xhwang1c5668e2014-09-10 02:42:0446class MEDIA_EXPORT Demuxer : public DemuxerStreamProvider {
[email protected]a2b5c472011-09-13 20:24:1047 public:
[email protected]322d22c2013-08-26 18:50:4148 // A new potentially encrypted stream has been parsed.
49 // First parameter - The type of initialization data.
50 // Second parameter - The initialization data associated with the stream.
51 typedef base::Callback<void(const std::string& type,
52 const std::vector<uint8>& init_data)> NeedKeyCB;
53
[email protected]236119c2011-12-16 17:14:2554 Demuxer();
dchengc24565478f2014-10-21 12:23:2755 ~Demuxer() override;
[email protected]236119c2011-12-16 17:14:2556
[email protected]9bfe9b82012-04-02 17:56:2757 // Completes initialization of the demuxer.
58 //
[email protected]d09ef252012-04-05 04:31:3059 // The demuxer does not own |host| as it is guaranteed to outlive the
60 // lifetime of the demuxer. Don't delete it!
61 virtual void Initialize(DemuxerHost* host,
[email protected]8a561062013-11-22 01:19:3162 const PipelineStatusCB& status_cb,
63 bool enable_text_tracks) = 0;
[email protected]9bfe9b82012-04-02 17:56:2764
[email protected]a2b5c472011-09-13 20:24:1065 // Carry out any actions required to seek to the given time, executing the
66 // callback upon completion.
[email protected]7c63c2e2013-10-10 20:00:4567 virtual void Seek(base::TimeDelta time,
68 const PipelineStatusCB& status_cb) = 0;
[email protected]a2b5c472011-09-13 20:24:1069
xhwangfcdacaf2014-09-02 18:08:3570 // Stops this demuxer.
[email protected]8b754552013-08-22 00:31:0571 //
xhwangfcdacaf2014-09-02 18:08:3572 // After this call the demuxer may be destroyed. It is illegal to call any
73 // method (including Stop()) after a demuxer has stopped.
74 virtual void Stop() = 0;
[email protected]a2b5c472011-09-13 20:24:1075
dalecurtisb9ec078cf2014-09-16 22:23:2176 // Returns the starting time for the media file; it's always positive.
77 virtual base::TimeDelta GetStartTime() const = 0;
78
[email protected]db66d0092014-04-16 07:15:1279 // Returns Time represented by presentation timestamp 0.
80 // If the timstamps are not associated with a Time, then
81 // a null Time is returned.
82 virtual base::Time GetTimelineOffset() const = 0;
83
[email protected]a2b5c472011-09-13 20:24:1084 private:
[email protected]a2b5c472011-09-13 20:24:1085 DISALLOW_COPY_AND_ASSIGN(Demuxer);
86};
87
88} // namespace media
89
90#endif // MEDIA_BASE_DEMUXER_H_