diff options
author | Chris Watkins <watk@google.com> | 2015-03-20 13:06:33 -0700 |
---|---|---|
committer | Chris Watkins <watk@google.com> | 2015-04-15 17:12:22 -0700 |
commit | 99f31604136d66ae10e20669fb6b5716f342bde0 (patch) | |
tree | 20e64f4f26533b37b087ce8656b1040b8189e24f /media/libmedia/mediaplayer.cpp | |
parent | 2f33dbc6ca08d45efea2df775c158e2a11e07ab6 (diff) | |
download | frameworks_av-99f31604136d66ae10e20669fb6b5716f342bde0.zip frameworks_av-99f31604136d66ae10e20669fb6b5716f342bde0.tar.gz frameworks_av-99f31604136d66ae10e20669fb6b5716f342bde0.tar.bz2 |
Unhide the android.media.[Media]DataSource interface.
This allows apps to implement MediaDataSource, which is modeled on
stagefright's DataSource, to supply media data to the framework. This
was already implemented for MediaExtractor, but it was renamed from
DataSource.
MediaExtractor, MediaPlayer and MediaMetadataRetriever each have a new
overload: #setDataSource(android.media.MediaDataSource)
Only NuPlayer supports this new data source.
The change introduces:
* IDataSource: The binder interface for DataSource.
* JMediaDataSource: The native counterpart to the java interface. It
implements IDataSource.
* CallbackDataSource: A stagefright DataSource that wraps an
IDataSource.
Change-Id: Ib3c944b49cc8a792c8eb9c85e5015c07f298ebc1
Diffstat (limited to 'media/libmedia/mediaplayer.cpp')
-rw-r--r-- | media/libmedia/mediaplayer.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp index 5dd8c02..6eddcb6 100644 --- a/media/libmedia/mediaplayer.cpp +++ b/media/libmedia/mediaplayer.cpp @@ -33,6 +33,7 @@ #include <media/mediaplayer.h> #include <media/AudioSystem.h> +#include <media/IDataSource.h> #include <binder/MemoryBase.h> @@ -195,6 +196,22 @@ status_t MediaPlayer::setDataSource(const sp<IStreamSource> &source) return err; } +status_t MediaPlayer::setDataSource(const sp<IDataSource> &source) +{ + ALOGV("setDataSource(IDataSource)"); + status_t err = UNKNOWN_ERROR; + const sp<IMediaPlayerService>& service(getMediaPlayerService()); + if (service != 0) { + sp<IMediaPlayer> player(service->create(this, mAudioSessionId)); + if ((NO_ERROR != doSetRetransmitEndpoint(player)) || + (NO_ERROR != player->setDataSource(source))) { + player.clear(); + } + err = attachNewPlayer(player); + } + return err; +} + status_t MediaPlayer::invoke(const Parcel& request, Parcel *reply) { Mutex::Autolock _l(mLock); |