- Changed plugins for new APIs

Original commit message from CVS:
- Changed plugins for new APIs
- modularized audiofile.
- added seeking, query and convert functions for mad, mpeg2dec,
avidemux, mpegdemux, mpegparse
- sync updates to oss. removed the ossclock for now
This commit is contained in:
Wim Taymans 2002-05-26 21:59:22 +00:00
parent 69bc511e38
commit b0c33553d3
12 changed files with 1200 additions and 186 deletions

View file

@ -37,37 +37,35 @@ typedef struct _GstMad GstMad;
typedef struct _GstMadClass GstMadClass;
struct _GstMad {
GstElement element;
GstElement element;
/* pads */
GstPad *sinkpad,*srcpad;
GstPad *sinkpad, *srcpad;
/* state */
struct mad_stream stream;
struct mad_frame frame;
struct mad_synth synth;
guchar *tempbuffer;
glong tempsize;
gboolean need_sync;
guint64 last_time;
guint64 framestamp; /* timestamp-like, but counted in frames */
guint64 sync_point;
guint64 total_samples; /* the number of samples since the sync point */
guchar *tempbuffer;
glong tempsize;
gboolean need_sync;
guint64 base_time;
guint64 framestamp; /* timestamp-like, but counted in frames */
guint64 total_samples; /* the number of samples since the sync point */
gint64 seek_point;
gboolean restart;
gboolean restart;
/* info */
struct mad_header header;
gboolean new_header;
gboolean can_seek;
gint channels;
guint framecount;
gint vbr_average; /* average bitrate */
gulong vbr_rate; /* average * framecount */
gboolean new_header;
gboolean can_seek;
gint channels;
guint framecount;
gint vbr_average; /* average bitrate */
guint64 vbr_rate; /* average * framecount */
/* caps */
gboolean caps_set;
gboolean caps_set;
};
struct _GstMadClass {
@ -143,6 +141,12 @@ static void gst_mad_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static gboolean gst_mad_src_event (GstPad *pad, GstEvent *event);
static gboolean gst_mad_src_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value);
static gboolean gst_mad_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value);
static gboolean gst_mad_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value);
static void gst_mad_chain (GstPad *pad, GstBuffer *buffer);
@ -160,7 +164,8 @@ gst_mad_get_type (void)
if (!mad_type) {
static const GTypeInfo mad_info = {
sizeof(GstMadClass), NULL,
sizeof(GstMadClass),
NULL,
NULL,
(GClassInitFunc)gst_mad_class_init,
NULL,
@ -228,26 +233,30 @@ gst_mad_init (GstMad *mad)
/* create the sink and src pads */
mad->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (mad_sink_template_factory), "sink");
gst_element_add_pad(GST_ELEMENT(mad),mad->sinkpad);
gst_pad_set_chain_function (mad->sinkpad, GST_DEBUG_FUNCPTR(gst_mad_chain));
gst_element_add_pad (GST_ELEMENT (mad), mad->sinkpad);
gst_pad_set_chain_function (mad->sinkpad, GST_DEBUG_FUNCPTR (gst_mad_chain));
gst_pad_set_convert_function (mad->sinkpad, GST_DEBUG_FUNCPTR (gst_mad_convert_sink));
mad->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (mad_src_template_factory), "src");
gst_element_add_pad(GST_ELEMENT(mad),mad->srcpad);
gst_pad_set_event_function (mad->srcpad, GST_DEBUG_FUNCPTR(gst_mad_src_event));
gst_element_add_pad (GST_ELEMENT (mad), mad->srcpad);
gst_pad_set_event_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_src_event));
gst_pad_set_query_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_src_query));
gst_pad_set_convert_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_convert_src));
mad->tempbuffer = g_malloc (MAD_BUFFER_MDLEN * 3);
mad->tempsize = 0;
mad->need_sync = TRUE;
mad->last_time = 0;
mad->base_time = 0;
mad->framestamp = 0;
mad->total_samples = 0;
mad->sync_point = 0;
mad->new_header = TRUE;
mad->framecount = 0;
mad->vbr_average = 0;
mad->vbr_rate = 0;
mad->restart = FALSE;
GST_FLAG_SET (mad, GST_ELEMENT_EVENT_AWARE);
}
static void
@ -260,24 +269,278 @@ gst_mad_dispose (GObject *object)
g_free (mad->tempbuffer);
}
static gboolean
gst_mad_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value)
{
gboolean res = TRUE;
GstMad *mad;
if (src_format == *dest_format) {
*dest_value = src_value;
return TRUE;
}
mad = GST_MAD (gst_pad_get_parent (pad));
if (mad->vbr_average == 0)
return FALSE;
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
/* multiply by 8 because vbr is in bits/second */
*dest_value = src_value * 8 * GST_SECOND / mad->vbr_average;
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES:
/* multiply by 8 because vbr is in bits/second */
*dest_value = src_value * mad->vbr_average / (8 * GST_SECOND);
break;
default:
res = FALSE;
}
break;
default:
res = FALSE;
}
return res;
}
static gboolean
gst_mad_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value)
{
gboolean res = TRUE;
guint scale = 1;
gint bytes_per_sample;
GstMad *mad;
if (src_format == *dest_format) {
*dest_value = src_value;
return res;
}
mad = GST_MAD (gst_pad_get_parent (pad));
bytes_per_sample = MAD_NCHANNELS (&mad->frame.header) << 1;
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_SAMPLES:
if (bytes_per_sample == 0)
return FALSE;
*dest_value = src_value / bytes_per_sample;
break;
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
{
gint byterate = bytes_per_sample * mad->frame.header.samplerate;
if (byterate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / byterate;
break;
}
default:
res = FALSE;
}
break;
case GST_FORMAT_SAMPLES:
switch (*dest_format) {
case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
break;
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
if (mad->frame.header.samplerate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / mad->frame.header.samplerate;
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES:
scale = bytes_per_sample;
/* fallthrough */
case GST_FORMAT_SAMPLES:
*dest_value = src_value * scale * mad->frame.header.samplerate / GST_SECOND;
break;
default:
res = FALSE;
}
break;
default:
res = FALSE;
}
return res;
}
static gboolean
gst_mad_src_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value)
{
gboolean res = TRUE;
GstMad *mad;
static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES };
gint i;
mad = GST_MAD (gst_pad_get_parent (pad));
switch (type) {
case GST_PAD_QUERY_TOTAL:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
case GST_FORMAT_BYTES:
case GST_FORMAT_SAMPLES:
case GST_FORMAT_TIME:
{
res = FALSE;
for (i = 0; i < 2 && !res; i++) {
GstFormat peer_format;
gint64 peer_value;
peer_format = formats[i];
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (mad->sinkpad), GST_PAD_QUERY_TOTAL,
&peer_format, &peer_value))
{
GstFormat conv_format;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_mad_convert_sink (pad,
peer_format, peer_value,
&conv_format, value);
/* and to final format */
res &= gst_mad_convert_src (pad,
GST_FORMAT_TIME, *value,
format, value);
}
}
break;
}
default:
res = FALSE;
break;
}
break;
}
case GST_PAD_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
default:
{
GstFormat time_format;
gint64 samples;
time_format = GST_FORMAT_SAMPLES;
res = gst_mad_convert_src (pad,
GST_FORMAT_TIME, mad->base_time,
&time_format, &samples);
/* we only know about our samples, convert to requested format */
res &= gst_mad_convert_src (pad,
GST_FORMAT_SAMPLES, mad->total_samples + samples,
format, value);
break;
}
}
break;
default:
res = FALSE;
break;
}
return res;
}
static gboolean
gst_mad_src_event (GstPad *pad, GstEvent *event)
{
gboolean res = TRUE;
GstMad *mad;
static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES };
gint i;
mad = GST_MAD (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
/* the all-formats seek logic */
case GST_EVENT_SEEK:
if (mad->can_seek) {
mad->seek_point = GST_EVENT_SEEK_OFFSET (event);
{
gint64 src_offset;
gboolean flush;
GstFormat format;
format = GST_FORMAT_TIME;
/* first bring the src_format to TIME */
if (!gst_mad_convert_src (pad,
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
&format, &src_offset))
{
/* didn't work, probably unsupported seek format then */
res = FALSE;
break;
}
else {
res = FALSE;
/* shave off the flush flag, we'll need it later */
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
/* we need to break out of the processing loop on flush */
mad->restart = flush;
/* assume the worst */
res = FALSE;
/* while we did not exhaust our seek formats without result */
for (i = 0; i < 2 && !res; i++) {
gint64 desired_offset;
format = formats[i];
/* try to convert requested format to one we can seek with on the sinkpad */
if (gst_mad_convert_sink (pad, GST_FORMAT_TIME, src_offset, &format, &desired_offset))
{
GstEvent *seek_event;
/* conversion succeeded, create the seek */
seek_event = gst_event_new_seek (formats[i] | GST_SEEK_METHOD_SET | flush, desired_offset);
/* do the seek */
if (gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
res = TRUE;
}
gst_event_free (seek_event);
}
/* at this point, either the seek worked or res == FALSE */
}
break;
}
default:
res = FALSE;
break;
}
@ -354,10 +617,13 @@ gst_mad_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec
break;
}
}
static void
gst_mad_update_info (GstMad *mad, struct mad_header const *header)
gst_mad_update_info (GstMad *mad)
{
gint abr = mad->vbr_average;
struct mad_header *header = &mad->frame.header;
#define CHECK_HEADER(h1,str) \
G_STMT_START{ \
if (mad->header.h1 != header->h1 || mad->new_header) { \
@ -369,8 +635,7 @@ G_STMT_START{ \
g_object_freeze_notify (G_OBJECT (mad));
/* update average bitrate */
if (mad->new_header)
{
if (mad->new_header) {
mad->framecount = 1;
mad->vbr_rate = header->bitrate;
abr = 0;
@ -379,8 +644,7 @@ G_STMT_START{ \
mad->vbr_rate += header->bitrate;
}
mad->vbr_average = (gint) (mad->vbr_rate / mad->framecount);
if (abr != mad->vbr_average)
{
if (abr != mad->vbr_average) {
g_object_notify (G_OBJECT (mad), "average_bitrate");
}
@ -409,19 +673,61 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
mad = GST_MAD (gst_pad_get_parent (pad));
if (GST_IS_EVENT (buffer)) {
GstEvent *event = GST_EVENT (buffer);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
{
gint n = GST_EVENT_DISCONT_OFFSET_LEN (event);
gint i;
for (i=0; i<n; i++) {
if (GST_EVENT_DISCONT_OFFSET(event,i).format == GST_FORMAT_BYTES ||
GST_EVENT_DISCONT_OFFSET(event,i).format == GST_FORMAT_TIME)
{
gint64 value = GST_EVENT_DISCONT_OFFSET (event, i).value;
gint64 time;
GstFormat format;
/* see how long the input bytes take */
format = GST_FORMAT_TIME;
if (!gst_mad_convert_sink (pad,
GST_EVENT_DISCONT_OFFSET (event, i).format, value,
&format, &time))
{
time = 0;
}
mad->base_time = time;
gst_event_free (event);
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, NULL);
break;
}
}
mad->total_samples = 0;
mad->tempsize = 0;
/* we don't need to restart when we get here */
mad->restart = FALSE;
}
default:
gst_pad_event_default (pad, event);
break;
}
gst_event_free (event);
return;
}
if (GST_BUFFER_TIMESTAMP (buffer) != -1) {
mad->base_time = GST_BUFFER_TIMESTAMP (buffer);
mad->total_samples = 0;
}
/* end of new bit */
data = GST_BUFFER_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
if (!GST_PAD_IS_CONNECTED (mad->srcpad)) {
gst_buffer_unref (buffer);
return;
}
if (mad->sync_point == 0 && GST_BUFFER_TIMESTAMP (buffer) != -1) {
mad->sync_point = GST_BUFFER_TIMESTAMP (buffer);
mad->total_samples = 0;
}
while (size > 0) {
gint tocopy;
guchar *mad_input_buffer;
@ -444,7 +750,6 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
mad_fixed_t const *left_ch, *right_ch;
GstBuffer *outbuffer;
gint16 *outdata;
guint pad_slot, N;
mad_stream_buffer (&mad->stream, mad_input_buffer, mad->tempsize);
@ -457,35 +762,12 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
gst_element_error (GST_ELEMENT (mad), "fatal error decoding stream");
return;
}
mad_frame_mute (&mad->frame);
mad_synth_mute (&mad->synth);
/* recoverable errors pass */
goto next;
}
/* calculate beginning of next frame */
pad_slot = (mad->frame.header.flags & MAD_FLAG_PADDING) ? 1 : 0;
/* FIXME: we're experiencing division by zero errors, so warn if
* samplerate is 0
* on the other hand, N is not used any further, so why not just
* remove this bit of code ? */
if (mad->frame.header.samplerate == 0)
{
g_warning ("mad->frame.header.samplerate is 0 !");
}
else
{
if (mad->frame.header.layer == MAD_LAYER_I)
N = ((12 * mad->frame.header.bitrate / mad->frame.header.samplerate) + pad_slot) * 4;
else {
unsigned int slots_per_frame;
slots_per_frame = (mad->frame.header.layer == MAD_LAYER_III &&
(mad->frame.header.flags & MAD_FLAG_LSF_EXT)) ? 72 : 144;
N = (slots_per_frame * mad->frame.header.bitrate / mad->frame.header.samplerate) + pad_slot;
}
}
mad_synth_frame (&mad->synth, &mad->frame);
nchannels = MAD_NCHANNELS (&mad->frame.header);
@ -496,20 +778,20 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
/* at this point we can accept seek events */
mad->can_seek = TRUE;
gst_mad_update_info (mad, &mad->frame.header);
gst_mad_update_info (mad);
outbuffer = gst_buffer_new ();
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer) = g_malloc (nsamples * nchannels * 2);
GST_BUFFER_SIZE (outbuffer) = nsamples * nchannels * 2;
if (mad->frame.header.samplerate == 0)
{
if (mad->frame.header.samplerate == 0) {
g_warning ("mad->frame.header.samplerate is 0 !");
}
else
GST_BUFFER_TIMESTAMP (outbuffer) = mad->sync_point +
mad->total_samples * 1000000LL / mad->frame.header.samplerate;
else {
GST_BUFFER_TIMESTAMP (outbuffer) = mad->base_time +
mad->total_samples * GST_SECOND / mad->frame.header.samplerate;
}
mad->total_samples += nsamples;
@ -546,9 +828,16 @@ gst_mad_chain (GstPad *pad, GstBuffer *buffer)
mad->caps_set = TRUE;
}
gst_pad_push (mad->srcpad, outbuffer);
if (GST_PAD_IS_CONNECTED (mad->srcpad)) {
gst_pad_push (mad->srcpad, outbuffer);
}
else {
gst_buffer_unref (outbuffer);
}
if (mad->restart) {
mad->restart = FALSE;
mad->tempsize = 0;
goto end;
}
next:
@ -559,13 +848,6 @@ next:
/* move out pointer to where mad want the next data */
mad_input_buffer += consumed;
mad->tempsize -= consumed;
if (GST_BUFFER_TIMESTAMP (buffer) != -1) {
if (GST_BUFFER_TIMESTAMP (buffer) > mad->sync_point) {
mad->sync_point = GST_BUFFER_TIMESTAMP (buffer);
mad->total_samples = 0;
}
}
}
memmove (mad->tempbuffer, mad_input_buffer, mad->tempsize);
}
@ -601,7 +883,8 @@ gst_mad_change_state (GstElement *element)
mad_synth_finish (&mad->synth);
mad_frame_finish (&mad->frame);
mad_stream_finish (&mad->stream);
mad->sync_point = 0;
mad->vbr_average = 0;
mad->frame.header.samplerate = 0;
mad->can_seek = FALSE;
mad->restart = TRUE;
break;

View file

@ -58,13 +58,13 @@ static double video_rates[16] =
50.0,
60000.0/1001.,
60.0,
1,
5,
10,
12,
15,
0,
0
1.0,
5.0,
10.0,
12.0,
15.0,
0.0,
0.0
};
GST_PAD_TEMPLATE_FACTORY (src_template_factory,
@ -102,6 +102,15 @@ static void gst_mpeg2dec_set_property (GObject *object, guint prop_id,
static void gst_mpeg2dec_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static gboolean gst_mpeg2dec_src_event (GstPad *pad, GstEvent *event);
static gboolean gst_mpeg2dec_src_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value);
static gboolean gst_mpeg2dec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value);
static gboolean gst_mpeg2dec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value);
static GstElementStateReturn
gst_mpeg2dec_change_state (GstElement *element);
@ -165,28 +174,11 @@ typedef struct gst_mpeg2dec_vo_frame_s {
typedef struct gst_mpeg2dec_vo_instance_s {
vo_instance_t vo;
GstMpeg2dec *mpeg2dec;
gint prediction_index;
gst_mpeg2dec_vo_frame_t frames[NUM_FRAMES];
} gst_mpeg2dec_vo_instance_t;
/* defined but not used
static void
gst_mpeg2dec_vo_frame_copy (vo_frame_t * frame, uint8_t ** src)
{
GST_INFO (GST_CAT_PLUGIN_INFO, "VO: copy");
}
static void
gst_mpeg2dec_vo_frame_field (vo_frame_t * frame, int flags)
{
GST_INFO (GST_CAT_PLUGIN_INFO, "VO: field");
}
*/
static void
gst_mpeg2dec_vo_frame_draw (vo_frame_t * frame)
{
@ -221,20 +213,22 @@ gst_mpeg2dec_vo_frame_draw (vo_frame_t * frame)
g_object_notify (G_OBJECT (mpeg2dec), "frame_rate");
}
pts = mpeg2dec->next_time - 3 * (1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code]);
pts = mpeg2dec->next_time - 3 * (GST_SECOND / video_rates[mpeg2dec->decoder->frame_rate_code]);
GST_BUFFER_TIMESTAMP (_frame->buffer) = pts;
/* g_print ("out: %lld\n", GST_BUFFER_TIMESTAMP (_frame->buffer)); */
GST_DEBUG (0, "out: %lld %d %lld", GST_BUFFER_TIMESTAMP (_frame->buffer),
mpeg2dec->decoder->frame_rate_code,
(long long)(1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code]));
(long long)(GST_SECOND / video_rates[mpeg2dec->decoder->frame_rate_code]));
mpeg2dec->next_time += (1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code]) + mpeg2dec->adjust;
mpeg2dec->next_time += (GST_SECOND / video_rates[mpeg2dec->decoder->frame_rate_code]) + mpeg2dec->adjust;
GST_BUFFER_FLAG_SET (_frame->buffer, GST_BUFFER_READONLY);
mpeg2dec->frames_per_PTS++;
mpeg2dec->first = FALSE;
_frame->sent = TRUE;
mpeg2dec->total_frames++;
gst_pad_push (mpeg2dec->srcpad, _frame->buffer);
}
@ -253,6 +247,7 @@ gst_mpeg2dec_vo_setup (vo_instance_t * instance, int width, int height)
_instance->prediction_index = 1;
mpeg2dec->width = width;
mpeg2dec->height = height;
mpeg2dec->total_frames = 0;
gst_pad_try_set_caps (mpeg2dec->srcpad,
gst_caps_new (
@ -403,19 +398,23 @@ gst_mpeg2dec_vo_destroy (GstMpeg2dec *mpeg2dec)
static void
gst_mpeg2dec_init (GstMpeg2dec *mpeg2dec)
{
/* create the sink and src pads */
mpeg2dec->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->sinkpad);
gst_pad_set_chain_function (mpeg2dec->sinkpad, gst_mpeg2dec_chain);
gst_pad_set_convert_function (mpeg2dec->sinkpad, gst_mpeg2dec_convert_sink);
mpeg2dec->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_template_factory), "src");
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->srcpad);
gst_pad_set_event_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_event));
gst_pad_set_query_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_query));
gst_pad_set_convert_function (mpeg2dec->srcpad, gst_mpeg2dec_convert_src);
/* initialize the mpeg2dec decoder state */
mpeg2dec->decoder = g_new (mpeg2dec_t, 1);
mpeg2dec->decoder->frame_rate_code = 0;
mpeg2dec->accel = mm_accel();
GST_FLAG_SET (GST_ELEMENT (mpeg2dec), GST_ELEMENT_EVENT_AWARE);
@ -443,13 +442,22 @@ gst_mpeg2dec_chain (GstPad *pad, GstBuffer *buf)
GST_DEBUG (0, "MPEG2DEC: chain called");
if (GST_IS_EVENT (buf)) {
GstEvent *ev = GST_EVENT (buf);
GstEvent *event = GST_EVENT (buf);
switch (ev->type) {
switch (event->type) {
case GST_EVENT_DISCONTINUOUS:
mpeg2dec->decoder->is_sequence_needed = 1;
gst_event_free (ev);
{
//gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
//mpeg2dec->decoder->is_sequence_needed = 1;
/* g_print ("mpeg2dec: discont %lld\n", value); */
mpeg2dec->first = TRUE;
mpeg2dec->frames_per_PTS = 0;
mpeg2dec->last_PTS = -1;
mpeg2dec->adjust = 0;
mpeg2dec->next_time = 0;
gst_pad_event_default (pad, event);
return;
}
case GST_EVENT_EOS:
if (!mpeg2dec->closed) {
/* close flushes the last few frames */
@ -457,7 +465,7 @@ gst_mpeg2dec_chain (GstPad *pad, GstBuffer *buf)
mpeg2dec->closed = TRUE;
}
default:
gst_pad_event_default (pad, ev);
gst_pad_event_default (pad, event);
return;
}
}
@ -476,21 +484,22 @@ gst_mpeg2dec_chain (GstPad *pad, GstBuffer *buf)
* - if the PTS and our own counter are adrift bu more than 10 frames, we assume
* a discontinuity in the PTS and adjust our own counter.
*/
GST_DEBUG (GST_CAT_CLOCK, "mpeg2dec: pts %llu\n", pts);
if (!mpeg2dec->first) {
if (mpeg2dec->last_PTS < pts) {
if (pts != mpeg2dec->next_time && mpeg2dec->frames_per_PTS > 10) {
gint64 diff = ABS (pts - mpeg2dec->last_PTS);
if (diff > (1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code])+1000) {
if (diff > (GST_SECOND / video_rates[mpeg2dec->decoder->frame_rate_code]) + GST_SECOND/1000) {
mpeg2dec->adjust = (diff / mpeg2dec->frames_per_PTS +1) -
(1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code]);
(GST_SECOND / video_rates[mpeg2dec->decoder->frame_rate_code]);
}
mpeg2dec->next_time = pts;
}
mpeg2dec->frames_per_PTS = 0;
}
if (ABS (pts - mpeg2dec->last_PTS) > (1000000LL/video_rates[mpeg2dec->decoder->frame_rate_code])*10) {
if (ABS (pts - mpeg2dec->last_PTS) > (GST_SECOND / video_rates[mpeg2dec->decoder->frame_rate_code])*10) {
mpeg2dec->frames_per_PTS = 0;
mpeg2dec->next_time = pts;
@ -510,6 +519,260 @@ gst_mpeg2dec_chain (GstPad *pad, GstBuffer *buf)
gst_buffer_unref(buf);
}
static gboolean
gst_mpeg2dec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value)
{
gboolean res = TRUE;
GstMpeg2dec *mpeg2dec;
if (src_format == *dest_format) {
*dest_value = src_value;
return TRUE;
}
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES:
default:
res = FALSE;
}
break;
default:
res = FALSE;
}
return res;
}
static gboolean
gst_mpeg2dec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
GstFormat *dest_format, gint64 *dest_value)
{
gboolean res = TRUE;
GstMpeg2dec *mpeg2dec;
if (src_format == *dest_format) {
*dest_value = src_value;
return TRUE;
}
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES:
*dest_value = src_value * 6 * (mpeg2dec->width * mpeg2dec->height >> 2) *
video_rates[mpeg2dec->decoder->frame_rate_code] / GST_SECOND;
break;
case GST_FORMAT_FRAMES:
case GST_FORMAT_FIELDS:
*dest_value = src_value * video_rates[mpeg2dec->decoder->frame_rate_code] / GST_SECOND;
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_FRAMES:
case GST_FORMAT_FIELDS:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
if (video_rates[mpeg2dec->decoder->frame_rate_code] != 0.0) {
*dest_value = src_value * GST_SECOND /
video_rates[mpeg2dec->decoder->frame_rate_code];
}
else
res = FALSE;
break;
case GST_FORMAT_BYTES:
*dest_value = src_value * 6 * (mpeg2dec->width * mpeg2dec->height >> 2);
break;
case GST_FORMAT_FRAMES:
case GST_FORMAT_FIELDS:
*dest_value = src_value;
break;
default:
res = FALSE;
}
break;
default:
res = FALSE;
}
return res;
}
static gboolean
gst_mpeg2dec_src_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value)
{
gboolean res = TRUE;
GstMpeg2dec *mpeg2dec;
static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES };
#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */
gint i;
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
switch (type) {
case GST_PAD_QUERY_TOTAL:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
case GST_FORMAT_TIME:
case GST_FORMAT_BYTES:
case GST_FORMAT_FRAMES:
case GST_FORMAT_FIELDS:
{
res = FALSE;
for (i = 0; i < MAX_SEEK_FORMATS && !res; i++) {
GstFormat peer_format;
gint64 peer_value;
peer_format = formats[i];
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (mpeg2dec->sinkpad), GST_PAD_QUERY_TOTAL,
&peer_format, &peer_value))
{
GstFormat conv_format;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_mpeg2dec_convert_sink (pad,
peer_format, peer_value,
&conv_format, value);
/* and to final format */
res &= gst_mpeg2dec_convert_src (pad,
GST_FORMAT_TIME, *value,
format, value);
}
}
break;
}
default:
res = FALSE;
break;
}
break;
}
case GST_PAD_QUERY_POSITION:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
default:
res = gst_mpeg2dec_convert_src (pad,
GST_FORMAT_TIME, mpeg2dec->next_time,
format, value);
break;
}
break;
}
default:
res = FALSE;
break;
}
return res;
}
static gboolean
gst_mpeg2dec_src_event (GstPad *pad, GstEvent *event)
{
gboolean res = TRUE;
GstMpeg2dec *mpeg2dec;
static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES };
#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */
gint i;
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
/* the all-formats seek logic */
case GST_EVENT_SEEK:
{
gint64 src_offset;
gboolean flush;
GstFormat format;
format = GST_FORMAT_TIME;
/* first bring the src_format to TIME */
if (!gst_mpeg2dec_convert_src (pad,
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
&format, &src_offset))
{
/* didn't work, probably unsupported seek format then */
res = FALSE;
break;
}
/* shave off the flush flag, we'll need it later */
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
/* assume the worst */
res = FALSE;
/* while we did not exhaust our seek formats without result */
for (i = 0; i < MAX_SEEK_FORMATS && !res; i++) {
gint64 desired_offset;
format = formats[i];
/* try to convert requested format to one we can seek with on the sinkpad */
if (gst_mpeg2dec_convert_sink (pad, GST_FORMAT_TIME, src_offset, &format, &desired_offset))
{
GstEvent *seek_event;
/* conversion succeeded, create the seek */
seek_event = gst_event_new_seek (formats[i] | GST_SEEK_METHOD_SET | flush, desired_offset);
/* do the seekk */
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
res = TRUE;
}
gst_event_free (seek_event);
}
/* at this point, either the seek worked or res == FALSE */
}
break;
}
default:
res = FALSE;
break;
}
return res;
}
static GstElementStateReturn
gst_mpeg2dec_change_state (GstElement *element)
{
@ -524,6 +787,7 @@ gst_mpeg2dec_change_state (GstElement *element)
mpeg2_init (mpeg2dec->decoder, mpeg2dec->accel, mpeg2dec->vo);
mpeg2dec->decoder->is_sequence_needed = 1;
mpeg2dec->decoder->frame_rate_code = 0;
mpeg2dec->next_time = 0;
mpeg2dec->peerpool = NULL;
mpeg2dec->closed = FALSE;

View file

@ -70,6 +70,7 @@ struct _GstMpeg2dec {
gint width;
gint height;
gint frame_rate_code;
gint64 total_frames;
};
struct _GstMpeg2decClass {

View file

@ -2,11 +2,11 @@ plugindir = $(libdir)/gst
plugin_LTLIBRARIES = libgstmpegstream.la
libgstmpegstream_la_SOURCES = gstmpegstream.c gstmpegparse.c gstmpegdemux.c gstmpegpacketize.c gstrfc2250enc.c
libgstmpegstream_la_SOURCES = gstmpegstream.c gstmpegparse.c gstmpegdemux.c gstmpegpacketize.c gstrfc2250enc.c gstmpegclock.c
libgstmpegstream_la_CFLAGS = $(GST_CFLAGS) -O3 $(FOMIT_FRAME_POINTER) -ffast-math
libgstmpegstream_la_LIBADD =
libgstmpegstream_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstmpegparse.h gstmpegdemux.h gstmpegpacketize.h gstrfc2250enc.h
noinst_HEADERS = gstmpegparse.h gstmpegdemux.h gstmpegpacketize.h gstrfc2250enc.h gstmpegclock.h
EXTRA_DIST = README notes

View file

@ -0,0 +1,98 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstclock.c: Clock subsystem for maintaining time sync
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gstmpegclock.h"
static void gst_mpeg_clock_class_init (GstMPEGClockClass *klass);
static void gst_mpeg_clock_init (GstMPEGClock *clock);
static GstClockTime gst_mpeg_clock_get_internal_time (GstClock *clock);
static GstSystemClockClass *parent_class = NULL;
/* static guint gst_mpeg_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_mpeg_clock_get_type (void)
{
static GType clock_type = 0;
if (!clock_type) {
static const GTypeInfo clock_info = {
sizeof (GstMPEGClockClass),
NULL,
NULL,
(GClassInitFunc) gst_mpeg_clock_class_init,
NULL,
NULL,
sizeof (GstMPEGClock),
4,
(GInstanceInitFunc) gst_mpeg_clock_init,
NULL
};
clock_type = g_type_register_static (GST_TYPE_SYSTEM_CLOCK, "GstMPEGClock",
&clock_info, 0);
}
return clock_type;
}
static void
gst_mpeg_clock_class_init (GstMPEGClockClass *klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstClockClass *gstclock_class;
gobject_class = (GObjectClass*) klass;
gstobject_class = (GstObjectClass*) klass;
gstclock_class = (GstClockClass*) klass;
parent_class = g_type_class_ref (GST_TYPE_SYSTEM_CLOCK);
gstclock_class->get_internal_time = gst_mpeg_clock_get_internal_time;
}
static void
gst_mpeg_clock_init (GstMPEGClock *clock)
{
gst_object_set_name (GST_OBJECT (clock), "GstMPEGClock");
}
GstClock*
gst_mpeg_clock_new (gchar *name, GstMPEGClockGetTimeFunc func, gpointer user_data)
{
GstMPEGClock *mpeg_clock = GST_MPEG_CLOCK (g_object_new (GST_TYPE_MPEG_CLOCK, NULL));
mpeg_clock->func = func;
mpeg_clock->user_data = user_data;
return GST_CLOCK (mpeg_clock);
}
static GstClockTime
gst_mpeg_clock_get_internal_time (GstClock *clock)
{
GstMPEGClock *mpeg_clock = GST_MPEG_CLOCK (clock);
return mpeg_clock->func (clock, mpeg_clock->user_data);
}

View file

@ -0,0 +1,71 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstclock.h: Header for clock subsystem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_MPEG_CLOCK_H__
#define __GST_MPEG_CLOCK_H__
#include <gst/gstsystemclock.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GST_TYPE_MPEG_CLOCK \
(gst_mpeg_clock_get_type())
#define GST_MPEG_CLOCK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MPEG_CLOCK,GstMPEGClock))
#define GST_MPEG_CLOCK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MPEG_CLOCK,GstMPEGClockClass))
#define GST_IS_MPEG_CLOCK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MPEG_CLOCK))
#define GST_IS_MPEG_CLOCK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MPEG_CLOCK))
typedef struct _GstMPEGClock GstMPEGClock;
typedef struct _GstMPEGClockClass GstMPEGClockClass;
typedef GstClockTime (*GstMPEGClockGetTimeFunc) (GstClock *clock, gpointer user_data);
struct _GstMPEGClock {
GstSystemClock clock;
GstMPEGClockGetTimeFunc func;
gpointer user_data;
};
struct _GstMPEGClockClass {
GstSystemClockClass parent_class;
};
GType gst_mpeg_clock_get_type (void);
GstClock* gst_mpeg_clock_new (gchar *name, GstMPEGClockGetTimeFunc func,
gpointer user_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_MPEG_CLOCK_H__ */

View file

@ -133,7 +133,8 @@ static gboolean gst_mpeg_demux_parse_packhead (GstMPEGParse *mpeg_parse, GstBuf
static gboolean gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer);
static gboolean gst_mpeg_demux_parse_packet (GstMPEGParse *mpeg_parse, GstBuffer *buffer);
static gboolean gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer);
static void gst_mpeg_demux_send_data (GstMPEGParse *mpeg_parse, GstData *data);
static void gst_mpeg_demux_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime time);
static void gst_mpeg_demux_handle_discont (GstMPEGParse *mpeg_parse);
static GstElementStateReturn
gst_mpeg_demux_change_state (GstElement *element);
@ -181,6 +182,7 @@ gst_mpeg_demux_class_init (GstMPEGDemuxClass *klass)
mpeg_parse_class->parse_packet = gst_mpeg_demux_parse_packet;
mpeg_parse_class->parse_pes = gst_mpeg_demux_parse_pes;
mpeg_parse_class->send_data = gst_mpeg_demux_send_data;
mpeg_parse_class->handle_discont = gst_mpeg_demux_handle_discont;
}
@ -209,12 +211,10 @@ gst_mpeg_demux_init (GstMPEGDemux *mpeg_demux)
mpeg_demux->private_2_offset = 0;
for (i=0;i<NUM_VIDEO_PADS;i++) {
mpeg_demux->video_pad[i] = NULL;
mpeg_demux->video_offset[i] = 0;
mpeg_demux->video_PTS[i] = 0;
}
for (i=0;i<NUM_AUDIO_PADS;i++) {
mpeg_demux->audio_pad[i] = NULL;
mpeg_demux->audio_offset[i] = 0;
mpeg_demux->audio_PTS[i] = 0;
}
@ -222,15 +222,57 @@ gst_mpeg_demux_init (GstMPEGDemux *mpeg_demux)
}
static void
gst_mpeg_demux_send_data (GstMPEGParse *mpeg_parse, GstData *data)
gst_mpeg_demux_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime time)
{
//GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
if (GST_IS_BUFFER (data)) {
gst_buffer_unref (GST_BUFFER (data));
}
else {
GstEvent *event = GST_EVENT (data);
gst_pad_event_default (mpeg_parse->sinkpad, event);
switch (GST_EVENT_TYPE (event)) {
default:
//g_print ("demux: default event %d\n", GST_EVENT_TYPE (event));
gst_pad_event_default (mpeg_parse->sinkpad, event);
break;
}
}
}
static void
gst_mpeg_demux_handle_discont (GstMPEGParse *mpeg_parse)
{
GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (mpeg_parse);
gint i;
gint64 current_time = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
GST_DEBUG (GST_CAT_EVENT, "mpegdemux: discont %llu\n", current_time);
for (i=0;i<NUM_VIDEO_PADS;i++) {
if (mpeg_demux->video_pad[i] &&
GST_PAD_IS_CONNECTED (mpeg_demux->video_pad[i]))
{
GstEvent *discont;
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
current_time, NULL);
mpeg_demux->video_PTS[i] = mpeg_parse->current_scr;
gst_pad_push (mpeg_demux->video_pad[i], GST_BUFFER (discont));
}
if (mpeg_demux->audio_pad[i] &&
GST_PAD_IS_CONNECTED (mpeg_demux->audio_pad[i]))
{
GstEvent *discont;
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
current_time, NULL);
mpeg_demux->audio_PTS[i] = mpeg_parse->current_scr;
gst_pad_push (mpeg_demux->audio_pad[i], GST_BUFFER (discont));
}
}
}
@ -362,7 +404,20 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
if (outpad && *outpad == NULL) {
*outpad = gst_pad_new_from_template (newtemp, name);
gst_pad_try_set_caps (*outpad, gst_pad_get_pad_template_caps (*outpad));
gst_pad_set_event_function (*outpad, gst_mpeg_parse_handle_src_event);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad));
if (GST_PAD_IS_CONNECTED (*outpad)) {
GstEvent *event;
gint64 current_time = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
current_time, NULL);
gst_pad_push (*outpad, GST_BUFFER (event));
}
}
else {
/* we won't be needing this. */
@ -398,7 +453,6 @@ gst_mpeg_demux_parse_packet (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
gint64 pts = -1;
guint16 datalen;
gulong outoffset = 0; /* wrong XXX FIXME */
GstPad **outpad = NULL;
GstBuffer *outbuf;
@ -515,14 +569,10 @@ done:
} else if ((id >= 0xC0) && (id <= 0xDF)) {
GST_DEBUG (0,"mpeg_demux::parse_packet: 0x%02X: we have an audio packet", id);
outpad = &mpeg_demux->audio_pad[id & 0x1F];
outoffset = mpeg_demux->audio_offset[id & 0x1F];
mpeg_demux->audio_offset[id & 0x1F] += datalen;
/* video */
} else if ((id >= 0xE0) && (id <= 0xEF)) {
GST_DEBUG (0,"mpeg_demux::parse_packet: 0x%02X: we have a video packet", id);
outpad = &mpeg_demux->video_pad[id & 0x0F];
outoffset = mpeg_demux->video_offset[id & 0x1F];
mpeg_demux->video_offset[id & 0x1F] += datalen;
if (pts == -1)
pts = mpeg_demux->video_PTS[id & 0x1F];
else
@ -550,13 +600,13 @@ done:
outbuf = gst_buffer_create_sub (buffer, headerlen+4, datalen);
GST_BUFFER_OFFSET (outbuf) = outoffset;
if (pts != -1) {
GST_BUFFER_TIMESTAMP (outbuf) = (pts * 100LL)/9LL;
GST_BUFFER_TIMESTAMP (outbuf) = (pts * GST_SECOND)/90000LL;
}
else {
GST_BUFFER_TIMESTAMP (outbuf) = -1LL;
}
GST_DEBUG (0,"mpeg_demux::parse_packet: pushing buffer of len %d id %d, ts %lld",
datalen, id, GST_BUFFER_TIMESTAMP (outbuf));
gst_pad_push ((*outpad), outbuf);
@ -576,7 +626,6 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
guint8 header_data_length = 0;
guint16 datalen;
gulong outoffset = 0; /* wrong XXX FIXME */
guint16 headerlen;
guint8 ps_id_code = 0x80;
@ -621,14 +670,14 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
pts |= (*buf++ & 0xFE) << 14;
pts |= *buf++ << 7;
pts |= (*buf++ & 0xFE) >> 1;
GST_DEBUG (0, "mpeg_demux::parse_packet: %x PTS = %llu", id, (pts*1000000LL)/90000LL);
GST_DEBUG (0, "mpeg_demux::parse_packet: %x PTS = %llu", id, (pts*GST_SECOND)/90000LL);
}
if ((flags2 & 0x40)) {
GST_DEBUG (0, "mpeg_demux::parse_packet: %x DTS foundu", id);
GST_DEBUG (0, "mpeg_demux::parse_packet: %x DTS found", id);
buf += 5;
}
if ((flags2 & 0x20)) {
GST_DEBUG (0, "mpeg_demux::parse_packet: %x ESCR foundu", id);
GST_DEBUG (0, "mpeg_demux::parse_packet: %x ESCR found", id);
buf += 6;
}
if ((flags2 & 0x10)) {
@ -637,7 +686,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
es_rate = (*buf++ & 0x07) << 14;
es_rate |= (*buf++ ) << 7;
es_rate |= (*buf++ & 0xFE) >> 1;
GST_DEBUG (0, "mpeg_demux::parse_packet: %x ES Rate foundu", id);
GST_DEBUG (0, "mpeg_demux::parse_packet: %x ES Rate found", id);
}
/* FIXME: lots of PES parsing missing here... */
@ -663,8 +712,6 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
/* scrap first 4 bytes (so-called "mystery AC3 tag") */
headerlen += 4;
datalen -= 4;
outoffset = mpeg_demux->private_1_offset[ps_id_code - 0x80];
mpeg_demux->private_1_offset[ps_id_code - 0x80] += datalen;
}
else if ((ps_id_code >= 0x20) && (ps_id_code <= 0x2f)) {
GST_DEBUG (0,"mpeg_demux: we have a subtitle_stream packet, track %d",
@ -672,21 +719,15 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
outpad = &mpeg_demux->subtitle_pad[ps_id_code - 0x20];
headerlen += 1;
datalen -= 1;
outoffset = mpeg_demux->subtitle_offset[ps_id_code - 0x20];
mpeg_demux->subtitle_offset[ps_id_code - 0x20] += datalen;
}
/* private_stream_1 */
} else if (id == 0xBF) {
GST_DEBUG (0,"mpeg_demux: we have a private_stream_2 packet");
outpad = &mpeg_demux->private_2_pad;
outoffset = mpeg_demux->private_2_offset;
mpeg_demux->private_2_offset += datalen;
/* audio */
} else if ((id >= 0xC0) && (id <= 0xDF)) {
GST_DEBUG (0,"mpeg_demux: we have an audio packet");
outpad = &mpeg_demux->audio_pad[id - 0xC0];
outoffset = mpeg_demux->audio_offset[id & 0x1F];
mpeg_demux->audio_offset[id & 0x1F] += datalen;
if (pts == -1)
pts = mpeg_demux->audio_PTS[id & 0x1F];
else
@ -695,8 +736,6 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
} else if ((id >= 0xE0) && (id <= 0xEF)) {
GST_DEBUG (0,"mpeg_demux: we have a video packet");
outpad = &mpeg_demux->video_pad[id - 0xE0];
outoffset = mpeg_demux->video_offset[id & 0x0F];
mpeg_demux->video_offset[id & 0x0F] += datalen;
if (pts == -1)
pts = mpeg_demux->video_PTS[id & 0x1F];
else
@ -747,6 +786,8 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
/* create the pad and add it to self */
(*outpad) = gst_pad_new_from_template (newtemp, name);
gst_pad_try_set_caps ((*outpad), gst_pad_get_pad_template_caps (*outpad));
gst_pad_set_event_function (*outpad, gst_mpeg_parse_handle_src_event);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
gst_element_add_pad(GST_ELEMENT(mpeg_demux),(*outpad));
}
else {
@ -762,8 +803,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
GST_DEBUG (0,"mpeg_demux: creating subbuffer len %d", datalen);
outbuf = gst_buffer_create_sub (buffer, headerlen+4, datalen);
GST_BUFFER_OFFSET(outbuf) = outoffset;
GST_BUFFER_TIMESTAMP(outbuf) = (pts*100LL)/9LL;
GST_BUFFER_TIMESTAMP(outbuf) = (pts * GST_SECOND) / 90000LL;
gst_pad_push((*outpad),outbuf);
}
@ -783,11 +823,9 @@ gst_mpeg_demux_change_state (GstElement *element)
break;
case GST_STATE_PAUSED_TO_READY:
for (i=0;i<NUM_VIDEO_PADS;i++) {
mpeg_demux->video_offset[i] = 0;
mpeg_demux->video_PTS[i] = 0;
}
for (i=0;i<NUM_AUDIO_PADS;i++) {
mpeg_demux->audio_offset[i] = 0;
mpeg_demux->audio_PTS[i] = 0;
}
break;

