bool LiveSource::seekTo(int64_t seekTimeUs) { LOGV("seek to %lld us", seekTimeUs); if (!mPlaylist->isComplete()) { return false; } int32_t targetDuration; if (!mPlaylist->meta()->findInt32("target-duration", &targetDuration)) { return false; } int64_t seekTimeSecs = (seekTimeUs + 500000ll) / 1000000ll; int64_t index = seekTimeSecs / targetDuration; if (index < 0 || index >= mPlaylist->size()) { return false; } size_t newPlaylistIndex = mFirstItemSequenceNumber + index; if (newPlaylistIndex == mPlaylistIndex) { return false; } mPlaylistIndex = newPlaylistIndex; switchToNext(); mOffsetBias = 0; LOGV("seeking to index %lld", index); return true; }
void ScreenManager::push(Screen *screen, int layerFlags) { if (nextScreen_ && stack_.empty()) { // we're during init, this is OK switchToNext(); } screen->setScreenManager(this); Layer layer = {screen, layerFlags}; stack_.push_back(layer); }
void ScreenManager::update(InputState &input) { if (nextScreen_) { switchToNext(); } if (stack_.size()) { stack_.back().screen->update(input); } }
void ScreenManager::update(InputState &input) { if (nextScreen_) { ILOG("Screen switch! Top of the stack switches."); switchToNext(); } if (stack_.size()) { stack_.back().screen->update(input); } }
void ScreenManager::update() { std::lock_guard<std::recursive_mutex> guard(inputLock_); if (nextScreen_) { switchToNext(); } if (stack_.size()) { stack_.back().screen->update(); } }
void ScreenManager::push(Screen *screen, int layerFlags) { if (nextScreen_ && stack_.empty()) { // we're during init, this is OK switchToNext(); } screen->setScreenManager(this); if (screen->isTransparent()) { layerFlags |= LAYER_TRANSPARENT; } Layer layer = {screen, layerFlags}; stack_.push_back(layer); }
void ScreenManager::push(Screen *screen, int layerFlags) { std::lock_guard<std::mutex> guard(inputLock_); if (nextScreen_ && stack_.empty()) { // we're during init, this is OK switchToNext(); } screen->setScreenManager(this); if (screen->isTransparent()) { layerFlags |= LAYER_TRANSPARENT; } UI::SetFocusedView(0); Layer layer = {screen, layerFlags}; stack_.push_back(layer); }
LiveSource::LiveSource(const char *url) : mMasterURL(url), mInitCheck(NO_INIT), mDurationUs(-1), mPlaylistIndex(0), mLastFetchTimeUs(-1), mSource(new NuHTTPDataSource), mSourceSize(0), mOffsetBias(0), mSignalDiscontinuity(false), mPrevBandwidthIndex(-1) { if (switchToNext()) { mInitCheck = OK; determineSeekability(); } }
ssize_t LiveSource::readAt(off64_t offset, void *data, size_t size) { CHECK(offset >= mOffsetBias); offset -= mOffsetBias; off64_t delta = mSignalDiscontinuity ? kHeaderSize : 0; if (offset >= mSourceSize + delta) { CHECK_EQ(offset, mSourceSize + delta); offset -= mSourceSize + delta; if (!switchToNext()) { return ERROR_END_OF_STREAM; } if (mSignalDiscontinuity) { LOGV("switchToNext changed streams"); } else { LOGV("switchToNext stayed within the same stream"); } mOffsetBias += delta; delta = mSignalDiscontinuity ? kHeaderSize : 0; } if (offset < delta) { size_t avail = delta - offset; memset(data, 0, avail); return avail; } size_t numRead = 0; while (numRead < size) { ssize_t n = mSource->readAt( offset + numRead - delta, (uint8_t *)data + numRead, size - numRead); if (n <= 0) { break; } numRead += n; } return numRead; }