Commit 6695dc84 authored by Thomas Guillem's avatar Thomas Guillem

wip

parent 8ffb52d0
......@@ -1139,6 +1139,10 @@ 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;
mtime_t current_pcr;
mtime_t last_pcr;
} bluray_esout_sys_t;
enum
......@@ -1264,11 +1268,23 @@ 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;
}
mtime_t offset = 0;
if (esout_sys->first_pcr != -1)
offset = esout_sys->offset_pcr - esout_sys->first_pcr;
p_block->i_pts += offset;
p_block->i_dts += offset;
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 +1396,34 @@ 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 );
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 );
mtime_t original = i_pcr;
if (esout_sys->first_pcr == -1)
esout_sys->first_pcr = i_pcr;
i_pcr += esout_sys->offset_pcr - esout_sys->first_pcr;
esout_sys->last_pcr = esout_sys->current_pcr;
esout_sys->current_pcr = i_pcr;
fprintf(stderr, "ES_OUT_SET_GROUP_PCR: %" PRId64 " fixed: %"PRId64" offset: %" PRId64"\n",
original, i_pcr, esout_sys->offset_pcr);
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 +1474,10 @@ 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 = 0;
esout_sys->current_pcr = 0;
esout_sys->last_pcr = 0;
vlc_mutex_init(&esout_sys->lock);
return p_out;
}
......@@ -2741,7 +2788,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 +2963,21 @@ 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;
if (esout_sys->first_pcr != -1)
{
esout_sys->offset_pcr = esout_sys->current_pcr;
//if (esout_sys->last_pcr > 0)
// esout_sys->offset_pcr += esout_sys->current_pcr - esout_sys->last_pcr;
esout_sys->last_pcr = esout_sys->current_pcr = 0;
esout_sys->first_pcr = -1;
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;
......@@ -2926,11 +2988,12 @@ static int blurayDemux(demux_t *p_demux)
}
else
{
msg_Dbg(p_demux, "Draining...");
msg_Warn(p_demux, "Draining...");
msleep( 40000 );
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