blob: 94090eef26a3f19fb4008f0e26db2e95a75d07b8 [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 MEDIA_EXTRACTOR_H_
18
19#define MEDIA_EXTRACTOR_H_
20
21#include <utils/RefBase.h>
22
23namespace android {
24
25class DataSource;
26class MediaSource;
27class MetaData;
28
Andreas Huberbe06d262009-08-14 14:37:10 -070029class MediaExtractor : public RefBase {
Andreas Hubere46b7be2009-07-14 16:56:47 -070030public:
Andreas Huberbe06d262009-08-14 14:37:10 -070031 static sp<MediaExtractor> Create(
32 const sp<DataSource> &source, const char *mime = NULL);
Andreas Hubere46b7be2009-07-14 16:56:47 -070033
Andreas Huberbe06d262009-08-14 14:37:10 -070034 virtual size_t countTracks() = 0;
35 virtual sp<MediaSource> getTrack(size_t index) = 0;
Andreas Hubere981c332009-10-22 13:49:30 -070036
37 enum GetTrackMetaDataFlags {
38 kIncludeExtensiveMetaData = 1
39 };
40 virtual sp<MetaData> getTrackMetaData(
41 size_t index, uint32_t flags = 0) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -070042
Andreas Huberaee3c632010-01-11 15:35:19 -080043 // Return container specific meta-data. The default implementation
44 // returns an empty metadata object.
45 virtual sp<MetaData> getMetaData();
46
Andreas Huber62f7ffe2010-05-06 10:18:05 -070047 enum Flags {
Andreas Huber10b9b3f2010-10-08 10:16:24 -070048 CAN_SEEK_BACKWARD = 1, // the "seek 10secs back button"
49 CAN_SEEK_FORWARD = 2, // the "seek 10secs forward button"
Andreas Huber62f7ffe2010-05-06 10:18:05 -070050 CAN_PAUSE = 4,
Andreas Huber10b9b3f2010-10-08 10:16:24 -070051 CAN_SEEK = 8, // the "seek bar"
Andreas Huber62f7ffe2010-05-06 10:18:05 -070052 };
53
54 // If subclasses do _not_ override this, the default is
Andreas Huber10b9b3f2010-10-08 10:16:24 -070055 // CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
Andreas Huber62f7ffe2010-05-06 10:18:05 -070056 virtual uint32_t flags() const;
57
Gloria Wangd5770912010-06-22 13:55:38 -070058 // for DRM
James Dongd1ba6ed2012-01-10 08:24:37 -080059 void setDrmFlag(bool flag) {
Gloria Wang82428a82011-06-27 11:09:00 -070060 mIsDrm = flag;
61 };
James Dongd1ba6ed2012-01-10 08:24:37 -080062 bool getDrmFlag() {
Gloria Wang82428a82011-06-27 11:09:00 -070063 return mIsDrm;
64 }
Gloria Wangd5770912010-06-22 13:55:38 -070065 virtual char* getDrmTrackInfo(size_t trackID, int *len) {
66 return NULL;
67 }
68
Andreas Hubere46b7be2009-07-14 16:56:47 -070069protected:
70 MediaExtractor() {}
Andreas Huberbe06d262009-08-14 14:37:10 -070071 virtual ~MediaExtractor() {}
Andreas Hubere46b7be2009-07-14 16:56:47 -070072
73private:
Gloria Wang82428a82011-06-27 11:09:00 -070074 bool mIsDrm;
75
Andreas Hubere46b7be2009-07-14 16:56:47 -070076 MediaExtractor(const MediaExtractor &);
77 MediaExtractor &operator=(const MediaExtractor &);
78};
79
80} // namespace android
81
82#endif // MEDIA_EXTRACTOR_H_