1bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi/*
2bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * Copyright (C) 2011 The Android Open Source Project
3bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi *
4bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * Licensed under the Apache License, Version 2.0 (the "License");
5bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * you may not use this file except in compliance with the License.
6bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * You may obtain a copy of the License at
7bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi *
8bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi *      http://www.apache.org/licenses/LICENSE-2.0
9bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi *
10bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * Unless required by applicable law or agreed to in writing, software
11bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * distributed under the License is distributed on an "AS IS" BASIS,
12bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * See the License for the specific language governing permissions and
14bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi * limitations under the License.
15bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi */
16bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
17bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#ifndef AAC_ADTS_EXTRACTOR_H_
18bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#define AAC_ADTS_EXTRACTOR_H_
19bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
20bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <utils/Vector.h>
21bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
22bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/foundation/ABuffer.h>
235f12770df2875b280acaf6a0de08ae0b57c930cfJames Dong#include <media/stagefright/foundation/ADebug.h>
24bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/DataSource.h>
25bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/MediaBufferGroup.h>
26bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/MediaDefs.h>
27bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/MediaErrors.h>
28bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/MediaExtractor.h>
29bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/MediaSource.h>
30bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <media/stagefright/MetaData.h>
31bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#include <utils/String8.h>
32bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
33bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivinamespace android {
34bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
35bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivistruct AMessage;
36bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviclass String8;
37bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
38bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
39bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviclass AacAdtsSource : public MediaSource {
40bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivipublic:
41bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    AacAdtsSource(const sp<DataSource> &source,
42bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi              const sp<MetaData> &meta,
43bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi              //const Vector<uint64_t> &offset_vector,
44bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi              int64_t frame_duration_us);
45bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
46bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual status_t start(MetaData *params = NULL);
47bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual status_t stop();
48bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
49bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual sp<MetaData> getFormat();
50bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
51bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual status_t read(
52bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi            MediaBuffer **buffer, const ReadOptions *options = NULL);
53bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
54bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviprotected:
55bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual ~AacAdtsSource();
56bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
57bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviprivate:
58bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    static const size_t kMaxFrameSize;
59bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    sp<DataSource> mDataSource;
60bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    sp<MetaData> mMeta;
61bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
62bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    off64_t mOffset;
63bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    int64_t mCurrentTimeUs;
64bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    bool mStarted;
65bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    MediaBufferGroup *mGroup;
66bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
67bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    int64_t mFrameDurationUs;
68bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
69bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    AacAdtsSource(const AacAdtsSource &);
70bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    AacAdtsSource &operator=(const AacAdtsSource &);
71bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi};
72bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
73bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
74bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviclass AacAdtsExtractor : public MediaExtractor {
75bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivipublic:
76bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    AacAdtsExtractor(const sp<DataSource> &source);
77bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
78bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual size_t countTracks();
79bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual sp<MediaSource> getTrack(size_t index);
80bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
81bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
82bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual sp<MetaData> getMetaData();
83bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
84bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviprotected:
85bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    virtual ~AacAdtsExtractor();
86bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
87bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Triviprivate:
88bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    sp<DataSource> mDataSource;
89bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    sp<MetaData> mMeta;
90bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    status_t mInitCheck;
91bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
92bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    int64_t mFrameDurationUs;
93bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
94bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    AacAdtsExtractor(const AacAdtsExtractor &);
95bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi    AacAdtsExtractor &operator=(const AacAdtsExtractor &);
96bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
97bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi};
98bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
99bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi}  // namespace android
100bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi
101bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#endif  // AAC_ADTS_EXTRACTOR_H_
102