bool LiveSource::switchToNext() { mSignalDiscontinuity = false; mOffsetBias += mSourceSize; mSourceSize = 0; if (mLastFetchTimeUs < 0 || getNowUs() >= mLastFetchTimeUs + 15000000ll || mPlaylistIndex == mPlaylist->size()) { int32_t nextSequenceNumber = mPlaylistIndex + mFirstItemSequenceNumber; if (!loadPlaylist(mLastFetchTimeUs < 0)) { LOGE("failed to reload playlist"); return false; } if (mLastFetchTimeUs < 0) { mPlaylistIndex = 0; } else { if (nextSequenceNumber < mFirstItemSequenceNumber || nextSequenceNumber >= mFirstItemSequenceNumber + (int32_t)mPlaylist->size()) { LOGE("Cannot find sequence number %d in new playlist", nextSequenceNumber); return false; } mPlaylistIndex = nextSequenceNumber - mFirstItemSequenceNumber; } mLastFetchTimeUs = getNowUs(); } AString uri; sp<AMessage> itemMeta; CHECK(mPlaylist->itemAt(mPlaylistIndex, &uri, &itemMeta)); LOGV("switching to %s", uri.c_str()); if (mSource->connect(uri.c_str()) != OK || mSource->getSize(&mSourceSize) != OK) { return false; } int32_t val; if (itemMeta->findInt32("discontinuity", &val) && val != 0) { mSignalDiscontinuity = true; } mPlaylistIndex++; return true; }
int testDecodePixels(SkImageDecoder* decoder, SkStream* stream, SkBitmap* bitmap) { int64_t startTime = getNowUs(); SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config; SkImageDecoder::Mode decodeMode = SkImageDecoder::kDecodePixels_Mode; // Decode the input stream and then use the bitmap. if (!decoder->decode(stream, bitmap, prefConfig, decodeMode)) { return nullObjectReturn("decoder->decode returned false"); } else { int64_t delay = getNowUs() - startTime; printf("Decoding Time in PixelsMode %.1f msec.\n", delay / 1000.0f); const char* filename = "/sdcard/omxJpegDecodedBitmap.rgba"; return storeBitmapToFile(bitmap, filename); } }
int testDecodeBounds(SkImageDecoder* decoder, SkStream* stream, SkBitmap* bitmap) { int64_t startTime = getNowUs(); SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config; SkImageDecoder::Mode decodeMode = SkImageDecoder::kDecodeBounds_Mode; // Decode the input stream and then use the bitmap. if (!decoder->decode(stream, bitmap, prefConfig, decodeMode)) { return nullObjectReturn("decoder->decode returned false"); } else { int64_t delay = getNowUs() - startTime; printf("WidthxHeight: %dx%d\n", bitmap->width(), bitmap->height()); printf("Decoding Time in BoundsMode %.1f msec.\n", delay / 1000.0f); return 0; } }
status_t Harness::dequeueMessageForNodeIgnoringBuffers( IOMX::node_id node, Vector<Buffer> *inputBuffers, Vector<Buffer> *outputBuffers, omx_message *msg, int64_t timeoutUs) { int64_t finishBy = getNowUs() + timeoutUs; for (;;) { Mutex::Autolock autoLock(mLock); List<omx_message>::iterator it = mMessageQueue.begin(); while (it != mMessageQueue.end()) { if ((*it).node == node) { if (handleBufferMessage(*it, inputBuffers, outputBuffers)) { it = mMessageQueue.erase(it); continue; } *msg = *it; mMessageQueue.erase(it); return OK; } ++it; } status_t err = (timeoutUs < 0) ? mMessageAddedCondition.wait(mLock) : mMessageAddedCondition.waitRelative( mLock, (finishBy - getNowUs()) * 1000); if (err == TIMED_OUT) { return err; } CHECK_EQ(err, OK); } }