• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 AAC_ADTS_EXTRACTOR_H_
18 #define AAC_ADTS_EXTRACTOR_H_
19 
20 #include <utils/Vector.h>
21 
22 #include <media/stagefright/foundation/ABuffer.h>
23 #include <media/stagefright/foundation/ADebug.h>
24 #include <media/stagefright/DataSource.h>
25 #include <media/stagefright/MediaBufferGroup.h>
26 #include <media/stagefright/MediaDefs.h>
27 #include <media/stagefright/MediaErrors.h>
28 #include <media/stagefright/MediaExtractor.h>
29 #include <media/stagefright/MediaSource.h>
30 #include <media/stagefright/MetaData.h>
31 #include <utils/String8.h>
32 
33 namespace android {
34 
35 struct AMessage;
36 class String8;
37 
38 
39 class AacAdtsSource : public MediaSource {
40 public:
41     AacAdtsSource(const sp<DataSource> &source,
42               const sp<MetaData> &meta,
43               //const Vector<uint64_t> &offset_vector,
44               int64_t frame_duration_us);
45 
46     virtual status_t start(MetaData *params = NULL);
47     virtual status_t stop();
48 
49     virtual sp<MetaData> getFormat();
50 
51     virtual status_t read(
52             MediaBuffer **buffer, const ReadOptions *options = NULL);
53 
54 protected:
55     virtual ~AacAdtsSource();
56 
57 private:
58     static const size_t kMaxFrameSize;
59     sp<DataSource> mDataSource;
60     sp<MetaData> mMeta;
61 
62     off64_t mOffset;
63     int64_t mCurrentTimeUs;
64     bool mStarted;
65     MediaBufferGroup *mGroup;
66 
67     int64_t mFrameDurationUs;
68 
69     AacAdtsSource(const AacAdtsSource &);
70     AacAdtsSource &operator=(const AacAdtsSource &);
71 };
72 
73 
74 class AacAdtsExtractor : public MediaExtractor {
75 public:
76     explicit AacAdtsExtractor(const sp<DataSource> &source);
77 
78     virtual size_t countTracks();
79     virtual sp<IMediaSource> getTrack(size_t index);
80     virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
81 
82     virtual sp<MetaData> getMetaData();
83 
84 protected:
85     virtual ~AacAdtsExtractor();
86 
87 private:
88     sp<DataSource> mDataSource;
89     sp<MetaData> mMeta;
90     status_t mInitCheck;
91 
92     int64_t mFrameDurationUs;
93 
94     AacAdtsExtractor(const AacAdtsExtractor &);
95     AacAdtsExtractor &operator=(const AacAdtsExtractor &);
96 
97 };
98 
99 }  // namespace android
100 
101 #endif  // AAC_ADTS_EXTRACTOR_H_
102