Loading media/ndk/NdkMediaDataSource.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ struct AMediaDataSource { AMediaDataSourceReadAt readAt; AMediaDataSourceGetSize getSize; AMediaDataSourceClose close; AMediaDataSourceGetAvailableSize getAvailableSize; sp<DataSource> mImpl; uint32_t mFlags; }; Loading Loading @@ -107,6 +108,17 @@ void NdkDataSource::close() { } } status_t NdkDataSource::getAvailableSize(off64_t offset, off64_t *sizeptr) { off64_t size = -1; if (mDataSource->getAvailableSize != NULL && mDataSource->userdata != NULL && sizeptr != NULL) { size = mDataSource->getAvailableSize(mDataSource->userdata, offset); *sizeptr = size; } return size >= 0 ? OK : UNKNOWN_ERROR; } static sp<MediaHTTPService> createMediaHttpServiceFromJavaObj(JNIEnv *env, jobject obj, int version) { if (obj == NULL) { return NULL; Loading Loading @@ -251,5 +263,11 @@ void AMediaDataSource_close(AMediaDataSource *mSource) { return mSource->close(mSource->userdata); } EXPORT void AMediaDataSource_setGetAvailableSize(AMediaDataSource *mSource, AMediaDataSourceGetAvailableSize getAvailableSize) { mSource->getAvailableSize = getAvailableSize; } } // extern "C" media/ndk/NdkMediaDataSourceCallbacks.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,11 @@ void DataSource_close(void *userdata) { source->close(); } ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset) { off64_t size = -1; DataSource *source = static_cast<DataSource *>(userdata); status_t err = source->getAvailableSize(offset, &size); return err == OK ? size : -1; } } // namespace android media/ndk/NdkMediaDataSourceCallbacksPriv.h +3 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ ssize_t DataSource_readAt(void *userdata, off64_t offset, void * buf, size_t siz void DataSource_close(void *userdata); ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset); static inline AMediaDataSource* convertDataSourceToAMediaDataSource(const sp<DataSource> &source) { if (source == NULL) { return NULL; Loading @@ -40,6 +42,7 @@ static inline AMediaDataSource* convertDataSourceToAMediaDataSource(const sp<Dat AMediaDataSource_setReadAt(mSource, DataSource_readAt); AMediaDataSource_setGetSize(mSource, DataSource_getSize); AMediaDataSource_setClose(mSource, DataSource_close); AMediaDataSource_setGetAvailableSize(mSource, DataSource_getAvailableSize); return mSource; } Loading media/ndk/NdkMediaDataSourcePriv.h +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ struct NdkDataSource : public DataSource { virtual String8 toString(); virtual String8 getMIMEType() const; virtual void close(); virtual status_t getAvailableSize(off64_t offset, off64_t *size); protected: virtual ~NdkDataSource(); Loading media/ndk/include/media/NdkMediaDataSource.h +20 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,14 @@ AMediaDataSource* AMediaDataSource_new() __INTRODUCED_IN(28); #if __ANDROID_API__ >= 29 /** * Called to get an estimate of the number of bytes that can be read from this data source * starting at |offset| without blocking for I/O. * * Return -1 when such an estimate is not possible. */ typedef ssize_t (*AMediaDataSourceGetAvailableSize)(void *userdata, off64_t offset); /** * Create new media data source. Returns NULL if memory allocation * for the new data source object fails. Loading Loading @@ -176,6 +184,18 @@ void AMediaDataSource_setClose( */ void AMediaDataSource_close(AMediaDataSource*) __INTRODUCED_IN(29); /** * Set a custom callback for supplying the estimated number of bytes * that can be read from this data source starting at an offset without * blocking for I/O. * * Please refer to the definition of AMediaDataSourceGetAvailableSize * for additional details. */ void AMediaDataSource_setGetAvailableSize( AMediaDataSource*, AMediaDataSourceGetAvailableSize) __INTRODUCED_IN(29); #endif /*__ANDROID_API__ >= 29 */ __END_DECLS Loading Loading
media/ndk/NdkMediaDataSource.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ struct AMediaDataSource { AMediaDataSourceReadAt readAt; AMediaDataSourceGetSize getSize; AMediaDataSourceClose close; AMediaDataSourceGetAvailableSize getAvailableSize; sp<DataSource> mImpl; uint32_t mFlags; }; Loading Loading @@ -107,6 +108,17 @@ void NdkDataSource::close() { } } status_t NdkDataSource::getAvailableSize(off64_t offset, off64_t *sizeptr) { off64_t size = -1; if (mDataSource->getAvailableSize != NULL && mDataSource->userdata != NULL && sizeptr != NULL) { size = mDataSource->getAvailableSize(mDataSource->userdata, offset); *sizeptr = size; } return size >= 0 ? OK : UNKNOWN_ERROR; } static sp<MediaHTTPService> createMediaHttpServiceFromJavaObj(JNIEnv *env, jobject obj, int version) { if (obj == NULL) { return NULL; Loading Loading @@ -251,5 +263,11 @@ void AMediaDataSource_close(AMediaDataSource *mSource) { return mSource->close(mSource->userdata); } EXPORT void AMediaDataSource_setGetAvailableSize(AMediaDataSource *mSource, AMediaDataSourceGetAvailableSize getAvailableSize) { mSource->getAvailableSize = getAvailableSize; } } // extern "C"
media/ndk/NdkMediaDataSourceCallbacks.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,11 @@ void DataSource_close(void *userdata) { source->close(); } ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset) { off64_t size = -1; DataSource *source = static_cast<DataSource *>(userdata); status_t err = source->getAvailableSize(offset, &size); return err == OK ? size : -1; } } // namespace android
media/ndk/NdkMediaDataSourceCallbacksPriv.h +3 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ ssize_t DataSource_readAt(void *userdata, off64_t offset, void * buf, size_t siz void DataSource_close(void *userdata); ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset); static inline AMediaDataSource* convertDataSourceToAMediaDataSource(const sp<DataSource> &source) { if (source == NULL) { return NULL; Loading @@ -40,6 +42,7 @@ static inline AMediaDataSource* convertDataSourceToAMediaDataSource(const sp<Dat AMediaDataSource_setReadAt(mSource, DataSource_readAt); AMediaDataSource_setGetSize(mSource, DataSource_getSize); AMediaDataSource_setClose(mSource, DataSource_close); AMediaDataSource_setGetAvailableSize(mSource, DataSource_getAvailableSize); return mSource; } Loading
media/ndk/NdkMediaDataSourcePriv.h +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ struct NdkDataSource : public DataSource { virtual String8 toString(); virtual String8 getMIMEType() const; virtual void close(); virtual status_t getAvailableSize(off64_t offset, off64_t *size); protected: virtual ~NdkDataSource(); Loading
media/ndk/include/media/NdkMediaDataSource.h +20 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,14 @@ AMediaDataSource* AMediaDataSource_new() __INTRODUCED_IN(28); #if __ANDROID_API__ >= 29 /** * Called to get an estimate of the number of bytes that can be read from this data source * starting at |offset| without blocking for I/O. * * Return -1 when such an estimate is not possible. */ typedef ssize_t (*AMediaDataSourceGetAvailableSize)(void *userdata, off64_t offset); /** * Create new media data source. Returns NULL if memory allocation * for the new data source object fails. Loading Loading @@ -176,6 +184,18 @@ void AMediaDataSource_setClose( */ void AMediaDataSource_close(AMediaDataSource*) __INTRODUCED_IN(29); /** * Set a custom callback for supplying the estimated number of bytes * that can be read from this data source starting at an offset without * blocking for I/O. * * Please refer to the definition of AMediaDataSourceGetAvailableSize * for additional details. */ void AMediaDataSource_setGetAvailableSize( AMediaDataSource*, AMediaDataSourceGetAvailableSize) __INTRODUCED_IN(29); #endif /*__ANDROID_API__ >= 29 */ __END_DECLS Loading