1/* 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 <media/IMediaExtractor.h> 22#include <media/IMediaSource.h> 23 24namespace android { 25 26class DataSource; 27class MediaSource; 28class MetaData; 29 30class MediaExtractor : public BnMediaExtractor { 31public: 32 static sp<IMediaExtractor> Create( 33 const sp<DataSource> &source, const char *mime = NULL); 34 static sp<MediaExtractor> CreateFromService( 35 const sp<DataSource> &source, const char *mime = NULL); 36 37 virtual size_t countTracks() = 0; 38 virtual sp<IMediaSource> getTrack(size_t index) = 0; 39 40 enum GetTrackMetaDataFlags { 41 kIncludeExtensiveMetaData = 1 42 }; 43 virtual sp<MetaData> getTrackMetaData( 44 size_t index, uint32_t flags = 0) = 0; 45 46 // Return container specific meta-data. The default implementation 47 // returns an empty metadata object. 48 virtual sp<MetaData> getMetaData(); 49 50 enum Flags { 51 CAN_SEEK_BACKWARD = 1, // the "seek 10secs back button" 52 CAN_SEEK_FORWARD = 2, // the "seek 10secs forward button" 53 CAN_PAUSE = 4, 54 CAN_SEEK = 8, // the "seek bar" 55 }; 56 57 // If subclasses do _not_ override this, the default is 58 // CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE 59 virtual uint32_t flags() const; 60 61 // for DRM 62 void setDrmFlag(bool flag) { 63 mIsDrm = flag; 64 }; 65 bool getDrmFlag() { 66 return mIsDrm; 67 } 68 virtual char* getDrmTrackInfo(size_t trackID, int *len) { 69 return NULL; 70 } 71 virtual void setUID(uid_t uid) { 72 } 73 74 virtual const char * name() { return "<unspecified>"; } 75 76protected: 77 MediaExtractor(); 78 virtual ~MediaExtractor() {} 79 80private: 81 bool mIsDrm; 82 83 MediaExtractor(const MediaExtractor &); 84 MediaExtractor &operator=(const MediaExtractor &); 85}; 86 87} // namespace android 88 89#endif // MEDIA_EXTRACTOR_H_ 90