Commit ca396307 authored by Thomas Guillem's avatar Thomas Guillem

wip

parent 8ffb52d0
......@@ -227,6 +227,11 @@ typedef struct
int i_next_block_flags;
bool b_recyling;
bool b_restart_decoders_on_reuse;
mtime_t first_dts;
mtime_t offset_dts;
mtime_t current_dts;
mtime_t last_dts;
} es_pair_t;
static bool es_pair_Add(vlc_array_t *p_array, const es_format_t *p_fmt,
......@@ -239,6 +244,12 @@ static bool es_pair_Add(vlc_array_t *p_array, const es_format_t *p_fmt,
p_pair->i_next_block_flags = 0;
p_pair->b_recyling = false;
p_pair->b_restart_decoders_on_reuse = true;
p_pair->first_dts = -1;
p_pair->offset_dts = VLC_TS_0;
p_pair->current_dts = 0;
p_pair->last_dts = 0;
if(vlc_array_append(p_array, p_pair) != VLC_SUCCESS)
{
free(p_pair);
......@@ -1139,6 +1150,8 @@ typedef struct
int i_audio_pid; /* Selected audio stream. -1 if default */
int i_spu_pid; /* Selected spu stream. -1 if default */
} selected;
mtime_t first_pcr;
mtime_t offset_pcr;
} bluray_esout_sys_t;
enum
......@@ -1264,11 +1277,40 @@ static int bluray_esOutSend(es_out_t *p_out, es_out_id_t *p_es, block_t *p_block
p_block->i_flags |= p_pair->i_next_block_flags;
p_pair->i_next_block_flags = 0;
}
if (p_pair->first_dts == -1)
{
p_pair->first_dts = p_block->i_dts;
if (p_pair->fmt.i_cat == VIDEO_ES)
p_block->i_flags |= BLOCK_FLAG_PREROLL;
else if (p_pair->last_dts != 0 && p_pair->current_dts != 0)
{
p_pair->first_dts += p_pair->current_dts - p_pair->last_dts;
block_Release(p_block);
p_pair->last_dts = p_pair->current_dts = 0;
vlc_mutex_unlock(&esout_sys->lock);
return VLC_SUCCESS;
}
p_pair->last_dts = p_pair->current_dts = 0;
}
mtime_t offset = p_pair->offset_dts - p_pair->first_dts;
p_block->i_pts += offset;
p_block->i_dts += offset;
p_pair->last_dts = p_pair->current_dts;
p_pair->current_dts = p_block->i_dts;
if (p_pair->fmt.i_cat == VIDEO_ES)
fprintf(stderr, "block: dts: %"PRId64 " fixed: %" PRId64 " offset: %"PRId64"\n",
p_block->i_dts - offset, p_block->i_dts, offset);
if(esout_sys->b_disable_output)
{
block_Release(p_block);
p_block = NULL;
}
vlc_mutex_unlock(&esout_sys->lock);
return (p_block) ? es_out_Send(esout_sys->p_dst_out, p_es, p_block) : VLC_SUCCESS;
}
......@@ -1380,7 +1422,32 @@ static int bluray_esOutControl(es_out_t *p_out, int i_query, va_list args)
*va_arg(args, bool *) = true;
i_ret = VLC_SUCCESS;
break;
case ES_OUT_SET_PCR:
{
mtime_t i_pcr = va_arg( args, int64_t );
fprintf(stderr, "ES_OUT_SET_PCR: %" PRId64 "\n", i_pcr);
i_ret = es_out_Control(esout_sys->p_dst_out, i_query, i_pcr);
break;
}
case ES_OUT_SET_GROUP_PCR:
{
int group = va_arg( args, int );
mtime_t i_pcr = va_arg( args, int64_t );
if (esout_sys->first_pcr == -1)
esout_sys->first_pcr = i_pcr;
mtime_t offset = esout_sys->offset_pcr - esout_sys->first_pcr;
i_pcr += offset;
fprintf(stderr, "ES_OUT_SET_GROUP_PCR: %" PRId64 " fixed: %"PRId64" offset: %" PRId64"\n",
i_pcr - offset, i_pcr, offset);
i_ret = es_out_Control(esout_sys->p_dst_out, i_query, group, i_pcr);
break;
}
default:
i_ret = es_out_vaControl(esout_sys->p_dst_out, i_query, args);
break;
......@@ -1431,6 +1498,8 @@ static es_out_t *esOutNew(vlc_object_t *p_obj, es_out_t *p_dst_out, void *priv)
esout_sys->b_lowdelay = false;
esout_sys->selected.i_audio_pid = -1;
esout_sys->selected.i_spu_pid = -1;
esout_sys->first_pcr = -1;
esout_sys->offset_pcr = VLC_TS_0;
vlc_mutex_init(&esout_sys->lock);
return p_out;
}
......@@ -2741,7 +2810,7 @@ static void blurayHandleEvent(demux_t *p_demux, const BD_EVENT *e, bool b_delaye
than break the clock by throwing post random access PCR */
blurayRestartParser(p_demux, true, true);
notifyDiscontinuityToParser(p_sys);
es_out_Control(p_sys->p_out, ES_OUT_RESET_PCR);
//es_out_Control(p_sys->p_out, ES_OUT_RESET_PCR);
break;
#if BLURAY_VERSION >= BLURAY_VERSION_CODE(0,8,1)
case BD_EVENT_UO_MASK_CHANGED:
......@@ -2916,6 +2985,33 @@ static int blurayDemux(demux_t *p_demux)
demux_sys_t *p_sys = p_demux->p_sys;
BD_EVENT e;
if(p_sys->b_draining)
{
bluray_esout_sys_t *esout_sys = (bluray_esout_sys_t *)p_sys->p_out->p_sys;
mtime_t min_offset_dts = INT64_MAX;
for (size_t i = 0; i < vlc_array_count(&esout_sys->es); ++i)
{
es_pair_t *p_pair = vlc_array_item_at_index(&esout_sys->es, i);
p_pair->offset_dts = p_pair->current_dts + VLC_TS_0;
if (p_pair->last_dts > 0)
p_pair->offset_dts += p_pair->current_dts - p_pair->last_dts;
if (i <= 1 /* XXX last track invalid ? */
&& (p_pair->fmt.i_cat == VIDEO_ES || p_pair->fmt.i_cat == AUDIO_ES))
{
if (min_offset_dts > p_pair->offset_dts)
min_offset_dts = p_pair->offset_dts;
}
p_pair->first_dts = -1;
}
esout_sys->offset_pcr = min_offset_dts;
fprintf(stderr, "draining: offset_pcr = %" PRId64 "\n", esout_sys->offset_pcr);
p_sys->b_draining = false;
}
#if 0
if(p_sys->b_draining)
{
bool b_empty = false;
......@@ -2931,6 +3027,7 @@ static int blurayDemux(demux_t *p_demux)
return VLC_DEMUXER_SUCCESS;
}
}
#endif
block_t *p_block = block_Alloc(BD_READ_SIZE);
if (!p_block)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment