diff options
author | James Dong <jdong@google.com> | 2012-04-13 13:02:57 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-04-13 13:08:57 -0700 |
commit | 613c8ae1b7a2b4f43b33a72dc2fff0bc8b7d4c6f (patch) | |
tree | e301e98ae7b69f611ce9d3a9d0ab57c556ecb8cc /media | |
parent | d2469c3fe382203eb7cd5060c94ed204bec98116 (diff) | |
download | frameworks_av-613c8ae1b7a2b4f43b33a72dc2fff0bc8b7d4c6f.zip frameworks_av-613c8ae1b7a2b4f43b33a72dc2fff0bc8b7d4c6f.tar.gz frameworks_av-613c8ae1b7a2b4f43b33a72dc2fff0bc8b7d4c6f.tar.bz2 |
Add external timed text source using a passed file descriptor
o Also fixed a minor issue where the file length should be of type off64_t rather than size_t
o related-to-bug: 5542712
Change-Id: I35fd8ceea0bc75e553b7f4a99932cf58ea560c4e
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 2 | ||||
-rw-r--r-- | media/libstagefright/timedtext/TimedTextDriver.cpp | 31 |
2 files changed, 22 insertions, 11 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index f96a4df..120a410 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -2292,7 +2292,7 @@ status_t AwesomePlayer::invoke(const Parcel &request, Parcel *reply) { } int fd = request.readFileDescriptor(); off64_t offset = request.readInt64(); - size_t length = request.readInt64(); + off64_t length = request.readInt64(); String8 mimeType(request.readString16()); return mTextDriver->addOutOfBandTextSource( fd, offset, length, mimeType); diff --git a/media/libstagefright/timedtext/TimedTextDriver.cpp b/media/libstagefright/timedtext/TimedTextDriver.cpp index 8ee15f8..7aad11b 100644 --- a/media/libstagefright/timedtext/TimedTextDriver.cpp +++ b/media/libstagefright/timedtext/TimedTextDriver.cpp @@ -23,6 +23,7 @@ #include <media/mediaplayer.h> #include <media/MediaPlayerInterface.h> #include <media/stagefright/DataSource.h> +#include <media/stagefright/FileSource.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MediaSource.h> @@ -161,15 +162,32 @@ status_t TimedTextDriver::addInBandTextSource( status_t TimedTextDriver::addOutOfBandTextSource( const char *uri, const char *mimeType) { - // TODO: Define "TimedTextSource::CreateFromURI(uri)" - // and move below lines there..? - // To support local subtitle file only for now if (strncasecmp("file://", uri, 7)) { + ALOGE("uri('%s') is not a file", uri); return ERROR_UNSUPPORTED; } + sp<DataSource> dataSource = DataSource::CreateFromURI(uri); + return createOutOfBandTextSource(mimeType, dataSource); +} + +status_t TimedTextDriver::addOutOfBandTextSource( + int fd, off64_t offset, off64_t length, const char *mimeType) { + + if (fd < 0) { + ALOGE("Invalid file descriptor: %d", fd); + return ERROR_UNSUPPORTED; + } + + sp<DataSource> dataSource = new FileSource(dup(fd), offset, length); + return createOutOfBandTextSource(mimeType, dataSource); +} + +status_t TimedTextDriver::createOutOfBandTextSource( + const char *mimeType, const sp<DataSource>& dataSource) { + if (dataSource == NULL) { return ERROR_UNSUPPORTED; } @@ -189,13 +207,6 @@ status_t TimedTextDriver::addOutOfBandTextSource( return OK; } -status_t TimedTextDriver::addOutOfBandTextSource( - int fd, off64_t offset, size_t length, const char *mimeType) { - // Not supported yet. This requires DataSource::sniff to detect various text - // formats such as srt/smi/ttml. - return ERROR_UNSUPPORTED; -} - void TimedTextDriver::getTrackInfo(Parcel *parcel) { Mutex::Autolock autoLock(mLock); Vector<sp<TimedTextSource> >::const_iterator iter; |