mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
ext/mpeg2dec/gstmpeg2dec.c: Set DELTA_UNIT flag on outgoing buffers if this is NOT a keyframe; nice-ify debug message...
Original commit message from CVS: * ext/mpeg2dec/gstmpeg2dec.c: (handle_slice), (gst_mpeg2dec_sink_event): Set DELTA_UNIT flag on outgoing buffers if this is NOT a keyframe; nice-ify debug message in event handler; add CHECKME. * gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_process_event), (gst_dvd_demux_send_event), (gst_dvd_demux_process_private), (gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset), (gst_dvd_demux_sync_stream_to_time): * gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_class_init), (gst_mpeg_demux_process_event), (gst_mpeg_demux_send_event), (gst_mpeg_demux_handle_discont), (gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_parse_packet), (gst_mpeg_demux_parse_pes), (gst_mpeg_demux_send_subbuffer), (gst_mpeg_demux_process_private), (gst_mpeg_demux_sync_stream_to_time), (gst_mpeg_demux_handle_src_event), (gst_mpeg_demux_reset): * gst/mpegstream/gstmpegdemux.h: * gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init), (gst_mpeg_parse_handle_discont), (gst_mpeg_parse_send_buffer), (gst_mpeg_parse_process_event), (gst_mpeg_parse_send_discont), (gst_mpeg_parse_send_event), (gst_mpeg_parse_event), (gst_mpeg_parse_chain): * gst/mpegstream/gstmpegparse.h: Get rid of GST_PAD_IS_USABLE and fix GstFlowReturn vs. gboolean return value confusion (gst_pad_push vs. gst_pad_send_event and gst_pad_push_event); pass flow return values to caller; miscellaneous fixes and clean-ups.
This commit is contained in:
parent
6bd2b6cc59
commit
cbc750649e
7 changed files with 214 additions and 195 deletions
30
ChangeLog
30
ChangeLog
|
@ -1,3 +1,33 @@
|
|||
2005-11-15 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* ext/mpeg2dec/gstmpeg2dec.c: (handle_slice),
|
||||
(gst_mpeg2dec_sink_event):
|
||||
Set DELTA_UNIT flag on outgoing buffers if this is NOT a keyframe;
|
||||
nice-ify debug message in event handler; add CHECKME.
|
||||
|
||||
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_process_event),
|
||||
(gst_dvd_demux_send_event), (gst_dvd_demux_process_private),
|
||||
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset),
|
||||
(gst_dvd_demux_sync_stream_to_time):
|
||||
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_class_init),
|
||||
(gst_mpeg_demux_process_event), (gst_mpeg_demux_send_event),
|
||||
(gst_mpeg_demux_handle_discont), (gst_mpeg_demux_new_output_pad),
|
||||
(gst_mpeg_demux_parse_packet), (gst_mpeg_demux_parse_pes),
|
||||
(gst_mpeg_demux_send_subbuffer), (gst_mpeg_demux_process_private),
|
||||
(gst_mpeg_demux_sync_stream_to_time),
|
||||
(gst_mpeg_demux_handle_src_event), (gst_mpeg_demux_reset):
|
||||
* gst/mpegstream/gstmpegdemux.h:
|
||||
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
|
||||
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_send_buffer),
|
||||
(gst_mpeg_parse_process_event), (gst_mpeg_parse_send_discont),
|
||||
(gst_mpeg_parse_send_event), (gst_mpeg_parse_event),
|
||||
(gst_mpeg_parse_chain):
|
||||
* gst/mpegstream/gstmpegparse.h:
|
||||
Get rid of GST_PAD_IS_USABLE and fix GstFlowReturn vs. gboolean
|
||||
return value confusion (gst_pad_push vs. gst_pad_send_event and
|
||||
gst_pad_push_event); pass flow return values to caller;
|
||||
miscellaneous fixes and clean-ups.
|
||||
|
||||
2005-11-14 Martin Soto <soto@localhost.localdomain>
|
||||
|
||||
* gst/mpegstream/Makefile.am (noinst_HEADERS): Add
|
||||
|
|
|
@ -633,7 +633,7 @@ handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|||
|
||||
GST_DEBUG_OBJECT (mpeg2dec, "picture keyframe %d", key_frame);
|
||||
|
||||
if (key_frame)
|
||||
if (!key_frame)
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
else
|
||||
GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
|
@ -706,8 +706,11 @@ handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|||
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
|
||||
|
||||
if ((mpeg2dec->decoded_height > mpeg2dec->height) ||
|
||||
(mpeg2dec->decoded_width > mpeg2dec->width))
|
||||
(mpeg2dec->decoded_width > mpeg2dec->width)) {
|
||||
/* CHECKME: this might unref outbuf and return a new buffer.
|
||||
* Does this affect the info->discard_fbuf stuff below? */
|
||||
outbuf = crop_buffer (mpeg2dec, outbuf);
|
||||
}
|
||||
|
||||
gst_buffer_ref (outbuf);
|
||||
ret = gst_pad_push (mpeg2dec->srcpad, outbuf);
|
||||
|
@ -883,6 +886,9 @@ gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
|
|||
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
||||
gboolean ret = TRUE;
|
||||
|
||||
GST_DEBUG_OBJECT (mpeg2dec, "Got %s event on sink pad",
|
||||
GST_EVENT_TYPE_NAME (event));
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
{
|
||||
|
@ -913,8 +919,6 @@ gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
|
|||
break;
|
||||
|
||||
default:
|
||||
GST_DEBUG_OBJECT (mpeg2dec, "Got event of type %d on sink pad",
|
||||
GST_EVENT_TYPE (event));
|
||||
ret = gst_pad_event_default (pad, event);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -133,16 +133,16 @@ static void gst_dvd_demux_init (GstDVDDemux * dvd_demux);
|
|||
|
||||
static GstFlowReturn gst_dvd_demux_send_buffer (GstMPEGParse * mpeg_parse,
|
||||
GstBuffer * buffer, GstClockTime time);
|
||||
static GstFlowReturn gst_dvd_demux_process_event (GstMPEGParse * mpeg_parse,
|
||||
static gboolean gst_dvd_demux_process_event (GstMPEGParse * mpeg_parse,
|
||||
GstEvent * event, GstClockTime time);
|
||||
|
||||
static GstFlowReturn gst_dvd_demux_handle_discont
|
||||
static gboolean gst_dvd_demux_handle_discont
|
||||
(GstMPEGParse * mpeg_parse, GstEvent * event);
|
||||
#if 0
|
||||
static GstFlowReturn gst_dvd_demux_handle_dvd_event
|
||||
static gboolean gst_dvd_demux_handle_dvd_event
|
||||
(GstDVDDemux * dvd_demux, GstEvent * event);
|
||||
#endif
|
||||
static GstFlowReturn gst_dvd_demux_send_event
|
||||
static gboolean gst_dvd_demux_send_event
|
||||
(GstMPEGParse * mpeg_parse, GstEvent * event, GstClockTime time);
|
||||
|
||||
static GstMPEGStream *gst_dvd_demux_get_video_stream
|
||||
|
@ -155,12 +155,12 @@ static GstMPEGStream *gst_dvd_demux_get_subpicture_stream
|
|||
(GstMPEGDemux * dvd_demux,
|
||||
guint8 stream_nr, gint type, const gpointer info);
|
||||
|
||||
static void gst_dvd_demux_process_private
|
||||
static GstFlowReturn gst_dvd_demux_process_private
|
||||
(GstMPEGDemux * mpeg_demux,
|
||||
GstBuffer * buffer,
|
||||
guint stream_nr, GstClockTime timestamp, guint headerlen, guint datalen);
|
||||
|
||||
static void gst_dvd_demux_send_subbuffer
|
||||
static GstFlowReturn gst_dvd_demux_send_subbuffer
|
||||
(GstMPEGDemux * mpeg_demux,
|
||||
GstMPEGStream * outstream,
|
||||
GstBuffer * buffer, GstClockTime timestamp, guint offset, guint size);
|
||||
|
@ -327,11 +327,12 @@ gst_dvd_demux_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer,
|
|||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_dvd_demux_process_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
||||
GstClockTime time)
|
||||
{
|
||||
GstDVDDemux *dvd_demux = GST_DVD_DEMUX (mpeg_parse);
|
||||
gboolean ret = TRUE;
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
#if 0
|
||||
|
@ -345,16 +346,16 @@ gst_dvd_demux_process_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
|||
case GST_EVENT_NEWSEGMENT:
|
||||
case GST_EVENT_FLUSH_START:
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
return PARSE_CLASS (dvd_demux)->send_event (mpeg_parse, event,
|
||||
ret = PARSE_CLASS (dvd_demux)->send_event (mpeg_parse, event,
|
||||
GST_CLOCK_TIME_NONE);
|
||||
break;
|
||||
default:
|
||||
/* Propagate the event normally. */
|
||||
if (!gst_pad_event_default (mpeg_parse->sinkpad, event))
|
||||
return GST_FLOW_ERROR;
|
||||
ret = gst_pad_event_default (mpeg_parse->sinkpad, event);
|
||||
break;
|
||||
}
|
||||
|
||||
return GST_FLOW_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -569,30 +570,22 @@ gst_dvd_demux_send_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
|||
|
||||
for (i = 0; i < GST_DVD_DEMUX_NUM_SUBPICTURE_STREAMS; i++) {
|
||||
if (dvd_demux->subpicture_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (dvd_demux->subpicture_stream[i]->pad)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->subpicture_stream[i]->pad, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->subpicture_stream[i]->pad, event);
|
||||
if (GST_CLOCK_TIME_IS_VALID (ts))
|
||||
dvd_demux->subpicture_stream[i]->cur_ts = ts;
|
||||
}
|
||||
}
|
||||
|
||||
/* Distribute the event to the "current" pads. */
|
||||
if (GST_PAD_IS_USABLE (dvd_demux->cur_video)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->cur_video, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->cur_video, event);
|
||||
|
||||
if (GST_PAD_IS_USABLE (dvd_demux->cur_audio)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->cur_audio, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->cur_audio, event);
|
||||
|
||||
if (GST_PAD_IS_USABLE (dvd_demux->cur_subpicture)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->cur_subpicture, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (dvd_demux->cur_subpicture, event);
|
||||
|
||||
GST_MPEG_PARSE_CLASS (parent_class)->send_event (mpeg_parse, event, ts);
|
||||
|
||||
|
@ -918,12 +911,13 @@ gst_dvd_demux_get_subpicture_stream (GstMPEGDemux * mpeg_demux,
|
|||
return str;
|
||||
}
|
||||
|
||||
static void
|
||||
static GstFlowReturn
|
||||
gst_dvd_demux_process_private (GstMPEGDemux * mpeg_demux,
|
||||
GstBuffer * buffer,
|
||||
guint stream_nr, GstClockTime timestamp, guint headerlen, guint datalen)
|
||||
{
|
||||
GstDVDDemux *dvd_demux = GST_DVD_DEMUX (mpeg_demux);
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 *basebuf;
|
||||
guint8 ps_id_code;
|
||||
GstMPEGStream *outstream = NULL;
|
||||
|
@ -1031,12 +1025,12 @@ gst_dvd_demux_process_private (GstMPEGDemux * mpeg_demux,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
g_return_val_if_reached (GST_FLOW_UNEXPECTED);
|
||||
break;
|
||||
}
|
||||
|
||||
if (outstream == NULL) {
|
||||
return;
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
if (timestamp != GST_CLOCK_TIME_NONE && first_access > 1) {
|
||||
|
@ -1048,14 +1042,14 @@ gst_dvd_demux_process_private (GstMPEGDemux * mpeg_demux,
|
|||
len = first_access - 1;
|
||||
len -= len % align;
|
||||
if (len > 0) {
|
||||
DEMUX_CLASS (dvd_demux)->send_subbuffer (mpeg_demux, outstream,
|
||||
ret = DEMUX_CLASS (dvd_demux)->send_subbuffer (mpeg_demux, outstream,
|
||||
buffer, GST_CLOCK_TIME_NONE, off, len);
|
||||
}
|
||||
off += len;
|
||||
len = datalen - len;
|
||||
len -= len % align;
|
||||
if (len > 0) {
|
||||
DEMUX_CLASS (dvd_demux)->send_subbuffer (mpeg_demux, outstream,
|
||||
ret = DEMUX_CLASS (dvd_demux)->send_subbuffer (mpeg_demux, outstream,
|
||||
buffer, timestamp, off, len);
|
||||
}
|
||||
} else {
|
||||
|
@ -1063,19 +1057,22 @@ gst_dvd_demux_process_private (GstMPEGDemux * mpeg_demux,
|
|||
len = datalen;
|
||||
len -= len % align;
|
||||
if (len > 0) {
|
||||
DEMUX_CLASS (dvd_demux)->send_subbuffer (mpeg_demux, outstream,
|
||||
ret = DEMUX_CLASS (dvd_demux)->send_subbuffer (mpeg_demux, outstream,
|
||||
buffer, timestamp, off, len);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
static GstFlowReturn
|
||||
gst_dvd_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
||||
GstMPEGStream * outstream, GstBuffer * buffer,
|
||||
GstClockTime timestamp, guint offset, guint size)
|
||||
{
|
||||
GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (mpeg_demux);
|
||||
GstDVDDemux *dvd_demux = GST_DVD_DEMUX (mpeg_demux);
|
||||
GstFlowReturn ret;
|
||||
GstPad *outpad;
|
||||
gint cur_nr;
|
||||
|
||||
|
@ -1100,7 +1097,7 @@ gst_dvd_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
|||
gst_buffer_ref (buffer);
|
||||
|
||||
/* Send the buffer to the standard output pad. */
|
||||
parent_class->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
ret = parent_class->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
timestamp, offset, size);
|
||||
|
||||
/* Determine the current output pad and stream number for the given
|
||||
|
@ -1123,24 +1120,27 @@ gst_dvd_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
|||
cur_nr = dvd_demux->cur_subpicture_nr;
|
||||
break;
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
g_return_val_if_reached (GST_FLOW_UNEXPECTED);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((outpad != NULL) && (cur_nr == outstream->number) && (size > 0)) {
|
||||
if (outpad != NULL && cur_nr == outstream->number && size > 0) {
|
||||
GstBuffer *outbuf;
|
||||
|
||||
/* We have a packet of the current stream. Send it to the
|
||||
corresponding pad as well. */
|
||||
outbuf = gst_buffer_create_sub (buffer, offset, size);
|
||||
g_return_val_if_fail (outbuf != NULL, GST_FLOW_UNEXPECTED);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer) + offset;
|
||||
|
||||
gst_pad_push (outpad, outbuf);
|
||||
ret = gst_pad_push (outpad, outbuf);
|
||||
}
|
||||
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -1210,10 +1210,9 @@ gst_dvd_demux_reset (GstDVDDemux * dvd_demux)
|
|||
GST_INFO ("Resetting the dvd demuxer");
|
||||
for (i = 0; i < GST_DVD_DEMUX_NUM_SUBPICTURE_STREAMS; i++) {
|
||||
if (dvd_demux->subpicture_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (dvd_demux->subpicture_stream[i]->pad)) {
|
||||
gst_pad_push_event (dvd_demux->subpicture_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
}
|
||||
gst_pad_push_event (dvd_demux->subpicture_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
|
||||
gst_element_remove_pad (GST_ELEMENT (dvd_demux),
|
||||
dvd_demux->subpicture_stream[i]->pad);
|
||||
g_free (dvd_demux->subpicture_stream[i]);
|
||||
|
@ -1303,7 +1302,7 @@ gst_dvd_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
|
|||
filler = gst_event_new_filler_stamped (last_ts, GST_CLOCK_TIME_NONE);
|
||||
|
||||
if (filler) {
|
||||
if (gst_pad_push_event (stream->pad, filler) != GST_FLOW_OK)
|
||||
if (!gst_pad_push_event (stream->pad, filler))
|
||||
gst_event_unref (filler);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,13 +89,13 @@ static void gst_mpeg_demux_init (GstMPEGDemux * mpeg_demux);
|
|||
|
||||
static GstFlowReturn gst_mpeg_demux_send_buffer (GstMPEGParse * mpeg_parse,
|
||||
GstBuffer * buffer, GstClockTime time);
|
||||
static GstFlowReturn gst_mpeg_demux_process_event (GstMPEGParse * mpeg_parse,
|
||||
static gboolean gst_mpeg_demux_process_event (GstMPEGParse * mpeg_parse,
|
||||
GstEvent * event, GstClockTime time);
|
||||
static GstFlowReturn gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse,
|
||||
static gboolean gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse,
|
||||
GstClockTime time);
|
||||
static GstFlowReturn gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse,
|
||||
static gboolean gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse,
|
||||
GstEvent * event);
|
||||
static GstFlowReturn gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse,
|
||||
static gboolean gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse,
|
||||
GstEvent * event, GstClockTime time);
|
||||
|
||||
static GstPad *gst_mpeg_demux_new_output_pad (GstMPEGDemux * mpeg_demux,
|
||||
|
@ -115,23 +115,23 @@ static gboolean gst_mpeg_demux_parse_packhead (GstMPEGParse * mpeg_parse,
|
|||
GstBuffer * buffer);
|
||||
static gboolean gst_mpeg_demux_parse_syshead (GstMPEGParse * mpeg_parse,
|
||||
GstBuffer * buffer);
|
||||
static gboolean gst_mpeg_demux_parse_packet (GstMPEGParse * mpeg_parse,
|
||||
static GstFlowReturn gst_mpeg_demux_parse_packet (GstMPEGParse * mpeg_parse,
|
||||
GstBuffer * buffer);
|
||||
static gboolean gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse,
|
||||
static GstFlowReturn gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse,
|
||||
GstBuffer * buffer);
|
||||
|
||||
static void gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
||||
static GstFlowReturn gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
||||
GstMPEGStream * outstream, GstBuffer * buffer,
|
||||
GstClockTime timestamp, guint offset, guint size);
|
||||
static void gst_mpeg_demux_process_private (GstMPEGDemux * mpeg_demux,
|
||||
static GstFlowReturn gst_mpeg_demux_process_private (GstMPEGDemux * mpeg_demux,
|
||||
GstBuffer * buffer,
|
||||
guint stream_nr, GstClockTime timestamp, guint headerlen, guint datalen);
|
||||
static void gst_mpeg_demux_synchronise_pads (GstMPEGDemux * mpeg_demux,
|
||||
GstClockTime threshold, GstClockTime new_ts);
|
||||
#if 0
|
||||
static void gst_mpeg_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
|
||||
GstMPEGStream * stream, GstClockTime last_ts);
|
||||
|
||||
#if 0
|
||||
const GstFormat *gst_mpeg_demux_get_src_formats (GstPad * pad);
|
||||
|
||||
static gboolean index_seek (GstPad * pad, GstEvent * event, gint64 * offset);
|
||||
|
@ -214,9 +214,10 @@ gst_mpeg_demux_class_init (GstMPEGDemuxClass * klass)
|
|||
gstelement_class = (GstElementClass *) klass;
|
||||
mpeg_parse_class = (GstMPEGParseClass *) klass;
|
||||
|
||||
gstelement_class->change_state = gst_mpeg_demux_change_state;
|
||||
gstelement_class->set_index = gst_mpeg_demux_set_index;
|
||||
gstelement_class->get_index = gst_mpeg_demux_get_index;
|
||||
gstelement_class->change_state =
|
||||
GST_DEBUG_FUNCPTR (gst_mpeg_demux_change_state);
|
||||
gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_mpeg_demux_set_index);
|
||||
gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_mpeg_demux_get_index);
|
||||
|
||||
mpeg_parse_class->parse_packhead = gst_mpeg_demux_parse_packhead;
|
||||
mpeg_parse_class->parse_syshead = gst_mpeg_demux_parse_syshead;
|
||||
|
@ -236,9 +237,7 @@ gst_mpeg_demux_class_init (GstMPEGDemuxClass * klass)
|
|||
klass->send_subbuffer = gst_mpeg_demux_send_subbuffer;
|
||||
klass->process_private = gst_mpeg_demux_process_private;
|
||||
klass->synchronise_pads = gst_mpeg_demux_synchronise_pads;
|
||||
#if 0
|
||||
klass->sync_stream_to_time = gst_mpeg_demux_sync_stream_to_time;
|
||||
#endif
|
||||
|
||||
/* we have our own sink pad template, but don't use it in subclasses */
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
|
@ -275,28 +274,30 @@ gst_mpeg_demux_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer,
|
|||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_demux_process_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
||||
GstClockTime time)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_FILLER:
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
case GST_EVENT_FLUSH_START:
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
return PARSE_CLASS (mpeg_parse)->send_event (mpeg_parse, event,
|
||||
ret = PARSE_CLASS (mpeg_parse)->send_event (mpeg_parse, event,
|
||||
GST_CLOCK_TIME_NONE);
|
||||
break;
|
||||
default:
|
||||
/* Propagate the event normally. */
|
||||
if (!gst_pad_event_default (mpeg_parse->sinkpad, event))
|
||||
return GST_FLOW_ERROR;
|
||||
ret = gst_pad_event_default (mpeg_parse->sinkpad, event);
|
||||
break;
|
||||
}
|
||||
|
||||
return GST_FLOW_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse, GstClockTime time)
|
||||
{
|
||||
GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
|
||||
|
@ -318,7 +319,7 @@ gst_mpeg_demux_send_discont (GstMPEGParse * mpeg_parse, GstClockTime time)
|
|||
return parent_class->send_discont (mpeg_parse, time);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
||||
GstClockTime time)
|
||||
{
|
||||
|
@ -328,17 +329,16 @@ gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
|||
GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
|
||||
gint i;
|
||||
|
||||
if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START) {
|
||||
GST_DEBUG_OBJECT (mpeg_demux, "Sending flush event");
|
||||
GST_DEBUG_OBJECT (mpeg_demux, "Sending %s event",
|
||||
GST_EVENT_TYPE_NAME (event));
|
||||
|
||||
if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START)
|
||||
mpeg_demux->just_flushed = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < GST_MPEG_DEMUX_NUM_VIDEO_STREAMS; i++) {
|
||||
if (mpeg_demux->video_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (mpeg_demux->video_stream[i]->pad)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (mpeg_demux->video_stream[i]->pad, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (mpeg_demux->video_stream[i]->pad, event);
|
||||
if (GST_CLOCK_TIME_IS_VALID (time))
|
||||
mpeg_demux->video_stream[i]->cur_ts = time;
|
||||
}
|
||||
|
@ -346,10 +346,8 @@ gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
|||
|
||||
for (i = 0; i < GST_MPEG_DEMUX_NUM_AUDIO_STREAMS; i++) {
|
||||
if (mpeg_demux->audio_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (mpeg_demux->audio_stream[i]->pad)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (mpeg_demux->audio_stream[i]->pad, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (mpeg_demux->audio_stream[i]->pad, event);
|
||||
if (GST_CLOCK_TIME_IS_VALID (time))
|
||||
mpeg_demux->audio_stream[i]->cur_ts = time;
|
||||
}
|
||||
|
@ -357,22 +355,23 @@ gst_mpeg_demux_send_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
|||
|
||||
for (i = 0; i < GST_MPEG_DEMUX_NUM_PRIVATE_STREAMS; i++) {
|
||||
if (mpeg_demux->private_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (mpeg_demux->private_stream[i]->pad)) {
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (mpeg_demux->private_stream[i]->pad, event);
|
||||
}
|
||||
gst_event_ref (event);
|
||||
gst_pad_push_event (mpeg_demux->private_stream[i]->pad, event);
|
||||
if (GST_CLOCK_TIME_IS_VALID (time))
|
||||
mpeg_demux->private_stream[i]->cur_ts = time;
|
||||
}
|
||||
}
|
||||
|
||||
return parent_class->send_event (mpeg_parse, event, time);
|
||||
if (parent_class->send_event)
|
||||
return parent_class->send_event (mpeg_parse, event, time);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
|
||||
{
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
#if 0
|
||||
GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
|
||||
|
@ -383,9 +382,9 @@ gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
|
|||
#endif
|
||||
|
||||
if (parent_class->handle_discont != NULL)
|
||||
result = parent_class->handle_discont (mpeg_parse, event);
|
||||
ret = parent_class->handle_discont (mpeg_parse, event);
|
||||
|
||||
return result;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -413,9 +412,12 @@ gst_mpeg_demux_new_output_pad (GstMPEGDemux * mpeg_demux,
|
|||
pad = gst_pad_new_from_template (temp, name);
|
||||
|
||||
#if 0
|
||||
gst_pad_set_event_function (pad, gst_mpeg_demux_handle_src_event);
|
||||
gst_pad_set_query_type_function (pad, gst_mpeg_parse_get_src_query_types);
|
||||
gst_pad_set_query_function (pad, gst_mpeg_demux_handle_src_query);
|
||||
gst_pad_set_event_function (pad,
|
||||
GST_DEBUG_FUNCPTR (gst_mpeg_demux_handle_src_event));
|
||||
gst_pad_set_query_type_function (pad,
|
||||
GST_DEBUG_FUNCPTR (gst_mpeg_parse_get_src_query_types));
|
||||
gst_pad_set_query_function (pad,
|
||||
GST_DEBUG_FUNCPTR (gst_mpeg_demux_handle_src_query));
|
||||
#endif
|
||||
gst_pad_use_fixed_caps (pad);
|
||||
|
||||
|
@ -721,7 +723,7 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static GstFlowReturn
|
||||
gst_mpeg_demux_parse_packet (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
||||
{
|
||||
GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
|
||||
|
@ -740,6 +742,8 @@ gst_mpeg_demux_parse_packet (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
|||
guint8 *buf, *basebuf;
|
||||
gint64 timestamp;
|
||||
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
basebuf = buf = GST_BUFFER_DATA (buffer);
|
||||
id = *(buf + 3);
|
||||
buf += 4;
|
||||
|
@ -858,7 +862,7 @@ done:
|
|||
GST_DEBUG_OBJECT (mpeg_demux, "we have an audio packet");
|
||||
outstream = CLASS (mpeg_demux)->get_audio_stream (mpeg_demux,
|
||||
id - 0xC0, GST_MPEG_DEMUX_AUDIO_MPEG, NULL);
|
||||
CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
ret = CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
timestamp, headerlen + 4, datalen);
|
||||
} else if (id >= 0xE0 && id <= 0xEF) {
|
||||
/* Video. */
|
||||
|
@ -868,16 +872,16 @@ done:
|
|||
|
||||
outstream = CLASS (mpeg_demux)->get_video_stream (mpeg_demux,
|
||||
id - 0xE0, GST_MPEG_DEMUX_VIDEO_MPEG, &mpeg_version);
|
||||
CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
ret = CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
timestamp, headerlen + 4, datalen);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (mpeg_demux, "unknown stream id 0x%02x", id);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static GstFlowReturn
|
||||
gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
||||
{
|
||||
GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
|
||||
|
@ -890,6 +894,8 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
|||
guint16 headerlen;
|
||||
GstClockTime timestamp;
|
||||
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
GstMPEGStream *outstream = NULL;
|
||||
guint8 *buf;
|
||||
|
||||
|
@ -990,7 +996,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
|||
GST_DEBUG_OBJECT (mpeg_demux, "we have an audio packet");
|
||||
outstream = CLASS (mpeg_demux)->get_audio_stream (mpeg_demux,
|
||||
id - 0xC0, GST_MPEG_DEMUX_AUDIO_MPEG, NULL);
|
||||
CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
ret = CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
timestamp, headerlen + 4, datalen);
|
||||
} else if (id >= 0xE0 && id <= 0xEF) {
|
||||
/* Video. */
|
||||
|
@ -1000,21 +1006,22 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
|||
|
||||
outstream = CLASS (mpeg_demux)->get_video_stream (mpeg_demux,
|
||||
id - 0xE0, GST_MPEG_DEMUX_VIDEO_MPEG, &mpeg_version);
|
||||
CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
ret = CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
timestamp, headerlen + 4, datalen);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (mpeg_demux, "unknown stream id 0x%02x", id);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
static GstFlowReturn
|
||||
gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
||||
GstMPEGStream * outstream, GstBuffer * buffer,
|
||||
GstClockTime timestamp, guint offset, guint size)
|
||||
{
|
||||
GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (mpeg_demux);
|
||||
GstFlowReturn ret;
|
||||
GstBuffer *outbuf;
|
||||
|
||||
mpeg_demux->just_flushed = FALSE;
|
||||
|
@ -1038,9 +1045,8 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
|||
mpeg_parse->current_ts + mpeg_demux->adjust + outstream->scr_offs;
|
||||
}
|
||||
|
||||
if (!GST_PAD_IS_USABLE (outstream->pad) || (size == 0)) {
|
||||
return;
|
||||
}
|
||||
if (size == 0)
|
||||
return GST_FLOW_OK;
|
||||
|
||||
GST_DEBUG_OBJECT (mpeg_demux, "Creating subbuffer size %d, time=%"
|
||||
GST_TIME_FORMAT, size, GST_TIME_ARGS (timestamp));
|
||||
|
@ -1048,8 +1054,8 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
|||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer) + offset;
|
||||
|
||||
gst_pad_push (outstream->pad, outbuf);
|
||||
g_print ("pushing buffer %p\n", GST_BUFFER (outbuf));
|
||||
ret = gst_pad_push (outstream->pad, outbuf);
|
||||
|
||||
if (GST_CLOCK_TIME_IS_VALID (mpeg_demux->max_gap) &&
|
||||
GST_CLOCK_TIME_IS_VALID (mpeg_parse->current_ts) &&
|
||||
|
@ -1062,19 +1068,23 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
|
|||
mpeg_parse->current_ts + mpeg_demux->adjust -
|
||||
mpeg_demux->max_gap_tolerance);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
static GstFlowReturn
|
||||
gst_mpeg_demux_process_private (GstMPEGDemux * mpeg_demux,
|
||||
GstBuffer * buffer,
|
||||
guint stream_nr, GstClockTime timestamp, guint headerlen, guint datalen)
|
||||
{
|
||||
GstMPEGStream *outstream;
|
||||
GstFlowReturn ret;
|
||||
|
||||
outstream = CLASS (mpeg_demux)->get_private_stream (mpeg_demux,
|
||||
stream_nr, GST_MPEG_DEMUX_PRIVATE_UNKNOWN, NULL);
|
||||
CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
ret = CLASS (mpeg_demux)->send_subbuffer (mpeg_demux, outstream, buffer,
|
||||
timestamp, headerlen + 4, datalen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1111,7 +1121,6 @@ gst_mpeg_demux_synchronise_pads (GstMPEGDemux * mpeg_demux,
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Send a filler event on the indicated pad to catch it up to
|
||||
* last_ts. Query the pad for current time, and use that time
|
||||
* to set the duration of the filler event, otherwise we use
|
||||
|
@ -1122,6 +1131,13 @@ static void
|
|||
gst_mpeg_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
|
||||
GstMPEGStream * stream, GstClockTime last_ts)
|
||||
{
|
||||
static gboolean beenhere; /* FALSE */
|
||||
|
||||
if (!beenhere) {
|
||||
g_message ("FIXME: %s\n", __FUNCTION__);
|
||||
beenhere = TRUE;
|
||||
}
|
||||
#if 0
|
||||
GstClockTime start_ts;
|
||||
GstEvent *filler = NULL;
|
||||
GstFormat fmt = GST_FORMAT_TIME;
|
||||
|
@ -1138,18 +1154,17 @@ gst_mpeg_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
|
|||
}
|
||||
|
||||
if (filler) {
|
||||
if (GST_PAD_IS_USABLE (stream->pad)) {
|
||||
GST_LOG ("Advancing %s from %llu by %lld to %llu (diff %lld)",
|
||||
gst_pad_get_name (stream->pad), stream->cur_ts,
|
||||
gst_event_filler_get_duration (filler), last_ts,
|
||||
GST_CLOCK_DIFF (last_ts, stream->cur_ts));
|
||||
GST_LOG ("Advancing %s from %llu by %lld to %llu (diff %lld)",
|
||||
gst_pad_get_name (stream->pad), stream->cur_ts,
|
||||
gst_event_filler_get_duration (filler), last_ts,
|
||||
GST_CLOCK_DIFF (last_ts, stream->cur_ts));
|
||||
|
||||
gst_pad_push (stream->pad, filler);
|
||||
} else
|
||||
gst_event_unref (filler);
|
||||
gst_pad_push_event (stream->pad, filler);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
const GstFormat *
|
||||
gst_mpeg_demux_get_src_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -1248,12 +1263,9 @@ gst_mpeg_demux_handle_src_event (GstPad * pad, GstEvent * event)
|
|||
}
|
||||
case GST_EVENT_NAVIGATION:
|
||||
{
|
||||
GstPad *out = GST_PAD_PEER (GST_MPEG_PARSE (mpeg_demux)->sinkpad);
|
||||
|
||||
if (out && GST_PAD_IS_USABLE (out))
|
||||
return gst_pad_send_event (out, event);
|
||||
res = gst_pad_push_event (GST_MPEG_PARSE (mpeg_demux)->sinkpad, event);
|
||||
break;
|
||||
}
|
||||
/* fall-through */
|
||||
default:
|
||||
gst_event_unref (event);
|
||||
break;
|
||||
|
@ -1294,10 +1306,8 @@ gst_mpeg_demux_reset (GstMPEGDemux * mpeg_demux)
|
|||
/* check get_audio/video_stream because it can be derivated */
|
||||
for (i = 0; i < GST_MPEG_DEMUX_NUM_VIDEO_STREAMS; i++)
|
||||
if (mpeg_demux->video_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (mpeg_demux->video_stream[i]->pad)) {
|
||||
gst_pad_push_event (mpeg_demux->video_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
}
|
||||
gst_pad_push_event (mpeg_demux->video_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
gst_element_remove_pad (GST_ELEMENT (mpeg_demux),
|
||||
mpeg_demux->video_stream[i]->pad);
|
||||
g_free (mpeg_demux->video_stream[i]);
|
||||
|
@ -1305,10 +1315,8 @@ gst_mpeg_demux_reset (GstMPEGDemux * mpeg_demux)
|
|||
}
|
||||
for (i = 0; i < GST_MPEG_DEMUX_NUM_AUDIO_STREAMS; i++)
|
||||
if (mpeg_demux->audio_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (mpeg_demux->audio_stream[i]->pad)) {
|
||||
gst_pad_push_event (mpeg_demux->audio_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
}
|
||||
gst_pad_push_event (mpeg_demux->audio_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
gst_element_remove_pad (GST_ELEMENT (mpeg_demux),
|
||||
mpeg_demux->audio_stream[i]->pad);
|
||||
g_free (mpeg_demux->audio_stream[i]);
|
||||
|
@ -1316,10 +1324,8 @@ gst_mpeg_demux_reset (GstMPEGDemux * mpeg_demux)
|
|||
}
|
||||
for (i = 0; i < GST_MPEG_DEMUX_NUM_PRIVATE_STREAMS; i++)
|
||||
if (mpeg_demux->private_stream[i]) {
|
||||
if (GST_PAD_IS_USABLE (mpeg_demux->private_stream[i]->pad)) {
|
||||
gst_pad_push_event (mpeg_demux->private_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
}
|
||||
gst_pad_push_event (mpeg_demux->private_stream[i]->pad,
|
||||
gst_event_new_eos ());
|
||||
gst_element_remove_pad (GST_ELEMENT (mpeg_demux),
|
||||
mpeg_demux->private_stream[i]->pad);
|
||||
g_free (mpeg_demux->private_stream[i]);
|
||||
|
|
|
@ -179,7 +179,7 @@ struct _GstMPEGDemuxClass {
|
|||
gint type,
|
||||
const gpointer info);
|
||||
|
||||
void (*send_subbuffer) (GstMPEGDemux *mpeg_demux,
|
||||
GstFlowReturn (*send_subbuffer) (GstMPEGDemux *mpeg_demux,
|
||||
GstMPEGStream *outstream,
|
||||
GstBuffer *buffer,
|
||||
GstClockTime timestamp,
|
||||
|
@ -187,7 +187,7 @@ struct _GstMPEGDemuxClass {
|
|||
guint size);
|
||||
|
||||
|
||||
void (*process_private) (GstMPEGDemux *mpeg_demux,
|
||||
GstFlowReturn (*process_private) (GstMPEGDemux *mpeg_demux,
|
||||
GstBuffer *buffer,
|
||||
guint stream_nr,
|
||||
GstClockTime timestamp,
|
||||
|
|
|
@ -107,7 +107,7 @@ static GstFlowReturn gst_mpeg_parse_process_event (GstMPEGParse * mpeg_parse,
|
|||
GstEvent * event, GstClockTime time);
|
||||
static GstFlowReturn gst_mpeg_parse_send_discont (GstMPEGParse * mpeg_parse,
|
||||
GstClockTime time);
|
||||
static GstFlowReturn gst_mpeg_parse_send_event (GstMPEGParse * mpeg_parse,
|
||||
static gboolean gst_mpeg_parse_send_event (GstMPEGParse * mpeg_parse,
|
||||
GstEvent * event, GstClockTime time);
|
||||
|
||||
static void gst_mpeg_parse_pad_added (GstElement * element, GstPad * pad);
|
||||
|
@ -244,9 +244,9 @@ gst_mpeg_parse_init (GstMPEGParse * mpeg_parse)
|
|||
GST_DEBUG_FUNCPTR (gst_mpeg_parse_handle_src_event));
|
||||
#if 0
|
||||
gst_pad_set_query_type_function (mpeg_parse->srcpad,
|
||||
gst_mpeg_parse_get_src_query_types);
|
||||
GST_DEBUG_FUNCPTR (gst_mpeg_parse_get_src_query_types));
|
||||
gst_pad_set_query_function (mpeg_parse->srcpad,
|
||||
gst_mpeg_parse_handle_src_query);
|
||||
GST_DEBUG_FUNCPTR (gst_mpeg_parse_handle_src_query));
|
||||
#endif
|
||||
gst_pad_use_fixed_caps (mpeg_parse->srcpad);
|
||||
}
|
||||
|
@ -326,11 +326,11 @@ gst_mpeg_parse_reset (GstMPEGParse * mpeg_parse)
|
|||
mpeg_parse->scr_pending = FALSE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_parse_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
|
||||
{
|
||||
GstFlowReturn result = GST_FLOW_OK;;
|
||||
GstFormat format;
|
||||
gboolean ret = TRUE;
|
||||
gint64 time;
|
||||
|
||||
#if 0
|
||||
|
@ -346,7 +346,7 @@ gst_mpeg_parse_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
|
|||
(double) time / GST_SECOND);
|
||||
|
||||
if (CLASS (mpeg_parse)->send_discont)
|
||||
result = CLASS (mpeg_parse)->send_discont (mpeg_parse, time);
|
||||
ret = CLASS (mpeg_parse)->send_discont (mpeg_parse, time);
|
||||
} else {
|
||||
/* Use the next SCR to send a discontinuous event. */
|
||||
GST_DEBUG_OBJECT (mpeg_parse, "Using next SCR to send discont");
|
||||
|
@ -356,7 +356,7 @@ gst_mpeg_parse_handle_discont (GstMPEGParse * mpeg_parse, GstEvent * event)
|
|||
mpeg_parse->packetize->resync = TRUE;
|
||||
|
||||
gst_event_unref (event);
|
||||
return result;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -365,7 +365,7 @@ gst_mpeg_parse_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer,
|
|||
{
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
|
||||
if (!gst_caps_is_fixed (gst_pad_get_caps (mpeg_parse->srcpad))) {
|
||||
if (!gst_caps_is_fixed (GST_PAD_CAPS (mpeg_parse->srcpad))) {
|
||||
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
|
||||
GstCaps *caps;
|
||||
|
||||
|
@ -377,68 +377,46 @@ gst_mpeg_parse_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer,
|
|||
if (!gst_pad_set_caps (mpeg_parse->srcpad, caps)) {
|
||||
GST_ELEMENT_ERROR (GST_ELEMENT (mpeg_parse),
|
||||
CORE, NEGOTIATION, (NULL), ("failed to set caps"));
|
||||
gst_caps_unref (caps);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
GST_BUFFER_TIMESTAMP (buffer) = time;
|
||||
GST_DEBUG ("current_scr %" G_GINT64_FORMAT, time);
|
||||
|
||||
if (GST_PAD_IS_USABLE (mpeg_parse->srcpad))
|
||||
result = gst_pad_push (mpeg_parse->srcpad, buffer);
|
||||
else
|
||||
gst_buffer_unref (buffer);
|
||||
result = gst_pad_push (mpeg_parse->srcpad, buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_parse_process_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
||||
GstClockTime time)
|
||||
{
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
default:
|
||||
if (!gst_pad_event_default (mpeg_parse->sinkpad, event))
|
||||
return GST_FLOW_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
return GST_FLOW_OK;
|
||||
return gst_pad_event_default (mpeg_parse->sinkpad, event);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_parse_send_discont (GstMPEGParse * mpeg_parse, GstClockTime time)
|
||||
{
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
GstEvent *event;
|
||||
|
||||
event = gst_event_new_newsegment (FALSE, 1.0, GST_FORMAT_TIME, time,
|
||||
GST_CLOCK_TIME_NONE, (gint64) 0);
|
||||
|
||||
if (!event) {
|
||||
GST_ELEMENT_ERROR (GST_ELEMENT (mpeg_parse),
|
||||
RESOURCE, FAILED, (NULL), ("Allocation failed"));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
if (CLASS (mpeg_parse)->send_event)
|
||||
result = CLASS (mpeg_parse)->send_event (mpeg_parse, event, time);
|
||||
return CLASS (mpeg_parse)->send_event (mpeg_parse, event, time);
|
||||
|
||||
return result;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
static gboolean
|
||||
gst_mpeg_parse_send_event (GstMPEGParse * mpeg_parse, GstEvent * event,
|
||||
GstClockTime time)
|
||||
{
|
||||
GstFlowReturn result = GST_FLOW_OK;
|
||||
|
||||
if (GST_PAD_IS_USABLE (mpeg_parse->srcpad))
|
||||
result = gst_pad_push_event (mpeg_parse->srcpad, event);
|
||||
else
|
||||
gst_event_unref (event);
|
||||
|
||||
return result;
|
||||
return gst_pad_push_event (mpeg_parse->srcpad, event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -633,9 +611,9 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
|
|||
static gboolean
|
||||
gst_mpeg_parse_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (gst_pad_get_parent (pad));
|
||||
GstClockTime time;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
time = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
|
||||
|
||||
|
@ -643,6 +621,8 @@ gst_mpeg_parse_event (GstPad * pad, GstEvent * event)
|
|||
case GST_EVENT_NEWSEGMENT:
|
||||
if (CLASS (mpeg_parse)->handle_discont)
|
||||
ret = CLASS (mpeg_parse)->handle_discont (mpeg_parse, event);
|
||||
else
|
||||
gst_event_unref (event);
|
||||
break;
|
||||
default:
|
||||
if (CLASS (mpeg_parse)->process_event)
|
||||
|
@ -653,7 +633,7 @@ gst_mpeg_parse_event (GstPad * pad, GstEvent * event)
|
|||
}
|
||||
|
||||
gst_object_unref (mpeg_parse);
|
||||
return ret == GST_FLOW_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -674,7 +654,7 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
while (1) {
|
||||
result = gst_mpeg_packetize_read (mpeg_parse->packetize, &buffer);
|
||||
if (result == GST_FLOW_RESEND) {
|
||||
// there was not enough data in packetizer cache
|
||||
/* there was not enough data in packetizer cache */
|
||||
result = GST_FLOW_OK;
|
||||
goto done;
|
||||
}
|
||||
|
@ -705,11 +685,11 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
} else {
|
||||
if (mpeg2) {
|
||||
if (CLASS (mpeg_parse)->parse_pes) {
|
||||
CLASS (mpeg_parse)->parse_pes (mpeg_parse, buffer);
|
||||
result = CLASS (mpeg_parse)->parse_pes (mpeg_parse, buffer);
|
||||
}
|
||||
} else {
|
||||
if (CLASS (mpeg_parse)->parse_packet) {
|
||||
CLASS (mpeg_parse)->parse_packet (mpeg_parse, buffer);
|
||||
result = CLASS (mpeg_parse)->parse_packet (mpeg_parse, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -727,13 +707,9 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
}
|
||||
#endif
|
||||
if (CLASS (mpeg_parse)->send_discont) {
|
||||
result = CLASS (mpeg_parse)->send_discont (mpeg_parse,
|
||||
CLASS (mpeg_parse)->send_discont (mpeg_parse,
|
||||
MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr +
|
||||
mpeg_parse->adjust));
|
||||
if (result != GST_FLOW_OK) {
|
||||
gst_buffer_unref (buffer);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
mpeg_parse->discont_pending = FALSE;
|
||||
} else {
|
||||
|
@ -805,7 +781,7 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
", next SCR: %" G_GINT64_FORMAT, size, bss, br, mpeg_parse->next_scr);
|
||||
}
|
||||
|
||||
if (result != GST_FLOW_OK) {
|
||||
if (result != GST_FLOW_OK && result != GST_FLOW_NOT_LINKED) {
|
||||
gst_buffer_unref (buffer);
|
||||
goto done;
|
||||
}
|
||||
|
@ -813,6 +789,10 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
|
||||
done:
|
||||
gst_object_unref (mpeg_parse);
|
||||
|
||||
if (result == GST_FLOW_NOT_LINKED)
|
||||
result = GST_FLOW_OK;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,22 +108,22 @@ G_BEGIN_DECLS
|
|||
GstElementClass parent_class;
|
||||
|
||||
/* process packet types */
|
||||
gboolean (*parse_packhead) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
gboolean (*parse_syshead) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
gboolean (*parse_packet) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
gboolean (*parse_pes) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
gboolean (*parse_packhead) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
gboolean (*parse_syshead) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
GstFlowReturn (*parse_packet) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
GstFlowReturn (*parse_pes) (GstMPEGParse * parse, GstBuffer * buffer);
|
||||
|
||||
/* process events */
|
||||
GstFlowReturn (*handle_discont) (GstMPEGParse * parse, GstEvent * event);
|
||||
|
||||
/* optional method to send out the data */
|
||||
GstFlowReturn (*send_buffer) (GstMPEGParse * parse, GstBuffer * buffer, GstClockTime time);
|
||||
GstFlowReturn (*process_event) (GstMPEGParse * parse, GstEvent * event, GstClockTime time);
|
||||
GstFlowReturn (*send_discont) (GstMPEGParse * parse, GstClockTime time);
|
||||
GstFlowReturn (*send_event) (GstMPEGParse * parse, GstEvent *event, GstClockTime time);
|
||||
GstFlowReturn (*send_buffer) (GstMPEGParse * parse, GstBuffer * buffer, GstClockTime time);
|
||||
gboolean (*process_event) (GstMPEGParse * parse, GstEvent * event, GstClockTime time);
|
||||
gboolean (*send_discont) (GstMPEGParse * parse, GstClockTime time);
|
||||
gboolean (*send_event) (GstMPEGParse * parse, GstEvent *event, GstClockTime time);
|
||||
|
||||
/* signals */
|
||||
void (*reached_offset) (GstMPEGParse *mpeg_parse, GstClockTime timeval);
|
||||
void (*reached_offset) (GstMPEGParse *parse, GstClockTime timeval);
|
||||
};
|
||||
|
||||
GType gst_mpeg_parse_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue