OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_DEMUXER_H_ | 5 #ifndef MEDIA_BASE_DEMUXER_H_ |
6 #define MEDIA_BASE_DEMUXER_H_ | 6 #define MEDIA_BASE_DEMUXER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/base/data_source.h" | 11 #include "media/base/data_source.h" |
12 #include "media/base/demuxer_stream.h" | 12 #include "media/base/demuxer_stream.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
| 18 class TextTrackConfig; |
| 19 |
18 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { | 20 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { |
19 public: | 21 public: |
20 // Sets the duration of the media in microseconds. | 22 // Sets the duration of the media in microseconds. |
21 // Duration may be kInfiniteDuration() if the duration is not known. | 23 // Duration may be kInfiniteDuration() if the duration is not known. |
22 virtual void SetDuration(base::TimeDelta duration) = 0; | 24 virtual void SetDuration(base::TimeDelta duration) = 0; |
23 | 25 |
24 // Stops execution of the pipeline due to a fatal error. Do not call this | 26 // Stops execution of the pipeline due to a fatal error. Do not call this |
25 // method with PIPELINE_OK. | 27 // method with PIPELINE_OK. |
26 virtual void OnDemuxerError(PipelineStatus error) = 0; | 28 virtual void OnDemuxerError(PipelineStatus error) = 0; |
27 | 29 |
| 30 // Add |text_stream| to the collection managed by the text renderer. |
| 31 virtual void AddTextStream(DemuxerStream* text_stream, |
| 32 const TextTrackConfig& config) = 0; |
| 33 |
| 34 // Remove |text_stream| from the presentation. |
| 35 virtual void RemoveTextStream(DemuxerStream* text_stream) = 0; |
| 36 |
28 protected: | 37 protected: |
29 virtual ~DemuxerHost(); | 38 virtual ~DemuxerHost(); |
30 }; | 39 }; |
31 | 40 |
32 class MEDIA_EXPORT Demuxer { | 41 class MEDIA_EXPORT Demuxer { |
33 public: | 42 public: |
34 // A new potentially encrypted stream has been parsed. | 43 // A new potentially encrypted stream has been parsed. |
35 // First parameter - The type of initialization data. | 44 // First parameter - The type of initialization data. |
36 // Second parameter - The initialization data associated with the stream. | 45 // Second parameter - The initialization data associated with the stream. |
37 typedef base::Callback<void(const std::string& type, | 46 typedef base::Callback<void(const std::string& type, |
38 const std::vector<uint8>& init_data)> NeedKeyCB; | 47 const std::vector<uint8>& init_data)> NeedKeyCB; |
39 | 48 |
40 Demuxer(); | 49 Demuxer(); |
41 virtual ~Demuxer(); | 50 virtual ~Demuxer(); |
42 | 51 |
43 // Completes initialization of the demuxer. | 52 // Completes initialization of the demuxer. |
44 // | 53 // |
45 // The demuxer does not own |host| as it is guaranteed to outlive the | 54 // The demuxer does not own |host| as it is guaranteed to outlive the |
46 // lifetime of the demuxer. Don't delete it! | 55 // lifetime of the demuxer. Don't delete it! |
47 virtual void Initialize(DemuxerHost* host, | 56 virtual void Initialize(DemuxerHost* host, |
48 const PipelineStatusCB& status_cb) = 0; | 57 const PipelineStatusCB& status_cb, |
| 58 bool enable_text_tracks) = 0; |
49 | 59 |
50 // Carry out any actions required to seek to the given time, executing the | 60 // Carry out any actions required to seek to the given time, executing the |
51 // callback upon completion. | 61 // callback upon completion. |
52 virtual void Seek(base::TimeDelta time, | 62 virtual void Seek(base::TimeDelta time, |
53 const PipelineStatusCB& status_cb) = 0; | 63 const PipelineStatusCB& status_cb) = 0; |
54 | 64 |
55 // Starts stopping this demuxer, executing the callback upon completion. | 65 // Starts stopping this demuxer, executing the callback upon completion. |
56 // | 66 // |
57 // After the callback completes the demuxer may be destroyed. It is illegal to | 67 // After the callback completes the demuxer may be destroyed. It is illegal to |
58 // call any method (including Stop()) after a demuxer has stopped. | 68 // call any method (including Stop()) after a demuxer has stopped. |
59 virtual void Stop(const base::Closure& callback) = 0; | 69 virtual void Stop(const base::Closure& callback) = 0; |
60 | 70 |
61 // This method is called from the pipeline when the audio renderer | 71 // This method is called from the pipeline when the audio renderer |
62 // is disabled. Demuxers can ignore the notification if they do not | 72 // is disabled. Demuxers can ignore the notification if they do not |
63 // need to react to this event. | 73 // need to react to this event. |
64 // | 74 // |
65 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). | 75 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). |
66 // TODO(scherkus): this might not be needed http://crbug.com/234708 | 76 // TODO(scherkus): this might not be needed http://crbug.com/234708 |
67 virtual void OnAudioRendererDisabled() = 0; | 77 virtual void OnAudioRendererDisabled() = 0; |
68 | 78 |
69 // Returns the given stream type, or NULL if that type is not present. | 79 // Returns the first stream of the given stream type (which is not allowed |
| 80 // to be DemuxerStream::TEXT), or NULL if that type of stream is not present. |
70 virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0; | 81 virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0; |
71 | 82 |
72 // Returns the starting time for the media file. | 83 // Returns the starting time for the media file. |
73 virtual base::TimeDelta GetStartTime() const = 0; | 84 virtual base::TimeDelta GetStartTime() const = 0; |
74 | 85 |
75 private: | 86 private: |
76 DISALLOW_COPY_AND_ASSIGN(Demuxer); | 87 DISALLOW_COPY_AND_ASSIGN(Demuxer); |
77 }; | 88 }; |
78 | 89 |
79 } // namespace media | 90 } // namespace media |
80 | 91 |
81 #endif // MEDIA_BASE_DEMUXER_H_ | 92 #endif // MEDIA_BASE_DEMUXER_H_ |
OLD | NEW |