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