1afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber/* 2afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * Copyright (C) 2012 The Android Open Source Project 3afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * 4afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * you may not use this file except in compliance with the License. 6afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * You may obtain a copy of the License at 7afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * 8afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * 10afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * Unless required by applicable law or agreed to in writing, software 11afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * See the License for the specific language governing permissions and 14afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber * limitations under the License. 15afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber */ 16afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 17afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber#ifndef GENERIC_SOURCE_H_ 18afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 19afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber#define GENERIC_SOURCE_H_ 20afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 21afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber#include "NuPlayer.h" 22afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber#include "NuPlayerSource.h" 23afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 24afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber#include "ATSParser.h" 25afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 26afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Hubernamespace android { 27afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 28afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberstruct AnotherPacketSource; 29afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberstruct ARTSPController; 30afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberstruct DataSource; 31afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberstruct MediaSource; 32afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 33afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberstruct NuPlayer::GenericSource : public NuPlayer::Source { 34afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber GenericSource( 35afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber const char *url, 36afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber const KeyedVector<String8, String8> *headers, 37afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber bool uidValid = false, 38afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber uid_t uid = 0); 39afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 40afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber GenericSource(int fd, int64_t offset, int64_t length); 41afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 42afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual void start(); 43afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 44afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual status_t feedMoreTSData(); 45afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 46afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual sp<MetaData> getFormat(bool audio); 47afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); 48afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 49afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual status_t getDuration(int64_t *durationUs); 50afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual status_t seekTo(int64_t seekTimeUs); 51afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual bool isSeekable(); 52afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 53afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberprotected: 54afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber virtual ~GenericSource(); 55afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 56afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huberprivate: 57afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber struct Track { 58afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber sp<MediaSource> mSource; 59afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber sp<AnotherPacketSource> mPackets; 60afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber }; 61afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 62afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber Track mAudioTrack; 63afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber Track mVideoTrack; 64afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 65afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber int64_t mDurationUs; 66afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber bool mAudioIsVorbis; 67afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 68afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber void initFromDataSource(const sp<DataSource> &dataSource); 69afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 70afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber void readBuffer( 71afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber bool audio, 72afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL); 73afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 74afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber DISALLOW_EVIL_CONSTRUCTORS(GenericSource); 75afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber}; 76afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 77afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber} // namespace android 78afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber 79afed0e1fa37473a4cd30018577b560acc79d9a3fAndreas Huber#endif // GENERIC_SOURCE_H_ 80