void VideoState::reqestVideoEnd() { if(!mRequestPerformed){ mRequestPerformed = true; onVideoEnd(); } }
void ofxOMXPlayerEngine::Process() { while (!m_bStop) { //struct timespec starttime, endtime; /*printf("V : %8.02f %8d %8d A : %8.02f %8.02f Cv : %8d Ca : %8d \r", clock.OMXMediaTime(), videoPlayer->GetDecoderBufferSize(), videoPlayer->GetDecoderFreeSpace(), audioPlayer->GetCurrentPTS() / DVD_TIME_BASE, audioPlayer->GetDelay(), videoPlayer->GetCached(), audioPlayer->GetCached());*/ if(omxReader.IsEof() && !packet) { //ofLogVerbose() << "Dumping Cache " << "Audio Cache: " << audioPlayer->GetCached() << " Video Cache: " << videoPlayer->GetCached(); bool isCacheEmpty = false; if (hasAudio) { if (!audioPlayer->GetCached() && !videoPlayer->GetCached()) { isCacheEmpty = true; } }else { if (!videoPlayer->GetCached()) { isCacheEmpty = true; } } if (isCacheEmpty) { /* The way this works is that loop_offset is a marker (actually the same as the DURATION) Once the file reader seeks to the beginning of the file again loop_offset is then added to subsequent packet's timestamps */ if (GlobalEGLContainer::getInstance().doLooping)//TODO: figure this out { ofLogVerbose(__func__) << "ABOUT TO ATTEMPT LOOP GlobalEGLContainer::getInstance().doLooping " << GlobalEGLContainer::getInstance().doLooping; omxReader.SeekTime(0 * 1000.0f, AVSEEK_FLAG_BACKWARD, &startpts); if(hasAudio) { loop_offset = audioPlayer->GetCurrentPTS(); ofLogVerbose() << "LOOP via audioPlayer [] [] [] [] [] [] [] []"; } else if(hasVideo) { loop_offset = videoPlayer->GetCurrentPTS(); ofLogVerbose() << "LOOP via videoPlayer [] [] [] [] [] [] [] []"; } loopCounter++; ofLog(OF_LOG_VERBOSE, "Loop offset : %8.02f\n", loop_offset / DVD_TIME_BASE); } else { onVideoEnd(); break; } } else { OMXClock::OMXSleep(10); continue; } } if (GlobalEGLContainer::getInstance().doLooping && OMXDecoderBase::fillBufferCounter>=getTotalNumFrames()) { OMXDecoderBase::fillBufferCounter=0; } if (hasAudio) { if(audioPlayer->Error()) { ofLogError(__func__) << "audio player error."; } } if(!packet) { packet = omxReader.Read(); if (packet && GlobalEGLContainer::getInstance().doLooping && packet->pts != DVD_NOPTS_VALUE) { packet->pts += loop_offset; packet->dts += loop_offset; } } if(hasVideo && packet && omxReader.IsActive(OMXSTREAM_VIDEO, packet->stream_index)) { if(videoPlayer->AddPacket(packet)) { packet = NULL; } else { OMXClock::OMXSleep(10); } } else if(hasAudio && packet && packet->codec_type == AVMEDIA_TYPE_AUDIO) { if(audioPlayer->AddPacket(packet)) { packet = NULL; } else { OMXClock::OMXSleep(10); } } else { if(packet) { omxReader.FreePacket(packet); packet = NULL; } } } }