ESQueue.h revision 95d7e994c73c17b27c7134ba3cc3acbb5889aa87
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ES_QUEUE_H_
18
19#define ES_QUEUE_H_
20
21#include <media/stagefright/foundation/ABase.h>
22#include <utils/Errors.h>
23#include <utils/List.h>
24#include <utils/RefBase.h>
25
26namespace android {
27
28struct ABuffer;
29struct MetaData;
30
31struct ElementaryStreamQueue {
32    enum Mode {
33        H264,
34        AAC
35    };
36    ElementaryStreamQueue(Mode mode);
37
38    status_t appendData(const void *data, size_t size, int64_t timeUs);
39    void clear(bool clearFormat);
40
41    sp<ABuffer> dequeueAccessUnit();
42
43    sp<MetaData> getFormat();
44
45private:
46    struct RangeInfo {
47        int64_t mTimestampUs;
48        size_t mLength;
49    };
50
51    Mode mMode;
52
53    sp<ABuffer> mBuffer;
54    List<RangeInfo> mRangeInfos;
55
56    sp<MetaData> mFormat;
57
58    sp<ABuffer> dequeueAccessUnitH264();
59    sp<ABuffer> dequeueAccessUnitAAC();
60
61    // consume a logical (compressed) access unit of size "size",
62    // returns its timestamp in us (or -1 if no time information).
63    int64_t fetchTimestamp(size_t size);
64
65    DISALLOW_EVIL_CONSTRUCTORS(ElementaryStreamQueue);
66};
67
68}  // namespace android
69
70#endif  // ES_QUEUE_H_
71