static gboolean gst_kate_tiger_seek (GstKateTiger * tiger, GstPad * pad, GstEvent * event) { GstFormat format; gdouble rate; GstSeekFlags flags; GstSeekType cur_type, stop_type; gint64 cur, stop; gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, &stop_type, &stop); /* forward to both sinks */ gst_event_ref (event); if (gst_pad_push_event (tiger->videosinkpad, event)) { if (gst_pad_push_event (tiger->katesinkpad, event)) { if (format == GST_FORMAT_TIME) { /* if seeking in time, we can update tiger to remove any appropriate events */ kate_float target = cur / (gdouble) GST_SECOND; GST_INFO_OBJECT (tiger, "Seeking in time to %f", target); g_mutex_lock (tiger->mutex); tiger_renderer_seek (tiger->tr, target); g_mutex_unlock (tiger->mutex); } return TRUE; } else { return FALSE; } } else { gst_event_unref (event); return FALSE; } }
/**************************************************************************** * DecodeBlock: the whole thing **************************************************************************** * This function must be fed with kate packets. ****************************************************************************/ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; block_t *p_block; kate_packet kp; if( !pp_block || !*pp_block ) return NULL; p_block = *pp_block; if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) { #ifdef HAVE_TIGER if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY) { /* Hmm, should we wait before flushing the renderer ? I think not, but not certain... */ vlc_mutex_lock( &p_sys->lock ); tiger_renderer_seek( p_sys->p_tr, 0 ); vlc_mutex_unlock( &p_sys->lock ); } #endif p_sys->i_max_stop = VLC_TS_INVALID; block_Release( p_block ); return NULL; } /* Block to Kate packet */ kate_packet_wrap(&kp, p_block->i_buffer, p_block->p_buffer); if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra ) { /* Headers already available as extra data */ p_sys->i_num_headers = ((unsigned char*)p_dec->fmt_in.p_extra)[0]; p_sys->i_headers = p_sys->i_num_headers; } else if( kp.nbytes && (p_sys->i_headers==0 || p_sys->i_headers < p_sys->ki.num_headers )) { /* Backup headers as extra data */ uint8_t *p_extra; p_dec->fmt_in.p_extra = realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra + kp.nbytes + 2 ); p_extra = (void*)(((unsigned char*)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra); *(p_extra++) = kp.nbytes >> 8; *(p_extra++) = kp.nbytes & 0xFF; memcpy( p_extra, kp.data, kp.nbytes ); p_dec->fmt_in.i_extra += kp.nbytes + 2; block_Release( *pp_block ); p_sys->i_num_headers = ((unsigned char*)p_dec->fmt_in.p_extra)[0]; p_sys->i_headers++; return NULL; }
/***************************************************************************** * Flush: *****************************************************************************/ static void Flush( decoder_t *p_dec ) { decoder_sys_t *p_sys = p_dec->p_sys; #ifdef HAVE_TIGER /* Hmm, should we wait before flushing the renderer ? I think not, but not certain... */ vlc_mutex_lock( &p_sys->lock ); tiger_renderer_seek( p_sys->p_tr, 0 ); vlc_mutex_unlock( &p_sys->lock ); #endif p_sys->i_max_stop = VLC_TS_INVALID; }
/**************************************************************************** * DecodeBlock: the whole thing **************************************************************************** * This function must be fed with kate packets. ****************************************************************************/ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; block_t *p_block; kate_packet kp; if( !pp_block || !*pp_block ) return NULL; p_block = *pp_block; *pp_block = NULL; if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) { #ifdef HAVE_TIGER if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY) { /* Hmm, should we wait before flushing the renderer ? I think not, but not certain... */ vlc_mutex_lock( &p_sys->lock ); tiger_renderer_seek( p_sys->p_tr, 0 ); vlc_mutex_unlock( &p_sys->lock ); } #endif if( p_block->i_flags & BLOCK_FLAG_CORRUPTED ) { p_sys->i_max_stop = VLC_TS_INVALID; block_Release( p_block ); return NULL; } } /* Block to Kate packet */ kate_packet_wrap(&kp, p_block->i_buffer, p_block->p_buffer); if( !p_sys->b_has_headers ) { if( ProcessHeaders( p_dec ) ) { block_Release( *pp_block ); return NULL; } p_sys->b_has_headers = true; } return ProcessPacket( p_dec, &kp, pp_block ); }