diff options
author | Apurupa Pattapu <apurupa@codeaurora.org> | 2015-07-07 12:27:10 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:24:30 -0600 |
commit | 0c4d3ced0a20b5cef6c51410754b40d4254f596b (patch) | |
tree | d6fd24c95573ca43af5c96325fb7bd61664b8836 | |
parent | daef932059bbeaf1b88a8871f348be128fdf0bfe (diff) | |
download | frameworks_av-0c4d3ced0a20b5cef6c51410754b40d4254f596b.zip frameworks_av-0c4d3ced0a20b5cef6c51410754b40d4254f596b.tar.gz frameworks_av-0c4d3ced0a20b5cef6c51410754b40d4254f596b.tar.bz2 |
Stagefright: Extensions for HTTP progressive streaming.
- Extend NuPlayer setDataSource for streaming
- Create ExtendedCachedSource only for MediaPlayer streaming
usecases by passing a flag to DataSource to use extended cache
- Add extension for MediaHTTP
Change-Id: Ic87c3744bf905eb8742863951b809e38d0a60339
-rw-r--r-- | include/media/stagefright/DataSource.h | 3 | ||||
-rw-r--r-- | include/media/stagefright/MediaHTTP.h | 2 | ||||
-rw-r--r-- | media/libavextensions/Android.mk | 3 | ||||
-rw-r--r-- | media/libavextensions/stagefright/AVExtensions.h | 9 | ||||
-rw-r--r-- | media/libavextensions/stagefright/AVFactory.cpp | 14 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/GenericSource.cpp | 3 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/GenericSource.h | 8 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 2 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.h | 5 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerSource.h | 4 | ||||
-rw-r--r-- | media/libstagefright/DataSource.cpp | 22 | ||||
-rw-r--r-- | media/libstagefright/include/NuCachedSource2.h | 2 |
12 files changed, 56 insertions, 21 deletions
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h index dcde36f..0c31e72 100644 --- a/include/media/stagefright/DataSource.h +++ b/include/media/stagefright/DataSource.h @@ -51,7 +51,8 @@ public: const char *uri, const KeyedVector<String8, String8> *headers = NULL, String8 *contentType = NULL, - HTTPBase *httpSource = NULL); + HTTPBase *httpSource = NULL, + bool useExtendedCache = false); static sp<DataSource> CreateMediaHTTP(const sp<IMediaHTTPService> &httpService); static sp<DataSource> CreateFromIDataSource(const sp<IDataSource> &source); diff --git a/include/media/stagefright/MediaHTTP.h b/include/media/stagefright/MediaHTTP.h index 006d8d8..88683bd 100644 --- a/include/media/stagefright/MediaHTTP.h +++ b/include/media/stagefright/MediaHTTP.h @@ -54,7 +54,7 @@ protected: virtual String8 getUri(); virtual String8 getMIMEType() const; -private: +protected: status_t mInitCheck; sp<IMediaHTTPConnection> mHTTPConnection; diff --git a/media/libavextensions/Android.mk b/media/libavextensions/Android.mk index 511f13f..26c9f85 100644 --- a/media/libavextensions/Android.mk +++ b/media/libavextensions/Android.mk @@ -12,7 +12,8 @@ LOCAL_C_INCLUDES:= \ $(TOP)/frameworks/native/include/media/hardware \ $(TOP)/frameworks/native/include/media/openmax \ $(TOP)/external/flac/include \ - $(TOP)/hardware/qcom/media/mm-core/inc + $(TOP)/hardware/qcom/media/mm-core/inc \ + $(TOP)/frameworks/av/media/libstagefright \ LOCAL_CFLAGS += -Wno-multichar diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h index 04588d5..06257be 100644 --- a/media/libavextensions/stagefright/AVExtensions.h +++ b/media/libavextensions/stagefright/AVExtensions.h @@ -39,6 +39,9 @@ struct ACodec; class MediaExtractor; struct MediaCodec; class AudioParameter; +struct NuCachedSource2; +struct MediaHTTP; +struct IMediaHTTPConnection; /* * Factory to create objects of base-classes in libstagefright @@ -47,6 +50,12 @@ struct AVFactory { virtual sp<ACodec> createACodec(); virtual MediaExtractor* createExtendedExtractor( const sp<DataSource> &source, const char *mime); + virtual sp<NuCachedSource2> createCachedSource( + const sp<DataSource> &source, + const char *cacheConfig = NULL, + bool disconnectAtHighwatermark = false); + virtual MediaHTTP* createMediaHTTP( + const sp<IMediaHTTPConnection> &conn); // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVFactory); diff --git a/media/libavextensions/stagefright/AVFactory.cpp b/media/libavextensions/stagefright/AVFactory.cpp index da60167..22969a2 100644 --- a/media/libavextensions/stagefright/AVFactory.cpp +++ b/media/libavextensions/stagefright/AVFactory.cpp @@ -40,9 +40,11 @@ #include <media/stagefright/DataSource.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaExtractor.h> +#include <media/stagefright/MediaHTTP.h> #include "common/ExtensionsLoader.hpp" #include "stagefright/AVExtensions.h" +#include "include/NuCachedSource2.h" namespace android { @@ -55,6 +57,18 @@ MediaExtractor* AVFactory::createExtendedExtractor( return NULL; } +sp<NuCachedSource2> AVFactory::createCachedSource( + const sp<DataSource> &source, + const char *cacheConfig, + bool disconnectAtHighwatermark) { + return new NuCachedSource2(source, cacheConfig, disconnectAtHighwatermark); +} + +MediaHTTP* AVFactory::createMediaHTTP( + const sp<IMediaHTTPConnection> &conn) { + return new MediaHTTP(conn); +} + // ----- NO TRESSPASSING BEYOND THIS LINE ------ AVFactory::AVFactory() { } diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp index 27a2934..3b2bcee 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp +++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp @@ -374,7 +374,8 @@ void NuPlayer::GenericSource::onPrepareAsync() { mDataSource = DataSource::CreateFromURI( mHTTPService, uri, &mUriHeaders, &contentType, - static_cast<HTTPBase *>(mHttpSource.get())); + static_cast<HTTPBase *>(mHttpSource.get()), + true /*use extended cache*/); } else { mIsWidevine = false; diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h index dc85d2d..0181947 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.h +++ b/media/libmediaplayerservice/nuplayer/GenericSource.h @@ -42,7 +42,7 @@ class WVMExtractor; struct NuPlayer::GenericSource : public NuPlayer::Source { GenericSource(const sp<AMessage> ¬ify, bool uidValid, uid_t uid); - status_t setDataSource( + virtual status_t setDataSource( const sp<IMediaHTTPService> &httpService, const char *url, const KeyedVector<String8, String8> *headers); @@ -84,7 +84,7 @@ protected: virtual sp<MetaData> getFormatMeta(bool audio); -private: +protected: enum { kWhatPrepareAsync, kWhatFetchSubtitleData, @@ -163,7 +163,7 @@ private: int64_t getLastReadPosition(); void setDrmPlaybackStatusIfNeeded(int playbackStatus, int64_t position); - void notifyPreparedAndCleanup(status_t err); + virtual void notifyPreparedAndCleanup(status_t err); void onSecureDecodersInstantiated(status_t err); void finishPrepareAsync(); status_t startSources(); @@ -180,7 +180,7 @@ private: void onSeek(sp<AMessage> msg); status_t doSeek(int64_t seekTimeUs); - void onPrepareAsync(); + virtual void onPrepareAsync(); void fetchTextData( uint32_t what, media_track_type type, diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 3af1659..3daa728 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -217,7 +217,7 @@ void NuPlayer::setDataSourceAsync(const sp<IStreamSource> &source) { msg->post(); } -static bool IsHTTPLiveURL(const char *url) { +bool NuPlayer::IsHTTPLiveURL(const char *url) { if (!strncasecmp("http://", url, 7) || !strncasecmp("https://", url, 8) || !strncasecmp("file://", url, 7)) { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 7a2c73e..190908f 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -41,7 +41,7 @@ struct NuPlayer : public AHandler { void setDataSourceAsync(const sp<IStreamSource> &source); - void setDataSourceAsync( + virtual void setDataSourceAsync( const sp<IMediaHTTPService> &httpService, const char *url, const KeyedVector<String8, String8> *headers); @@ -90,6 +90,7 @@ protected: virtual void setDecodedPcmOffload(bool /*decodePcmOffload*/) {} virtual bool canOffloadDecodedPCMStream(const sp<MetaData> /*meta*/, bool /*hasVideo*/, bool /*isStreaming*/, audio_stream_type_t /*streamType*/) {return false;} + static bool IsHTTPLiveURL(const char *url); public: struct NuPlayerStreamListener; struct Source; @@ -236,7 +237,7 @@ protected: const sp<AMessage> &inputFormat, const sp<AMessage> &outputFormat = NULL); - void notifyListener(int msg, int ext1, int ext2, const Parcel *in = NULL); + virtual void notifyListener(int msg, int ext1, int ext2, const Parcel *in = NULL); void handleFlushComplete(bool audio, bool isDecoder); void finishFlushIfPossible(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h index 11a6a9f..c87f172 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h @@ -132,10 +132,10 @@ protected: void notifyFlagsChanged(uint32_t flags); void notifyVideoSizeChanged(const sp<AMessage> &format = NULL); void notifyInstantiateSecureDecoders(const sp<AMessage> &reply); - void notifyPrepared(status_t err = OK); + virtual void notifyPrepared(status_t err = OK); -private: sp<AMessage> mNotify; +private: DISALLOW_EVIL_CONSTRUCTORS(Source); }; diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp index fdd6d96..85d0292 100644 --- a/media/libstagefright/DataSource.cpp +++ b/media/libstagefright/DataSource.cpp @@ -193,7 +193,8 @@ sp<DataSource> DataSource::CreateFromURI( const char *uri, const KeyedVector<String8, String8> *headers, String8 *contentType, - HTTPBase *httpSource) { + HTTPBase *httpSource, + bool useExtendedCache) { if (contentType != NULL) { *contentType = ""; } @@ -217,7 +218,7 @@ sp<DataSource> DataSource::CreateFromURI( ALOGE("Failed to make http connection from http service!"); return NULL; } - httpSource = new MediaHTTP(conn); + httpSource = AVFactory::get()->createMediaHTTP(conn); } String8 tmp; @@ -249,10 +250,17 @@ sp<DataSource> DataSource::CreateFromURI( *contentType = httpSource->getMIMEType(); } - source = new NuCachedSource2( - httpSource, - cacheConfig.isEmpty() ? NULL : cacheConfig.string(), - disconnectAtHighwatermark); + if (useExtendedCache) { + source = AVFactory::get()->createCachedSource( + httpSource, + cacheConfig.isEmpty() ? NULL : cacheConfig.string(), + disconnectAtHighwatermark); + } else { + source = new NuCachedSource2( + httpSource, + cacheConfig.isEmpty() ? NULL : cacheConfig.string(), + disconnectAtHighwatermark); + } } else { // We do not want that prefetching, caching, datasource wrapper // in the widevine:// case. @@ -281,7 +289,7 @@ sp<DataSource> DataSource::CreateMediaHTTP(const sp<IMediaHTTPService> &httpServ if (conn == NULL) { return NULL; } else { - return new MediaHTTP(conn); + return AVFactory::get()->createMediaHTTP(conn); } } diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h index 4252706..d36da6a 100644 --- a/media/libstagefright/include/NuCachedSource2.h +++ b/media/libstagefright/include/NuCachedSource2.h @@ -69,7 +69,7 @@ struct NuCachedSource2 : public DataSource { protected: virtual ~NuCachedSource2(); -private: +protected: friend struct AHandlerReflector<NuCachedSource2>; enum { |