15bc087c573c70c84c6a39946457590b42d392a33Andreas Huber/* 25bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * Copyright (C) 2010 The Android Open Source Project 35bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * 45bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 55bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * you may not use this file except in compliance with the License. 65bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * You may obtain a copy of the License at 75bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * 85bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 95bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * 105bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * Unless required by applicable law or agreed to in writing, software 115bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 125bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * See the License for the specific language governing permissions and 145bc087c573c70c84c6a39946457590b42d392a33Andreas Huber * limitations under the License. 155bc087c573c70c84c6a39946457590b42d392a33Andreas Huber */ 165bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 175bc087c573c70c84c6a39946457590b42d392a33Andreas Huber#ifndef HTTP_LIVE_SOURCE_H_ 185bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 195bc087c573c70c84c6a39946457590b42d392a33Andreas Huber#define HTTP_LIVE_SOURCE_H_ 205bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 215bc087c573c70c84c6a39946457590b42d392a33Andreas Huber#include "NuPlayer.h" 225bc087c573c70c84c6a39946457590b42d392a33Andreas Huber#include "NuPlayerSource.h" 235bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 240852843d304006e3ab333081fddda13b07193de8Robert Shih#include "LiveSession.h" 250852843d304006e3ab333081fddda13b07193de8Robert Shih 265bc087c573c70c84c6a39946457590b42d392a33Andreas Hubernamespace android { 275bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 285bc087c573c70c84c6a39946457590b42d392a33Andreas Huberstruct LiveSession; 295bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 305bc087c573c70c84c6a39946457590b42d392a33Andreas Huberstruct NuPlayer::HTTPLiveSource : public NuPlayer::Source { 31ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber HTTPLiveSource( 32b5f25f005bc1d3ae35f45b58c88345e183dc336dAndreas Huber const sp<AMessage> ¬ify, 331b86fe063badb5f28c467ade39be0f4008688947Andreas Huber const sp<IMediaHTTPService> &httpService, 34ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber const char *url, 3581e68448f3361eaf8618930471fdc3c21bdf5cbcAndreas Huber const KeyedVector<String8, String8> *headers); 365bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 379575c96b6e418914e2ffc6741ecc8d71e3968dbeAndreas Huber virtual void prepareAsync(); 3843c3e6ce02215ca99d506458f596cb1211639f29Andreas Huber virtual void start(); 395bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 4043c3e6ce02215ca99d506458f596cb1211639f29Andreas Huber virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); 4114f7672b5d450ed26a06fd3bb3ce045ea78b11b2Andreas Huber virtual sp<AMessage> getFormat(bool audio); 4243c3e6ce02215ca99d506458f596cb1211639f29Andreas Huber 4314f7672b5d450ed26a06fd3bb3ce045ea78b11b2Andreas Huber virtual status_t feedMoreTSData(); 4443c3e6ce02215ca99d506458f596cb1211639f29Andreas Huber virtual status_t getDuration(int64_t *durationUs); 45404fced9bfa8fa423ee210a271ca051ffd1bec13Chong Zhang virtual size_t getTrackCount() const; 46404fced9bfa8fa423ee210a271ca051ffd1bec13Chong Zhang virtual sp<AMessage> getTrackInfo(size_t trackIndex) const; 4789bf2525c5b57f17260de5b00c5f3f78ac4b881eRobert Shih virtual ssize_t getSelectedTrack(media_track_type /* type */) const; 486ffb1fd67eb8f00f130a6db914ba42a8432aec70Robert Shih virtual status_t selectTrack(size_t trackIndex, bool select, int64_t timeUs); 4943c3e6ce02215ca99d506458f596cb1211639f29Andreas Huber virtual status_t seekTo(int64_t seekTimeUs); 50b7c8e91880463ff4981e3e53e98e45d68e2fe374Andreas Huber 515bc087c573c70c84c6a39946457590b42d392a33Andreas Huberprotected: 525bc087c573c70c84c6a39946457590b42d392a33Andreas Huber virtual ~HTTPLiveSource(); 535bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 540df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber virtual void onMessageReceived(const sp<AMessage> &msg); 550df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber 565bc087c573c70c84c6a39946457590b42d392a33Andreas Huberprivate: 57ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber enum Flags { 58ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber // Don't log any URLs. 59ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber kFlagIncognito = 1, 60ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber }; 61ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber 620df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber enum { 630df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber kWhatSessionNotify, 64dcb89b3b505522efde173c105a851c412f947178Chong Zhang kWhatFetchSubtitleData, 650852843d304006e3ab333081fddda13b07193de8Robert Shih kWhatFetchMetaData, 660df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber }; 670df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber 681b86fe063badb5f28c467ade39be0f4008688947Andreas Huber sp<IMediaHTTPService> mHTTPService; 695bc087c573c70c84c6a39946457590b42d392a33Andreas Huber AString mURL; 70ad0d9c9c39a24b7fbd94e935a5855c9025341929Andreas Huber KeyedVector<String8, String8> mExtraHeaders; 717314fa17093d514199fedcb55ac41136a1b31cb3Andreas Huber uint32_t mFlags; 72eac68baf095aeef54865c28b6888924dc6295cbdAndreas Huber status_t mFinalResult; 735bc087c573c70c84c6a39946457590b42d392a33Andreas Huber off64_t mOffset; 745bc087c573c70c84c6a39946457590b42d392a33Andreas Huber sp<ALooper> mLiveLooper; 755bc087c573c70c84c6a39946457590b42d392a33Andreas Huber sp<LiveSession> mLiveSession; 76dcb89b3b505522efde173c105a851c412f947178Chong Zhang int32_t mFetchSubtitleDataGeneration; 770852843d304006e3ab333081fddda13b07193de8Robert Shih int32_t mFetchMetaDataGeneration; 780852843d304006e3ab333081fddda13b07193de8Robert Shih bool mHasMetadata; 790852843d304006e3ab333081fddda13b07193de8Robert Shih bool mMetadataSelected; 805bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 810df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber void onSessionNotify(const sp<AMessage> &msg); 820852843d304006e3ab333081fddda13b07193de8Robert Shih void pollForRawData( 830852843d304006e3ab333081fddda13b07193de8Robert Shih const sp<AMessage> &msg, int32_t currentGeneration, 840852843d304006e3ab333081fddda13b07193de8Robert Shih LiveSession::StreamType fetchType, int32_t pushWhat); 850df36ec3303c2c6bf9b42c07945ac8bd234153f3Andreas Huber 865bc087c573c70c84c6a39946457590b42d392a33Andreas Huber DISALLOW_EVIL_CONSTRUCTORS(HTTPLiveSource); 875bc087c573c70c84c6a39946457590b42d392a33Andreas Huber}; 885bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 895bc087c573c70c84c6a39946457590b42d392a33Andreas Huber} // namespace android 905bc087c573c70c84c6a39946457590b42d392a33Andreas Huber 915bc087c573c70c84c6a39946457590b42d392a33Andreas Huber#endif // HTTP_LIVE_SOURCE_H_ 92