View file

@ -101,11 +101,9 @@ struct _GstMPEGDemux {
gulong private_2_offset;
GstPad *video_pad[NUM_VIDEO_PADS];
gulong video_offset[NUM_VIDEO_PADS];
gint64 video_PTS[NUM_VIDEO_PADS];
GstPad *audio_pad[NUM_AUDIO_PADS];
gulong audio_offset[NUM_AUDIO_PADS];
gint64 audio_PTS[NUM_AUDIO_PADS];
};

View file

@ -96,7 +96,7 @@ parse_generic (GstMPEGPacketize *packetize)
GstBuffer *outbuf;
guint32 got_bytes;
GST_DEBUG (0, "packetize: in parse_syshead");
GST_DEBUG (0, "packetize: in parse_generic");
got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&buf, 2 + 4);
if (got_bytes < 6) return NULL;
@ -173,7 +173,6 @@ find_start_code (GstMPEGPacketize *packetize)
code = (code << 8) | buf[offset++];
GST_DEBUG (0, " code = %08x", code);
/* g_print (" code = %08x\n", code); */
if (offset == chunksize) {
if (!gst_bytestream_flush (bs, offset))
@ -204,6 +203,15 @@ gst_mpeg_packetize_read (GstMPEGPacketize *packetize)
else {
GST_DEBUG (0, "packetize: have chunk 0x%02X", packetize->id);
if (packetize->type == GST_MPEG_PACKETIZE_SYSTEM) {
if (packetize->resync) {
if (packetize->id != PACK_START_CODE) {
if (!gst_bytestream_flush (packetize->bs, 4))
got_event = TRUE;
continue;
}
packetize->resync = FALSE;
}
switch (packetize->id) {
case PACK_START_CODE:
outbuf = parse_packhead (packetize);
@ -244,6 +252,7 @@ gst_mpeg_packetize_read (GstMPEGPacketize *packetize)
switch (etype) {
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG (GST_CAT_EVENT, "packetize: discont\n");
gst_bytestream_flush_fast (packetize->bs, remaining);
break;
}

View file

@ -64,6 +64,7 @@ struct _GstMPEGPacketize {
GstMPEGPacketizeType type;
gboolean MPEG2;
gboolean resync;
};
GstMPEGPacketize* gst_mpeg_packetize_new (GstPad *pad, GstMPEGPacketizeType type);

View file

@ -20,6 +20,7 @@
/*#define GST_DEBUG_ENABLED*/
#include "gstmpegparse.h"
#include "gstmpegclock.h"
/* elementfactory information */
static GstElementDetails mpeg_parse_details = {
@ -44,6 +45,7 @@ enum {
ARG_0,
ARG_BIT_RATE,
ARG_MPEG2,
ARG_SYNC,
/* FILL ME */
};
@ -72,18 +74,25 @@ GST_PAD_TEMPLATE_FACTORY (src_factory,
)
);
static void gst_mpeg_parse_class_init (GstMPEGParseClass *klass);
static void gst_mpeg_parse_init (GstMPEGParse *mpeg_parse);
static void gst_mpeg_parse_class_init (GstMPEGParseClass *klass);
static void gst_mpeg_parse_init (GstMPEGParse *mpeg_parse);
static GstElementStateReturn
gst_mpeg_parse_change_state (GstElement *element);
gst_mpeg_parse_change_state (GstElement *element);
static gboolean gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer);
static void gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data);
static void gst_mpeg_parse_set_clock (GstElement *element, GstClock *clock);
static GstClock* gst_mpeg_parse_get_clock (GstElement *element);
static GstClockTime gst_mpeg_parse_get_time (GstClock *clock, gpointer data);
static void gst_mpeg_parse_loop (GstElement *element);
static gboolean gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer);
static void gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime time);
static void gst_mpeg_parse_handle_discont (GstMPEGParse *mpeg_parse);
static void gst_mpeg_parse_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void gst_mpeg_parse_loop (GstElement *element);
static void gst_mpeg_parse_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void gst_mpeg_parse_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static GstElementClass *parent_class = NULL;
/*static guint gst_mpeg_parse_signals[LAST_SIGNAL] = { 0 };*/
@ -126,8 +135,12 @@ gst_mpeg_parse_class_init (GstMPEGParseClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MPEG2,
g_param_spec_boolean ("mpeg2", "mpeg2", "is this an mpeg2 stream",
FALSE, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Synchronize on the stream SCR",
TRUE, G_PARAM_READWRITE));
gobject_class->get_property = gst_mpeg_parse_get_property;
gobject_class->set_property = gst_mpeg_parse_set_property;
gstelement_class->change_state = gst_mpeg_parse_change_state;
@ -136,7 +149,7 @@ gst_mpeg_parse_class_init (GstMPEGParseClass *klass)
klass->parse_packet = NULL;
klass->parse_pes = NULL;
klass->send_data = gst_mpeg_parse_send_data;
klass->handle_discont = gst_mpeg_parse_handle_discont;
}
static void
@ -145,30 +158,72 @@ gst_mpeg_parse_init (GstMPEGParse *mpeg_parse)
mpeg_parse->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_element_add_pad(GST_ELEMENT(mpeg_parse),mpeg_parse->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (mpeg_parse), gst_mpeg_parse_loop);
mpeg_parse->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (src_factory), "src");
gst_element_add_pad(GST_ELEMENT(mpeg_parse),mpeg_parse->srcpad);
gst_pad_set_event_function (mpeg_parse->srcpad, gst_mpeg_parse_handle_src_event);
gst_pad_set_query_function (mpeg_parse->srcpad, gst_mpeg_parse_handle_src_query);
gst_element_set_loop_function (GST_ELEMENT (mpeg_parse), gst_mpeg_parse_loop);
/* initialize parser state */
mpeg_parse->packetize = NULL;
mpeg_parse->next_ts = 0;
mpeg_parse->current_scr = 0;
mpeg_parse->previous_scr = 0;
mpeg_parse->sync = TRUE;
/* zero counters (should be done at RUNNING?) */
mpeg_parse->bit_rate = 0;
mpeg_parse->discont_pending = FALSE;
mpeg_parse->scr_pending = TRUE;
mpeg_parse->provided_clock = gst_mpeg_clock_new ("MPEGParseClock",
gst_mpeg_parse_get_time, mpeg_parse);
GST_ELEMENT (mpeg_parse)->getclockfunc = gst_mpeg_parse_get_clock;
GST_ELEMENT (mpeg_parse)->setclockfunc = gst_mpeg_parse_set_clock;
GST_FLAG_SET (mpeg_parse, GST_ELEMENT_EVENT_AWARE);
}
static GstClock*
gst_mpeg_parse_get_clock (GstElement *element)
{
//GstMPEGParse *parse = GST_MPEG_PARSE (element);
//return parse->provided_clock;
return NULL;
}
static void
gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data)
gst_mpeg_parse_set_clock (GstElement *element, GstClock *clock)
{
GstMPEGParse *parse = GST_MPEG_PARSE (element);
parse->clock = clock;
}
static GstClockTime
gst_mpeg_parse_get_time (GstClock *clock, gpointer data)
{
GstMPEGParse *parse = GST_MPEG_PARSE (data);
return MPEGTIME_TO_GSTTIME (parse->previous_scr);
}
static void
gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime time)
{
if (GST_IS_EVENT (data)) {
gst_pad_event_default (mpeg_parse->sinkpad, GST_EVENT (data));
GstEvent *event = GST_EVENT (data);
switch (GST_EVENT_TYPE (event)) {
default:
gst_pad_event_default (mpeg_parse->sinkpad, event);
break;
}
}
else {
guint64 size = GST_BUFFER_SIZE (data);
if (!GST_PAD_CAPS (mpeg_parse->srcpad)) {
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
@ -182,14 +237,24 @@ gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data)
));
}
GST_BUFFER_TIMESTAMP (data) = mpeg_parse->next_ts;
gst_pad_push (mpeg_parse->srcpad, GST_BUFFER (data));
mpeg_parse->next_ts += ((size * 1000000.0) / (mpeg_parse->bit_rate));
GST_DEBUG (0, "mpeg_parse: next_ts %lld", mpeg_parse->next_ts);
GST_BUFFER_TIMESTAMP (data) = time;
GST_DEBUG (0, "mpeg_parse: current_scr %lld", time);
gst_pad_push (mpeg_parse->srcpad, GST_BUFFER (data));
}
}
static void
gst_mpeg_parse_handle_discont (GstMPEGParse *mpeg_parse)
{
GstEvent *event;
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr), NULL);
gst_pad_push (mpeg_parse->srcpad, GST_BUFFER (event));
}
static gboolean
gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
{
@ -216,7 +281,8 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
buf += 6;
new_rate = (GUINT32_FROM_BE ((*(guint32 *) buf)) & 0xfffffc00) >> 10;
new_rate *= 133; /* FIXME trial and error */
//new_rate *= 133; /* FIXME trial and error */
new_rate *= 223; /* FIXME trial and error */
}
else {
scr = (scr1 & 0x0e000000) << 5;
@ -229,8 +295,17 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
new_rate *= 400;
}
GST_DEBUG (0, "mpeg_parse: SCR is %llu", scr);
mpeg_parse->next_ts = (scr*100)/9;
mpeg_parse->previous_scr = mpeg_parse->current_scr;
mpeg_parse->current_scr = scr;
GST_DEBUG (0, "mpeg_parse: SCR is %llu (%llu)", scr,
MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr));
if (mpeg_parse->previous_scr > mpeg_parse->current_scr) {
mpeg_parse->discont_pending = TRUE;
}
mpeg_parse->scr_pending = FALSE;
if (mpeg_parse->bit_rate != new_rate) {
mpeg_parse->bit_rate = new_rate;
@ -251,6 +326,7 @@ gst_mpeg_parse_loop (GstElement *element)
GstData *data;
guint id;
gboolean mpeg2;
GstClockTime time;
data = gst_mpeg_packetize_read (mpeg_parse->packetize);
@ -292,8 +368,150 @@ gst_mpeg_parse_loop (GstElement *element)
}
}
if (CLASS (mpeg_parse)->send_data)
CLASS (mpeg_parse)->send_data (mpeg_parse, data);
time = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
if (GST_IS_EVENT (data)) {
GstEvent *event = GST_EVENT (data);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG (GST_CAT_EVENT, "event: %d\n", GST_EVENT_TYPE (data));
mpeg_parse->discont_pending = TRUE;
mpeg_parse->scr_pending = TRUE;
mpeg_parse->packetize->resync = TRUE;
gst_event_free (event);
return;
default:
break;
}
if (CLASS (mpeg_parse)->send_data)
CLASS (mpeg_parse)->send_data (mpeg_parse, data, time);
}
else {
guint64 size;
/* we're not sending data as long as no new SCR was found */
if (mpeg_parse->discont_pending) {
if (!mpeg_parse->scr_pending) {
if (CLASS (mpeg_parse)->handle_discont) {
CLASS (mpeg_parse)->handle_discont (mpeg_parse);
}
mpeg_parse->discont_pending = FALSE;
}
else {
GST_DEBUG (0, "waiting for SCR\n");
}
gst_buffer_unref (GST_BUFFER (data));
return;
}
if (CLASS (mpeg_parse)->send_data)
CLASS (mpeg_parse)->send_data (mpeg_parse, data, time);
if (mpeg_parse->clock && mpeg_parse->sync) {
gst_element_clock_wait (GST_ELEMENT (mpeg_parse), mpeg_parse->clock, time, NULL);
}
size = GST_BUFFER_SIZE (data);
/* we are interpolating the scr here */
mpeg_parse->current_scr += ((size * 90000LL) / (mpeg_parse->bit_rate));
}
}
gboolean
gst_mpeg_parse_handle_src_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value)
{
gboolean res = TRUE;
GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (gst_pad_get_parent (pad));
switch (type) {
case GST_PAD_QUERY_TOTAL:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
case GST_FORMAT_TIME:
{
GstFormat peer_format;
gint64 peer_value;
if (mpeg_parse->bit_rate == 0)
return FALSE;
peer_format = GST_FORMAT_BYTES;
if (gst_pad_query (GST_PAD_PEER (mpeg_parse->sinkpad),
GST_PAD_QUERY_TOTAL, &peer_format, &peer_value))
{
/* multiply bywith 8 because vbr is in bits/second */
*value = peer_value * 8 * GST_SECOND / mpeg_parse->bit_rate;
}
else
res = FALSE;
break;
}
default:
res = FALSE;
break;
}
break;
}
case GST_PAD_QUERY_POSITION:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
case GST_FORMAT_TIME:
*value = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
break;
default:
res = FALSE;
break;
}
break;
}
default:
res = FALSE;
break;
}
return res;
}
gboolean
gst_mpeg_parse_handle_src_event (GstPad *pad, GstEvent *event)
{
gboolean res = TRUE;
GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
{
guint64 desired_offset;
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_TIME) {
return FALSE;
}
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
}
desired_offset = mpeg_parse->bit_rate * GST_EVENT_SEEK_OFFSET (event) / (8 * GST_SECOND);
if (!gst_bytestream_seek (mpeg_parse->packetize->bs, desired_offset, GST_SEEK_METHOD_SET)) {
return FALSE;
}
break;
}
default:
res = FALSE;
break;
}
return res;
}
static GstElementStateReturn
@ -344,6 +562,25 @@ gst_mpeg_parse_get_property (GObject *object, guint prop_id, GValue *value, GPar
}
}
static void
gst_mpeg_parse_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
GstMPEGParse *mpeg_parse;
/* it's not null if we got it, but it might not be ours */
mpeg_parse = GST_MPEG_PARSE(object);
switch (prop_id) {
case ARG_SYNC:
mpeg_parse->sync = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
gboolean
gst_mpeg_parse_plugin_init (GModule *module, GstPlugin *plugin)

View file

@ -46,19 +46,29 @@ extern "C" {
#define GST_MPEG_PARSE_IS_MPEG2(parse) (GST_MPEG_PACKETIZE_IS_MPEG2 (GST_MPEG_PARSE (parse)->packetize))
#define MPEGTIME_TO_GSTTIME(time) (((time) * GST_SECOND) / 90000LL)
typedef struct _GstMPEGParse GstMPEGParse;
typedef struct _GstMPEGParseClass GstMPEGParseClass;
struct _GstMPEGParse {
GstElement element;
GstPad *sinkpad, *srcpad;
GstPad *sinkpad, *srcpad;
GstMPEGPacketize *packetize;
/* pack header values */
guint32 bit_rate;
guint64 next_ts;
guint32 bit_rate;
guint64 current_scr;
guint64 previous_scr;
gboolean discont_pending;
gboolean scr_pending;
GstClock *provided_clock;
GstClock *clock;
gboolean sync;
};
struct _GstMPEGParseClass {
@ -71,13 +81,17 @@ struct _GstMPEGParseClass {
gboolean (*parse_pes) (GstMPEGParse *parse, GstBuffer *buffer);
/* optional method to send out the data */
void (*send_data) (GstMPEGParse *parse, GstData *data);
void (*send_data) (GstMPEGParse *parse, GstData *data, GstClockTime time);
void (*handle_discont) (GstMPEGParse *parse);
};
GType gst_mpeg_parse_get_type(void);
gboolean gst_mpeg_parse_plugin_init (GModule *module, GstPlugin *plugin);
gboolean gst_mpeg_parse_plugin_init (GModule *module, GstPlugin *plugin);
gboolean gst_mpeg_parse_handle_src_event (GstPad *pad, GstEvent *event);
gboolean gst_mpeg_parse_handle_src_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value);
#ifdef __cplusplus
}