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

Side by Side Diff: media/mp4/mp4_stream_parser.h

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Inject parameter sets Created 8 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_MP4_MP4_STREAM_PARSER_H_
6 #define MEDIA_MP4_MP4_STREAM_PARSER_H_
7
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "media/base/stream_parser.h"
13 #include "media/mp4/offset_byte_queue.h"
14 #include "media/mp4/track_run_iterator.h"
15
16 namespace media {
17 namespace mp4 {
18
19 struct Movie;
20 class BoxReader;
21
22 class MP4StreamParser : public StreamParser {
23 public:
24 MP4StreamParser();
25 virtual ~MP4StreamParser();
26
27 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb,
28 const NewBuffersCB& audio_cb,
29 const NewBuffersCB& video_cb,
30 const KeyNeededCB& key_needed_cb) OVERRIDE;
31 virtual void Flush() OVERRIDE;
32 virtual bool Parse(const uint8* buf, int size) OVERRIDE;
33
34 private:
35 enum State {
36 kWaitingForInit,
37 kParsingBoxes,
38 kEmittingSamples,
39 kError
40 };
41
42 bool ParseBox(bool* err);
43 bool ParseMoov(mp4::BoxReader* reader);
44 bool ParseMoof(mp4::BoxReader* reader);
45
46 bool ReadMDATsUntil(const int64 tgt_tail);
47
48 void ChangeState(State new_state);
49
50 bool EmitConfigs();
51 bool EnqueueSample(BufferQueue* audio_buffers,
52 BufferQueue* video_buffers,
53 bool* err);
54
55 State state_;
56 InitCB init_cb_;
57 NewConfigCB config_cb_;
58 NewBuffersCB audio_cb_;
59 NewBuffersCB video_cb_;
60 KeyNeededCB key_needed_cb_;
61
62 OffsetByteQueue queue_;
63
64 // These two parameters are only valid in the |kEmittingSegments| state.
65 //
66 // |moof_head_| is the offset of the start of the most recently parsed moof
67 // block. All byte offsets in sample information are relative to this offset,
68 // as mandated by the Media Source spec.
69 int64 moof_head_;
70 // |mdat_tail_| is the stream offset of the end of the current 'mdat' box.
71 // Valid iff it is greater than the head of the queue.
72 int64 mdat_tail_;
73
74 mp4::TrackRunIterator runs_;
75
76 scoped_ptr<mp4::Movie> moov_;
77
78 bool has_audio_;
79 bool has_video_;
80 uint32 audio_track_id_;
81 uint32 video_track_id_;
82 bool parameter_sets_inserted_;
83
84 // We keep this around to avoid having to go digging through the moov with
85 // every frame.
86 uint8 size_of_nalu_length_;
87
88 DISALLOW_COPY_AND_ASSIGN(MP4StreamParser);
89 };
90
91 } // namespace mp4
92 } // namespace media
93
94 #endif // MEDIA_MP4_MP4_STREAM_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698