[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" |
13 | #include "media/base/media_export.h" | ||||
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 14 | #include "media/base/pipeline_status.h" |
15 | |||||
16 | namespace media { | ||||
17 | |||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 18 | class MEDIA_EXPORT DemuxerHost : public DataSourceHost { |
19 | public: | ||||
[email protected] | 60bf922 | 2012-05-26 00:31:34 | [diff] [blame] | 20 | // Sets the duration of the media in microseconds. |
21 | // Duration may be kInfiniteDuration() if the duration is not known. | ||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 22 | virtual void SetDuration(base::TimeDelta duration) = 0; |
23 | |||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 24 | // Stops execution of the pipeline due to a fatal error. Do not call this |
25 | // method with PIPELINE_OK. | ||||
26 | virtual void OnDemuxerError(PipelineStatus error) = 0; | ||||
[email protected] | 512d03f | 2012-06-26 01:06:06 | [diff] [blame] | 27 | |
28 | protected: | ||||
29 | virtual ~DemuxerHost(); | ||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 30 | }; |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 31 | |
[email protected] | f5443ef7 | 2013-04-22 04:03:38 | [diff] [blame] | 32 | class MEDIA_EXPORT Demuxer { |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 33 | public: |
[email protected] | 322d22c | 2013-08-26 18:50:41 | [diff] [blame^] | 34 | // A new potentially encrypted stream has been parsed. |
35 | // First parameter - The type of initialization data. | ||||
36 | // Second parameter - The initialization data associated with the stream. | ||||
37 | typedef base::Callback<void(const std::string& type, | ||||
38 | const std::vector<uint8>& init_data)> NeedKeyCB; | ||||
39 | |||||
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 40 | Demuxer(); |
[email protected] | f5443ef7 | 2013-04-22 04:03:38 | [diff] [blame] | 41 | virtual ~Demuxer(); |
[email protected] | 236119c | 2011-12-16 17:14:25 | [diff] [blame] | 42 | |
[email protected] | 9bfe9b8 | 2012-04-02 17:56:27 | [diff] [blame] | 43 | // Completes initialization of the demuxer. |
44 | // | ||||
[email protected] | d09ef25 | 2012-04-05 04:31:30 | [diff] [blame] | 45 | // The demuxer does not own |host| as it is guaranteed to outlive the |
46 | // lifetime of the demuxer. Don't delete it! | ||||
47 | virtual void Initialize(DemuxerHost* host, | ||||
48 | const PipelineStatusCB& status_cb) = 0; | ||||
[email protected] | 9bfe9b8 | 2012-04-02 17:56:27 | [diff] [blame] | 49 | |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 50 | // The pipeline playback rate has been changed. Demuxers may implement this |
51 | // method if they need to respond to this call. | ||||
52 | virtual void SetPlaybackRate(float playback_rate); | ||||
53 | |||||
54 | // Carry out any actions required to seek to the given time, executing the | ||||
55 | // callback upon completion. | ||||
[email protected] | a4dae8e | 2012-03-15 23:35:31 | [diff] [blame] | 56 | virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb); |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 57 | |
[email protected] | 8b75455 | 2013-08-22 00:31:05 | [diff] [blame] | 58 | // Starts stopping this demuxer, executing the callback upon completion. |
59 | // | ||||
60 | // After the callback completes the demuxer may be destroyed. It is illegal to | ||||
61 | // call any method (including Stop()) after a demuxer has stopped. | ||||
[email protected] | adabb627 | 2011-09-29 22:36:38 | [diff] [blame] | 62 | virtual void Stop(const base::Closure& callback); |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 63 | |
64 | // This method is called from the pipeline when the audio renderer | ||||
65 | // is disabled. Demuxers can ignore the notification if they do not | ||||
66 | // need to react to this event. | ||||
67 | // | ||||
68 | // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). | ||||
[email protected] | 34811ef | 2013-04-25 08:51:47 | [diff] [blame] | 69 | // TODO(scherkus): this might not be needed http://crbug.com/234708 |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 70 | virtual void OnAudioRendererDisabled(); |
71 | |||||
72 | // Returns the given stream type, or NULL if that type is not present. | ||||
[email protected] | 34811ef | 2013-04-25 08:51:47 | [diff] [blame] | 73 | virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0; |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 74 | |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 75 | // Returns the starting time for the media file. |
76 | virtual base::TimeDelta GetStartTime() const = 0; | ||||
77 | |||||
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 78 | private: |
[email protected] | a2b5c47 | 2011-09-13 20:24:10 | [diff] [blame] | 79 | DISALLOW_COPY_AND_ASSIGN(Demuxer); |
80 | }; | ||||
81 | |||||
82 | } // namespace media | ||||
83 | |||||
84 | #endif // MEDIA_BASE_DEMUXER_H_ |