[email protected] | a4dae8e | 2012-03-15 23:35:31 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 2 | // 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] | 322d22c | 2013-08-26 18:50:41 | [diff] [blame] | 8 | #include <vector> |
9 | |||||
[email protected] | 7e72e7b | 2013-06-28 05:40:10 | [diff] [blame] | 10 | #include "base/time/time.h" |
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 11 | #include "media/base/data_source.h" |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 12 | #include "media/base/demuxer_stream.h" |
xhwang | 1c5668e | 2014-09-10 02:42:04 | [diff] [blame^] | 13 | #include "media/base/demuxer_stream_provider.h" |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 14 | #include "media/base/media_export.h" |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 15 | #include "media/base/pipeline_status.h" |
16 | |||||
17 | namespace media { | ||||
18 | |||||
[email protected] | 8a56106 | 2013-11-22 01:19:31 | [diff] [blame] | 19 | class TextTrackConfig; |
20 | |||||
[email protected] | a61ce5a9 | 2014-04-03 18:54:39 | [diff] [blame] | 21 | class MEDIA_EXPORT DemuxerHost { |
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 22 | public: |
[email protected] | a61ce5a9 | 2014-04-03 18:54:39 | [diff] [blame] | 23 | // 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] | 60bf922 | 2012-05-26 00:31:34 | [diff] [blame] | 27 | // Sets the duration of the media in microseconds. |
28 | // Duration may be kInfiniteDuration() if the duration is not known. | ||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 29 | virtual void SetDuration(base::TimeDelta duration) = 0; |
30 | |||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 31 | // 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] | 512d03f | 2012-06-26 01:06:06 | [diff] [blame] | 34 | |
[email protected] | 8a56106 | 2013-11-22 01:19:31 | [diff] [blame] | 35 | // 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] | 512d03f | 2012-06-26 01:06:06 | [diff] [blame] | 42 | protected: |
43 | virtual ~DemuxerHost(); | ||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 44 | }; |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 45 | |
xhwang | 1c5668e | 2014-09-10 02:42:04 | [diff] [blame^] | 46 | class MEDIA_EXPORT Demuxer : public DemuxerStreamProvider { |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 47 | public: |
[email protected] | 322d22c | 2013-08-26 18:50:41 | [diff] [blame] | 48 | // 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] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 54 | Demuxer(); |
[email protected] | f5443ef7 | 2013-04-22 04:03:38 | [diff] [blame] | 55 | virtual ~Demuxer(); |
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 56 | |
[email protected] | 9bfe9b8 | 2012-04-02 17:56:27 | [diff] [blame] | 57 | // Completes initialization of the demuxer. |
58 | // | ||||
[email protected] | d09ef25 | 2012-04-05 04:31:30 | [diff] [blame] | 59 | // 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] | 8a56106 | 2013-11-22 01:19:31 | [diff] [blame] | 62 | const PipelineStatusCB& status_cb, |
63 | bool enable_text_tracks) = 0; | ||||
[email protected] | 9bfe9b8 | 2012-04-02 17:56:27 | [diff] [blame] | 64 | |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 65 | // Carry out any actions required to seek to the given time, executing the |
66 | // callback upon completion. | ||||
[email protected] | 7c63c2e | 2013-10-10 20:00:45 | [diff] [blame] | 67 | virtual void Seek(base::TimeDelta time, |
68 | const PipelineStatusCB& status_cb) = 0; | ||||
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 69 | |
xhwang | fcdacaf | 2014-09-02 18:08:35 | [diff] [blame] | 70 | // Stops this demuxer. |
[email protected] | 8b75455 | 2013-08-22 00:31:05 | [diff] [blame] | 71 | // |
xhwang | fcdacaf | 2014-09-02 18:08:35 | [diff] [blame] | 72 | // 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] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 75 | |
[email protected] | db66d009 | 2014-04-16 07:15:12 | [diff] [blame] | 76 | // Returns Time represented by presentation timestamp 0. |
77 | // If the timstamps are not associated with a Time, then | ||||
78 | // a null Time is returned. | ||||
79 | virtual base::Time GetTimelineOffset() const = 0; | ||||
80 | |||||
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 81 | private: |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 82 | DISALLOW_COPY_AND_ASSIGN(Demuxer); |
83 | }; | ||||
84 | |||||
85 | } // namespace media | ||||
86 | |||||
87 | #endif // MEDIA_BASE_DEMUXER_H_ |