| 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); |
| 48 |
| 45 void EndOfStream(PipelineStatus status); | 49 void EndOfStream(PipelineStatus status); |
| 46 bool HasEnded(); | 50 bool HasEnded(); |
| 47 void Shutdown(); | 51 void Shutdown(); |
| 48 | 52 |
| 49 private: | 53 private: |
| 50 enum State { | 54 enum State { |
| 51 WAITING_FOR_INIT, | 55 WAITING_FOR_INIT, |
| 52 INITIALIZING, | 56 INITIALIZING, |
| 53 INITIALIZED, | 57 INITIALIZED, |
| 54 ENDED, | 58 ENDED, |
| 55 INIT_ERROR, | 59 PARSE_ERROR, |
| 56 SHUTDOWN, | 60 SHUTDOWN, |
| 57 }; | 61 }; |
| 58 | 62 |
| 59 void ChangeState(State new_state); | 63 void ChangeState(State new_state); |
| 60 | 64 |
| 61 // Parses a buffer that contains an INFO & TRACKS element. Returns false if | 65 // Parses a buffer that contains an INFO & TRACKS element. Returns false if |
| 62 // the parse fails. This method handles calling & clearing |init_cb_| | 66 // the parse fails. This method handles calling & clearing |init_cb_| |
| 63 // before it returns. | 67 // before it returns. |
| 64 bool ParseInfoAndTracks_Locked(const uint8* data, int size); | 68 bool ParseInfoAndTracks_Locked(const uint8* data, int size); |
| 65 | 69 |
| 66 // Generates an AVFormatContext for the INFO & TRACKS elements contained | 70 // Generates an AVFormatContext for the INFO & TRACKS elements contained |
| 67 // in |data|. Returns NULL if parsing |data| fails. | 71 // in |data|. Returns NULL if parsing |data| fails. |
| 68 AVFormatContext* CreateFormatContext(const uint8* data, int size); | 72 AVFormatContext* CreateFormatContext(const uint8* data, int size); |
| 69 | 73 |
| 70 // Sets up |audio_| & |video_| DemuxerStreams based on the data in | 74 // Sets up |audio_| & |video_| DemuxerStreams based on the data in |
| 71 // |format_context_|. Returns false if no valid audio or video stream were | 75 // |format_context_|. Returns false if no valid audio or video stream were |
| 72 // found. | 76 // found. |
| 73 bool SetupStreams(); | 77 bool SetupStreams(); |
| 74 | 78 |
| 75 // Parse a buffer that was passed to AppendData(). |data| is expected to | 79 // 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. | 80 // contain one or more WebM Clusters. Returns false if parsing the data fails. |
| 77 bool ParseAndAppendData_Locked(const uint8* data, int length); | 81 bool ParseAndAppendData_Locked(const uint8* data, int length); |
| 78 | 82 |
| 79 // Called when initialization fails. Handles calling & clearing init_cb_. | 83 // Schedules a ReportErrorTask() call to report error status to the pipeline. |
| 80 void InitFailed_Locked(); | 84 void ReportError_Locked(PipelineStatus status); |
| 85 |
| 86 // Reports an error and puts the demuxer in a state where it won't accept more |
| 87 // data. |
| 88 void ReportErrorTask(PipelineStatus status); |
| 81 | 89 |
| 82 base::Lock lock_; | 90 base::Lock lock_; |
| 83 State state_; | 91 State state_; |
| 84 | 92 |
| 85 ChunkDemuxerClient* client_; | 93 ChunkDemuxerClient* client_; |
| 86 PipelineStatusCB init_cb_; | 94 PipelineStatusCB init_cb_; |
| 87 FilterStatusCB seek_cb_; | 95 FilterStatusCB seek_cb_; |
| 88 | 96 |
| 89 scoped_refptr<ChunkDemuxerStream> audio_; | 97 scoped_refptr<ChunkDemuxerStream> audio_; |
| 90 scoped_refptr<ChunkDemuxerStream> video_; | 98 scoped_refptr<ChunkDemuxerStream> video_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 // Should a Seek() call wait for more data before calling the | 117 // Should a Seek() call wait for more data before calling the |
| 110 // callback. | 118 // callback. |
| 111 bool seek_waits_for_data_; | 119 bool seek_waits_for_data_; |
| 112 | 120 |
| 113 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 121 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 114 }; | 122 }; |
| 115 | 123 |
| 116 } // namespace media | 124 } // namespace media |
| 117 | 125 |
| 118 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 126 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |