Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1044)

Side by Side Diff: media/filters/chunk_demuxer.h

Issue 191513002: Extract coded frame processing from SourceState into LegacyFrameProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some lint errors Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/chunk_demuxer.cc » ('j') | media/filters/chunk_demuxer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque>
8 #include <map> 9 #include <map>
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "media/base/byte_queue.h" 15 #include "media/base/byte_queue.h"
15 #include "media/base/demuxer.h" 16 #include "media/base/demuxer.h"
16 #include "media/base/ranges.h" 17 #include "media/base/ranges.h"
17 #include "media/base/stream_parser.h" 18 #include "media/base/stream_parser.h"
18 #include "media/filters/source_buffer_stream.h" 19 #include "media/filters/source_buffer_stream.h"
19 20
20 namespace media { 21 namespace media {
21 22
22 class ChunkDemuxerStream;
23 class FFmpegURLProtocol; 23 class FFmpegURLProtocol;
24 class SourceState; 24 class SourceState;
25 25
26 class ChunkDemuxerStream : public DemuxerStream {
27 public:
28 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
29
30 explicit ChunkDemuxerStream(Type type);
31 virtual ~ChunkDemuxerStream();
32
33 // ChunkDemuxerStream control methods.
34 void StartReturningData();
35 void AbortReads();
36 void CompletePendingReadIfPossible();
37 void Shutdown();
38
39 // SourceBufferStream manipulation methods.
40 void Seek(base::TimeDelta time);
41 bool IsSeekWaitingForData() const;
42
43 // Add buffers to this stream. Buffers are stored in SourceBufferStreams,
44 // which handle ordering and overlap resolution.
45 // Returns true if buffers were successfully added.
46 bool Append(const StreamParser::BufferQueue& buffers);
47
48 // Removes buffers between |start| and |end| according to the steps
49 // in the "Coded Frame Removal Algorithm" in the Media Source
50 // Extensions Spec.
51 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal
52 //
53 // |duration| is the current duration of the presentation. It is
54 // required by the computation outlined in the spec.
55 void Remove(base::TimeDelta start, base::TimeDelta end,
56 base::TimeDelta duration);
57
58 // Signal to the stream that duration has changed to |duration|.
59 void OnSetDuration(base::TimeDelta duration);
60
61 // Returns the range of buffered data in this stream, capped at |duration|.
62 Ranges<base::TimeDelta> GetBufferedRanges(base::TimeDelta duration) const;
63
64 // Returns the duration of the buffered data.
65 // Returns base::TimeDelta() if the stream has no buffered data.
66 base::TimeDelta GetBufferedDuration() const;
67
68 // Signal to the stream that buffers handed in through subsequent calls to
69 // Append() belong to a media segment that starts at |start_timestamp|.
70 void OnNewMediaSegment(base::TimeDelta start_timestamp);
71
72 // Called when midstream config updates occur.
73 // Returns true if the new config is accepted.
74 // Returns false if the new config should trigger an error.
75 bool UpdateAudioConfig(const AudioDecoderConfig& config, const LogCB& log_cb);
76 bool UpdateVideoConfig(const VideoDecoderConfig& config, const LogCB& log_cb);
77 void UpdateTextConfig(const TextTrackConfig& config, const LogCB& log_cb);
78
79 void MarkEndOfStream();
80 void UnmarkEndOfStream();
81
82 // DemuxerStream methods.
83 virtual void Read(const ReadCB& read_cb) OVERRIDE;
84 virtual Type type() OVERRIDE;
85 virtual void EnableBitstreamConverter() OVERRIDE;
86 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE;
87 virtual VideoDecoderConfig video_decoder_config() OVERRIDE;
88
89 // Returns the text track configuration. It is an error to call this method
90 // if type() != TEXT.
91 TextTrackConfig text_track_config();
92
93 // Sets the memory limit, in bytes, on the SourceBufferStream.
94 void set_memory_limit_for_testing(int memory_limit) {
95 stream_->set_memory_limit_for_testing(memory_limit);
96 }
97
98 private:
99 enum State {
100 UNINITIALIZED,
101 RETURNING_DATA_FOR_READS,
102 RETURNING_ABORT_FOR_READS,
103 SHUTDOWN,
104 };
105
106 // Assigns |state_| to |state|
107 void ChangeState_Locked(State state);
108
109 void CompletePendingReadIfPossible_Locked();
110
111 // Specifies the type of the stream.
112 Type type_;
113
114 scoped_ptr<SourceBufferStream> stream_;
115
116 mutable base::Lock lock_;
117 State state_;
118 ReadCB read_cb_;
119
120 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream);
121 };
122
26 // Demuxer implementation that allows chunks of media data to be passed 123 // Demuxer implementation that allows chunks of media data to be passed
27 // from JavaScript to the media stack. 124 // from JavaScript to the media stack.
28 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { 125 class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
29 public: 126 public:
30 enum Status { 127 enum Status {
31 kOk, // ID added w/o error. 128 kOk, // ID added w/o error.
32 kNotSupported, // Type specified is not supported. 129 kNotSupported, // Type specified is not supported.
33 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. 130 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs.
34 }; 131 };
35 132
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // removed with RemoveID() but can not be re-added (yet). 372 // removed with RemoveID() but can not be re-added (yet).
276 std::string source_id_audio_; 373 std::string source_id_audio_;
277 std::string source_id_video_; 374 std::string source_id_video_;
278 375
279 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); 376 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer);
280 }; 377 };
281 378
282 } // namespace media 379 } // namespace media
283 380
284 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ 381 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/chunk_demuxer.cc » ('j') | media/filters/chunk_demuxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698