diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-07-06 20:49:52 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-07-06 20:49:52 +0000 |
commit | 292fec2a0bd1f221a46ad69c5100995d04c01057 (patch) | |
tree | 658db299e0e03b2454ff840730569d79539e67c4 /gst/avi/gstavimux.c | |
parent | a8183e9a3fa87cf4247c7df16207f440ea4069c0 (diff) |
New mimetypes gone into effect today - this commit changes all old mimetypes over to the new mimetypes spec as descri...
Original commit message from CVS:
New mimetypes gone into effect today - this commit changes all old mimetypes over to the new mimetypes spec as described in the previous commit's document. Note: some plugins will break, some pipelines will break, expect HEAD to be broken or at least not 100% working for a few days, but don't forget to report bugs
Diffstat (limited to 'gst/avi/gstavimux.c')
-rw-r--r-- | gst/avi/gstavimux.c | 406 |
1 files changed, 217 insertions, 189 deletions
diff --git a/gst/avi/gstavimux.c b/gst/avi/gstavimux.c index 8dfa50fa..6b3a442b 100644 --- a/gst/avi/gstavimux.c +++ b/gst/avi/gstavimux.c @@ -84,55 +84,74 @@ GST_PAD_TEMPLATE_FACTORY (video_sink_factory, GST_PAD_SINK, GST_PAD_REQUEST, GST_CAPS_NEW ( - "avimux_sink_video_avi", - "video/avi", - "format", GST_PROPS_STRING ("strf_vids") - ), - GST_CAPS_NEW ( "avimux_sink_video_yuv", - "video/raw", + "video/x-raw-yuv", "format", GST_PROPS_LIST ( GST_PROPS_FOURCC (GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC('Y','4','1','P')) + GST_PROPS_FOURCC (GST_MAKE_FOURCC('I','4','2','0')) ), "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096) ), GST_CAPS_NEW ( - "avimux_sink_video_rgb", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC('R','G','B',' ')), + "avimux_sink_video_jpeg", + "video/x-jpeg", + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096) + ), + GST_CAPS_NEW ( + "avimux_sink_video_divx", + "video/x-divx", "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096), - "depth", GST_PROPS_LIST( - GST_PROPS_INT(16), - GST_PROPS_INT(16), - GST_PROPS_INT(24), - GST_PROPS_INT(32) - ), - "bpp", GST_PROPS_LIST( - GST_PROPS_INT(15), - GST_PROPS_INT(16), - GST_PROPS_INT(24), - GST_PROPS_INT(32) - ) + "divxversion", GST_PROPS_INT_RANGE (3, 5) ), GST_CAPS_NEW ( - "avimux_sink_video_jpeg", - "video/jpeg", + "avimux_sink_video_xvid", + "video/x-xvid", "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096) ), GST_CAPS_NEW ( - "avimux_sink_video_divx", - "video/divx", + "avimux_sink_video_3ivx", + "video/x-3ivx", "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096) ), GST_CAPS_NEW ( - "avimux_sink_video_xvid", - "video/xvid", + "avimux_sink_video_msmpeg", + "video/x-msmpeg", + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096), + "msmpegversion", GST_PROPS_INT_RANGE (41, 43) + ), + GST_CAPS_NEW ( + "avimux_sink_video_mpeg", + "video/mpeg", + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096), + "mpegversion", GST_PROPS_INT (1), + "systemstream", GST_PROPS_BOOLEAN (FALSE) + ), + GST_CAPS_NEW ( + "avimux_sink_video_h263", + "video/x-h263", + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096) + ), + GST_CAPS_NEW ( + "avimux_sink_video_dv", + "video/x-dv", + "width", GST_PROPS_INT (720), + "height", GST_PROPS_LIST ( + GST_PROPS_INT (576), + GST_PROPS_INT (480) + ), + "systemstream", GST_PROPS_BOOLEAN (FALSE) + ), + GST_CAPS_NEW ( + "avimux_sink_video_hfyu", + "video/x-huffyuv", "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096) ) @@ -143,15 +162,8 @@ GST_PAD_TEMPLATE_FACTORY (audio_sink_factory, GST_PAD_SINK, GST_PAD_REQUEST, GST_CAPS_NEW ( - "avimux_sink_audio", - "video/avi", - "format", GST_PROPS_STRING ("strf_auds") - ), - GST_CAPS_NEW ( - "avimux_sink_audio", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "avimux_sink_audio_raw", + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_LITTLE_ENDIAN), "signed", GST_PROPS_LIST ( GST_PROPS_BOOLEAN (TRUE), @@ -165,18 +177,27 @@ GST_PAD_TEMPLATE_FACTORY (audio_sink_factory, GST_PROPS_INT (8), GST_PROPS_INT (16) ), - "rate", GST_PROPS_INT_RANGE (1000, 48000), + "rate", GST_PROPS_INT_RANGE (1000, 96000), + "channels", GST_PROPS_INT_RANGE (1, 2) + ), + GST_CAPS_NEW ( + "avimux_sink_audio_mpeg", + "audio/mpeg", + "layer", GST_PROPS_INT_RANGE (1, 3), + "rate", GST_PROPS_INT_RANGE (1000, 96000), "channels", GST_PROPS_INT_RANGE (1, 2) ), GST_CAPS_NEW ( - "avimux_sink_audio", - "audio/x-mp3", - NULL + "avimux_sink_audio_vorbis", + "audio/x-vorbis", + "rate", GST_PROPS_INT_RANGE (1000, 96000), + "channels", GST_PROPS_INT_RANGE (1, 2) ), GST_CAPS_NEW ( - "avimux_sink_audio", - "application/x-ogg", - NULL + "avimux_sink_audio_ac3", + "audio/x-ac3", + "rate", GST_PROPS_INT_RANGE (1000, 96000), + "channels", GST_PROPS_INT_RANGE (1, 6) ) ) @@ -237,7 +258,8 @@ gst_avimux_class_init (GstAviMuxClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BIGFILE, - g_param_spec_boolean("bigfile","Bigfile Support","Whether to capture large or small AVI files", + g_param_spec_boolean("bigfile","Bigfile Support", + "Support for openDML-2.0 (big) AVI files", 0,G_PARAM_READWRITE)); gstelement_class->request_new_pad = gst_avimux_request_new_pad; @@ -300,7 +322,7 @@ gst_avimux_init (GstAviMux *avimux) } static GstPadLinkReturn -gst_avimux_sinkconnect (GstPad *pad, GstCaps *vscaps) +gst_avimux_vidsinkconnect (GstPad *pad, GstCaps *vscaps) { GstAviMux *avimux; GstCaps *caps; @@ -311,170 +333,188 @@ gst_avimux_sinkconnect (GstPad *pad, GstCaps *vscaps) if (!GST_CAPS_IS_FIXED (vscaps)) return GST_PAD_LINK_DELAYED; - GST_DEBUG ("avimux: sinkconnect triggered on %s", gst_pad_get_name (pad)); + GST_DEBUG ("avimux: video sinkconnect triggered on %s", + gst_pad_get_name (pad)); for (caps = vscaps; caps != NULL; caps = vscaps = vscaps->next) { const gchar* mimetype = gst_caps_get_mime(caps); - - if (!strcmp (mimetype, "video/avi")) - { - const gchar* format; - - gst_caps_get_string (caps, "format", &format); - - if (!strncmp (format, "strf_vids", 9)) { - avimux->vids.size = sizeof(gst_riff_strf_vids); - gst_caps_get (caps, - "width", &avimux->vids.width, - "height", &avimux->vids.height, - "planes", &avimux->vids.planes, - "bit_cnt", &avimux->vids.bit_cnt, - "compression", &avimux->vids.compression, - "image_size", &avimux->vids.image_size, - "xpels_meter", &avimux->vids.xpels_meter, - "ypels_meter", &avimux->vids.ypels_meter, - "num_colors", &avimux->vids.num_colors, - "imp_colors", &avimux->vids.imp_colors, - NULL); - avimux->vids_hdr.fcc_handler = avimux->vids.compression; - avimux->avi_hdr.width = avimux->vids.width; - avimux->avi_hdr.height = avimux->vids.height; - goto done; - } - else if (!strncmp (format, "strf_auds", 9)) { - gst_caps_get (caps, - "format", &avimux->auds.format, - "channels", &avimux->auds.channels, - "rate", &avimux->auds.rate, - "av_bps", &avimux->auds.av_bps, - "blockalign", &avimux->auds.blockalign, - "size", &avimux->auds.size, - NULL); - avimux->auds_hdr.samplesize = avimux->auds_hdr.scale = avimux->auds.blockalign; - avimux->auds_hdr.rate = avimux->auds.av_bps; - goto done; - } - } - else if (!strcmp (mimetype, "video/raw")) + gfloat fps = 0.; + + /* global */ + avimux->vids.size = sizeof(gst_riff_strf_vids); + avimux->vids.planes = 1; + gst_caps_get (caps, "width", &avimux->vids.width, + "height", &avimux->vids.height, + "framerate", &fps, + NULL); + if (fps != 0.) + avimux->vids_hdr.scale = avimux->vids_hdr.rate / fps; + + if (!strcmp (mimetype, "video/x-raw-yuv")) { guint32 format; - gint temp; gst_caps_get_fourcc_int (caps, "format", &format); + avimux->vids.compression = format; switch (format) { case GST_MAKE_FOURCC('Y','U','Y','2'): + avimux->vids.bit_cnt = 16; + break; case GST_MAKE_FOURCC('I','4','2','0'): - case GST_MAKE_FOURCC('Y','4','1','P'): - case GST_MAKE_FOURCC('R','G','B',' '): - avimux->vids.size = sizeof(gst_riff_strf_vids); - gst_caps_get (caps, "width", &avimux->vids.width, - "height", &avimux->vids.height, NULL); - avimux->vids.planes = 1; - switch (format) - { - case GST_MAKE_FOURCC('Y','U','Y','2'): - avimux->vids.bit_cnt = 16; /* YUY2 */ - break; - case GST_MAKE_FOURCC('R','G','B',' '): - gst_caps_get_int (caps, "bpp", &temp); /* RGB */ - avimux->vids.bit_cnt = temp; - break; - case GST_MAKE_FOURCC('Y','4','1','P'): - case GST_MAKE_FOURCC('I','4','2','0'): - avimux->vids.bit_cnt = 12; /* Y41P or I420 */ - break; - } - gst_caps_get_fourcc_int(caps, "format", &avimux->vids.compression); - avimux->vids_hdr.fcc_handler = avimux->vids.compression; - avimux->vids.image_size = avimux->vids.height * avimux->vids.width; - avimux->avi_hdr.width = avimux->vids.width; - avimux->avi_hdr.height = avimux->vids.height; - goto done; - default: + avimux->vids.bit_cnt = 12; break; } + + goto done; } - else if (!strcmp (mimetype, "video/jpeg") || - !strcmp (mimetype, "video/xvid") || - !strcmp (mimetype, "video/divx")) + else { - avimux->vids.size = sizeof(gst_riff_strf_vids); - gst_caps_get (caps, "width", &avimux->vids.width, - "height", &avimux->vids.height, NULL); - avimux->vids.planes = 1; - avimux->vids.bit_cnt = 24; + avimux->vids.bit_cnt = 24; + avimux->vids.compression = 0; - if (!strcmp (mimetype, "video/jpeg")) + /* find format */ + if (!strcmp (mimetype, "video/x-huffyuv")) { + avimux->vids.compression = GST_MAKE_FOURCC('H','F','Y','U'); + } else if (!strcmp (mimetype, "video/x-jpeg")) { avimux->vids.compression = GST_MAKE_FOURCC('M','J','P','G'); - else if (!strcmp (mimetype, "video/divx")) - avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','X'); - else if (!strcmp (mimetype, "video/xvid")) + } else if (!strcmp (mimetype, "video/x-divx")) { + gint divxversion; + gst_caps_get_int (caps, "divxversion", &divxversion); + switch (divxversion) { + case 3: + avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','3'); + break; + case 4: + avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','X'); + break; + case 5: + avimux->vids.compression = GST_MAKE_FOURCC('D','X','5','0'); + break; + } + } else if (!strcmp (mimetype, "video/x-xvid")) { avimux->vids.compression = GST_MAKE_FOURCC('X','V','I','D'); + } else if (!strcmp (mimetype, "video/x-3ivx")) { + avimux->vids.compression = GST_MAKE_FOURCC('3','I','V','2'); + } else if (!strcmp (mimetype, "video/x-msmpeg")) { + gint msmpegversion; + gst_caps_get_int (caps, "msmpegversion", &msmpegversion); + switch (msmpegversion) { + case 41: + avimux->vids.compression = GST_MAKE_FOURCC('M','P','G','4'); + break; + case 42: + avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','2'); + break; + case 43: + avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','3'); + break; + } + } else if (!strcmp (mimetype, "video/x-dv")) { + avimux->vids.compression = GST_MAKE_FOURCC('D','V','S','D'); + } else if (!strcmp (mimetype, "video/x-h263")) { + avimux->vids.compression = GST_MAKE_FOURCC('H','2','6','3'); + } else if (!strcmp (mimetype, "video/mpeg")) { + avimux->vids.compression = GST_MAKE_FOURCC('M','P','E','G'); + } + + if (!avimux->vids.compression) { + continue; + } - avimux->vids_hdr.fcc_handler = avimux->vids.compression; - avimux->avi_hdr.width = avimux->vids.width; - avimux->avi_hdr.height = avimux->vids.height; - avimux->vids.image_size = avimux->vids.height * avimux->vids.width; goto done; } - else if (!strcmp (mimetype, "audio/raw")) - { - gint width; + } + return GST_PAD_LINK_REFUSED; + +done: + avimux->vids_hdr.fcc_handler = avimux->vids.compression; + avimux->vids.image_size = avimux->vids.height * avimux->vids.width; + avimux->avi_hdr.width = avimux->vids.width; + avimux->avi_hdr.height = avimux->vids.height; + avimux->avi_hdr.us_frame = avimux->vids_hdr.scale; + return GST_PAD_LINK_OK; +} +static GstPadLinkReturn +gst_avimux_audsinkconnect (GstPad *pad, GstCaps *vscaps) +{ + GstAviMux *avimux; + GstCaps *caps; + + avimux = GST_AVIMUX (gst_pad_get_parent (pad)); + + /* we are not going to act on variable caps */ + if (!GST_CAPS_IS_FIXED (vscaps)) + return GST_PAD_LINK_DELAYED; + + GST_DEBUG ("avimux: audio sinkconnect triggered on %s", + gst_pad_get_name (pad)); + + for (caps = vscaps; caps != NULL; caps = vscaps = vscaps->next) + { + const gchar* mimetype = gst_caps_get_mime(caps); + + /* we want these for all */ + gst_caps_get (caps, "channels", &avimux->auds.channels, + "rate", &avimux->auds.rate, + NULL); + + if (!strcmp (mimetype, "audio/x-raw-int")) + { avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM; - gst_caps_get (caps, "channels", &avimux->auds.channels, - "rate", &avimux->auds.rate, - "width", &width, + + gst_caps_get (caps, "width", &avimux->auds.blockalign, "depth", &avimux->auds.size, NULL); - avimux->auds_hdr.rate = avimux->auds.av_bps = width * avimux->auds.rate * avimux->auds.channels / 8; - avimux->auds_hdr.samplesize = avimux->auds_hdr.scale = avimux->auds.blockalign = width * avimux->auds.channels/8; + + /* set some more info straight */ + avimux->auds.blockalign /= 8; + avimux->auds.blockalign *= avimux->auds.channels; + avimux->auds.av_bps = avimux->auds.blockalign * avimux->auds.rate; goto done; } - else if (!strcmp (mimetype, "audio/x-mp3")) + else if (!strcmp (mimetype, "audio/mpeg") || + !strcmp (mimetype, "audio/x-vorbis") || + !strcmp (mimetype, "audio/x-ac3")) { - gint layer = 3; + avimux->auds.format = 0; - if (GST_CAPS_PROPERTIES(caps) != NULL && - gst_caps_has_property(caps, "layer")) + if (!strcmp (mimetype, "audio/mpeg")) { + gint layer = 3; gst_caps_get_int(caps, "layer", &layer); - else - GST_DEBUG ( - "No layer specified, assuming layer 3"); - - /* we don't need to do anything here, compressed mp3 contains it all */ - avimux->auds.format = (layer == 3? - GST_RIFF_WAVE_FORMAT_MPEGL3 : - GST_RIFF_WAVE_FORMAT_MPEGL12); - avimux->auds_hdr.scale = avimux->auds_hdr.samplesize = - avimux->auds.blockalign = 1; - avimux->auds_hdr.rate = avimux->auds.av_bps = 0; - avimux->auds.size = 16; - /* nobody cares about this valus, but is has to be set (regardless of - * whether the value is correct) */ - avimux->auds.channels = 1; - /* we'll request this later on from the earlier pads */ - avimux->auds.rate = 0; - goto done; - } - else if (!strcmp (mimetype, "application/x-ogg")) - { - avimux->auds.format = GST_RIFF_WAVE_FORMAT_VORBIS1; - avimux->auds_hdr.scale = avimux->auds_hdr.samplesize = - avimux->auds.blockalign = 1; - avimux->auds_hdr.rate = avimux->auds.av_bps = 0; + switch (layer) { + case 3: + avimux->auds.format = GST_RIFF_WAVE_FORMAT_MPEGL3; + break; + case 1: case 2: + avimux->auds.format = GST_RIFF_WAVE_FORMAT_MPEGL12; + break; + } + } else if (!strcmp (mimetype, "audio/x-vorbis")) { + avimux->auds.format = GST_RIFF_WAVE_FORMAT_VORBIS3; + } else if (!strcmp (mimetype, "audio/x-ac3")) { + avimux->auds.format = GST_RIFF_WAVE_FORMAT_A52; + } + + avimux->auds.blockalign = 1; + avimux->auds.av_bps = 0; avimux->auds.size = 16; - /* see above */ - avimux->auds.channels = 1; - avimux->auds.rate = 0; + + if (!avimux->auds.format) { + continue; + } + goto done; } } return GST_PAD_LINK_REFUSED; done: + avimux->auds_hdr.rate = avimux->auds.blockalign * avimux->auds.rate; + avimux->auds_hdr.samplesize = avimux->auds.blockalign; + avimux->auds_hdr.scale = avimux->auds.blockalign; return GST_PAD_LINK_OK; } @@ -552,11 +592,13 @@ gst_avimux_request_new_pad (GstElement *element, if (templ == GST_PAD_TEMPLATE_GET (audio_sink_factory)) { g_return_val_if_fail(avimux->audiosinkpad == NULL, NULL); newpad = gst_pad_new_from_template (templ, "audio_00"); + gst_pad_set_link_function (newpad, gst_avimux_audsinkconnect); avimux->audiosinkpad = newpad; } else if (templ == GST_PAD_TEMPLATE_GET (video_sink_factory)) { g_return_val_if_fail(avimux->videosinkpad == NULL, NULL); newpad = gst_pad_new_from_template (templ, "video_00"); + gst_pad_set_link_function (newpad, gst_avimux_vidsinkconnect); avimux->videosinkpad = newpad; } else { @@ -568,7 +610,6 @@ gst_avimux_request_new_pad (GstElement *element, G_CALLBACK(gst_avimux_pad_link), (gpointer)avimux); g_signal_connect(newpad, "unlinked", G_CALLBACK(gst_avimux_pad_unlink), (gpointer)avimux); - gst_pad_set_link_function (newpad, gst_avimux_sinkconnect); gst_element_add_pad (element, newpad); gst_pad_set_event_function(newpad, gst_avimux_handle_event); gst_pad_set_event_mask_function(newpad, gst_avimux_get_event_masks); @@ -997,25 +1038,12 @@ gst_avimux_stop_file (GstAviMux *avimux) avimux->avi_hdr.tot_frames = avimux->num_frames; if (avimux->video_pad_connected) { avimux->vids_hdr.length = avimux->num_frames; - - /* get fps */ - framerate = gst_video_frame_rate(GST_PAD_PEER(avimux->videosinkpad)); - avimux->vids_hdr.scale = 1000000 / framerate; } - if (avimux->audio_pad_connected) - { - if (avimux->auds_hdr.scale) - avimux->auds_hdr.length = avimux->audio_size/(avimux->auds.channels*avimux->auds.size/8); - else - avimux->auds_hdr.length = 0; /* urm...? FIXME! ;-) */ - - /* sampling rate, if known - yes this is a hack */ - if (!avimux->auds.rate) - avimux->auds.rate = gst_video_frame_rate(GST_PAD_PEER(avimux->audiosinkpad)); + if (avimux->audio_pad_connected) { + avimux->auds_hdr.length = avimux->audio_size/avimux->auds.blockalign; } /* set rate and everything having to do with that */ - avimux->avi_hdr.us_frame = avimux->vids_hdr.scale; avimux->avi_hdr.max_bps = 0; if (avimux->audio_pad_connected) { /* calculate bps if needed */ |