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_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 #include <string> | |
9 | 10 |
10 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
11 #include "media/base/byte_queue.h" | 12 #include "media/base/byte_queue.h" |
12 #include "media/base/demuxer.h" | 13 #include "media/base/demuxer.h" |
13 #include "media/base/stream_parser.h" | 14 #include "media/base/stream_parser.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
17 class ChunkDemuxerClient; | 18 class ChunkDemuxerClient; |
18 class ChunkDemuxerStream; | 19 class ChunkDemuxerStream; |
19 class FFmpegURLProtocol; | 20 class FFmpegURLProtocol; |
20 | 21 |
21 // Demuxer implementation that allows chunks of media data to be passed | 22 // Demuxer implementation that allows chunks of media data to be passed |
22 // from JavaScript to the media stack. | 23 // from JavaScript to the media stack. |
23 class MEDIA_EXPORT ChunkDemuxer : public Demuxer, public StreamParserHost { | 24 class MEDIA_EXPORT ChunkDemuxer : public Demuxer, public StreamParserHost { |
24 public: | 25 public: |
26 enum Status { | |
27 kOk, // ID added w/o error. | |
28 kNotSupported, // Type specified is not supported. | |
29 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | |
30 }; | |
31 | |
25 explicit ChunkDemuxer(ChunkDemuxerClient* client); | 32 explicit ChunkDemuxer(ChunkDemuxerClient* client); |
26 virtual ~ChunkDemuxer(); | 33 virtual ~ChunkDemuxer(); |
27 | 34 |
28 // Demuxer implementation. | 35 // Demuxer implementation. |
29 virtual void Initialize(DemuxerHost* host, | 36 virtual void Initialize(DemuxerHost* host, |
30 const PipelineStatusCB& cb) OVERRIDE; | 37 const PipelineStatusCB& cb) OVERRIDE; |
31 virtual void Stop(const base::Closure& callback) OVERRIDE; | 38 virtual void Stop(const base::Closure& callback) OVERRIDE; |
32 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 39 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
33 virtual void OnAudioRendererDisabled() OVERRIDE; | 40 virtual void OnAudioRendererDisabled() OVERRIDE; |
34 virtual scoped_refptr<DemuxerStream> GetStream( | 41 virtual scoped_refptr<DemuxerStream> GetStream( |
35 DemuxerStream::Type type) OVERRIDE; | 42 DemuxerStream::Type type) OVERRIDE; |
36 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 43 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
37 virtual int GetBitrate() OVERRIDE; | 44 virtual int GetBitrate() OVERRIDE; |
38 virtual bool IsLocalSource() OVERRIDE; | 45 virtual bool IsLocalSource() OVERRIDE; |
39 virtual bool IsSeekable() OVERRIDE; | 46 virtual bool IsSeekable() OVERRIDE; |
40 | 47 |
41 // Methods used by an external object to control this demuxer. | 48 // Methods used by an external object to control this demuxer. |
42 void FlushData(); | 49 void FlushData(); |
43 | 50 |
44 // Appends media data to the stream. Returns false if this method | 51 // Registers a new |id| to use for AppendData() calls. |type| indicates |
45 // is called in an invalid state. | 52 // the MIME type for the data that we intend to append for this ID. |
46 bool AppendData(const uint8* data, size_t length); | 53 // kOk is returned if the demuxer has enough resources to support another ID |
54 // and supports the format indicated by |type|. | |
55 // kNotSupported is returned if |type| is not a supported format. | |
56 // kReachedIdLimit is returned if the demuxer cannot handle another ID right | |
57 // now. | |
58 Status AddId(const std::string& id, const std::string& type); | |
59 | |
60 // Removed an ID & associated resources that were previously added with | |
61 // AddId(). | |
62 bool RemoveId(const std::string& id); | |
scherkus (not reviewing)
2012/04/23 19:24:17
what does true/false mean? could we have void?
is
acolwell GONE FROM CHROMIUM
2012/04/23 22:15:23
Yes we could have void. Eric wanted a bool returne
| |
63 | |
64 // Appends media data to the source buffer associated with |id|. Returns | |
65 // false if this method is called in an invalid state. | |
66 bool AppendData(const std::string& id, const uint8* data, size_t length); | |
scherkus (not reviewing)
2012/04/23 19:24:17
CHECK-fail instead?
acolwell GONE FROM CHROMIUM
2012/04/23 22:15:23
No. It is possible for appends to happen when the
| |
47 void EndOfStream(PipelineStatus status); | 67 void EndOfStream(PipelineStatus status); |
48 bool HasEnded(); | 68 bool HasEnded(); |
49 void Shutdown(); | 69 void Shutdown(); |
50 | 70 |
51 private: | 71 private: |
52 enum State { | 72 enum State { |
53 WAITING_FOR_INIT, | 73 WAITING_FOR_INIT, |
54 INITIALIZING, | 74 INITIALIZING, |
55 INITIALIZED, | 75 INITIALIZED, |
56 ENDED, | 76 ENDED, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 base::TimeDelta duration_; | 108 base::TimeDelta duration_; |
89 | 109 |
90 scoped_ptr<StreamParser> stream_parser_; | 110 scoped_ptr<StreamParser> stream_parser_; |
91 | 111 |
92 // Should a Seek() call wait for more data before calling the | 112 // Should a Seek() call wait for more data before calling the |
93 // callback. | 113 // callback. |
94 bool seek_waits_for_data_; | 114 bool seek_waits_for_data_; |
95 | 115 |
96 ByteQueue byte_queue_; | 116 ByteQueue byte_queue_; |
97 | 117 |
118 // TODO(acolwell): Remove this when fixing http://crbug.com/122909 . | |
scherkus (not reviewing)
2012/04/23 19:24:17
nit: I'd just leave off that trailing period in th
acolwell GONE FROM CHROMIUM
2012/04/23 22:15:23
Done.
| |
119 std::string source_id_; | |
120 | |
98 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 121 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
99 }; | 122 }; |
100 | 123 |
101 } // namespace media | 124 } // namespace media |
102 | 125 |
103 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 126 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |