blob: cf1146bcdecbae73564d1dee22b78ac532390288 [file] [log] [blame]
Andreas Hubere46b7be2009-07-14 16:56:47 -07001/*
2 * Copyright (C) 2009 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 MP3_EXTRACTOR_H_
18
19#define MP3_EXTRACTOR_H_
20
Mathias Agopiana688b572011-02-16 15:23:08 -080021#include <utils/Errors.h>
Andreas Hubere46b7be2009-07-14 16:56:47 -070022#include <media/stagefright/MediaExtractor.h>
23
24namespace android {
25
Andreas Huberefdd0882010-08-25 11:09:41 -070026struct AMessage;
Andreas Hubere46b7be2009-07-14 16:56:47 -070027class DataSource;
Andreas Huber1bd994982010-11-09 08:57:45 -080028struct MP3Seeker;
Andreas Hubere46b7be2009-07-14 16:56:47 -070029class String8;
30
31class MP3Extractor : public MediaExtractor {
32public:
33 // Extractor assumes ownership of "source".
Andreas Huberefdd0882010-08-25 11:09:41 -070034 MP3Extractor(const sp<DataSource> &source, const sp<AMessage> &meta);
Andreas Hubere46b7be2009-07-14 16:56:47 -070035
Andreas Huber5a65a6e2009-09-08 16:07:15 -070036 virtual size_t countTracks();
37 virtual sp<MediaSource> getTrack(size_t index);
Andreas Hubere981c332009-10-22 13:49:30 -070038 virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
Andreas Hubere46b7be2009-07-14 16:56:47 -070039
Andreas Huberaee3c632010-01-11 15:35:19 -080040 virtual sp<MetaData> getMetaData();
41
Andreas Huber1bd994982010-11-09 08:57:45 -080042 static bool get_mp3_frame_size(
43 uint32_t header, size_t *frame_size,
44 int *out_sampling_rate = NULL, int *out_channels = NULL,
Jason Simmons293e03d2011-04-06 18:16:12 -070045 int *out_bitrate = NULL, int *out_num_samples = NULL);
Andreas Huber1bd994982010-11-09 08:57:45 -080046
Andreas Hubere46b7be2009-07-14 16:56:47 -070047private:
Andreas Huber3e0f2be2010-09-09 09:48:41 -070048 status_t mInitCheck;
49
Andreas Huberbe06d262009-08-14 14:37:10 -070050 sp<DataSource> mDataSource;
James Dongb1262a82010-11-16 14:04:54 -080051 off64_t mFirstFramePos;
Andreas Hubere46b7be2009-07-14 16:56:47 -070052 sp<MetaData> mMeta;
53 uint32_t mFixedHeader;
Andreas Huber1bd994982010-11-09 08:57:45 -080054 sp<MP3Seeker> mSeeker;
Andreas Hubere46b7be2009-07-14 16:56:47 -070055
56 MP3Extractor(const MP3Extractor &);
57 MP3Extractor &operator=(const MP3Extractor &);
58};
59
Andreas Huberbe06d262009-08-14 14:37:10 -070060bool SniffMP3(
Andreas Huberefdd0882010-08-25 11:09:41 -070061 const sp<DataSource> &source, String8 *mimeType, float *confidence,
62 sp<AMessage> *meta);
Andreas Hubere46b7be2009-07-14 16:56:47 -070063
64} // namespace android
65
66#endif // MP3_EXTRACTOR_H_