blob: 5a2218a32663e1a66ba4519d690010ce165b1da1 [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
avi1323b9c22015-12-23 06:22:368#include <stdint.h>
9
[email protected]322d22c2013-08-26 18:50:4110#include <vector>
11
avia82b9b52015-12-19 04:27:0812#include "base/macros.h"
[email protected]7e72e7b2013-06-28 05:40:1013#include "base/time/time.h"
[email protected]236119c2011-12-16 17:14:2514#include "media/base/data_source.h"
[email protected]a2b5c472011-09-13 20:24:1015#include "media/base/demuxer_stream.h"
xhwang1c5668e2014-09-10 02:42:0416#include "media/base/demuxer_stream_provider.h"
jrummellcf78967c2015-04-03 05:03:5817#include "media/base/eme_constants.h"
[email protected]a2b5c472011-09-13 20:24:1018#include "media/base/media_export.h"
[email protected]a2b5c472011-09-13 20:24:1019#include "media/base/pipeline_status.h"
servolk21e682e2016-01-14 22:38:2320#include "media/base/ranges.h"
[email protected]a2b5c472011-09-13 20:24:1021
22namespace media {
23
[email protected]8a561062013-11-22 01:19:3124class TextTrackConfig;
25
[email protected]a61ce5a92014-04-03 18:54:3926class MEDIA_EXPORT DemuxerHost {
[email protected]236119c2011-12-16 17:14:2527 public:
servolk21e682e2016-01-14 22:38:2328 // Notify the host that buffered time ranges have changed. Note that buffered
29 // time ranges can grow (when new media data is appended), but they can also
30 // shrink (when buffering reaches limit capacity and some buffered data
31 // becomes evicted, e.g. due to MSE GC algorithm, or by explicit removal of
32 // ranges directed by MSE web app).
33 virtual void OnBufferedTimeRangesChanged(
34 const Ranges<base::TimeDelta>& ranges) = 0;
[email protected]a61ce5a92014-04-03 18:54:3935
[email protected]60bf9222012-05-26 00:31:3436 // Sets the duration of the media in microseconds.
37 // Duration may be kInfiniteDuration() if the duration is not known.
[email protected]236119c2011-12-16 17:14:2538 virtual void SetDuration(base::TimeDelta duration) = 0;
39
[email protected]236119c2011-12-16 17:14:2540 // Stops execution of the pipeline due to a fatal error. Do not call this
41 // method with PIPELINE_OK.
42 virtual void OnDemuxerError(PipelineStatus error) = 0;
[email protected]512d03f2012-06-26 01:06:0643
[email protected]8a561062013-11-22 01:19:3144 // Add |text_stream| to the collection managed by the text renderer.
45 virtual void AddTextStream(DemuxerStream* text_stream,
46 const TextTrackConfig& config) = 0;
47
48 // Remove |text_stream| from the presentation.
49 virtual void RemoveTextStream(DemuxerStream* text_stream) = 0;
50
[email protected]512d03f2012-06-26 01:06:0651 protected:
52 virtual ~DemuxerHost();
[email protected]236119c2011-12-16 17:14:2553};
[email protected]a2b5c472011-09-13 20:24:1054
xhwang1c5668e2014-09-10 02:42:0455class MEDIA_EXPORT Demuxer : public DemuxerStreamProvider {
[email protected]a2b5c472011-09-13 20:24:1056 public:
[email protected]322d22c2013-08-26 18:50:4157 // A new potentially encrypted stream has been parsed.
58 // First parameter - The type of initialization data.
59 // Second parameter - The initialization data associated with the stream.
jrummellcf78967c2015-04-03 05:03:5860 typedef base::Callback<void(EmeInitDataType type,
Avi Drissman97785ea2015-12-19 01:11:3161 const std::vector<uint8_t>& init_data)>
xhwange8c4181a2014-12-06 08:10:0162 EncryptedMediaInitDataCB;
[email protected]322d22c2013-08-26 18:50:4163
[email protected]236119c2011-12-16 17:14:2564 Demuxer();
dchengc24565478f2014-10-21 12:23:2765 ~Demuxer() override;
[email protected]236119c2011-12-16 17:14:2566
xhwanga9ca9db2015-06-11 23:52:3967 // Returns the name of the demuxer for logging purpose.
68 virtual std::string GetDisplayName() const = 0;
69
[email protected]9bfe9b82012-04-02 17:56:2770 // Completes initialization of the demuxer.
71 //
[email protected]d09ef252012-04-05 04:31:3072 // The demuxer does not own |host| as it is guaranteed to outlive the
dalecurtis21b128292015-01-21 11:09:2473 // lifetime of the demuxer. Don't delete it! |status_cb| must only be run
74 // after this method has returned.
[email protected]d09ef252012-04-05 04:31:3075 virtual void Initialize(DemuxerHost* host,
[email protected]8a561062013-11-22 01:19:3176 const PipelineStatusCB& status_cb,
77 bool enable_text_tracks) = 0;
[email protected]9bfe9b82012-04-02 17:56:2778
[email protected]a2b5c472011-09-13 20:24:1079 // Carry out any actions required to seek to the given time, executing the
80 // callback upon completion.
[email protected]7c63c2e2013-10-10 20:00:4581 virtual void Seek(base::TimeDelta time,
82 const PipelineStatusCB& status_cb) = 0;
[email protected]a2b5c472011-09-13 20:24:1083
xhwangfcdacaf2014-09-02 18:08:3584 // Stops this demuxer.
[email protected]8b754552013-08-22 00:31:0585 //
xhwangfcdacaf2014-09-02 18:08:3586 // After this call the demuxer may be destroyed. It is illegal to call any
87 // method (including Stop()) after a demuxer has stopped.
88 virtual void Stop() = 0;
[email protected]a2b5c472011-09-13 20:24:1089
dalecurtisb9ec078cf2014-09-16 22:23:2190 // Returns the starting time for the media file; it's always positive.
91 virtual base::TimeDelta GetStartTime() const = 0;
92
[email protected]db66d0092014-04-16 07:15:1293 // Returns Time represented by presentation timestamp 0.
94 // If the timstamps are not associated with a Time, then
95 // a null Time is returned.
96 virtual base::Time GetTimelineOffset() const = 0;
97
wdzierzanowski98368632015-12-04 09:22:0198 // Returns the memory usage in bytes for the demuxer.
dalecurtis83266c72015-10-29 18:43:2099 virtual int64_t GetMemoryUsage() const = 0;
100
[email protected]a2b5c472011-09-13 20:24:10101 private:
[email protected]a2b5c472011-09-13 20:24:10102 DISALLOW_COPY_AND_ASSIGN(Demuxer);
103};
104
105} // namespace media
106
107#endif // MEDIA_BASE_DEMUXER_H_