GenericSource.h revision cc227036b05f7c2f960a89c567a61f9decefe742
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 isWidevine = false, 40 bool uidValid = false, 41 uid_t uid = 0); 42 43 GenericSource( 44 const sp<AMessage> ¬ify, 45 int fd, int64_t offset, int64_t length); 46 47 virtual void prepareAsync(); 48 49 virtual void start(); 50 51 virtual status_t feedMoreTSData(); 52 53 virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); 54 55 virtual status_t getDuration(int64_t *durationUs); 56 virtual size_t getTrackCount() const; 57 virtual sp<AMessage> getTrackInfo(size_t trackIndex) const; 58 virtual status_t seekTo(int64_t seekTimeUs); 59 60 virtual status_t setBuffers(bool audio, Vector<MediaBuffer *> &buffers); 61 62protected: 63 virtual ~GenericSource(); 64 65 virtual sp<MetaData> getFormatMeta(bool audio); 66 67private: 68 Vector<sp<MediaSource> > mSources; 69 70 struct Track { 71 size_t mIndex; 72 sp<MediaSource> mSource; 73 sp<AnotherPacketSource> mPackets; 74 }; 75 76 Track mAudioTrack; 77 Track mVideoTrack; 78 79 int64_t mDurationUs; 80 bool mAudioIsVorbis; 81 bool mIsWidevine; 82 bool mUIDValid; 83 uid_t mUID; 84 85 void initFromDataSource(const sp<DataSource> &dataSource); 86 87 void readBuffer( 88 bool audio, 89 int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL); 90 91 DISALLOW_EVIL_CONSTRUCTORS(GenericSource); 92}; 93 94} // namespace android 95 96#endif // GENERIC_SOURCE_H_ 97