OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_FILTERS_CHUNK_DEMUXER_H_ | 5 #ifndef MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
6 #define MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 6 #define MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb); | 34 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb); |
35 virtual void OnAudioRendererDisabled(); | 35 virtual void OnAudioRendererDisabled(); |
36 virtual void SetPreload(Preload preload); | 36 virtual void SetPreload(Preload preload); |
37 | 37 |
38 // Demuxer implementation. | 38 // Demuxer implementation. |
39 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type); | 39 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type); |
40 virtual base::TimeDelta GetStartTime() const; | 40 virtual base::TimeDelta GetStartTime() const; |
41 | 41 |
42 // Methods used by an external object to control this demuxer. | 42 // Methods used by an external object to control this demuxer. |
43 void FlushData(); | 43 void FlushData(); |
| 44 |
| 45 // Appends media data to the stream. Returns false if this method |
| 46 // is called in an invalid state. |
44 bool AppendData(const uint8* data, unsigned length); | 47 bool AppendData(const uint8* data, unsigned length); |
45 void EndOfStream(PipelineStatus status); | 48 void EndOfStream(PipelineStatus status); |
46 bool HasEnded(); | 49 bool HasEnded(); |
47 void Shutdown(); | 50 void Shutdown(); |
48 | 51 |
49 private: | 52 private: |
50 enum State { | 53 enum State { |
51 WAITING_FOR_INIT, | 54 WAITING_FOR_INIT, |
52 INITIALIZING, | 55 INITIALIZING, |
53 INITIALIZED, | 56 INITIALIZED, |
54 ENDED, | 57 ENDED, |
55 INIT_ERROR, | 58 PARSE_ERROR, |
56 SHUTDOWN, | 59 SHUTDOWN, |
57 }; | 60 }; |
58 | 61 |
59 void ChangeState(State new_state); | 62 void ChangeState(State new_state); |
60 | 63 |
61 // Parses a buffer that contains an INFO & TRACKS element. Returns false if | 64 // Parses a buffer that contains an INFO & TRACKS element. Returns false if |
62 // the parse fails. This method handles calling & clearing |init_cb_| | 65 // the parse fails. This method handles calling & clearing |init_cb_| |
63 // before it returns. | 66 // before it returns. |
64 bool ParseInfoAndTracks_Locked(const uint8* data, int size); | 67 bool ParseInfoAndTracks_Locked(const uint8* data, int size); |
65 | 68 |
66 // Generates an AVFormatContext for the INFO & TRACKS elements contained | 69 // Generates an AVFormatContext for the INFO & TRACKS elements contained |
67 // in |data|. Returns NULL if parsing |data| fails. | 70 // in |data|. Returns NULL if parsing |data| fails. |
68 AVFormatContext* CreateFormatContext(const uint8* data, int size); | 71 AVFormatContext* CreateFormatContext(const uint8* data, int size); |
69 | 72 |
70 // Sets up |audio_| & |video_| DemuxerStreams based on the data in | 73 // Sets up |audio_| & |video_| DemuxerStreams based on the data in |
71 // |format_context_|. Returns false if no valid audio or video stream were | 74 // |format_context_|. Returns false if no valid audio or video stream were |
72 // found. | 75 // found. |
73 bool SetupStreams(); | 76 bool SetupStreams(); |
74 | 77 |
75 // Parse a buffer that was passed to AppendData(). |data| is expected to | 78 // Parse a buffer that was passed to AppendData(). |data| is expected to |
76 // contain one or more WebM Clusters. Returns false if parsing the data fails. | 79 // contain one or more WebM Clusters. Returns false if parsing the data fails. |
77 bool ParseAndAppendData_Locked(const uint8* data, int length); | 80 bool ParseAndAppendData_Locked(const uint8* data, int length); |
78 | 81 |
79 // Called when initialization fails. Handles calling & clearing init_cb_. | 82 // Reports an error and puts the demuxer in a state where it won't accept more |
80 void InitFailed_Locked(); | 83 // data. |
| 84 void ReportError_Locked(PipelineStatus error); |
81 | 85 |
82 base::Lock lock_; | 86 base::Lock lock_; |
83 State state_; | 87 State state_; |
84 | 88 |
85 ChunkDemuxerClient* client_; | 89 ChunkDemuxerClient* client_; |
86 PipelineStatusCB init_cb_; | 90 PipelineStatusCB init_cb_; |
87 FilterStatusCB seek_cb_; | 91 FilterStatusCB seek_cb_; |
88 | 92 |
89 scoped_refptr<ChunkDemuxerStream> audio_; | 93 scoped_refptr<ChunkDemuxerStream> audio_; |
90 scoped_refptr<ChunkDemuxerStream> video_; | 94 scoped_refptr<ChunkDemuxerStream> video_; |
(...skipping 18 matching lines...) Expand all Loading... |
109 // Should a Seek() call wait for more data before calling the | 113 // Should a Seek() call wait for more data before calling the |
110 // callback. | 114 // callback. |
111 bool seek_waits_for_data_; | 115 bool seek_waits_for_data_; |
112 | 116 |
113 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 117 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
114 }; | 118 }; |
115 | 119 |
116 } // namespace media | 120 } // namespace media |
117 | 121 |
118 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 122 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |