- struct timeb now;
- ftime( &now );
- int64_t start = ( ( int64_t )now.time * 1000 + now.millitm );
-
- if ( mlt_properties_get_int( properties, "video_off" ) )
- {
- mlt_frame_close( frame );
- return 0;
- }
-
- if ( frame != NULL )
- {
- // Set playtime
- mlt_properties_set_position( mlt_frame_properties( frame ), "playtime", playtime );
- mlt_properties_set_double( mlt_frame_properties( frame ), "consumer_scale", ( double )height / mlt_properties_get_double( properties, "height" ) );
-
- // Push this frame to the back of the queue
- mlt_deque_push_back( this->queue, frame );
- }
-
- if ( this->playing )
- {
- // We might want to use an old frame if the current frame is skipped
- mlt_frame candidate = NULL;
- frame = NULL;
-
- while ( frame == NULL && mlt_deque_count( this->queue ) )
- {
- frame = mlt_deque_peek_front( this->queue );
- playtime = mlt_properties_get_position( mlt_frame_properties( frame ), "playtime" );
-
- // Check if frame is in the future or past
- if ( playtime > elapsed + 500 )
- {
- // Too far in the future - play it now
- frame = mlt_deque_pop_front( this->queue );
- }
- else if ( playtime > elapsed + 160 )
- {
- // Time to squeeze a few more frames in
- frame = candidate;
- candidate = NULL;
- error = 1;
- break;
- }
- else if ( playtime < elapsed )
- {
- if ( candidate != NULL )
- mlt_frame_close( candidate );
- candidate = mlt_deque_pop_front( this->queue );
- frame = NULL;
- }
- else
- {
- // Get the frame at the front of the queue
- frame = mlt_deque_pop_front( this->queue );
- }
- }
-
- if ( frame == NULL )
- frame = candidate;
- else if ( candidate != NULL )
- mlt_frame_close( candidate );
- }
- else
- {
- if ( frame != NULL )
- mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
- frame = NULL;
- }