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 HTTP_LIVE_SOURCE_H_ |
| 18 | |
| 19 | #define HTTP_LIVE_SOURCE_H_ |
| 20 | |
| 21 | #include "NuPlayer.h" |
| 22 | #include "NuPlayerSource.h" |
| 23 | |
| 24 | namespace android { |
| 25 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 26 | struct LiveSession; |
| 27 | |
| 28 | struct NuPlayer::HTTPLiveSource : public NuPlayer::Source { |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 29 | HTTPLiveSource( |
Andreas Huber | b5f25f0 | 2013-02-05 10:14:26 -0800 | [diff] [blame] | 30 | const sp<AMessage> ¬ify, |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 31 | const sp<IMediaHTTPService> &httpService, |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 32 | const char *url, |
Andreas Huber | 81e6844 | 2014-02-05 11:52:33 -0800 | [diff] [blame] | 33 | const KeyedVector<String8, String8> *headers); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 34 | |
Andreas Huber | 9575c96 | 2013-02-05 13:59:56 -0800 | [diff] [blame] | 35 | virtual void prepareAsync(); |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 36 | virtual void start(); |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 37 | |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 38 | virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 39 | virtual sp<AMessage> getFormat(bool audio); |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 40 | |
Andreas Huber | 14f7672 | 2013-01-15 09:04:18 -0800 | [diff] [blame] | 41 | virtual status_t feedMoreTSData(); |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 42 | virtual status_t getDuration(int64_t *durationUs); |
Chong Zhang | 404fced | 2014-06-11 14:45:31 -0700 | [diff] [blame^] | 43 | virtual size_t getTrackCount() const; |
| 44 | virtual sp<AMessage> getTrackInfo(size_t trackIndex) const; |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 45 | virtual status_t selectTrack(size_t trackIndex, bool select); |
Andreas Huber | 43c3e6c | 2011-01-05 12:17:08 -0800 | [diff] [blame] | 46 | virtual status_t seekTo(int64_t seekTimeUs); |
Andreas Huber | b7c8e91 | 2012-11-27 15:02:53 -0800 | [diff] [blame] | 47 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 48 | protected: |
| 49 | virtual ~HTTPLiveSource(); |
| 50 | |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 51 | virtual void onMessageReceived(const sp<AMessage> &msg); |
| 52 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 53 | private: |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 54 | enum Flags { |
| 55 | // Don't log any URLs. |
| 56 | kFlagIncognito = 1, |
| 57 | }; |
| 58 | |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 59 | enum { |
| 60 | kWhatSessionNotify, |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 61 | kWhatFetchSubtitleData, |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 64 | sp<IMediaHTTPService> mHTTPService; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 65 | AString mURL; |
Andreas Huber | ad0d9c9 | 2011-04-19 11:50:27 -0700 | [diff] [blame] | 66 | KeyedVector<String8, String8> mExtraHeaders; |
Andreas Huber | 7314fa1 | 2011-02-24 14:42:48 -0800 | [diff] [blame] | 67 | uint32_t mFlags; |
Andreas Huber | eac68ba | 2011-09-27 12:12:25 -0700 | [diff] [blame] | 68 | status_t mFinalResult; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 69 | off64_t mOffset; |
| 70 | sp<ALooper> mLiveLooper; |
| 71 | sp<LiveSession> mLiveSession; |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 72 | int32_t mFetchSubtitleDataGeneration; |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 73 | |
Andreas Huber | 0df36ec | 2013-02-06 10:44:39 -0800 | [diff] [blame] | 74 | void onSessionNotify(const sp<AMessage> &msg); |
| 75 | |
Andreas Huber | 5bc087c | 2010-12-23 10:27:40 -0800 | [diff] [blame] | 76 | DISALLOW_EVIL_CONSTRUCTORS(HTTPLiveSource); |
| 77 | }; |
| 78 | |
| 79 | } // namespace android |
| 80 | |
| 81 | #endif // HTTP_LIVE_SOURCE_H_ |