Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 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 | |
| 26 | namespace android { |
| 27 | |
| 28 | struct AnotherPacketSource; |
| 29 | struct ARTSPController; |
| 30 | struct DataSource; |
| 31 | struct MediaSource; |
| 32 | |
| 33 | struct NuPlayer::GenericSource : public NuPlayer::Source { |
| 34 | GenericSource( |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 35 | const sp<AMessage> ¬ify, |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 36 | const sp<IMediaHTTPService> &httpService, |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 37 | const char *url, |
Andreas Huber | 81e6844 | 2014-02-05 11:52:33 -0800 | [diff] [blame] | 38 | const KeyedVector<String8, String8> *headers); |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 39 | |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 40 | GenericSource( |
| 41 | const sp<AMessage> ¬ify, |
| 42 | int fd, int64_t offset, int64_t length); |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 43 | |
Andreas Huber | 9575c96 | 2013-02-05 13:59:56 -0800 | [diff] [blame] | 44 | virtual void prepareAsync(); |
| 45 | |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 46 | virtual void start(); |
| 47 | |
| 48 | virtual status_t feedMoreTSData(); |
| 49 | |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 50 | virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); |
| 51 | |
| 52 | virtual status_t getDuration(int64_t *durationUs); |
Robert Shih | dd23572 | 2014-06-12 14:49:23 -0700 | [diff] [blame^] | 53 | virtual size_t getTrackCount() const; |
| 54 | virtual sp<AMessage> getTrackInfo(size_t trackIndex) const; |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 55 | virtual status_t seekTo(int64_t seekTimeUs); |
Andreas Huber | b7c8e91 | 2012-11-27 15:02:53 -0800 | [diff] [blame] | 56 | |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 57 | protected: |
| 58 | virtual ~GenericSource(); |
| 59 | |
Andreas Huber | 8406678 | 2011-08-16 09:34:26 -0700 | [diff] [blame] | 60 | virtual sp<MetaData> getFormatMeta(bool audio); |
| 61 | |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 62 | private: |
Robert Shih | dd23572 | 2014-06-12 14:49:23 -0700 | [diff] [blame^] | 63 | Vector<sp<MediaSource> > mSources; |
| 64 | |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 65 | struct Track { |
Robert Shih | dd23572 | 2014-06-12 14:49:23 -0700 | [diff] [blame^] | 66 | size_t mIndex; |
Andreas Huber | afed0e1 | 2011-09-20 15:39:58 -0700 | [diff] [blame] | 67 | sp<MediaSource> mSource; |
| 68 | sp<AnotherPacketSource> mPackets; |
| 69 | }; |
| 70 | |
| 71 | Track mAudioTrack; |
| 72 | Track mVideoTrack; |
| 73 | |
| 74 | int64_t mDurationUs; |
| 75 | bool mAudioIsVorbis; |
| 76 | |
| 77 | void initFromDataSource(const sp<DataSource> &dataSource); |
| 78 | |
| 79 | void readBuffer( |
| 80 | bool audio, |
| 81 | int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL); |
| 82 | |
| 83 | DISALLOW_EVIL_CONSTRUCTORS(GenericSource); |
| 84 | }; |
| 85 | |
| 86 | } // namespace android |
| 87 | |
| 88 | #endif // GENERIC_SOURCE_H_ |