diff options
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/ACodec.cpp | 22 | ||||
-rw-r--r-- | media/libstagefright/avc_utils.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveDataSource.cpp | 31 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveDataSource.h | 3 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 15 | ||||
-rw-r--r-- | media/libstagefright/include/LiveSession.h | 2 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 29 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.h | 6 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ESQueue.cpp | 8 |
10 files changed, 99 insertions, 29 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 3bb61f2..39e0c51 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -1082,7 +1082,7 @@ bool ACodec::BaseState::onOMXMessage(const sp<AMessage> &msg) { bool ACodec::BaseState::onOMXEvent( OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { if (event != OMX_EventError) { - LOGI("[%s] EVENT(%d, 0x%08lx, 0x%08lx)", + LOGV("[%s] EVENT(%d, 0x%08lx, 0x%08lx)", mCodec->mComponentName.c_str(), event, data1, data2); return false; @@ -1520,7 +1520,7 @@ ACodec::LoadedToIdleState::LoadedToIdleState(ACodec *codec) } void ACodec::LoadedToIdleState::stateEntered() { - LOGI("[%s] Now Loaded->Idle", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Loaded->Idle", mCodec->mComponentName.c_str()); CHECK_EQ(allocateBuffers(), (status_t)OK); } @@ -1577,7 +1577,7 @@ ACodec::IdleToExecutingState::IdleToExecutingState(ACodec *codec) } void ACodec::IdleToExecutingState::stateEntered() { - LOGI("[%s] Now Idle->Executing", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Idle->Executing", mCodec->mComponentName.c_str()); } bool ACodec::IdleToExecutingState::onMessageReceived(const sp<AMessage> &msg) { @@ -1661,7 +1661,7 @@ void ACodec::ExecutingState::resume() { } void ACodec::ExecutingState::stateEntered() { - LOGI("[%s] Now Executing", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Executing", mCodec->mComponentName.c_str()); mCodec->processDeferredMessages(); } @@ -1787,7 +1787,7 @@ bool ACodec::OutputPortSettingsChangedState::onMessageReceived( } void ACodec::OutputPortSettingsChangedState::stateEntered() { - LOGI("[%s] Now handling output port settings change", + LOGV("[%s] Now handling output port settings change", mCodec->mComponentName.c_str()); } @@ -1868,7 +1868,7 @@ bool ACodec::ExecutingToIdleState::onMessageReceived(const sp<AMessage> &msg) { } void ACodec::ExecutingToIdleState::stateEntered() { - LOGI("[%s] Now Executing->Idle", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Executing->Idle", mCodec->mComponentName.c_str()); } bool ACodec::ExecutingToIdleState::onOMXEvent( @@ -1950,7 +1950,7 @@ bool ACodec::IdleToLoadedState::onMessageReceived(const sp<AMessage> &msg) { } void ACodec::IdleToLoadedState::stateEntered() { - LOGI("[%s] Now Idle->Loaded", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Idle->Loaded", mCodec->mComponentName.c_str()); } bool ACodec::IdleToLoadedState::onOMXEvent( @@ -1961,7 +1961,7 @@ bool ACodec::IdleToLoadedState::onOMXEvent( CHECK_EQ(data1, (OMX_U32)OMX_CommandStateSet); CHECK_EQ(data2, (OMX_U32)OMX_StateLoaded); - LOGI("[%s] Now Loaded", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Loaded", mCodec->mComponentName.c_str()); CHECK_EQ(mCodec->mOMX->freeNode(mCodec->mNode), (status_t)OK); @@ -1995,12 +1995,12 @@ bool ACodec::ErrorState::onMessageReceived(const sp<AMessage> &msg) { } void ACodec::ErrorState::stateEntered() { - LOGI("[%s] Now in ErrorState", mCodec->mComponentName.c_str()); + LOGV("[%s] Now in ErrorState", mCodec->mComponentName.c_str()); } bool ACodec::ErrorState::onOMXEvent( OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { - LOGI("EVENT(%d, 0x%08lx, 0x%08lx)", event, data1, data2); + LOGV("EVENT(%d, 0x%08lx, 0x%08lx)", event, data1, data2); return true; } @@ -2011,7 +2011,7 @@ ACodec::FlushingState::FlushingState(ACodec *codec) } void ACodec::FlushingState::stateEntered() { - LOGI("[%s] Now Flushing", mCodec->mComponentName.c_str()); + LOGV("[%s] Now Flushing", mCodec->mComponentName.c_str()); mFlushComplete[kPortIndexInput] = mFlushComplete[kPortIndexOutput] = false; } diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index 2fe5e18..fa12cf0 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "avc_utils" +#include <utils/Log.h> + #include "include/avc_utils.h" #include <media/stagefright/foundation/ABitReader.h> diff --git a/media/libstagefright/httplive/LiveDataSource.cpp b/media/libstagefright/httplive/LiveDataSource.cpp index 25e2902..5f5c6d4 100644 --- a/media/libstagefright/httplive/LiveDataSource.cpp +++ b/media/libstagefright/httplive/LiveDataSource.cpp @@ -54,9 +54,40 @@ size_t LiveDataSource::countQueuedBuffers() { return mBufferQueue.size(); } +ssize_t LiveDataSource::readAtNonBlocking( + off64_t offset, void *data, size_t size) { + Mutex::Autolock autoLock(mLock); + + if (offset != mOffset) { + LOGE("Attempt at reading non-sequentially from LiveDataSource."); + return -EPIPE; + } + + size_t totalAvailable = 0; + for (List<sp<ABuffer> >::iterator it = mBufferQueue.begin(); + it != mBufferQueue.end(); ++it) { + sp<ABuffer> buffer = *it; + + totalAvailable += buffer->size(); + + if (totalAvailable >= size) { + break; + } + } + + if (totalAvailable < size) { + return mFinalResult == OK ? -EWOULDBLOCK : mFinalResult; + } + + return readAt_l(offset, data, size); +} + ssize_t LiveDataSource::readAt(off64_t offset, void *data, size_t size) { Mutex::Autolock autoLock(mLock); + return readAt_l(offset, data, size); +} +ssize_t LiveDataSource::readAt_l(off64_t offset, void *data, size_t size) { if (offset != mOffset) { LOGE("Attempt at reading non-sequentially from LiveDataSource."); return -EPIPE; diff --git a/media/libstagefright/httplive/LiveDataSource.h b/media/libstagefright/httplive/LiveDataSource.h index a489ec6..b7be637 100644 --- a/media/libstagefright/httplive/LiveDataSource.h +++ b/media/libstagefright/httplive/LiveDataSource.h @@ -33,6 +33,7 @@ struct LiveDataSource : public DataSource { virtual status_t initCheck() const; virtual ssize_t readAt(off64_t offset, void *data, size_t size); + ssize_t readAtNonBlocking(off64_t offset, void *data, size_t size); void queueBuffer(const sp<ABuffer> &buffer); void queueEOS(status_t finalResult); @@ -53,6 +54,8 @@ private: FILE *mBackupFile; + ssize_t readAt_l(off64_t offset, void *data, size_t size); + DISALLOW_EVIL_CONSTRUCTORS(LiveDataSource); }; diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 5c4c5df..5b1f14d 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -157,9 +157,16 @@ void LiveSession::onConnect(const sp<AMessage> &msg) { mBandwidthItems.sort(SortByBandwidth); - if (mBandwidthItems.size() > 1) { - // XXX Remove the lowest bitrate stream for now... - mBandwidthItems.removeAt(0); + char value[PROPERTY_VALUE_MAX]; + if (!property_get("media.httplive.enable-nuplayer", value, NULL) + || (strcasecmp(value, "true") && strcmp(value, "1"))) { + // The "legacy" player cannot deal with audio format changes, + // some streams use different audio encoding parameters for + // their lowest bandwidth stream. + if (mBandwidthItems.size() > 1) { + // XXX Remove the lowest bitrate stream for now... + mBandwidthItems.removeAt(0); + } } } @@ -421,7 +428,7 @@ void LiveSession::onDownloadNext() { ++mNumRetries; mLastPlaylistFetchTimeUs = -1; - postMonitorQueue(1000000ll); + postMonitorQueue(3000000ll); return; } diff --git a/media/libstagefright/include/LiveSession.h b/media/libstagefright/include/LiveSession.h index 50c0a99..3873d5d 100644 --- a/media/libstagefright/include/LiveSession.h +++ b/media/libstagefright/include/LiveSession.h @@ -50,7 +50,7 @@ protected: private: enum { kMaxNumQueuedFragments = 2, - kMaxNumRetries = 3, + kMaxNumRetries = 5, }; static const int64_t kMaxPlaylistAgeUs; diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp index ee9b573..7c81ffd 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -334,7 +334,7 @@ void ATSParser::Stream::signalDiscontinuity(DiscontinuityType type) { if (mStreamType == 0x1b && mSource != NULL) { // Don't signal discontinuities on audio streams. - mSource->queueDiscontinuity(true /* formatChange */); + mSource->queueDiscontinuity(type); } break; } @@ -348,7 +348,7 @@ void ATSParser::Stream::signalDiscontinuity(DiscontinuityType type) { if (mSource != NULL) { mSource->clear(); - mSource->queueDiscontinuity(!isASeek); + mSource->queueDiscontinuity(type); } break; } @@ -561,6 +561,10 @@ void ATSParser::Stream::onPayloadData( // After a discontinuity we invalidate the queue's format // and won't enqueue any access units to the source until // the queue has reestablished the new format. + + if (mSource->getFormat() == NULL) { + mSource->setFormat(mQueue.getFormat()); + } mSource->queueAccessUnit(accessUnit); } } diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index a8fe2c1..c6edf0a 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -33,6 +33,11 @@ AnotherPacketSource::AnotherPacketSource(const sp<MetaData> &meta) mEOSResult(OK) { } +void AnotherPacketSource::setFormat(const sp<MetaData> &meta) { + CHECK(mFormat == NULL); + mFormat = meta; +} + AnotherPacketSource::~AnotherPacketSource() { } @@ -61,8 +66,12 @@ status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) { mBuffers.erase(mBuffers.begin()); int32_t discontinuity; - if ((*buffer)->meta()->findInt32("discontinuity", &discontinuity) - && discontinuity) { + if ((*buffer)->meta()->findInt32("discontinuity", &discontinuity)) { + + if (discontinuity == ATSParser::DISCONTINUITY_FORMATCHANGE) { + mFormat.clear(); + } + return INFO_DISCONTINUITY; } @@ -86,8 +95,11 @@ status_t AnotherPacketSource::read( mBuffers.erase(mBuffers.begin()); int32_t discontinuity; - if (buffer->meta()->findInt32("discontinuity", &discontinuity) - && discontinuity) { + if (buffer->meta()->findInt32("discontinuity", &discontinuity)) { + if (discontinuity == ATSParser::DISCONTINUITY_FORMATCHANGE) { + mFormat.clear(); + } + return INFO_DISCONTINUITY; } else { int64_t timeUs; @@ -123,13 +135,10 @@ void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { mCondition.signal(); } -void AnotherPacketSource::queueDiscontinuity(bool formatChange) { +void AnotherPacketSource::queueDiscontinuity( + ATSParser::DiscontinuityType type) { sp<ABuffer> buffer = new ABuffer(0); - buffer->meta()->setInt32("discontinuity", true); - - if (formatChange) { - buffer->meta()->setInt32("format-change", true); - } + buffer->meta()->setInt32("discontinuity", static_cast<int32_t>(type)); Mutex::Autolock autoLock(mLock); diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h index f25a067..c20fca3 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h @@ -23,6 +23,8 @@ #include <utils/threads.h> #include <utils/List.h> +#include "ATSParser.h" + namespace android { struct ABuffer; @@ -30,6 +32,8 @@ struct ABuffer; struct AnotherPacketSource : public MediaSource { AnotherPacketSource(const sp<MetaData> &meta); + void setFormat(const sp<MetaData> &meta); + virtual status_t start(MetaData *params = NULL); virtual status_t stop(); virtual sp<MetaData> getFormat(); @@ -42,7 +46,7 @@ struct AnotherPacketSource : public MediaSource { status_t nextBufferTime(int64_t *timeUs); void queueAccessUnit(const sp<ABuffer> &buffer); - void queueDiscontinuity(bool formatChange); + void queueDiscontinuity(ATSParser::DiscontinuityType type); void signalEOS(status_t result); void clear(); diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp index 4e7759d..73efdfe 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.cpp +++ b/media/libstagefright/mpeg2ts/ESQueue.cpp @@ -225,6 +225,14 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitAAC() { mFormat = MakeAACCodecSpecificData( profile, sampling_freq_index, channel_configuration); + + int32_t sampleRate; + int32_t numChannels; + CHECK(mFormat->findInt32(kKeySampleRate, &sampleRate)); + CHECK(mFormat->findInt32(kKeyChannelCount, &numChannels)); + + LOGI("found AAC codec config (%d Hz, %d channels)", + sampleRate, numChannels); } else { // profile_ObjectType, sampling_frequency_index, private_bits, // channel_configuration, original_copy, home |