ESQueue.h revision a093f92042cf65060d1474c0fe116c12f8981717
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/List.h>
23#include <utils/RefBase.h>
24
25namespace android {
26
27struct ABuffer;
28struct MetaData;
29
30struct ElementaryStreamQueue {
31    enum Mode {
32        H264,
33        AAC
34    };
35    ElementaryStreamQueue(Mode mode);
36
37    status_t appendData(const void *data, size_t size, int64_t timeUs);
38    void clear();
39
40    sp<ABuffer> dequeueAccessUnit();
41
42    sp<MetaData> getFormat();
43
44private:
45    struct RangeInfo {
46        int64_t mTimestampUs;
47        size_t mLength;
48    };
49
50    Mode mMode;
51
52    sp<ABuffer> mBuffer;
53    List<RangeInfo> mRangeInfos;
54
55    sp<MetaData> mFormat;
56
57    sp<ABuffer> dequeueAccessUnitH264();
58    sp<ABuffer> dequeueAccessUnitAAC();
59
60    // consume a logical (compressed) access unit of size "size",
61    // returns its timestamp in us (or -1 if no time information).
62    int64_t fetchTimestamp(size_t size);
63
64    static sp<MetaData> MakeAACCodecSpecificData(
65            unsigned profile, unsigned sampling_freq_index,
66            unsigned channel_configuration);
67
68    DISALLOW_EVIL_CONSTRUCTORS(ElementaryStreamQueue);
69};
70
71}  // namespace android
72
73#endif  // ES_QUEUE_H_
74