diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /ext/swfdec | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) | |
download | gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2 gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'ext/swfdec')
-rw-r--r-- | ext/swfdec/gstswfdec.c | 544 | ||||
-rw-r--r-- | ext/swfdec/gstswfdec.h | 65 |
2 files changed, 303 insertions, 306 deletions
diff --git a/ext/swfdec/gstswfdec.c b/ext/swfdec/gstswfdec.c index d958c882..06723d1e 100644 --- a/ext/swfdec/gstswfdec.c +++ b/ext/swfdec/gstswfdec.c @@ -26,80 +26,77 @@ #include <gst/video/video.h> /* elementfactory information */ -static GstElementDetails gst_swfdec_details = GST_ELEMENT_DETAILS ( - "SWF video decoder", - "Codec/Decoder/Video", - "Uses libswfdec to decode Flash video streams", - "David Schleef <ds@schleef.org>" -); +static GstElementDetails gst_swfdec_details = +GST_ELEMENT_DETAILS ("SWF video decoder", + "Codec/Decoder/Video", + "Uses libswfdec to decode Flash video streams", + "David Schleef <ds@schleef.org>"); /* Swfdec signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, /* FILL ME */ }; static GstStaticPadTemplate video_template_factory = -GST_STATIC_PAD_TEMPLATE ( - "video_00", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx) -); +GST_STATIC_PAD_TEMPLATE ("video_00", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx) + ); static GstStaticPadTemplate audio_template_factory = -GST_STATIC_PAD_TEMPLATE ( - "audio_00", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-int, " - "rate = (int) 44100, " - "channels = (int) 2, " - "endianness = (int) BYTE_ORDER, " - "width = (int) 16, " - "depth = (int) 16, " - "signed = (boolean) true, " - "buffer-frames = (int) [ 1, MAX ]") -); +GST_STATIC_PAD_TEMPLATE ("audio_00", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int, " + "rate = (int) 44100, " + "channels = (int) 2, " + "endianness = (int) BYTE_ORDER, " + "width = (int) 16, " + "depth = (int) 16, " + "signed = (boolean) true, " "buffer-frames = (int) [ 1, MAX ]") + ); static GstStaticPadTemplate sink_template_factory = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( "application/x-shockwave-flash") -); +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-shockwave-flash") + ); -static void gst_swfdec_base_init (gpointer g_class); -static void gst_swfdec_class_init (GstSwfdecClass *klass); -static void gst_swfdec_init (GstSwfdec *swfdec); +static void gst_swfdec_base_init (gpointer g_class); +static void gst_swfdec_class_init (GstSwfdecClass * klass); +static void gst_swfdec_init (GstSwfdec * swfdec); -static void gst_swfdec_dispose (GObject *object); +static void gst_swfdec_dispose (GObject * object); -static void gst_swfdec_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_swfdec_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_swfdec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_swfdec_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); #if 0 -static gboolean gst_swfdec_src_event (GstPad *pad, GstEvent *event); +static gboolean gst_swfdec_src_event (GstPad * pad, GstEvent * event); #endif -static gboolean gst_swfdec_src_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); +static gboolean gst_swfdec_src_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); #if 0 -static gboolean gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); -static gboolean gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); +static gboolean gst_swfdec_convert_sink (GstPad * pad, GstFormat src_format, + gint64 src_value, GstFormat * dest_format, gint64 * dest_value); +static gboolean gst_swfdec_convert_src (GstPad * pad, GstFormat src_format, + gint64 src_value, GstFormat * dest_format, gint64 * dest_value); #endif -static GstElementStateReturn gst_swfdec_change_state (GstElement *element); +static GstElementStateReturn gst_swfdec_change_state (GstElement * element); static GstElementClass *parent_class = NULL; @@ -111,55 +108,56 @@ gst_swfdec_get_type (void) if (!swfdec_type) { static const GTypeInfo swfdec_info = { - sizeof(GstSwfdecClass), + sizeof (GstSwfdecClass), gst_swfdec_base_init, NULL, - (GClassInitFunc)gst_swfdec_class_init, + (GClassInitFunc) gst_swfdec_class_init, NULL, NULL, - sizeof(GstSwfdec), + sizeof (GstSwfdec), 0, - (GInstanceInitFunc)gst_swfdec_init, + (GInstanceInitFunc) gst_swfdec_init, }; - swfdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSwfdec", &swfdec_info, 0); + swfdec_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstSwfdec", &swfdec_info, 0); } return swfdec_type; } static void -gst_swfdec_base_init(gpointer g_class) +gst_swfdec_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_set_details (element_class, &gst_swfdec_details); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&video_template_factory)); + gst_static_pad_template_get (&video_template_factory)); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&audio_template_factory)); + gst_static_pad_template_get (&audio_template_factory)); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_template_factory)); + gst_static_pad_template_get (&sink_template_factory)); } static void -gst_swfdec_class_init(GstSwfdecClass *klass) +gst_swfdec_class_init (GstSwfdecClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gobject_class->set_property = gst_swfdec_set_property; - gobject_class->get_property = gst_swfdec_get_property; - gobject_class->dispose = gst_swfdec_dispose; + gobject_class->set_property = gst_swfdec_set_property; + gobject_class->get_property = gst_swfdec_get_property; + gobject_class->dispose = gst_swfdec_dispose; gstelement_class->change_state = gst_swfdec_change_state; } static GstCaps * -gst_swfdec_video_getcaps (GstPad *pad) +gst_swfdec_video_getcaps (GstPad * pad) { GstSwfdec *swfdec; GstCaps *caps; @@ -169,15 +167,14 @@ gst_swfdec_video_getcaps (GstPad *pad) caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); if (swfdec->have_format) { gst_caps_set_simple (caps, - "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, - NULL); + "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, NULL); } return caps; } static GstPadLinkReturn -gst_swfdec_video_link (GstPad *pad, const GstCaps *caps) +gst_swfdec_video_link (GstPad * pad, const GstCaps * caps) { GstSwfdec *swfdec; GstStructure *structure; @@ -215,164 +212,162 @@ copy_image (void *dest, void *src, int width, int height) { guint8 *d = dest; guint8 *s = src; - int x,y; + int x, y; - for(y=0;y<height;y++){ - for(x=0;x<width;x++){ + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; d[3] = 0; - d+=4; - s+=3; + d += 4; + s += 3; } } - + } static void -gst_swfdec_loop(GstElement *element) +gst_swfdec_loop (GstElement * element) { - GstSwfdec *swfdec; - GstBuffer *buf = NULL; - int ret; + GstSwfdec *swfdec; + GstBuffer *buf = NULL; + int ret; - g_return_if_fail(element != NULL); - g_return_if_fail(GST_IS_SWFDEC(element)); + g_return_if_fail (element != NULL); + g_return_if_fail (GST_IS_SWFDEC (element)); - swfdec = GST_SWFDEC(element); + swfdec = GST_SWFDEC (element); - if(!swfdec->videopad){ - } + if (!swfdec->videopad) { + } - ret = swfdec_decoder_parse(swfdec->state); - if(ret==SWF_NEEDBITS){ - buf = GST_BUFFER (gst_pad_pull(swfdec->sinkpad)); - if(GST_IS_EVENT(buf)){ - switch (GST_EVENT_TYPE (buf)) { - case GST_EVENT_EOS: - GST_DEBUG("got eos"); - break; - default: - GST_DEBUG("got event"); - break; - } - - }else{ - if(!GST_BUFFER_DATA(buf)){ - GST_DEBUG("expected non-null buffer"); - } - ret = swfdec_decoder_addbits(swfdec->state, - GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); - } - } + ret = swfdec_decoder_parse (swfdec->state); + if (ret == SWF_NEEDBITS) { + buf = GST_BUFFER (gst_pad_pull (swfdec->sinkpad)); + if (GST_IS_EVENT (buf)) { + switch (GST_EVENT_TYPE (buf)) { + case GST_EVENT_EOS: + GST_DEBUG ("got eos"); + break; + default: + GST_DEBUG ("got event"); + break; + } - if(ret==SWF_CHANGE){ - GstCaps *caps; - GstPadLinkReturn link_ret; - - swfdec_decoder_get_image_size(swfdec->state, - &swfdec->width, &swfdec->height); - swfdec_decoder_get_rate(swfdec->state, &swfdec->rate); - swfdec->interval = GST_SECOND / swfdec->rate; - - caps = gst_caps_copy (gst_pad_get_pad_template_caps ( - swfdec->videopad)); - swfdec_decoder_get_rate (swfdec->state, &swfdec->frame_rate); - gst_caps_set_simple (caps, - "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, - "height",G_TYPE_INT,swfdec->height, - "width",G_TYPE_INT,swfdec->width, - NULL); - link_ret = gst_pad_try_set_caps (swfdec->videopad, caps); - if (GST_PAD_LINK_SUCCESSFUL (link_ret)){ - /* good */ - } else { - GST_ELEMENT_ERROR (swfdec, CORE, NEGOTIATION, (NULL), (NULL)); - return; - } - swfdec->have_format = TRUE; - - return; - } + } else { + if (!GST_BUFFER_DATA (buf)) { + GST_DEBUG ("expected non-null buffer"); + } + ret = swfdec_decoder_addbits (swfdec->state, + GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); + } + } - if(ret==SWF_IMAGE){ - GstBuffer *newbuf = NULL; - unsigned char *data; - int len; + if (ret == SWF_CHANGE) { + GstCaps *caps; + GstPadLinkReturn link_ret; - /* video stuff */ - //newbuf = gst_buffer_new(); - //GST_BUFFER_SIZE(newbuf) = swfdec->width * swfdec->height * 3; + swfdec_decoder_get_image_size (swfdec->state, + &swfdec->width, &swfdec->height); + swfdec_decoder_get_rate (swfdec->state, &swfdec->rate); + swfdec->interval = GST_SECOND / swfdec->rate; - newbuf = gst_pad_alloc_buffer (swfdec->videopad, GST_BUFFER_OFFSET_NONE, - swfdec->width * 4 * swfdec->height); + caps = gst_caps_copy (gst_pad_get_pad_template_caps (swfdec->videopad)); + swfdec_decoder_get_rate (swfdec->state, &swfdec->frame_rate); + gst_caps_set_simple (caps, + "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, + "height", G_TYPE_INT, swfdec->height, + "width", G_TYPE_INT, swfdec->width, NULL); + link_ret = gst_pad_try_set_caps (swfdec->videopad, caps); + if (GST_PAD_LINK_SUCCESSFUL (link_ret)) { + /* good */ + } else { + GST_ELEMENT_ERROR (swfdec, CORE, NEGOTIATION, (NULL), (NULL)); + return; + } + swfdec->have_format = TRUE; - swfdec_decoder_get_image(swfdec->state, &data); - copy_image (GST_BUFFER_DATA (newbuf), data, swfdec->width, - swfdec->height); - free (data); - //GST_BUFFER_DATA(newbuf) = data; + return; + } - swfdec->timestamp += swfdec->interval; - GST_BUFFER_TIMESTAMP(newbuf) = swfdec->timestamp; + if (ret == SWF_IMAGE) { + GstBuffer *newbuf = NULL; + unsigned char *data; + int len; - gst_pad_push(swfdec->videopad, GST_DATA (newbuf)); + /* video stuff */ + //newbuf = gst_buffer_new(); + //GST_BUFFER_SIZE(newbuf) = swfdec->width * swfdec->height * 3; - /* audio stuff */ + newbuf = gst_pad_alloc_buffer (swfdec->videopad, GST_BUFFER_OFFSET_NONE, + swfdec->width * 4 * swfdec->height); - data = swfdec_decoder_get_sound_chunk(swfdec->state, &len); - while(data){ - newbuf = gst_buffer_new(); + swfdec_decoder_get_image (swfdec->state, &data); + copy_image (GST_BUFFER_DATA (newbuf), data, swfdec->width, swfdec->height); + free (data); + //GST_BUFFER_DATA(newbuf) = data; - GST_BUFFER_SIZE(newbuf) = len; - GST_BUFFER_DATA(newbuf) = data; - GST_BUFFER_TIMESTAMP(newbuf) = swfdec->timestamp; + swfdec->timestamp += swfdec->interval; + GST_BUFFER_TIMESTAMP (newbuf) = swfdec->timestamp; - gst_pad_push(swfdec->audiopad, GST_DATA (newbuf)); + gst_pad_push (swfdec->videopad, GST_DATA (newbuf)); - data = swfdec_decoder_get_sound_chunk(swfdec->state, &len); - } - } + /* audio stuff */ - if(ret==SWF_EOF){ - gst_pad_push(swfdec->videopad, GST_DATA (gst_event_new (GST_EVENT_EOS))); - gst_pad_push(swfdec->audiopad, GST_DATA (gst_event_new (GST_EVENT_EOS))); - } + data = swfdec_decoder_get_sound_chunk (swfdec->state, &len); + while (data) { + newbuf = gst_buffer_new (); + + GST_BUFFER_SIZE (newbuf) = len; + GST_BUFFER_DATA (newbuf) = data; + GST_BUFFER_TIMESTAMP (newbuf) = swfdec->timestamp; + + gst_pad_push (swfdec->audiopad, GST_DATA (newbuf)); + + data = swfdec_decoder_get_sound_chunk (swfdec->state, &len); + } + } + + if (ret == SWF_EOF) { + gst_pad_push (swfdec->videopad, GST_DATA (gst_event_new (GST_EVENT_EOS))); + gst_pad_push (swfdec->audiopad, GST_DATA (gst_event_new (GST_EVENT_EOS))); + } } static void -gst_swfdec_init (GstSwfdec *swfdec) +gst_swfdec_init (GstSwfdec * swfdec) { /* create the sink and src pads */ - swfdec->sinkpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&sink_template_factory), "sink"); + swfdec->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&sink_template_factory), "sink"); gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->sinkpad); - swfdec->videopad = gst_pad_new_from_template( - gst_static_pad_template_get (&video_template_factory), - "video_00"); + swfdec->videopad = + gst_pad_new_from_template (gst_static_pad_template_get + (&video_template_factory), "video_00"); gst_pad_set_query_function (swfdec->videopad, - GST_DEBUG_FUNCPTR (gst_swfdec_src_query)); + GST_DEBUG_FUNCPTR (gst_swfdec_src_query)); gst_pad_set_getcaps_function (swfdec->videopad, gst_swfdec_video_getcaps); gst_pad_set_link_function (swfdec->videopad, gst_swfdec_video_link); - gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->videopad); + gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->videopad); - swfdec->audiopad = gst_pad_new_from_template( - gst_static_pad_template_get (&audio_template_factory), - "audio_00"); + swfdec->audiopad = + gst_pad_new_from_template (gst_static_pad_template_get + (&audio_template_factory), "audio_00"); gst_pad_set_query_function (swfdec->audiopad, - GST_DEBUG_FUNCPTR (gst_swfdec_src_query)); + GST_DEBUG_FUNCPTR (gst_swfdec_src_query)); + + gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->audiopad); - gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->audiopad); - - gst_element_set_loop_function(GST_ELEMENT(swfdec), gst_swfdec_loop); + gst_element_set_loop_function (GST_ELEMENT (swfdec), gst_swfdec_loop); /* initialize the swfdec decoder state */ - swfdec->state = swfdec_decoder_new(); - g_return_if_fail(swfdec->state != NULL); + swfdec->state = swfdec_decoder_new (); + g_return_if_fail (swfdec->state != NULL); - swfdec_decoder_set_colorspace(swfdec->state, SWF_COLORSPACE_RGB888); + swfdec_decoder_set_colorspace (swfdec->state, SWF_COLORSPACE_RGB888); GST_FLAG_SET (GST_ELEMENT (swfdec), GST_ELEMENT_EVENT_AWARE); @@ -380,7 +375,7 @@ gst_swfdec_init (GstSwfdec *swfdec) } static void -gst_swfdec_dispose (GObject *object) +gst_swfdec_dispose (GObject * object) { //GstSwfdec *swfdec = GST_SWFDEC (object); @@ -392,27 +387,27 @@ gst_swfdec_dispose (GObject *object) #if 0 static gboolean -gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_swfdec_convert_sink (GstPad * pad, GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { gboolean res = TRUE; GstSwfdec *swfdec; - + swfdec = GST_SWFDEC (gst_pad_get_parent (pad)); switch (src_format) { case GST_FORMAT_BYTES: switch (*dest_format) { - case GST_FORMAT_TIME: - default: - res = FALSE; + case GST_FORMAT_TIME: + default: + res = FALSE; } break; case GST_FORMAT_TIME: switch (*dest_format) { - case GST_FORMAT_BYTES: - default: - res = FALSE; + case GST_FORMAT_BYTES: + default: + res = FALSE; } break; default: @@ -424,53 +419,54 @@ gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value, #if 0 static gboolean -gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_swfdec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { gboolean res = TRUE; GstSwfdec *swfdec; - + swfdec = GST_SWFDEC (gst_pad_get_parent (pad)); switch (src_format) { case GST_FORMAT_BYTES: switch (*dest_format) { - case GST_FORMAT_TIME: - default: - res = FALSE; + case GST_FORMAT_TIME: + default: + res = FALSE; } break; case GST_FORMAT_TIME: switch (*dest_format) { - case GST_FORMAT_BYTES: - *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2) * - video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND; + case GST_FORMAT_BYTES: + *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2) * + video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND; break; - case GST_FORMAT_DEFAULT: - *dest_value = src_value * video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND; + case GST_FORMAT_DEFAULT: + *dest_value = + src_value * video_rates[swfdec->decoder->frame_rate_code] / + GST_SECOND; break; - default: - res = FALSE; + default: + res = FALSE; } break; case GST_FORMAT_DEFAULT: switch (*dest_format) { - case GST_FORMAT_TIME: + case GST_FORMAT_TIME: if (video_rates[swfdec->decoder->frame_rate_code] != 0.0) { *dest_value = src_value * GST_SECOND / - video_rates[swfdec->decoder->frame_rate_code]; - } - else + video_rates[swfdec->decoder->frame_rate_code]; + } else res = FALSE; break; - case GST_FORMAT_BYTES: + case GST_FORMAT_BYTES: *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2); break; - case GST_FORMAT_DEFAULT: + case GST_FORMAT_DEFAULT: *dest_value = src_value; break; - default: - res = FALSE; + default: + res = FALSE; } break; default: @@ -480,9 +476,9 @@ gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value, } #endif -static gboolean -gst_swfdec_src_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +static gboolean +gst_swfdec_src_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { gboolean res = TRUE; GstSwfdec *swfdec; @@ -493,31 +489,31 @@ gst_swfdec_src_query (GstPad *pad, GstQueryType type, case GST_QUERY_TOTAL: { switch (*format) { - case GST_FORMAT_TIME: + case GST_FORMAT_TIME: { int n_frames; int ret; - res = FALSE; - ret = swfdec_decoder_get_n_frames(swfdec->state, &n_frames); - if(ret == SWF_OK){ + res = FALSE; + ret = swfdec_decoder_get_n_frames (swfdec->state, &n_frames); + if (ret == SWF_OK) { *value = n_frames * swfdec->interval; - res = TRUE; + res = TRUE; } - break; + break; } - default: + default: res = FALSE; - break; + break; } break; } case GST_QUERY_POSITION: { switch (*format) { - default: - res = FALSE; - break; + default: + res = FALSE; + break; } break; } @@ -530,35 +526,34 @@ gst_swfdec_src_query (GstPad *pad, GstQueryType type, } #if 0 -static gboolean -gst_swfdec_src_event (GstPad *pad, GstEvent *event) +static gboolean +gst_swfdec_src_event (GstPad * pad, GstEvent * event) { gboolean res = TRUE; GstSwfdec *swfdec; static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES }; -#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */ +#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */ gint i; swfdec = GST_SWFDEC (gst_pad_get_parent (pad)); switch (GST_EVENT_TYPE (event)) { - /* the all-formats seek logic */ + /* 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_pad_convert (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; + 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 */ @@ -569,24 +564,26 @@ gst_swfdec_src_event (GstPad *pad, GstEvent *event) /* 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_pad_convert (swfdec->sinkpad, 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 (swfdec->sinkpad), seek_event)) { - /* seek worked, we're done, loop will exit */ - res = TRUE; - } - } - /* at this point, either the seek worked or res == FALSE */ + gint64 desired_offset; + + format = formats[i]; + + /* try to convert requested format to one we can seek with on the sinkpad */ + if (gst_pad_convert (swfdec->sinkpad, 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 (swfdec->sinkpad), seek_event)) { + /* seek worked, we're done, loop will exit */ + res = TRUE; + } + } + /* at this point, either the seek worked or res == FALSE */ } break; } @@ -600,11 +597,11 @@ gst_swfdec_src_event (GstPad *pad, GstEvent *event) #endif static GstElementStateReturn -gst_swfdec_change_state (GstElement *element) +gst_swfdec_change_state (GstElement * element) { GstSwfdec *swfdec = GST_SWFDEC (element); - switch (GST_STATE_TRANSITION (element)) { + switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: break; case GST_STATE_READY_TO_PAUSED: @@ -633,7 +630,7 @@ gst_swfdec_change_state (GstElement *element) /* if we are not closed by an EOS event do so now, this cen send a few frames but * we are prepared to not really send them (see above) */ if (!swfdec->closed) { - /*swf_close (swfdec->decoder); */ + /*swf_close (swfdec->decoder); */ swfdec->closed = TRUE; } //gst_swfdec_vo_destroy (swfdec); @@ -650,7 +647,8 @@ gst_swfdec_change_state (GstElement *element) } static void -gst_swfdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_swfdec_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstSwfdec *src; @@ -665,7 +663,8 @@ gst_swfdec_set_property (GObject *object, guint prop_id, const GValue *value, GP } static void -gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_swfdec_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstSwfdec *swfdec; @@ -680,19 +679,14 @@ gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSp } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { - return gst_element_register (plugin, "swfdec", GST_RANK_PRIMARY, GST_TYPE_SWFDEC); + return gst_element_register (plugin, "swfdec", GST_RANK_PRIMARY, + GST_TYPE_SWFDEC); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "swfdec", - "Uses libswfdec to decode Flash video streams", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "swfdec", + "Uses libswfdec to decode Flash video streams", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/ext/swfdec/gstswfdec.h b/ext/swfdec/gstswfdec.h index 05015682..dab1ac17 100644 --- a/ext/swfdec/gstswfdec.h +++ b/ext/swfdec/gstswfdec.h @@ -26,8 +26,9 @@ #include <swfdec.h> #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_SWFDEC \ @@ -41,47 +42,49 @@ extern "C" { #define GST_IS_SWFDEC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SWFDEC)) -typedef struct _GstSwfdec GstSwfdec; -typedef struct _GstSwfdecClass GstSwfdecClass; + typedef struct _GstSwfdec GstSwfdec; + typedef struct _GstSwfdecClass GstSwfdecClass; -struct _GstSwfdec { - GstElement element; + struct _GstSwfdec + { + GstElement element; - /* pads */ - GstPad *sinkpad; - GstPad *videopad; - GstPad *audiopad; + /* pads */ + GstPad *sinkpad; + GstPad *videopad; + GstPad *audiopad; - SwfdecDecoder *state; - gboolean closed; + SwfdecDecoder *state; + gboolean closed; - /* the timestamp of the next frame */ - gboolean first; - gboolean have_format; + /* the timestamp of the next frame */ + gboolean first; + gboolean have_format; - double rate; - gint64 timestamp; - gint64 interval; - double frame_rate; + double rate; + gint64 timestamp; + gint64 interval; + double frame_rate; - /* video state */ - gint format; - gint width; - gint height; - gint64 total_frames; + /* video state */ + gint format; + gint width; + gint height; + gint64 total_frames; -}; + }; -struct _GstSwfdecClass { - GstElementClass parent_class; -}; + struct _GstSwfdecClass + { + GstElementClass parent_class; + }; -GType gst_swfdec_get_type(void); + GType gst_swfdec_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_SWFDEC_H__ */ +#endif /* __GST_SWFDEC_H__ */ |