Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 STREAMING_SOURCE_H_ |
| 18 | |
| 19 | #define STREAMING_SOURCE_H_ |
| 20 | |
| 21 | #include "NuPlayer.h" |
| 22 | #include "NuPlayerSource.h" |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | struct ABuffer; |
| 27 | struct ATSParser; |
Chong Zhang | 180d1b9 | 2014-12-02 18:35:35 -0800 | [diff] [blame] | 28 | struct AnotherPacketSource; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 29 | |
| 30 | struct NuPlayer::StreamingSource : public NuPlayer::Source { |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 31 | StreamingSource( |
| 32 | const sp<AMessage> ¬ify, |
| 33 | const sp<IStreamSource> &source); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 34 | |
Wei Jia | 48fa06d | 2016-12-20 15:30:49 -0800 | [diff] [blame^] | 35 | virtual status_t getDefaultBufferingSettings( |
| 36 | BufferingSettings* buffering /* nonnull */) override; |
| 37 | virtual status_t setBufferingSettings(const BufferingSettings& buffering) override; |
| 38 | |
Andreas Huber | 9575c96 | 2013-02-05 13:59:56 -0800 | [diff] [blame] | 39 | virtual void prepareAsync(); |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 40 | virtual void start(); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 41 | |
Andreas Huber | eac68ba | 2011-09-27 12:12:25 -0700 | [diff] [blame] | 42 | virtual status_t feedMoreTSData(); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 43 | |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 44 | virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 45 | |
Andreas Huber | d5e5623 | 2013-03-12 11:01:43 -0700 | [diff] [blame] | 46 | virtual bool isRealTime() const; |
| 47 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 48 | protected: |
| 49 | virtual ~StreamingSource(); |
| 50 | |
Chong Zhang | 180d1b9 | 2014-12-02 18:35:35 -0800 | [diff] [blame] | 51 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 52 | |
Robert Shih | 093024b | 2016-05-12 13:45:56 -0700 | [diff] [blame] | 53 | virtual sp<AMessage> getFormat(bool audio); |
Andreas Huber | 8406678 | 2011-08-16 09:34:26 -0700 | [diff] [blame] | 54 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 55 | private: |
Chong Zhang | 180d1b9 | 2014-12-02 18:35:35 -0800 | [diff] [blame] | 56 | enum { |
| 57 | kWhatReadBuffer, |
| 58 | }; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 59 | sp<IStreamSource> mSource; |
Andreas Huber | eac68ba | 2011-09-27 12:12:25 -0700 | [diff] [blame] | 60 | status_t mFinalResult; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 61 | sp<NuPlayerStreamListener> mStreamListener; |
| 62 | sp<ATSParser> mTSParser; |
| 63 | |
Chong Zhang | 180d1b9 | 2014-12-02 18:35:35 -0800 | [diff] [blame] | 64 | bool mBuffering; |
| 65 | Mutex mBufferingLock; |
| 66 | sp<ALooper> mLooper; |
| 67 | |
| 68 | void setError(status_t err); |
| 69 | sp<AnotherPacketSource> getSource(bool audio); |
| 70 | bool haveSufficientDataOnAllTracks(); |
| 71 | status_t postReadBuffer(); |
| 72 | void onReadBuffer(); |
| 73 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 74 | DISALLOW_EVIL_CONSTRUCTORS(StreamingSource); |
| 75 | }; |
| 76 | |
| 77 | } // namespace android |
| 78 | |
| 79 | #endif // STREAMING_SOURCE_H_ |