GenericSource.h revision 1b86fe063badb5f28c467ade39be0f4008688947
1/* 2 * Copyright (C) 2012 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 GENERIC_SOURCE_H_ 18 19#define GENERIC_SOURCE_H_ 20 21#include "NuPlayer.h" 22#include "NuPlayerSource.h" 23 24#include "ATSParser.h" 25 26namespace android { 27 28struct AnotherPacketSource; 29struct ARTSPController; 30struct DataSource; 31struct MediaSource; 32 33struct NuPlayer::GenericSource : public NuPlayer::Source { 34 GenericSource( 35 const sp<AMessage> ¬ify, 36 const sp<IMediaHTTPService> &httpService, 37 const char *url, 38 const KeyedVector<String8, String8> *headers, 39 bool uidValid = false, 40 uid_t uid = 0); 41 42 GenericSource( 43 const sp<AMessage> ¬ify, 44 int fd, int64_t offset, int64_t length); 45 46 virtual void prepareAsync(); 47 48 virtual void start(); 49 50 virtual status_t feedMoreTSData(); 51 52 virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); 53 54 virtual status_t getDuration(int64_t *durationUs); 55 virtual status_t seekTo(int64_t seekTimeUs); 56 57protected: 58 virtual ~GenericSource(); 59 60 virtual sp<MetaData> getFormatMeta(bool audio); 61 62private: 63 struct Track { 64 sp<MediaSource> mSource; 65 sp<AnotherPacketSource> mPackets; 66 }; 67 68 Track mAudioTrack; 69 Track mVideoTrack; 70 71 int64_t mDurationUs; 72 bool mAudioIsVorbis; 73 74 void initFromDataSource(const sp<DataSource> &dataSource); 75 76 void readBuffer( 77 bool audio, 78 int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL); 79 80 DISALLOW_EVIL_CONSTRUCTORS(GenericSource); 81}; 82 83} // namespace android 84 85#endif // GENERIC_SOURCE_H_ 86