2002-02-02 16:27:20 +00:00
|
|
|
/* AVI muxer plugin for GStreamer
|
|
|
|
* Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2001-12-22 23:22:30 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
/* based on:
|
|
|
|
* - the old avimuxer (by Wim Taymans)
|
|
|
|
* - xawtv's aviwriter (by Gerd Knorr)
|
|
|
|
* - mjpegtools' avilib (by Rainer Johanni)
|
|
|
|
* - openDML large-AVI docs
|
|
|
|
*/
|
|
|
|
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-01-19 13:50:39 +00:00
|
|
|
#include "gst/gst-i18n-plugin.h"
|
2001-12-22 23:22:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
2001-12-22 23:22:30 +00:00
|
|
|
#include "gstavimux.h"
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
#ifndef LE_FROM_GUINT16
|
|
|
|
#define LE_FROM_GUINT16 GUINT16_FROM_LE
|
|
|
|
#endif
|
|
|
|
#ifndef LE_FROM_GUINT32
|
|
|
|
#define LE_FROM_GUINT32 GUINT32_FROM_LE
|
|
|
|
#endif
|
2001-12-22 23:22:30 +00:00
|
|
|
|
|
|
|
/* AviMux signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:22:30 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:22:30 +00:00
|
|
|
ARG_0,
|
2004-05-21 22:39:30 +00:00
|
|
|
ARG_BIGFILE
|
2001-12-22 23:22:30 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-msvideo")
|
|
|
|
);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate video_sink_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("video_%d",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS ("video/x-raw-yuv, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"format = (fourcc) { YUY2, I420 }, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"height = (int) [ 16, 4096 ], "
|
|
|
|
"framerate = (double) [ 0, MAX ]; "
|
2004-04-13 23:25:19 +00:00
|
|
|
"image/jpeg, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"width = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"height = (int) [ 16, 4096 ], "
|
|
|
|
"framerate = (double) [ 0, MAX ]; "
|
2004-03-15 19:32:27 +00:00
|
|
|
"video/x-divx, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"framerate = (double) [ 0, MAX ], "
|
2004-03-15 19:32:27 +00:00
|
|
|
"divxversion = (int) [ 3, 5 ]; "
|
|
|
|
"video/x-xvid, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"height = (int) [ 16, 4096 ], "
|
|
|
|
"framerate = (double) [ 0, MAX ]; "
|
2004-03-15 19:32:27 +00:00
|
|
|
"video/x-3ivx, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"height = (int) [ 16, 4096 ], "
|
|
|
|
"framerate = (double) [ 0, MAX ]; "
|
2004-03-15 19:32:27 +00:00
|
|
|
"video/x-msmpeg, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"framerate = (double) [ 0, MAX ], "
|
2004-03-15 19:32:27 +00:00
|
|
|
"msmpegversion = (int) [ 41, 43 ]; "
|
|
|
|
"video/mpeg, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"framerate = (double) [ 0, MAX ], "
|
2004-03-15 19:32:27 +00:00
|
|
|
"mpegversion = (int) 1, "
|
|
|
|
"systemstream = (boolean) FALSE; "
|
|
|
|
"video/x-h263, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
2004-10-24 21:22:07 +00:00
|
|
|
"height = (int) [ 16, 4096 ], "
|
|
|
|
"framerate = (double) [ 0, MAX ]; "
|
2004-12-13 12:18:07 +00:00
|
|
|
"video/x-h264, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
|
|
|
"framerate = (double) [ 0, MAX ]; "
|
2004-03-15 19:32:27 +00:00
|
|
|
"video/x-dv, "
|
|
|
|
"width = (int) 720, "
|
|
|
|
"height = (int) { 576, 480 }, "
|
2004-10-24 21:22:07 +00:00
|
|
|
"framerate = (double) [ 0, MAX ], "
|
2004-03-15 19:32:27 +00:00
|
|
|
"systemstream = (boolean) FALSE; "
|
|
|
|
"video/x-huffyuv, "
|
2004-10-24 21:22:07 +00:00
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], " "framerate = (double) [ 0, MAX ]")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate audio_sink_factory =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("audio_%d",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"endianness = (int) LITTLE_ENDIAN, "
|
|
|
|
"signed = (boolean) { TRUE, FALSE }, "
|
|
|
|
"width = (int) { 8, 16 }, "
|
|
|
|
"depth = (int) { 8, 16 }, "
|
|
|
|
"rate = (int) [ 1000, 96000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/mpeg, "
|
|
|
|
"mpegversion = (int) 1, "
|
|
|
|
"layer = (int) [ 1, 3 ], "
|
|
|
|
"rate = (int) [ 1000, 96000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-vorbis, "
|
|
|
|
"rate = (int) [ 1000, 96000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-ac3, "
|
|
|
|
"rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
static void gst_avimux_base_init (gpointer g_class);
|
|
|
|
static void gst_avimux_class_init (GstAviMuxClass * klass);
|
|
|
|
static void gst_avimux_init (GstAviMux * avimux);
|
|
|
|
|
|
|
|
static void gst_avimux_loop (GstElement * element);
|
|
|
|
static gboolean gst_avimux_handle_event (GstPad * pad, GstEvent * event);
|
|
|
|
static GstPad *gst_avimux_request_new_pad (GstElement * element,
|
|
|
|
GstPadTemplate * templ, const gchar * name);
|
2005-01-11 16:52:47 +00:00
|
|
|
static void gst_avimux_release_pad (GstElement * element, GstPad * pad);
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_avimux_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_avimux_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
static GstElementStateReturn gst_avimux_change_state (GstElement * element);
|
2001-12-22 23:22:30 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-01-19 14:57:47 +00:00
|
|
|
/*static guint gst_avimux_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-22 23:22:30 +00:00
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_get_type (void)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
|
|
|
static GType avimux_type = 0;
|
|
|
|
|
|
|
|
if (!avimux_type) {
|
|
|
|
static const GTypeInfo avimux_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstAviMuxClass),
|
2003-11-01 02:07:52 +00:00
|
|
|
gst_avimux_base_init,
|
2001-12-22 23:22:30 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_avimux_class_init,
|
2001-12-22 23:22:30 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstAviMux),
|
2001-12-22 23:22:30 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_avimux_init,
|
2001-12-22 23:22:30 +00:00
|
|
|
};
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
static const GInterfaceInfo tag_setter_info = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstAviMux", &avimux_info, 0);
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
g_type_add_interface_static (avimux_type, GST_TYPE_TAG_SETTER,
|
|
|
|
&tag_setter_info);
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
return avimux_type;
|
|
|
|
}
|
|
|
|
|
2003-11-01 02:07:52 +00:00
|
|
|
static void
|
|
|
|
gst_avimux_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstElementDetails gst_avimux_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Avi multiplexer",
|
|
|
|
"Codec/Muxer",
|
|
|
|
"Muxes audio and video into an avi stream",
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
2003-11-01 02:07:52 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_static_pad_template_get (&src_factory));
|
2003-11-01 02:07:52 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_static_pad_template_get (&audio_sink_factory));
|
2003-11-01 02:07:52 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_static_pad_template_get (&video_sink_factory));
|
2003-11-01 02:07:52 +00:00
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &gst_avimux_details);
|
|
|
|
}
|
|
|
|
|
2001-12-22 23:22:30 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_class_init (GstAviMuxClass * klass)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIGFILE,
|
|
|
|
g_param_spec_boolean ("bigfile", "Bigfile Support",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Support for openDML-2.0 (big) AVI files", 0, G_PARAM_READWRITE));
|
2001-12-22 23:22:30 +00:00
|
|
|
|
|
|
|
gstelement_class->request_new_pad = gst_avimux_request_new_pad;
|
2005-01-11 16:52:47 +00:00
|
|
|
gstelement_class->release_pad = gst_avimux_release_pad;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_avimux_change_state;
|
|
|
|
|
|
|
|
gstelement_class->get_property = gst_avimux_get_property;
|
|
|
|
gstelement_class->set_property = gst_avimux_set_property;
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
static const GstEventMask *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_get_event_masks (GstPad * pad)
|
2002-07-24 21:41:38 +00:00
|
|
|
{
|
2002-10-23 18:56:28 +00:00
|
|
|
static const GstEventMask gst_avimux_sink_event_masks[] = {
|
2004-03-14 22:34:33 +00:00
|
|
|
{GST_EVENT_EOS, 0},
|
|
|
|
{0,}
|
2002-10-23 18:56:28 +00:00
|
|
|
};
|
2002-07-24 21:41:38 +00:00
|
|
|
|
2003-06-01 12:23:46 +00:00
|
|
|
return gst_avimux_sink_event_masks;
|
2002-07-24 21:41:38 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_avimux_init (GstAviMux * avimux)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
2003-11-09 13:48:36 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (avimux);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
2004-03-15 19:32:27 +00:00
|
|
|
"src"), "src");
|
2001-12-22 23:22:30 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (avimux), avimux->srcpad);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_FLAG_SET (GST_ELEMENT (avimux), GST_ELEMENT_EVENT_AWARE);
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->audiosinkpad = NULL;
|
|
|
|
avimux->audio_pad_connected = FALSE;
|
|
|
|
avimux->videosinkpad = NULL;
|
|
|
|
avimux->video_pad_connected = FALSE;
|
|
|
|
|
|
|
|
avimux->audio_buffer_queue = NULL;
|
|
|
|
avimux->video_buffer_queue = NULL;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->num_frames = 0;
|
|
|
|
|
|
|
|
/* audio/video/AVI header initialisation */
|
2004-03-14 22:34:33 +00:00
|
|
|
memset (&(avimux->avi_hdr), 0, sizeof (gst_riff_avih));
|
|
|
|
memset (&(avimux->vids_hdr), 0, sizeof (gst_riff_strh));
|
|
|
|
memset (&(avimux->vids), 0, sizeof (gst_riff_strf_vids));
|
|
|
|
memset (&(avimux->auds_hdr), 0, sizeof (gst_riff_strh));
|
|
|
|
memset (&(avimux->auds), 0, sizeof (gst_riff_strf_auds));
|
|
|
|
avimux->vids_hdr.type = GST_MAKE_FOURCC ('v', 'i', 'd', 's');
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->vids_hdr.rate = 1000000;
|
2003-10-09 22:11:53 +00:00
|
|
|
avimux->avi_hdr.max_bps = 10000000;
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->auds_hdr.type = GST_MAKE_FOURCC ('a', 'u', 'd', 's');
|
2003-06-01 12:23:46 +00:00
|
|
|
avimux->vids_hdr.quality = 0xFFFFFFFF;
|
|
|
|
avimux->auds_hdr.quality = 0xFFFFFFFF;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
avimux->tags = NULL;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
avimux->idx = NULL;
|
|
|
|
|
|
|
|
avimux->write_header = TRUE;
|
|
|
|
|
|
|
|
avimux->enable_large_avi = TRUE;
|
2002-02-20 07:25:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_set_loop_function (GST_ELEMENT (avimux), gst_avimux_loop);
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_vidsinkconnect (GstPad * pad, const GstCaps * vscaps)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
|
|
|
GstAviMux *avimux;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2004-03-14 22:34:33 +00:00
|
|
|
const gchar *mimetype;
|
2003-12-22 01:47:09 +00:00
|
|
|
gdouble fps = 0.;
|
|
|
|
gboolean ret;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
|
|
|
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
|
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
GST_DEBUG ("avimux: video sinkconnect triggered on %s",
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_get_name (pad));
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (vscaps, 0);
|
|
|
|
mimetype = gst_structure_get_name (structure);
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
/* global */
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.size = sizeof (gst_riff_strf_vids);
|
|
|
|
avimux->vids.planes = 1;
|
2003-12-22 01:47:09 +00:00
|
|
|
ret = gst_structure_get_int (structure, "width", &avimux->vids.width);
|
|
|
|
ret &= gst_structure_get_int (structure, "height", &avimux->vids.height);
|
|
|
|
ret &= gst_structure_get_double (structure, "framerate", &fps);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!ret)
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
2003-12-22 01:47:09 +00:00
|
|
|
|
|
|
|
if (fps != 0.)
|
|
|
|
avimux->vids_hdr.scale = avimux->vids_hdr.rate / fps;
|
|
|
|
|
|
|
|
if (!strcmp (mimetype, "video/x-raw-yuv")) {
|
|
|
|
guint32 format;
|
|
|
|
|
|
|
|
gst_structure_get_fourcc (structure, "format", &format);
|
|
|
|
avimux->vids.compression = format;
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (format) {
|
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->vids.bit_cnt = 16;
|
|
|
|
break;
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->vids.bit_cnt = 12;
|
|
|
|
break;
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
avimux->vids.bit_cnt = 24;
|
|
|
|
avimux->vids.compression = 0;
|
|
|
|
|
|
|
|
/* find format */
|
|
|
|
if (!strcmp (mimetype, "video/x-huffyuv")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('H', 'F', 'Y', 'U');
|
2004-04-13 23:25:19 +00:00
|
|
|
} else if (!strcmp (mimetype, "image/jpeg")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-divx")) {
|
|
|
|
gint divxversion;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "divxversion", &divxversion);
|
|
|
|
switch (divxversion) {
|
2004-03-15 19:32:27 +00:00
|
|
|
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;
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-xvid")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-3ivx")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('3', 'I', 'V', '2');
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
|
|
|
|
gint msmpegversion;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
|
|
|
|
switch (msmpegversion) {
|
2004-03-15 19:32:27 +00:00
|
|
|
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;
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-dv")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('D', 'V', 'S', 'D');
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/x-h263")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('H', '2', '6', '3');
|
2003-12-22 01:47:09 +00:00
|
|
|
} else if (!strcmp (mimetype, "video/mpeg")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->vids.compression = GST_MAKE_FOURCC ('M', 'P', 'E', 'G');
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
2003-05-30 23:05:29 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
if (!avimux->vids.compression) {
|
|
|
|
return GST_PAD_LINK_DELAYED;
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2002-03-30 17:06:26 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_audsinkconnect (GstPad * pad, const GstCaps * vscaps)
|
2003-07-06 20:49:52 +00:00
|
|
|
{
|
|
|
|
GstAviMux *avimux;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2004-03-14 22:34:33 +00:00
|
|
|
const gchar *mimetype;
|
2003-12-22 01:47:09 +00:00
|
|
|
int i;
|
2003-07-06 20:49:52 +00:00
|
|
|
|
|
|
|
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
GST_DEBUG ("avimux: audio sinkconnect triggered on %s",
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_get_name (pad));
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (vscaps, 0);
|
|
|
|
mimetype = gst_structure_get_name (structure);
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
/* we want these for all */
|
|
|
|
gst_structure_get_int (structure, "channels", &i);
|
|
|
|
avimux->auds.channels = i;
|
|
|
|
gst_structure_get_int (structure, "rate", &i);
|
|
|
|
avimux->auds.rate = i;
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
if (!strcmp (mimetype, "audio/x-raw-int")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "width", &i);
|
|
|
|
avimux->auds.blockalign = i;
|
|
|
|
gst_structure_get_int (structure, "depth", &i);
|
|
|
|
avimux->auds.size = i;
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
/* 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;
|
|
|
|
} else if (!strcmp (mimetype, "audio/mpeg") ||
|
2004-03-14 22:34:33 +00:00
|
|
|
!strcmp (mimetype, "audio/x-vorbis") ||
|
|
|
|
!strcmp (mimetype, "audio/x-ac3")) {
|
2003-12-22 01:47:09 +00:00
|
|
|
avimux->auds.format = 0;
|
|
|
|
|
|
|
|
if (!strcmp (mimetype, "audio/mpeg")) {
|
|
|
|
gint layer = 3;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "layer", &layer);
|
|
|
|
switch (layer) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case 3:
|
|
|
|
avimux->auds.format = GST_RIFF_WAVE_FORMAT_MPEGL3;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
avimux->auds.format = GST_RIFF_WAVE_FORMAT_MPEGL12;
|
|
|
|
break;
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
} 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;
|
|
|
|
}
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
avimux->auds.blockalign = 1;
|
|
|
|
avimux->auds.av_bps = 0;
|
|
|
|
avimux->auds.size = 16;
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
if (!avimux->auds.format) {
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-10-27 18:08:43 +00:00
|
|
|
}
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->auds_hdr.rate = avimux->auds.blockalign * avimux->auds.rate;
|
2003-07-06 20:49:52 +00:00
|
|
|
avimux->auds_hdr.samplesize = avimux->auds.blockalign;
|
2004-10-26 11:22:07 +00:00
|
|
|
avimux->auds_hdr.scale = 1;
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2002-09-19 10:46:01 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_pad_link (GstPad * pad, GstPad * peer, gpointer data)
|
2002-09-19 10:46:01 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstAviMux *avimux = GST_AVIMUX (data);
|
2002-09-19 10:46:01 +00:00
|
|
|
const gchar *padname = gst_pad_get_name (pad);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (pad == avimux->audiosinkpad) {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->audio_pad_connected = TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (pad == avimux->videosinkpad) {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->video_pad_connected = TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
|
|
|
g_warning ("Unknown padname '%s'", padname);
|
2002-09-19 10:46:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("pad '%s' connected", padname);
|
2002-09-19 10:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_pad_unlink (GstPad * pad, GstPad * peer, gpointer data)
|
2002-09-19 10:46:01 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstAviMux *avimux = GST_AVIMUX (data);
|
2002-09-19 10:46:01 +00:00
|
|
|
const gchar *padname = gst_pad_get_name (pad);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (pad == avimux->audiosinkpad) {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->audio_pad_connected = FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (pad == avimux->videosinkpad) {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->video_pad_connected = FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
|
|
|
g_warning ("Unknown padname '%s'", padname);
|
2002-09-19 10:46:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("pad '%s' unlinked", padname);
|
2002-09-19 10:46:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstPad *
|
|
|
|
gst_avimux_request_new_pad (GstElement * element,
|
|
|
|
GstPadTemplate * templ, const gchar * req_name)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
|
|
|
GstAviMux *avimux;
|
|
|
|
GstPad *newpad;
|
2003-11-09 13:48:36 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
2002-03-06 16:17:14 +00:00
|
|
|
|
2001-12-22 23:22:30 +00:00
|
|
|
g_return_val_if_fail (templ != NULL, NULL);
|
|
|
|
|
|
|
|
if (templ->direction != GST_PAD_SINK) {
|
|
|
|
g_warning ("avimux: request pad that is not a SINK pad\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_AVIMUX (element), NULL);
|
|
|
|
|
|
|
|
avimux = GST_AVIMUX (element);
|
|
|
|
|
2003-11-09 13:48:36 +00:00
|
|
|
if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_val_if_fail (avimux->audiosinkpad == NULL, NULL);
|
2002-10-23 18:56:28 +00:00
|
|
|
newpad = gst_pad_new_from_template (templ, "audio_00");
|
2003-07-06 20:49:52 +00:00
|
|
|
gst_pad_set_link_function (newpad, gst_avimux_audsinkconnect);
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->audiosinkpad = newpad;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
|
|
|
|
g_return_val_if_fail (avimux->videosinkpad == NULL, NULL);
|
2002-10-23 18:56:28 +00:00
|
|
|
newpad = gst_pad_new_from_template (templ, "video_00");
|
2003-07-06 20:49:52 +00:00
|
|
|
gst_pad_set_link_function (newpad, gst_avimux_vidsinkconnect);
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->videosinkpad = newpad;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2001-12-22 23:22:30 +00:00
|
|
|
g_warning ("avimux: this is not our template!\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_connect (newpad, "linked",
|
|
|
|
G_CALLBACK (gst_avimux_pad_link), (gpointer) avimux);
|
|
|
|
g_signal_connect (newpad, "unlinked",
|
|
|
|
G_CALLBACK (gst_avimux_pad_unlink), (gpointer) avimux);
|
2001-12-22 23:22:30 +00:00
|
|
|
gst_element_add_pad (element, newpad);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_set_event_mask_function (newpad, gst_avimux_get_event_masks);
|
|
|
|
|
2001-12-22 23:22:30 +00:00
|
|
|
return newpad;
|
|
|
|
}
|
|
|
|
|
2005-01-11 16:52:47 +00:00
|
|
|
static void
|
|
|
|
gst_avimux_release_pad (GstElement * element, GstPad * pad)
|
|
|
|
{
|
|
|
|
GstAviMux *avimux = GST_AVIMUX (element);
|
|
|
|
|
|
|
|
if (pad == avimux->videosinkpad) {
|
|
|
|
avimux->videosinkpad = NULL;
|
|
|
|
} else if (pad == avimux->audiosinkpad) {
|
|
|
|
avimux->audiosinkpad = NULL;
|
|
|
|
} else {
|
|
|
|
g_warning ("Unknown pad %s", gst_pad_get_name (pad));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG ("Removed pad '%s'", gst_pad_get_name (pad));
|
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
/* maybe some of these functions should be moved to riff.h? */
|
|
|
|
|
|
|
|
/* DISCLAIMER: this function is ugly. So be it (i.e. it makes the rest easier) */
|
|
|
|
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
static void
|
|
|
|
gst_avimux_write_tag (const GstTagList * list, const gchar * tag, gpointer data)
|
|
|
|
{
|
|
|
|
const struct
|
|
|
|
{
|
|
|
|
guint32 fcc;
|
|
|
|
gchar *tag;
|
|
|
|
} rifftags[] = {
|
|
|
|
{
|
|
|
|
GST_RIFF_INFO_ICMT, GST_TAG_COMMENT}, {
|
|
|
|
GST_RIFF_INFO_INAM, GST_TAG_TITLE}, {
|
|
|
|
GST_RIFF_INFO_ISFT, GST_TAG_ENCODER}, {
|
|
|
|
GST_RIFF_INFO_IGNR, GST_TAG_GENRE}, {
|
|
|
|
GST_RIFF_INFO_ICOP, GST_TAG_COPYRIGHT}, {
|
|
|
|
GST_RIFF_INFO_IART, GST_TAG_ARTIST}, {
|
|
|
|
GST_RIFF_INFO_IARL, GST_TAG_LOCATION}, {
|
|
|
|
0, NULL}
|
|
|
|
};
|
2005-01-19 20:25:26 +00:00
|
|
|
gint n, len, plen;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GstBuffer *buf = data;
|
2005-01-22 10:54:07 +00:00
|
|
|
guint8 *buffdata = GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf);
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
for (n = 0; rifftags[n].fcc != 0; n++) {
|
|
|
|
if (!strcmp (rifftags[n].tag, tag) &&
|
|
|
|
gst_tag_list_get_string (list, tag, &str)) {
|
|
|
|
len = strlen (str);
|
2005-01-19 20:25:26 +00:00
|
|
|
plen = len + 1;
|
|
|
|
if (plen & 1)
|
|
|
|
plen++;
|
|
|
|
if (GST_BUFFER_MAXSIZE (buf) >= GST_BUFFER_SIZE (buf) + 8 + plen) {
|
2005-01-22 10:54:07 +00:00
|
|
|
GST_WRITE_UINT32_LE (buffdata, rifftags[n].fcc);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, len + 1);
|
|
|
|
memcpy (buffdata + 8, str, len);
|
|
|
|
buffdata[8 + len] = 0;
|
2005-01-19 20:25:26 +00:00
|
|
|
GST_BUFFER_SIZE (buf) += 8 + plen;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
}
|
2005-01-22 10:54:07 +00:00
|
|
|
break;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
static GstBuffer *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_riff_get_avi_header (GstAviMux * avimux)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GstTagList *tags;
|
|
|
|
const GstTagList *iface_tags;
|
2002-02-02 16:27:20 +00:00
|
|
|
GstBuffer *buffer;
|
|
|
|
guint8 *buffdata;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
guint size = 0;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
/* first, let's see what actually needs to be in the buffer */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
size += 32 + sizeof (gst_riff_avih); /* avi header */
|
2004-03-15 19:32:27 +00:00
|
|
|
if (avimux->video_pad_connected) { /* we have video */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
size += 28 + sizeof (gst_riff_strh) + sizeof (gst_riff_strf_vids); /* vid hdr */
|
|
|
|
size += 24; /* odml header */
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
2004-03-15 19:32:27 +00:00
|
|
|
if (avimux->audio_pad_connected) { /* we have audio */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
size += 28 + sizeof (gst_riff_strh) + sizeof (gst_riff_strf_auds); /* aud hdr */
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
|
|
|
/* this is the "riff size" */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
avimux->header_size = size;
|
|
|
|
size += 12; /* avi data header */
|
|
|
|
|
|
|
|
/* tags */
|
|
|
|
iface_tags = gst_tag_setter_get_list (GST_TAG_SETTER (avimux));
|
|
|
|
if (iface_tags || avimux->tags) {
|
|
|
|
size += 1024;
|
|
|
|
if (iface_tags && avimux->tags) {
|
|
|
|
tags = gst_tag_list_merge (iface_tags, avimux->tags,
|
|
|
|
GST_TAG_MERGE_APPEND);
|
|
|
|
} else if (iface_tags) {
|
|
|
|
tags = gst_tag_list_copy (iface_tags);
|
|
|
|
} else {
|
|
|
|
tags = gst_tag_list_copy (avimux->tags);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tags = NULL;
|
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
/* allocate the buffer */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
buffer = gst_buffer_new_and_alloc (size);
|
|
|
|
buffdata = GST_BUFFER_DATA (buffer);
|
|
|
|
GST_BUFFER_SIZE (buffer) = 0;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
/* avi header metadata */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 0, "RIFF", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4,
|
|
|
|
avimux->header_size + avimux->idx_size + avimux->data_size);
|
|
|
|
memcpy (buffdata + 8, "AVI ", 4);
|
|
|
|
memcpy (buffdata + 12, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 16, avimux->header_size - 4 * 5);
|
|
|
|
memcpy (buffdata + 20, "hdrl", 4);
|
|
|
|
memcpy (buffdata + 24, "avih", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 28, sizeof (gst_riff_avih));
|
|
|
|
buffdata += 32;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 32;
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
/* the AVI header itself */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GST_WRITE_UINT32_LE (buffdata + 0, avimux->avi_hdr.us_frame);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, avimux->avi_hdr.max_bps);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 8, avimux->avi_hdr.pad_gran);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 12, avimux->avi_hdr.flags);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 16, avimux->avi_hdr.tot_frames);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 20, avimux->avi_hdr.init_frames);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 24, avimux->avi_hdr.streams);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 28, avimux->avi_hdr.bufsize);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 32, avimux->avi_hdr.width);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 36, avimux->avi_hdr.height);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 40, avimux->avi_hdr.scale);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 44, avimux->avi_hdr.rate);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 48, avimux->avi_hdr.start);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 52, avimux->avi_hdr.length);
|
|
|
|
buffdata += 56;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 56;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (avimux->video_pad_connected) {
|
2002-02-04 19:44:08 +00:00
|
|
|
/* video header metadata */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 0, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4,
|
|
|
|
sizeof (gst_riff_strh) + sizeof (gst_riff_strf_vids) + 4 * 5);
|
|
|
|
memcpy (buffdata + 8, "strl", 4);
|
2002-02-04 19:44:08 +00:00
|
|
|
/* generic header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 12, "strh", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 16, sizeof (gst_riff_strh));
|
2002-02-04 19:44:08 +00:00
|
|
|
/* the actual header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GST_WRITE_UINT32_LE (buffdata + 20, avimux->vids_hdr.type);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 24, avimux->vids_hdr.fcc_handler);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 28, avimux->vids_hdr.flags);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 32, avimux->vids_hdr.priority);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 36, avimux->vids_hdr.init_frames);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 40, avimux->vids_hdr.scale);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 44, avimux->vids_hdr.rate);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 48, avimux->vids_hdr.start);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 52, avimux->vids_hdr.length);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 56, avimux->vids_hdr.bufsize);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 60, avimux->vids_hdr.quality);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 64, avimux->vids_hdr.samplesize);
|
2002-02-04 19:44:08 +00:00
|
|
|
/* the video header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 68, "strf", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 72, sizeof (gst_riff_strf_vids));
|
2002-02-04 19:44:08 +00:00
|
|
|
/* the actual header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GST_WRITE_UINT32_LE (buffdata + 76, avimux->vids.size);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 80, avimux->vids.width);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 84, avimux->vids.height);
|
|
|
|
GST_WRITE_UINT16_LE (buffdata + 88, avimux->vids.planes);
|
|
|
|
GST_WRITE_UINT16_LE (buffdata + 90, avimux->vids.bit_cnt);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 92, avimux->vids.compression);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 96, avimux->vids.image_size);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 100, avimux->vids.xpels_meter);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 104, avimux->vids.ypels_meter);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 108, avimux->vids.num_colors);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 112, avimux->vids.imp_colors);
|
|
|
|
buffdata += 116;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 116;
|
2002-02-04 19:44:08 +00:00
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->audio_pad_connected) {
|
2002-02-04 19:44:08 +00:00
|
|
|
/* audio header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 0, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4,
|
|
|
|
sizeof (gst_riff_strh) + sizeof (gst_riff_strf_auds) + 4 * 5);
|
|
|
|
memcpy (buffdata + 8, "strl", 4);
|
2002-02-04 19:44:08 +00:00
|
|
|
/* generic header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 12, "strh", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 16, sizeof (gst_riff_strh));
|
2002-02-04 19:44:08 +00:00
|
|
|
/* the actual header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GST_WRITE_UINT32_LE (buffdata + 20, avimux->auds_hdr.type);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 24, avimux->auds_hdr.fcc_handler);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 28, avimux->auds_hdr.flags);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 32, avimux->auds_hdr.priority);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 36, avimux->auds_hdr.init_frames);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 40, avimux->auds_hdr.scale);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 44, avimux->auds_hdr.rate);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 48, avimux->auds_hdr.start);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 52, avimux->auds_hdr.length);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 56, avimux->auds_hdr.bufsize);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 60, avimux->auds_hdr.quality);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 64, avimux->auds_hdr.samplesize);
|
2002-02-04 19:44:08 +00:00
|
|
|
/* the audio header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 68, "strf", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 72, sizeof (gst_riff_strf_auds));
|
2002-02-04 19:44:08 +00:00
|
|
|
/* the actual header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GST_WRITE_UINT16_LE (buffdata + 76, avimux->auds.format);
|
|
|
|
GST_WRITE_UINT16_LE (buffdata + 78, avimux->auds.channels);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 80, avimux->auds.rate);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 84, avimux->auds.av_bps);
|
|
|
|
GST_WRITE_UINT16_LE (buffdata + 88, avimux->auds.blockalign);
|
|
|
|
GST_WRITE_UINT16_LE (buffdata + 90, avimux->auds.size);
|
|
|
|
buffdata += 92;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 92;
|
2002-02-04 19:44:08 +00:00
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->video_pad_connected) {
|
2002-02-04 19:44:08 +00:00
|
|
|
/* odml header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 0, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, sizeof (guint32) + 4 * 3);
|
|
|
|
memcpy (buffdata + 8, "odml", 4);
|
|
|
|
memcpy (buffdata + 12, "dmlh", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 16, sizeof (guint32));
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 20, avimux->total_frames);
|
|
|
|
buffdata += 24;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 24;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tags */
|
|
|
|
if (tags) {
|
|
|
|
guint8 *ptr;
|
|
|
|
guint startsize;
|
|
|
|
|
|
|
|
memcpy (buffdata + 0, "LIST", 4);
|
|
|
|
ptr = buffdata + 4; /* fill in later */
|
|
|
|
startsize = GST_BUFFER_SIZE (buffer) + 4;
|
|
|
|
memcpy (buffdata + 8, "INFO", 4);
|
|
|
|
buffdata += 12;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 12;
|
|
|
|
|
|
|
|
/* 12 bytes is needed for data header */
|
|
|
|
GST_BUFFER_MAXSIZE (buffer) -= 12;
|
|
|
|
gst_tag_list_foreach (tags, gst_avimux_write_tag, buffer);
|
|
|
|
gst_tag_list_free (tags);
|
|
|
|
GST_BUFFER_MAXSIZE (buffer) += 12;
|
|
|
|
buffdata = GST_BUFFER_DATA (buffer) + GST_BUFFER_SIZE (buffer);
|
|
|
|
|
|
|
|
/* update list size */
|
2005-01-22 10:54:07 +00:00
|
|
|
GST_WRITE_UINT32_LE (ptr, GST_BUFFER_SIZE (buffer) - startsize - 4);
|
2002-02-04 19:44:08 +00:00
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
/* avi data header */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
memcpy (buffdata + 0, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, avimux->data_size);
|
2005-01-22 10:54:07 +00:00
|
|
|
memcpy (buffdata + 8, "movi", 4);
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
buffdata += 12;
|
|
|
|
GST_BUFFER_SIZE (buffer) += 12;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
gst_avimux_riff_get_avix_header (guint32 datax_size)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
guint8 *buffdata;
|
|
|
|
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
buffer = gst_buffer_new_and_alloc (24);
|
|
|
|
buffdata = GST_BUFFER_DATA (buffer);
|
|
|
|
|
|
|
|
memcpy (buffdata + 0, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, datax_size + 4 * 4);
|
|
|
|
memcpy (buffdata + 8, "AVIX", 4);
|
|
|
|
memcpy (buffdata + 12, "LIST", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 16, datax_size);
|
|
|
|
memcpy (buffdata + 20, "movi", 4);
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
gst_avimux_riff_get_video_header (guint32 video_frame_size)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
guint8 *buffdata;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
buffer = gst_buffer_new_and_alloc (8);
|
|
|
|
buffdata = GST_BUFFER_DATA (buffer);
|
|
|
|
memcpy (buffdata + 0, "00db", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, video_frame_size);
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
gst_avimux_riff_get_audio_header (guint32 audio_sample_size)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
guint8 *buffdata;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
buffer = gst_buffer_new_and_alloc (8);
|
|
|
|
buffdata = GST_BUFFER_DATA (buffer);
|
|
|
|
memcpy (buffdata + 0, "01wb", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4, audio_sample_size);
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* some other usable functions (thankyou xawtv ;-) ) */
|
|
|
|
|
2001-12-22 23:22:30 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_add_index (GstAviMux * avimux, guchar * code, guint32 flags,
|
|
|
|
guint32 size)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->idx_index == avimux->idx_count) {
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->idx_count += 256;
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->idx =
|
2004-03-15 19:32:27 +00:00
|
|
|
realloc (avimux->idx,
|
|
|
|
avimux->idx_count * sizeof (gst_riff_index_entry));
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
memcpy (&(avimux->idx[avimux->idx_index].id), code, 4);
|
|
|
|
avimux->idx[avimux->idx_index].flags = LE_FROM_GUINT32 (flags);
|
|
|
|
avimux->idx[avimux->idx_index].offset = LE_FROM_GUINT32 (avimux->idx_offset);
|
|
|
|
avimux->idx[avimux->idx_index].size = LE_FROM_GUINT32 (size);
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->idx_index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_write_index (GstAviMux * avimux)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
guint8 *buffdata;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
buffer = gst_buffer_new_and_alloc (8);
|
|
|
|
buffdata = GST_BUFFER_DATA (buffer);
|
|
|
|
memcpy (buffdata + 0, "idx1", 4);
|
|
|
|
GST_WRITE_UINT32_LE (buffdata + 4,
|
|
|
|
avimux->idx_index * sizeof (gst_riff_index_entry));
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (buffer));
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
buffer = gst_buffer_new ();
|
|
|
|
GST_BUFFER_SIZE (buffer) = avimux->idx_index * sizeof (gst_riff_index_entry);
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
GST_BUFFER_DATA (buffer) = (guint8 *) avimux->idx;
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->idx = NULL; /* will be free()'ed by gst_buffer_unref() */
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
avimux->total_data += GST_BUFFER_SIZE (buffer) + 8;
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (buffer));
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->idx_size += avimux->idx_index * sizeof (gst_riff_index_entry) + 8;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
/* update header */
|
|
|
|
avimux->avi_hdr.flags |= GST_RIFF_AVIH_HASINDEX;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_bigfile (GstAviMux * avimux, gboolean last)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstBuffer *header;
|
|
|
|
GstEvent *event;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (avimux->is_bigfile) {
|
2002-02-02 16:27:20 +00:00
|
|
|
/* sarch back */
|
2004-03-14 22:34:33 +00:00
|
|
|
event = gst_event_new_seek (GST_FORMAT_BYTES |
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, avimux->avix_start);
|
2002-05-26 21:59:22 +00:00
|
|
|
/* if the event succeeds */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (event));
|
2003-09-12 11:39:29 +00:00
|
|
|
|
|
|
|
/* rewrite AVIX header */
|
2004-03-14 22:34:33 +00:00
|
|
|
header = gst_avimux_riff_get_avix_header (avimux->datax_size);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (header));
|
2003-09-12 11:39:29 +00:00
|
|
|
|
|
|
|
/* go back to current location */
|
2004-03-14 22:34:33 +00:00
|
|
|
event = gst_event_new_seek (GST_FORMAT_BYTES |
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, avimux->total_data);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (event));
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
|
|
|
avimux->avix_start = avimux->total_data;
|
|
|
|
|
|
|
|
if (last)
|
|
|
|
return;
|
|
|
|
|
|
|
|
avimux->is_bigfile = TRUE;
|
|
|
|
avimux->numx_frames = 0;
|
|
|
|
avimux->datax_size = 0;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
header = gst_avimux_riff_get_avix_header (0);
|
|
|
|
avimux->total_data += GST_BUFFER_SIZE (header);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (header));
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* enough header blabla now, let's go on to actually writing the headers */
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_start_file (GstAviMux * avimux)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstBuffer *header;
|
|
|
|
|
|
|
|
avimux->total_data = 0;
|
|
|
|
avimux->total_frames = 0;
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->data_size = 4; /* ? */
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->datax_size = 0;
|
|
|
|
avimux->num_frames = 0;
|
|
|
|
avimux->numx_frames = 0;
|
|
|
|
avimux->audio_size = 0;
|
2003-05-30 23:05:29 +00:00
|
|
|
avimux->audio_time = 0;
|
2002-09-19 16:52:11 +00:00
|
|
|
avimux->avix_start = 0;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
avimux->idx_index = 0;
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->idx_offset = 0; /* see 10 lines below */
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->idx_size = 0;
|
|
|
|
avimux->idx_count = 0;
|
|
|
|
avimux->idx = NULL;
|
|
|
|
|
2002-02-04 19:44:08 +00:00
|
|
|
/* header */
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->avi_hdr.streams =
|
|
|
|
(avimux->video_pad_connected ? 1 : 0) +
|
|
|
|
(avimux->audio_pad_connected ? 1 : 0);
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->is_bigfile = FALSE;
|
2002-02-04 19:44:08 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
header = gst_avimux_riff_get_avi_header (avimux);
|
|
|
|
avimux->total_data += GST_BUFFER_SIZE (header);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (header));
|
2002-02-02 16:27:20 +00:00
|
|
|
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
avimux->idx_offset = avimux->total_data;
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->write_header = FALSE;
|
2002-02-03 15:47:02 +00:00
|
|
|
avimux->restart = FALSE;
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_stop_file (GstAviMux * avimux)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstBuffer *header;
|
|
|
|
|
|
|
|
/* if bigfile, rewrite header, else write indexes */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->video_pad_connected) {
|
|
|
|
if (avimux->is_bigfile) {
|
|
|
|
gst_avimux_bigfile (avimux, TRUE);
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux->idx_size = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
|
|
|
gst_avimux_write_index (avimux);
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
/* set rate and everything having to do with that */
|
2002-02-04 19:44:08 +00:00
|
|
|
avimux->avi_hdr.max_bps = 0;
|
2003-05-14 21:59:18 +00:00
|
|
|
if (avimux->audio_pad_connected) {
|
|
|
|
/* calculate bps if needed */
|
|
|
|
if (!avimux->auds.av_bps) {
|
2003-09-12 11:39:29 +00:00
|
|
|
if (avimux->audio_time) {
|
2004-10-26 11:22:07 +00:00
|
|
|
avimux->auds.av_bps =
|
2004-03-15 19:32:27 +00:00
|
|
|
(GST_SECOND * avimux->audio_size) / avimux->audio_time;
|
2003-09-12 11:39:29 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_ELEMENT_ERROR (avimux, STREAM, MUX,
|
|
|
|
(_("No or invalid input audio, AVI stream will be corrupt.")),
|
|
|
|
(NULL));
|
2004-10-26 11:22:07 +00:00
|
|
|
avimux->auds.av_bps = 0;
|
2003-09-12 11:39:29 +00:00
|
|
|
}
|
2004-10-26 11:22:07 +00:00
|
|
|
avimux->auds_hdr.rate = avimux->auds.av_bps * avimux->auds_hdr.scale;
|
2003-05-14 21:59:18 +00:00
|
|
|
}
|
2002-02-04 19:44:08 +00:00
|
|
|
avimux->avi_hdr.max_bps += avimux->auds.av_bps;
|
2003-05-14 21:59:18 +00:00
|
|
|
}
|
2003-06-01 12:23:46 +00:00
|
|
|
if (avimux->video_pad_connected) {
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->avi_hdr.max_bps += ((avimux->vids.bit_cnt + 7) / 8) *
|
2004-03-15 19:32:27 +00:00
|
|
|
(1000000. / avimux->avi_hdr.us_frame) * avimux->vids.image_size;
|
2003-06-01 12:23:46 +00:00
|
|
|
}
|
2002-02-04 19:44:08 +00:00
|
|
|
|
2004-10-26 11:22:07 +00:00
|
|
|
/* statistics/total_frames/... */
|
|
|
|
avimux->avi_hdr.tot_frames = avimux->num_frames;
|
|
|
|
if (avimux->video_pad_connected) {
|
|
|
|
avimux->vids_hdr.length = avimux->num_frames;
|
|
|
|
}
|
|
|
|
if (avimux->audio_pad_connected) {
|
|
|
|
avimux->auds_hdr.length =
|
|
|
|
(avimux->audio_time * avimux->auds_hdr.rate) / GST_SECOND;
|
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
/* seek and rewrite the header */
|
2004-03-14 22:34:33 +00:00
|
|
|
header = gst_avimux_riff_get_avi_header (avimux);
|
|
|
|
event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (event));
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (header));
|
2003-10-09 22:11:53 +00:00
|
|
|
event = gst_event_new_seek (GST_FORMAT_BYTES |
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_SEEK_METHOD_SET, avimux->total_data);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (event));
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
avimux->write_header = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_restart_file (GstAviMux * avimux)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstEvent *event;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_stop_file (avimux);
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
event = gst_event_new (GST_EVENT_EOS);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (event));
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_start_file (avimux);
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
/* handle events (search) */
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_handle_event (GstPad * pad, GstEvent * event)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstAviMux *avimux;
|
|
|
|
GstEventType type;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
switch (type) {
|
2002-10-23 18:56:28 +00:00
|
|
|
case GST_EVENT_EOS:
|
|
|
|
/* is this allright? */
|
2003-06-01 12:23:46 +00:00
|
|
|
if (pad == avimux->videosinkpad) {
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->video_pad_eos = TRUE;
|
2003-06-01 12:23:46 +00:00
|
|
|
} else if (pad == avimux->audiosinkpad) {
|
2004-03-15 19:32:27 +00:00
|
|
|
avimux->audio_pad_eos = TRUE;
|
2003-06-01 12:23:46 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_warning ("Unknown pad for EOS!");
|
2003-06-01 12:23:46 +00:00
|
|
|
}
|
2002-10-23 18:56:28 +00:00
|
|
|
break;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
case GST_EVENT_TAG:
|
|
|
|
if (avimux->tags) {
|
|
|
|
gst_tag_list_insert (avimux->tags, gst_event_tag_get_list (event),
|
|
|
|
GST_TAG_MERGE_PREPEND);
|
|
|
|
} else {
|
|
|
|
avimux->tags = gst_tag_list_copy (gst_event_tag_get_list (event));
|
|
|
|
}
|
|
|
|
break;
|
2002-02-02 16:27:20 +00:00
|
|
|
default:
|
|
|
|
break;
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2005-01-16 10:08:12 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
return TRUE;
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
|
|
|
|
/* fill the internal queue for each available pad */
|
2001-12-22 23:22:30 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_fill_queue (GstAviMux * avimux)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
2002-10-23 18:56:28 +00:00
|
|
|
GstBuffer *buffer;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2003-06-01 12:23:46 +00:00
|
|
|
while (!avimux->audio_buffer_queue &&
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->audiosinkpad &&
|
|
|
|
avimux->audio_pad_connected &&
|
|
|
|
GST_PAD_IS_USABLE (avimux->audiosinkpad) && !avimux->audio_pad_eos) {
|
|
|
|
buffer = GST_BUFFER (gst_pad_pull (avimux->audiosinkpad));
|
|
|
|
if (GST_IS_EVENT (buffer)) {
|
|
|
|
gst_avimux_handle_event (avimux->audiosinkpad, GST_EVENT (buffer));
|
2003-06-01 12:23:46 +00:00
|
|
|
} else {
|
|
|
|
avimux->audio_buffer_queue = buffer;
|
|
|
|
break;
|
2002-10-23 18:56:28 +00:00
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2003-06-01 12:23:46 +00:00
|
|
|
while (!avimux->video_buffer_queue &&
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->videosinkpad &&
|
|
|
|
avimux->video_pad_connected &&
|
|
|
|
GST_PAD_IS_USABLE (avimux->videosinkpad) && !avimux->video_pad_eos) {
|
|
|
|
buffer = GST_BUFFER (gst_pad_pull (avimux->videosinkpad));
|
|
|
|
if (GST_IS_EVENT (buffer)) {
|
|
|
|
gst_avimux_handle_event (avimux->videosinkpad, GST_EVENT (buffer));
|
2003-06-01 12:23:46 +00:00
|
|
|
} else {
|
|
|
|
avimux->video_buffer_queue = buffer;
|
|
|
|
break;
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
2002-10-23 18:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2002-10-24 19:32:11 +00:00
|
|
|
/* send extra 'padding' data */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
|
2002-10-24 19:32:11 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
buffer = gst_buffer_new ();
|
|
|
|
GST_BUFFER_SIZE (buffer) = num_bytes;
|
|
|
|
GST_BUFFER_DATA (buffer) = g_malloc (num_bytes);
|
|
|
|
memset (GST_BUFFER_DATA (buffer), 0, num_bytes);
|
2002-10-24 19:32:11 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (buffer));
|
2002-10-24 19:32:11 +00:00
|
|
|
}
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
/* do audio buffer */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_audio_buffer (GstAviMux * avimux)
|
2002-10-23 18:56:28 +00:00
|
|
|
{
|
|
|
|
GstBuffer *data = avimux->audio_buffer_queue, *header;
|
2003-07-22 20:55:08 +00:00
|
|
|
gulong total_size, pad_bytes = 0;
|
2002-10-23 18:56:28 +00:00
|
|
|
|
|
|
|
/* write a audio header + index entry */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (GST_BUFFER_SIZE (data) & 1) {
|
|
|
|
pad_bytes = 2 - (GST_BUFFER_SIZE (data) & 1);
|
2003-07-22 20:55:08 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
header = gst_avimux_riff_get_audio_header (GST_BUFFER_SIZE (data));
|
|
|
|
total_size = GST_BUFFER_SIZE (header) + GST_BUFFER_SIZE (data) + pad_bytes;
|
2002-10-23 18:56:28 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->is_bigfile) {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->datax_size += total_size;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->data_size += total_size;
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->audio_size += GST_BUFFER_SIZE (data);
|
|
|
|
avimux->audio_time += GST_BUFFER_DURATION (data);
|
|
|
|
gst_avimux_add_index (avimux, "01wb", 0x0, GST_BUFFER_SIZE (data));
|
2002-10-23 18:56:28 +00:00
|
|
|
}
|
2002-02-03 15:47:02 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (header));
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (data));
|
2003-07-22 20:55:08 +00:00
|
|
|
if (pad_bytes) {
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_send_pad_data (avimux, pad_bytes);
|
2003-07-22 20:55:08 +00:00
|
|
|
}
|
|
|
|
avimux->total_data += total_size;
|
|
|
|
avimux->idx_offset += total_size;
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->audio_buffer_queue = NULL;
|
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
/* do video buffer */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_video_buffer (GstAviMux * avimux)
|
2002-10-23 18:56:28 +00:00
|
|
|
{
|
|
|
|
GstBuffer *data = avimux->video_buffer_queue, *header;
|
2003-07-22 20:55:08 +00:00
|
|
|
gulong total_size, pad_bytes = 0;
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
if (avimux->restart)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_restart_file (avimux);
|
2002-10-23 18:56:28 +00:00
|
|
|
|
|
|
|
/* write a video header + index entry */
|
2004-03-14 22:34:33 +00:00
|
|
|
if ((avimux->is_bigfile ? avimux->datax_size : avimux->data_size) +
|
|
|
|
GST_BUFFER_SIZE (data) > 1024 * 1024 * 2000) {
|
2002-10-23 18:56:28 +00:00
|
|
|
if (avimux->enable_large_avi)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_bigfile (avimux, FALSE);
|
2002-02-02 16:27:20 +00:00
|
|
|
else
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_restart_file (avimux);
|
2002-10-23 18:56:28 +00:00
|
|
|
}
|
2002-02-02 16:27:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (GST_BUFFER_SIZE (data) & 1) {
|
|
|
|
pad_bytes = 2 - (GST_BUFFER_SIZE (data) & 1);
|
2003-07-22 20:55:08 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
header = gst_avimux_riff_get_video_header (GST_BUFFER_SIZE (data));
|
|
|
|
total_size = GST_BUFFER_SIZE (header) + GST_BUFFER_SIZE (data) + pad_bytes;
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->total_frames++;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->is_bigfile) {
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->datax_size += total_size;
|
|
|
|
avimux->numx_frames++;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2003-09-30 21:06:43 +00:00
|
|
|
guint flags = 0x2;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-09-30 21:06:43 +00:00
|
|
|
if (GST_BUFFER_FLAG_IS_SET (data, GST_BUFFER_KEY_UNIT))
|
|
|
|
flags |= 0x10;
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->data_size += total_size;
|
|
|
|
avimux->num_frames++;
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_add_index (avimux, "00db", flags, GST_BUFFER_SIZE (data));
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (header));
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (data));
|
2003-07-22 20:55:08 +00:00
|
|
|
if (pad_bytes) {
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_send_pad_data (avimux, pad_bytes);
|
2003-07-22 20:55:08 +00:00
|
|
|
}
|
|
|
|
avimux->total_data += total_size;
|
|
|
|
avimux->idx_offset += total_size;
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->video_buffer_queue = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* take the oldest buffer in our internal queue and push-it */
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_one_buffer (GstAviMux * avimux)
|
2002-10-23 18:56:28 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (avimux->video_buffer_queue && avimux->audio_buffer_queue) {
|
|
|
|
if (GST_BUFFER_TIMESTAMP (avimux->video_buffer_queue) <=
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (avimux->audio_buffer_queue))
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_video_buffer (avimux);
|
2002-10-23 18:56:28 +00:00
|
|
|
else
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_audio_buffer (avimux);
|
|
|
|
} else if (avimux->video_buffer_queue || avimux->audio_buffer_queue) {
|
2002-10-23 18:56:28 +00:00
|
|
|
if (avimux->video_buffer_queue)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_video_buffer (avimux);
|
2002-10-23 18:56:28 +00:00
|
|
|
else
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_audio_buffer (avimux);
|
|
|
|
} else {
|
2003-05-30 23:05:29 +00:00
|
|
|
/* simply finish off the file and send EOS */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_stop_file (avimux);
|
|
|
|
gst_pad_push (avimux->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
|
|
|
gst_element_set_eos (GST_ELEMENT (avimux));
|
2002-10-23 18:56:28 +00:00
|
|
|
return FALSE;
|
2003-05-30 23:05:29 +00:00
|
|
|
}
|
2002-10-23 18:56:28 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_loop (GstElement * element)
|
2002-10-23 18:56:28 +00:00
|
|
|
{
|
|
|
|
GstAviMux *avimux;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux = GST_AVIMUX (element);
|
2002-10-23 18:56:28 +00:00
|
|
|
|
|
|
|
/* first fill queue (some elements only set caps when
|
|
|
|
* flowing data), then write header */
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_fill_queue (avimux);
|
|
|
|
|
2002-10-23 18:56:28 +00:00
|
|
|
if (avimux->write_header)
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_start_file (avimux);
|
2002-10-23 18:56:28 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_do_one_buffer (avimux);
|
2001-12-22 23:22:30 +00:00
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
2002-02-02 16:27:20 +00:00
|
|
|
GstAviMux *avimux;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_AVIMUX (object));
|
|
|
|
avimux = GST_AVIMUX (object);
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (prop_id) {
|
2002-02-02 16:27:20 +00:00
|
|
|
case ARG_BIGFILE:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value, avimux->enable_large_avi);
|
2002-02-02 16:27:20 +00:00
|
|
|
break;
|
2001-12-22 23:22:30 +00:00
|
|
|
default:
|
2002-02-02 16:27:20 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-22 23:22:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2001-12-22 23:22:30 +00:00
|
|
|
{
|
2002-02-02 16:27:20 +00:00
|
|
|
GstAviMux *avimux;
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_AVIMUX (object));
|
|
|
|
avimux = GST_AVIMUX (object);
|
2001-12-22 23:22:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (prop_id) {
|
2002-02-02 16:27:20 +00:00
|
|
|
case ARG_BIGFILE:
|
2004-03-14 22:34:33 +00:00
|
|
|
avimux->enable_large_avi = g_value_get_boolean (value);
|
2002-02-02 16:27:20 +00:00
|
|
|
break;
|
2001-12-22 23:22:30 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-02 16:27:20 +00:00
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_avimux_change_state (GstElement * element)
|
2002-02-02 16:27:20 +00:00
|
|
|
{
|
|
|
|
GstAviMux *avimux;
|
|
|
|
gint transition = GST_STATE_TRANSITION (element);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_val_if_fail (GST_IS_AVIMUX (element), GST_STATE_FAILURE);
|
|
|
|
|
|
|
|
avimux = GST_AVIMUX (element);
|
2002-02-02 16:27:20 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
2002-10-23 18:56:28 +00:00
|
|
|
avimux->video_pad_eos = avimux->audio_pad_eos = FALSE;
|
2002-02-02 16:27:20 +00:00
|
|
|
break;
|
ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of...
Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain):
Fail if caps negotiation fails. Should fix #162184, and should
definately be in there regardless of it fixing the actual bug.
* gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init),
(gst_avimux_write_tag), (gst_avimux_riff_get_avi_header),
(gst_avimux_riff_get_avix_header),
(gst_avimux_riff_get_video_header),
(gst_avimux_riff_get_audio_header), (gst_avimux_write_index),
(gst_avimux_start_file), (gst_avimux_handle_event),
(gst_avimux_change_state):
* gst/avi/gstavimux.h:
Refactor structure writing to use GST_WRITE_UINT macros, add
metadata writing support.
2005-01-19 11:01:09 +00:00
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
if (avimux->tags) {
|
|
|
|
gst_tag_list_free (avimux->tags);
|
|
|
|
avimux->tags = NULL;
|
|
|
|
}
|
|
|
|
break;
|
2002-02-02 16:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|