2002-11-06 23:53:46 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:22:16 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2002-11-06 23:53:46 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2002-11-26 14:50:05 +00:00
|
|
|
#include "config.h"
|
2003-06-09 15:04:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2012-09-10 15:08:00 +00:00
|
|
|
#include <libavformat/avformat.h>
|
2012-12-12 12:09:32 +00:00
|
|
|
#include <libavutil/opt.h>
|
2002-11-06 23:53:46 +00:00
|
|
|
#include <gst/gst.h>
|
2012-04-17 13:36:12 +00:00
|
|
|
#include <gst/base/gstcollectpads.h>
|
2002-11-26 14:50:05 +00:00
|
|
|
|
2012-09-10 15:53:54 +00:00
|
|
|
#include "gstav.h"
|
|
|
|
#include "gstavcodecmap.h"
|
|
|
|
#include "gstavutils.h"
|
2012-12-22 09:49:52 +00:00
|
|
|
#include "gstavprotocol.h"
|
2003-06-09 15:04:26 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
typedef struct _GstFFMpegMux GstFFMpegMux;
|
2006-09-08 15:25:51 +00:00
|
|
|
typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
|
|
|
|
|
|
|
|
struct _GstFFMpegMuxPad
|
|
|
|
{
|
2012-04-17 13:36:12 +00:00
|
|
|
GstCollectData collect; /* we extend the CollectData */
|
2006-09-08 15:25:51 +00:00
|
|
|
|
|
|
|
gint padnum;
|
|
|
|
};
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
struct _GstFFMpegMux
|
|
|
|
{
|
|
|
|
GstElement element;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2012-04-17 13:36:12 +00:00
|
|
|
GstCollectPads *collect;
|
2002-11-06 23:53:46 +00:00
|
|
|
/* We need to keep track of our pads, so we do so here. */
|
2004-03-29 16:39:18 +00:00
|
|
|
GstPad *srcpad;
|
2003-06-09 15:04:26 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
AVFormatContext *context;
|
|
|
|
gboolean opened;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2011-11-04 11:43:17 +00:00
|
|
|
guint videopads, audiopads;
|
2006-09-08 15:25:51 +00:00
|
|
|
|
2007-02-09 16:17:50 +00:00
|
|
|
/*< private > */
|
2006-09-08 16:52:19 +00:00
|
|
|
/* event_function is the collectpads default eventfunction */
|
2007-02-09 16:17:50 +00:00
|
|
|
GstPadEventFunction event_function;
|
2009-03-05 07:52:11 +00:00
|
|
|
int max_delay;
|
2012-12-12 12:09:32 +00:00
|
|
|
int preload;
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
struct _GstFFMpegMuxClass
|
|
|
|
{
|
|
|
|
GstElementClass parent_class;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
AVOutputFormat *in_plugin;
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GST_TYPE_FFMPEGMUX \
|
|
|
|
(gst_ffmpegdec_get_type())
|
|
|
|
#define GST_FFMPEGMUX(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
|
|
|
|
#define GST_FFMPEGMUX_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
|
|
|
|
#define GST_IS_FFMPEGMUX(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
|
2006-09-16 22:19:40 +00:00
|
|
|
#define GST_IS_FFMPEGMUX_CLASS(klass) \
|
2002-11-06 23:53:46 +00:00
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-11-06 23:53:46 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2009-03-05 07:52:11 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_PRELOAD,
|
|
|
|
PROP_MAXDELAY
|
|
|
|
};
|
|
|
|
|
2007-02-16 11:48:15 +00:00
|
|
|
/* A number of function prototypes are given so we can refer to them later. */
|
2004-03-29 16:39:18 +00:00
|
|
|
static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
|
2006-09-08 15:25:51 +00:00
|
|
|
static void gst_ffmpegmux_base_init (gpointer g_class);
|
2007-02-09 16:17:50 +00:00
|
|
|
static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
|
|
|
|
GstFFMpegMuxClass * g_class);
|
2005-05-01 10:15:33 +00:00
|
|
|
static void gst_ffmpegmux_finalize (GObject * object);
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
|
2004-03-29 16:39:18 +00:00
|
|
|
static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
|
2011-06-02 14:23:19 +00:00
|
|
|
GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
|
2012-04-17 13:36:12 +00:00
|
|
|
static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
|
2007-02-09 16:17:50 +00:00
|
|
|
gpointer user_data);
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2011-11-17 11:49:33 +00:00
|
|
|
static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2006-09-08 16:52:19 +00:00
|
|
|
|
2005-09-05 14:06:29 +00:00
|
|
|
static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2009-03-05 07:52:11 +00:00
|
|
|
static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
2014-01-03 15:28:44 +00:00
|
|
|
static GstCaps *gst_ffmpegmux_get_id_caps (enum AVCodecID *id_list);
|
2009-11-02 07:49:43 +00:00
|
|
|
static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
|
|
|
|
const gchar * field, guint num, const gint * values);
|
|
|
|
|
2012-04-12 17:41:52 +00:00
|
|
|
#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("avmux-params")
|
2007-02-16 11:48:15 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
2010-06-25 22:59:24 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *replacement;
|
|
|
|
} GstFFMpegMuxReplacement;
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
gst_ffmpegmux_get_replacement (const char *name)
|
|
|
|
{
|
|
|
|
static const GstFFMpegMuxReplacement blacklist[] = {
|
|
|
|
{"avi", "avimux"},
|
|
|
|
{"matroska", "matroskamux"},
|
|
|
|
{"mov", "qtmux"},
|
|
|
|
{"mpegts", "mpegtsmux"},
|
|
|
|
{"mp4", "mp4mux"},
|
|
|
|
{"mpjpeg", "multipartmux"},
|
|
|
|
{"ogg", "oggmux"},
|
|
|
|
{"wav", "wavenc"},
|
|
|
|
{"webm", "webmmux"},
|
|
|
|
{"mxf", "mxfmux"},
|
|
|
|
{"3gp", "gppmux"},
|
2010-07-06 11:58:05 +00:00
|
|
|
{"yuv4mpegpipe", "y4menc"},
|
|
|
|
{"aiff", "aiffmux"},
|
|
|
|
{"adts", "aacparse"},
|
|
|
|
{"asf", "asfmux"},
|
|
|
|
{"asf_stream", "asfmux"},
|
|
|
|
{"flv", "flvmux"},
|
|
|
|
{"mp3", "id3v2mux"},
|
|
|
|
{"mp2", "id3v2mux"}
|
2010-06-25 22:59:24 +00:00
|
|
|
};
|
2018-07-01 00:34:41 +00:00
|
|
|
guint i;
|
2010-06-25 22:59:24 +00:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
|
|
|
|
if (strcmp (blacklist[i].name, name) == 0) {
|
|
|
|
return blacklist[i].replacement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-06 11:58:30 +00:00
|
|
|
static gboolean
|
|
|
|
gst_ffmpegmux_is_formatter (const char *name)
|
|
|
|
{
|
|
|
|
static const char *replace[] = {
|
|
|
|
"mp2", "mp3", NULL
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; replace[i]; i++)
|
|
|
|
if (strcmp (replace[i], name) == 0)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
static void
|
2006-09-08 15:25:51 +00:00
|
|
|
gst_ffmpegmux_base_init (gpointer g_class)
|
2003-11-02 13:12:14 +00:00
|
|
|
{
|
2006-09-08 15:25:51 +00:00
|
|
|
GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
2003-11-02 13:12:14 +00:00
|
|
|
GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
|
2009-11-02 07:49:43 +00:00
|
|
|
AVOutputFormat *in_plugin;
|
|
|
|
GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
|
2014-01-03 15:28:44 +00:00
|
|
|
enum AVCodecID *video_ids = NULL, *audio_ids = NULL;
|
2016-01-07 17:13:29 +00:00
|
|
|
gchar *longname, *description, *name;
|
2010-06-25 22:59:24 +00:00
|
|
|
const char *replacement;
|
2010-07-06 11:58:30 +00:00
|
|
|
gboolean is_formatter;
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
in_plugin =
|
|
|
|
(AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
|
2007-02-16 11:48:15 +00:00
|
|
|
GST_FFMUX_PARAMS_QDATA);
|
2009-11-02 07:49:43 +00:00
|
|
|
g_assert (in_plugin != NULL);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2016-01-07 17:13:29 +00:00
|
|
|
name = g_strdup (in_plugin->name);
|
|
|
|
g_strdelimit (name, ".,|-<> ", '_');
|
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
/* construct the element details struct */
|
2010-06-25 22:59:24 +00:00
|
|
|
replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
|
2010-07-06 11:58:30 +00:00
|
|
|
is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
|
2010-06-25 22:59:24 +00:00
|
|
|
if (replacement != NULL) {
|
|
|
|
longname =
|
2012-04-12 17:41:52 +00:00
|
|
|
g_strdup_printf ("libav %s %s (not recommended, use %s instead)",
|
2010-07-06 11:58:30 +00:00
|
|
|
in_plugin->long_name, is_formatter ? "formatter" : "muxer",
|
|
|
|
replacement);
|
2010-06-25 22:59:24 +00:00
|
|
|
description =
|
2012-04-12 17:41:52 +00:00
|
|
|
g_strdup_printf ("libav %s %s (not recommended, use %s instead)",
|
2010-07-06 11:58:30 +00:00
|
|
|
in_plugin->long_name, is_formatter ? "formatter" : "muxer",
|
|
|
|
replacement);
|
2010-06-25 22:59:24 +00:00
|
|
|
} else {
|
2012-04-12 17:41:52 +00:00
|
|
|
longname = g_strdup_printf ("libav %s %s", in_plugin->long_name,
|
2010-07-06 11:58:30 +00:00
|
|
|
is_formatter ? "formatter" : "muxer");
|
2012-04-12 17:41:52 +00:00
|
|
|
description = g_strdup_printf ("libav %s %s", in_plugin->long_name,
|
2010-07-06 11:58:30 +00:00
|
|
|
is_formatter ? "formatter" : "muxer");
|
2010-06-25 22:59:24 +00:00
|
|
|
}
|
2012-04-09 23:59:24 +00:00
|
|
|
gst_element_class_set_metadata (element_class, longname,
|
2010-07-06 11:58:30 +00:00
|
|
|
is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
|
2010-03-24 10:51:26 +00:00
|
|
|
"Wim Taymans <wim.taymans@chello.be>, "
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
|
|
|
g_free (longname);
|
|
|
|
g_free (description);
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
/* Try to find the caps that belongs here */
|
2016-01-07 17:13:29 +00:00
|
|
|
srccaps = gst_ffmpeg_formatid_to_caps (name);
|
2009-11-02 07:49:43 +00:00
|
|
|
if (!srccaps) {
|
2016-01-07 17:13:29 +00:00
|
|
|
GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping", name);
|
2009-11-02 07:49:43 +00:00
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
|
|
|
|
&video_ids, &audio_ids, in_plugin)) {
|
|
|
|
gst_caps_unref (srccaps);
|
2016-01-07 17:13:29 +00:00
|
|
|
GST_DEBUG ("Couldn't get sink caps for muxer '%s'. Most likely because "
|
|
|
|
"no input format mapping exists.", name);
|
2009-11-02 07:49:43 +00:00
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
|
|
|
videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
|
|
|
|
audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
|
|
|
|
|
|
|
|
/* fix up allowed caps for some muxers */
|
|
|
|
/* FIXME : This should be in gstffmpegcodecmap.c ! */
|
|
|
|
if (strcmp (in_plugin->name, "flv") == 0) {
|
|
|
|
const gint rates[] = { 44100, 22050, 11025 };
|
|
|
|
|
|
|
|
gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
|
2014-01-21 11:58:42 +00:00
|
|
|
} else if (strcmp (in_plugin->name, "dv") == 0) {
|
|
|
|
gst_caps_set_simple (audiosinkcaps,
|
|
|
|
"rate", G_TYPE_INT, 48000, "channels", G_TYPE_INT, 2, NULL);
|
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 13:12:14 +00:00
|
|
|
/* pad templates */
|
2009-11-02 07:49:43 +00:00
|
|
|
srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
|
2003-11-02 13:12:14 +00:00
|
|
|
gst_element_class_add_pad_template (element_class, srctempl);
|
2017-01-02 03:36:09 +00:00
|
|
|
gst_caps_unref (srccaps);
|
2006-11-14 12:34:20 +00:00
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
if (audiosinkcaps) {
|
2011-11-04 11:43:17 +00:00
|
|
|
audiosinktempl = gst_pad_template_new ("audio_%u",
|
2009-11-02 07:49:43 +00:00
|
|
|
GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
|
2006-11-14 12:34:20 +00:00
|
|
|
gst_element_class_add_pad_template (element_class, audiosinktempl);
|
2017-01-02 03:36:09 +00:00
|
|
|
gst_caps_unref (audiosinkcaps);
|
2006-11-14 12:34:20 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
if (videosinkcaps) {
|
2011-11-04 11:43:17 +00:00
|
|
|
videosinktempl = gst_pad_template_new ("video_%u",
|
2009-11-02 07:49:43 +00:00
|
|
|
GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
|
2006-11-14 12:34:20 +00:00
|
|
|
gst_element_class_add_pad_template (element_class, videosinktempl);
|
2017-01-02 03:36:09 +00:00
|
|
|
gst_caps_unref (videosinkcaps);
|
2006-11-14 12:34:20 +00:00
|
|
|
}
|
2003-11-02 13:12:14 +00:00
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
beach:
|
|
|
|
klass->in_plugin = in_plugin;
|
2016-01-07 17:13:29 +00:00
|
|
|
|
|
|
|
g_free (name);
|
2003-11-02 13:12:14 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
static void
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2006-04-08 21:55:22 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2009-03-05 07:52:11 +00:00
|
|
|
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
|
|
|
|
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_PRELOAD,
|
|
|
|
g_param_spec_int ("preload", "preload",
|
2012-12-12 12:09:32 +00:00
|
|
|
"Set the initial demux-decode delay (in microseconds)",
|
2012-12-04 17:28:11 +00:00
|
|
|
0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2009-03-05 07:52:11 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_MAXDELAY,
|
|
|
|
g_param_spec_int ("maxdelay", "maxdelay",
|
|
|
|
"Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
|
2010-10-19 14:26:08 +00:00
|
|
|
0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2009-03-05 07:52:11 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
|
|
|
|
gstelement_class->change_state = gst_ffmpegmux_change_state;
|
2005-05-01 10:15:33 +00:00
|
|
|
gobject_class->finalize = gst_ffmpegmux_finalize;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
static void
|
2006-09-08 15:25:51 +00:00
|
|
|
gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2006-09-08 15:25:51 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
|
2004-03-29 16:39:18 +00:00
|
|
|
GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
|
2002-11-06 23:53:46 +00:00
|
|
|
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
|
2009-03-15 09:19:53 +00:00
|
|
|
gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
|
2003-06-09 15:04:26 +00:00
|
|
|
|
2012-04-17 13:36:12 +00:00
|
|
|
ffmpegmux->collect = gst_collect_pads_new ();
|
|
|
|
gst_collect_pads_set_function (ffmpegmux->collect,
|
|
|
|
(GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
|
2006-09-08 15:25:51 +00:00
|
|
|
|
2012-12-17 15:35:36 +00:00
|
|
|
ffmpegmux->context = avformat_alloc_context ();
|
2003-06-09 15:04:26 +00:00
|
|
|
ffmpegmux->context->oformat = oclass->in_plugin;
|
|
|
|
ffmpegmux->context->nb_streams = 0;
|
|
|
|
ffmpegmux->opened = FALSE;
|
|
|
|
|
|
|
|
ffmpegmux->videopads = 0;
|
|
|
|
ffmpegmux->audiopads = 0;
|
2009-03-05 07:52:11 +00:00
|
|
|
ffmpegmux->max_delay = 0;
|
2003-06-09 15:04:26 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2009-03-05 07:52:11 +00:00
|
|
|
static void
|
|
|
|
gst_ffmpegmux_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstFFMpegMux *src;
|
|
|
|
|
|
|
|
src = (GstFFMpegMux *) object;
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_PRELOAD:
|
2012-12-12 12:09:32 +00:00
|
|
|
src->preload = g_value_get_int (value);
|
2009-03-05 07:52:11 +00:00
|
|
|
break;
|
|
|
|
case PROP_MAXDELAY:
|
|
|
|
src->max_delay = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstFFMpegMux *src;
|
|
|
|
|
|
|
|
src = (GstFFMpegMux *) object;
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_PRELOAD:
|
2012-12-12 12:09:32 +00:00
|
|
|
g_value_set_int (value, src->preload);
|
2009-03-05 07:52:11 +00:00
|
|
|
break;
|
|
|
|
case PROP_MAXDELAY:
|
|
|
|
g_value_set_int (value, src->max_delay);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
static void
|
2005-05-01 10:15:33 +00:00
|
|
|
gst_ffmpegmux_finalize (GObject * object)
|
2003-06-09 15:04:26 +00:00
|
|
|
{
|
|
|
|
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2012-12-17 15:35:36 +00:00
|
|
|
avformat_free_context (ffmpegmux->context);
|
|
|
|
ffmpegmux->context = NULL;
|
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
gst_object_unref (ffmpegmux->collect);
|
2005-05-01 10:15:33 +00:00
|
|
|
|
|
|
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
static GstPad *
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegmux_request_new_pad (GstElement * element,
|
2011-06-02 14:23:19 +00:00
|
|
|
GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2003-06-09 15:04:26 +00:00
|
|
|
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
2006-09-08 15:25:51 +00:00
|
|
|
GstFFMpegMuxPad *collect_pad;
|
2003-06-09 15:04:26 +00:00
|
|
|
gchar *padname;
|
|
|
|
GstPad *pad;
|
|
|
|
AVStream *st;
|
2011-04-19 17:29:57 +00:00
|
|
|
enum AVMediaType type;
|
2006-09-08 15:25:51 +00:00
|
|
|
gint bitrate = 0, framesize = 0;
|
2003-06-09 15:04:26 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (templ != NULL, NULL);
|
|
|
|
g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
|
|
|
|
g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
|
|
|
|
|
|
|
|
/* figure out a name that *we* like */
|
2011-11-04 11:43:17 +00:00
|
|
|
if (templ == gst_element_class_get_pad_template (klass, "video_%u")) {
|
|
|
|
padname = g_strdup_printf ("video_%u", ffmpegmux->videopads++);
|
2011-04-19 17:29:57 +00:00
|
|
|
type = AVMEDIA_TYPE_VIDEO;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
bitrate = 64 * 1024;
|
|
|
|
framesize = 1152;
|
2011-11-04 11:43:17 +00:00
|
|
|
} else if (templ == gst_element_class_get_pad_template (klass, "audio_%u")) {
|
|
|
|
padname = g_strdup_printf ("audio_%u", ffmpegmux->audiopads++);
|
2011-04-19 17:29:57 +00:00
|
|
|
type = AVMEDIA_TYPE_AUDIO;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
bitrate = 285 * 1024;
|
2003-06-09 15:04:26 +00:00
|
|
|
} else {
|
2012-04-12 17:41:52 +00:00
|
|
|
g_warning ("avmux: unknown pad template!");
|
2003-06-09 15:04:26 +00:00
|
|
|
return NULL;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* create pad */
|
|
|
|
pad = gst_pad_new_from_template (templ, padname);
|
2006-09-08 15:25:51 +00:00
|
|
|
collect_pad = (GstFFMpegMuxPad *)
|
2012-04-17 13:36:12 +00:00
|
|
|
gst_collect_pads_add_pad (ffmpegmux->collect, pad,
|
2012-09-12 19:15:24 +00:00
|
|
|
sizeof (GstFFMpegMuxPad), NULL, TRUE);
|
2006-09-08 15:25:51 +00:00
|
|
|
collect_pad->padnum = ffmpegmux->context->nb_streams;
|
|
|
|
|
2006-09-08 16:52:19 +00:00
|
|
|
/* small hack to put our own event pad function and chain up to collect pad */
|
2007-02-09 16:17:50 +00:00
|
|
|
ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
|
|
|
|
gst_pad_set_event_function (pad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
|
2006-09-08 16:52:19 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
gst_element_add_pad (element, pad);
|
|
|
|
|
|
|
|
/* AVStream needs to be created */
|
2012-12-04 17:28:11 +00:00
|
|
|
st = avformat_new_stream (ffmpegmux->context, NULL);
|
|
|
|
st->id = collect_pad->padnum;
|
2018-06-29 18:37:14 +00:00
|
|
|
st->codecpar->codec_type = type;
|
|
|
|
st->codecpar->codec_id = AV_CODEC_ID_NONE; /* this is a check afterwards */
|
|
|
|
st->codecpar->bit_rate = bitrate;
|
|
|
|
st->codecpar->frame_size = framesize;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
/* we fill in codec during capsnego */
|
2003-06-09 15:04:26 +00:00
|
|
|
|
|
|
|
/* we love debug output (c) (tm) (r) */
|
2012-04-12 17:41:52 +00:00
|
|
|
GST_DEBUG ("Created %s pad for avmux_%s element",
|
2009-06-17 06:22:14 +00:00
|
|
|
padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
|
2003-06-09 15:04:26 +00:00
|
|
|
g_free (padname);
|
|
|
|
|
|
|
|
return pad;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
/**
|
|
|
|
* gst_ffmpegmux_setcaps
|
|
|
|
* @pad: #GstPad
|
|
|
|
* @caps: New caps.
|
|
|
|
*
|
|
|
|
* Set caps to pad.
|
|
|
|
*
|
|
|
|
* Returns: #TRUE on success.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2004-03-29 16:39:18 +00:00
|
|
|
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
|
2006-09-08 15:25:51 +00:00
|
|
|
GstFFMpegMuxPad *collect_pad;
|
2003-06-09 15:04:26 +00:00
|
|
|
AVStream *st;
|
2018-06-29 18:37:14 +00:00
|
|
|
AVCodecContext tmp;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
|
|
|
|
|
|
|
|
st = ffmpegmux->context->streams[collect_pad->padnum];
|
2014-02-04 16:17:32 +00:00
|
|
|
av_opt_set_int (ffmpegmux->context, "preload", ffmpegmux->preload, 0);
|
2009-03-05 07:52:11 +00:00
|
|
|
ffmpegmux->context->max_delay = ffmpegmux->max_delay;
|
2020-04-15 07:00:02 +00:00
|
|
|
memset (&tmp, 0, sizeof (tmp));
|
2003-06-09 15:04:26 +00:00
|
|
|
|
|
|
|
/* for the format-specific guesses, we'll go to
|
|
|
|
* our famous codec mapper */
|
2018-06-29 18:37:14 +00:00
|
|
|
if (gst_ffmpeg_caps_to_codecid (caps, &tmp) == AV_CODEC_ID_NONE)
|
2008-11-11 17:18:46 +00:00
|
|
|
goto not_accepted;
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2018-06-29 18:37:14 +00:00
|
|
|
avcodec_parameters_from_context (st->codecpar, &tmp);
|
|
|
|
|
2008-11-11 17:18:46 +00:00
|
|
|
/* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
|
|
|
|
* codec aspect. */
|
2018-06-29 18:37:14 +00:00
|
|
|
st->sample_aspect_ratio = st->codecpar->sample_aspect_ratio;
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2008-11-11 17:18:46 +00:00
|
|
|
GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_accepted:
|
|
|
|
{
|
|
|
|
GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
|
|
|
|
return FALSE;
|
2004-03-29 16:39:18 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
|
2006-09-08 16:52:19 +00:00
|
|
|
static gboolean
|
2011-11-17 11:49:33 +00:00
|
|
|
gst_ffmpegmux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2006-09-08 16:52:19 +00:00
|
|
|
{
|
2011-11-17 11:49:33 +00:00
|
|
|
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) parent;
|
2006-09-08 16:52:19 +00:00
|
|
|
gboolean res = TRUE;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2007-02-09 16:17:50 +00:00
|
|
|
case GST_EVENT_TAG:{
|
2008-12-16 14:24:05 +00:00
|
|
|
GstTagList *taglist;
|
|
|
|
GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
|
|
|
|
const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
|
2007-02-09 16:17:50 +00:00
|
|
|
|
|
|
|
gst_event_parse_tag (event, &taglist);
|
2008-12-16 14:24:05 +00:00
|
|
|
gst_tag_setter_merge_tags (setter, taglist, mode);
|
2007-02-09 16:17:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-06-08 16:04:07 +00:00
|
|
|
case GST_EVENT_CAPS:{
|
|
|
|
GstCaps *caps;
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
if (!(res = gst_ffmpegmux_setcaps (pad, caps)))
|
|
|
|
goto beach;
|
|
|
|
break;
|
|
|
|
}
|
2007-02-09 16:17:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-09-08 16:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* chaining up to collectpads default event function */
|
2011-11-17 11:49:33 +00:00
|
|
|
res = ffmpegmux->event_function (pad, parent, event);
|
2006-09-08 16:52:19 +00:00
|
|
|
|
2011-06-08 16:04:07 +00:00
|
|
|
beach:
|
2006-09-08 16:52:19 +00:00
|
|
|
return res;
|
|
|
|
}
|
2006-09-08 15:25:51 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-04-17 13:36:12 +00:00
|
|
|
gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
|
2006-09-08 15:25:51 +00:00
|
|
|
{
|
|
|
|
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
|
|
|
|
GSList *collected;
|
|
|
|
GstFFMpegMuxPad *best_pad;
|
|
|
|
GstClockTime best_time;
|
2011-04-20 15:37:34 +00:00
|
|
|
#if 0
|
|
|
|
/* Re-enable once converted to new AVMetaData API
|
|
|
|
* See #566605
|
|
|
|
*/
|
2008-12-16 14:24:05 +00:00
|
|
|
const GstTagList *tags;
|
2011-04-20 15:37:34 +00:00
|
|
|
#endif
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* open "file" (gstreamer protocol to next element) */
|
|
|
|
if (!ffmpegmux->opened) {
|
2012-12-04 17:28:11 +00:00
|
|
|
int open_flags = AVIO_FLAG_WRITE;
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
/* we do need all streams to have started capsnego,
|
|
|
|
* or things will go horribly wrong */
|
2006-09-08 15:25:51 +00:00
|
|
|
for (collected = ffmpegmux->collect->data; collected;
|
|
|
|
collected = g_slist_next (collected)) {
|
|
|
|
GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
|
|
|
|
AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
/* check whether the pad has successfully completed capsnego */
|
2018-06-29 18:37:14 +00:00
|
|
|
if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
|
2006-09-08 15:25:51 +00:00
|
|
|
GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
|
|
|
|
("no caps set on stream %d (%s)", collect_pad->padnum,
|
2018-07-01 00:34:41 +00:00
|
|
|
(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ?
|
2004-03-29 16:39:18 +00:00
|
|
|
"video" : "audio"));
|
2006-09-08 15:25:51 +00:00
|
|
|
return GST_FLOW_ERROR;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
}
|
2006-09-08 15:25:51 +00:00
|
|
|
/* set framerate for audio */
|
2018-06-29 18:37:14 +00:00
|
|
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
|
|
|
switch (st->codecpar->codec_id) {
|
2013-05-06 22:56:22 +00:00
|
|
|
case AV_CODEC_ID_PCM_S16LE:
|
|
|
|
case AV_CODEC_ID_PCM_S16BE:
|
|
|
|
case AV_CODEC_ID_PCM_U16LE:
|
|
|
|
case AV_CODEC_ID_PCM_U16BE:
|
|
|
|
case AV_CODEC_ID_PCM_S8:
|
|
|
|
case AV_CODEC_ID_PCM_U8:
|
2018-06-29 18:37:14 +00:00
|
|
|
st->codecpar->frame_size = 1;
|
2007-02-09 16:17:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
/* FIXME : This doesn't work for RAW AUDIO...
|
|
|
|
* in fact I'm wondering if it even works for any kind of audio... */
|
2012-04-17 13:36:12 +00:00
|
|
|
buffer = gst_collect_pads_peek (ffmpegmux->collect,
|
|
|
|
(GstCollectData *) collect_pad);
|
2007-02-09 16:17:50 +00:00
|
|
|
if (buffer) {
|
2018-06-29 18:37:14 +00:00
|
|
|
st->codecpar->frame_size =
|
|
|
|
st->codecpar->sample_rate *
|
2007-02-09 16:17:50 +00:00
|
|
|
GST_BUFFER_DURATION (buffer) / GST_SECOND;
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 15:37:34 +00:00
|
|
|
#if 0
|
|
|
|
/* Re-enable once converted to new AVMetaData API
|
|
|
|
* See #566605
|
|
|
|
*/
|
|
|
|
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
/* tags */
|
2008-12-16 14:24:05 +00:00
|
|
|
tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
|
|
|
|
if (tags) {
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
gint i;
|
|
|
|
gchar *s;
|
|
|
|
|
|
|
|
/* get the interesting ones */
|
|
|
|
if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
|
|
|
|
strncpy (ffmpegmux->context->title, s,
|
|
|
|
sizeof (ffmpegmux->context->title));
|
|
|
|
}
|
|
|
|
if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
|
|
|
|
strncpy (ffmpegmux->context->author, s,
|
|
|
|
sizeof (ffmpegmux->context->author));
|
|
|
|
}
|
|
|
|
if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
|
|
|
|
strncpy (ffmpegmux->context->copyright, s,
|
|
|
|
sizeof (ffmpegmux->context->copyright));
|
|
|
|
}
|
|
|
|
if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
|
|
|
|
strncpy (ffmpegmux->context->comment, s,
|
|
|
|
sizeof (ffmpegmux->context->comment));
|
|
|
|
}
|
|
|
|
if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
|
|
|
|
strncpy (ffmpegmux->context->album, s,
|
|
|
|
sizeof (ffmpegmux->context->album));
|
|
|
|
}
|
|
|
|
if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
|
|
|
|
strncpy (ffmpegmux->context->genre, s,
|
|
|
|
sizeof (ffmpegmux->context->genre));
|
|
|
|
}
|
2006-09-08 16:52:19 +00:00
|
|
|
if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
ffmpegmux->context->track = i;
|
|
|
|
}
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
}
|
2011-04-20 15:37:34 +00:00
|
|
|
#endif
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
/* set the streamheader flag for gstffmpegprotocol if codec supports it */
|
2007-02-09 16:17:50 +00:00
|
|
|
if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
|
|
|
|
open_flags |= GST_FFMPEG_URL_STREAMHEADER;
|
2006-09-08 15:25:51 +00:00
|
|
|
}
|
2005-07-11 12:34:18 +00:00
|
|
|
|
2014-02-22 20:54:08 +00:00
|
|
|
/* some house-keeping for downstream before starting data flow */
|
|
|
|
/* stream-start (FIXME: create id based on input ids) */
|
|
|
|
{
|
|
|
|
gchar s_id[32];
|
|
|
|
|
|
|
|
g_snprintf (s_id, sizeof (s_id), "avmux-%08x", g_random_int ());
|
|
|
|
gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_stream_start (s_id));
|
|
|
|
}
|
|
|
|
/* segment */
|
|
|
|
{
|
|
|
|
GstSegment segment;
|
|
|
|
|
|
|
|
/* let downstream know we think in BYTES and expect to do seeking later on */
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_segment (&segment));
|
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
|
|
|
|
&ffmpegmux->context->pb) < 0) {
|
2006-09-08 15:25:51 +00:00
|
|
|
GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
|
2012-04-12 17:41:52 +00:00
|
|
|
("Failed to open stream context in avmux"));
|
2006-09-08 15:25:51 +00:00
|
|
|
return GST_FLOW_ERROR;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* now open the mux format */
|
2012-11-19 14:25:42 +00:00
|
|
|
if (avformat_write_header (ffmpegmux->context, NULL) < 0) {
|
2006-09-08 15:25:51 +00:00
|
|
|
GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
("Failed to write file header - check codec settings"));
|
2006-09-08 15:25:51 +00:00
|
|
|
return GST_FLOW_ERROR;
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
}
|
2006-09-08 15:25:51 +00:00
|
|
|
|
2007-02-09 16:17:50 +00:00
|
|
|
/* we're now opened */
|
|
|
|
ffmpegmux->opened = TRUE;
|
|
|
|
|
2005-07-11 12:34:18 +00:00
|
|
|
/* flush the header so it will be used as streamheader */
|
2012-12-04 17:28:11 +00:00
|
|
|
avio_flush (ffmpegmux->context->pb);
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* take the one with earliest timestamp,
|
|
|
|
* and push it forward */
|
2006-09-08 15:25:51 +00:00
|
|
|
best_pad = NULL;
|
|
|
|
best_time = GST_CLOCK_TIME_NONE;
|
|
|
|
for (collected = ffmpegmux->collect->data; collected;
|
|
|
|
collected = g_slist_next (collected)) {
|
|
|
|
GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
|
2012-04-17 13:36:12 +00:00
|
|
|
GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
|
|
|
|
(GstCollectData *) collect_pad);
|
2006-09-08 15:25:51 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* if there's no buffer, just continue */
|
2006-09-08 15:25:51 +00:00
|
|
|
if (buffer == NULL) {
|
2003-06-09 15:04:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* if we have no buffer yet, just use the first one */
|
2006-09-08 15:25:51 +00:00
|
|
|
if (best_pad == NULL) {
|
|
|
|
best_pad = collect_pad;
|
|
|
|
best_time = GST_BUFFER_TIMESTAMP (buffer);
|
|
|
|
goto next_pad;
|
2003-06-09 15:04:26 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* if we do have one, only use this one if it's older */
|
2006-09-08 15:25:51 +00:00
|
|
|
if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
|
|
|
|
best_time = GST_BUFFER_TIMESTAMP (buffer);
|
|
|
|
best_pad = collect_pad;
|
2003-06-09 15:04:26 +00:00
|
|
|
}
|
2006-09-08 15:25:51 +00:00
|
|
|
|
2007-02-09 16:17:50 +00:00
|
|
|
next_pad:
|
2006-09-08 15:25:51 +00:00
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
/* Mux buffers with invalid timestamp first */
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (best_time))
|
|
|
|
break;
|
2003-06-09 15:04:26 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* now handle the buffer, or signal EOS if we have
|
|
|
|
* no buffers left */
|
2006-09-08 15:25:51 +00:00
|
|
|
if (best_pad != NULL) {
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
GstBuffer *buf;
|
2020-06-18 20:16:30 +00:00
|
|
|
AVPacket pkt = { 0, };
|
2012-01-24 13:40:37 +00:00
|
|
|
GstMapInfo map;
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
|
2003-06-09 15:04:26 +00:00
|
|
|
/* push out current buffer */
|
2012-04-17 13:36:12 +00:00
|
|
|
buf =
|
|
|
|
gst_collect_pads_pop (ffmpegmux->collect, (GstCollectData *) best_pad);
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
|
|
|
|
/* set time */
|
2005-07-27 16:03:51 +00:00
|
|
|
pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
|
2006-09-08 15:25:51 +00:00
|
|
|
ffmpegmux->context->streams[best_pad->padnum]->time_base);
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
pkt.dts = pkt.pts;
|
2007-12-17 20:31:35 +00:00
|
|
|
|
2018-02-12 07:32:01 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
|
|
|
pkt.data = map.data;
|
|
|
|
pkt.size = map.size;
|
2007-12-17 20:31:35 +00:00
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
pkt.stream_index = best_pad->padnum;
|
2005-06-27 20:41:55 +00:00
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
|
2011-04-19 17:30:44 +00:00
|
|
|
pkt.flags |= AV_PKT_FLAG_KEY;
|
2005-06-27 20:41:55 +00:00
|
|
|
|
2004-12-16 18:14:19 +00:00
|
|
|
if (GST_BUFFER_DURATION_IS_VALID (buf))
|
2007-02-09 16:17:50 +00:00
|
|
|
pkt.duration =
|
2008-07-06 21:06:45 +00:00
|
|
|
gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
|
2008-10-30 12:05:45 +00:00
|
|
|
ffmpegmux->context->streams[best_pad->padnum]->time_base);
|
2004-12-16 18:14:19 +00:00
|
|
|
av_write_frame (ffmpegmux->context, &pkt);
|
2018-05-11 12:19:42 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2011-04-04 11:18:13 +00:00
|
|
|
gst_buffer_unref (buf);
|
2003-06-09 15:04:26 +00:00
|
|
|
} else {
|
|
|
|
/* close down */
|
HACKING: Add some basic documentation on how our wrapping works.
Original commit message from CVS:
* HACKING:
Add some basic documentation on how our wrapping works.
* TODO:
Add a list of things that could be worked on or that need doing.
* configure.ac:
Update snapshot.
* ext/ffmpeg/Makefile.am:
Changne .la links. See below (autotools patch).
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable demuxers. See below (gstffmpegdemux.c).
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_formatid_to_caps):
Realmedia caused a crash - fix that.
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_averror),
(gst_ffmpegdemux_base_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_dispose),
(gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_src_event_mask), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_format_list),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_src_convert), (gst_ffmpegdemux_add),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Right. OK, so I fixed up the demuxing and have it basically-working,
and the best way to get some more people to test it is to actually
enable it. I'm not sure if we want this for 0.8.0, but we can at
least give it a try. I've tested avi, matroska and mpeg, all appear
to work. The cool thing is that this gives us instant support for
several exotic formats that we'd never care about ourselves. Again,
this needs more testing for it to still be enabled in 0.8.0, but I
want to give it a try...
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
(gst_ffmpegmux_init), (gst_ffmpegmux_request_new_pad),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_register):
Add some fixups that I use locally. Make it work in the case of
MPEG encoding, but the muxer is still not in shape to be enabled.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Some small fixups that crept into it while it was disabled for the
last few years. Basically works.
* gst-libs/ext/ffmpeg/Makefile.am:
Instead of having our local-autotoolized version, I patch the ffmpeg
source to be fully autotoolized. That means a simple SUBDIRS here
is now enough.
* gst-libs/ext/ffmpeg/Tag:
Version update.
* gst-libs/ext/ffmpeg/patch/autotools.diff:
Autotoolize ffmpeg. Needs to be sent to ffmpeg-devel@...
* gst-libs/ext/ffmpeg/patch/disableinstalllibs.diff:
Don't install their libs.
* gst-libs/ext/ffmpeg/patch/disablemmx.diff:
Don't use MMX. It cannot ocmpile using PIC.
* gst-libs/ext/ffmpeg/patch/disabletools.diff:
Don't compile/install their tools, we don't use them.
* gst-libs/ext/ffmpeg/patch/functions.diff:
Prevent symbol conflicts.
* gst-libs/ext/ffmpeg/patch/matroska.diff:
Add a matroska demuxer. Needs to be sent to ffmpeg-devel@...
2004-03-01 04:59:17 +00:00
|
|
|
av_write_trailer (ffmpegmux->context);
|
2003-06-09 15:04:26 +00:00
|
|
|
ffmpegmux->opened = FALSE;
|
2012-12-04 17:28:11 +00:00
|
|
|
avio_flush (ffmpegmux->context->pb);
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpegdata_close (ffmpegmux->context->pb);
|
2006-09-08 15:25:51 +00:00
|
|
|
gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
|
2012-01-03 14:27:54 +00:00
|
|
|
return GST_FLOW_EOS;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
2006-09-08 15:25:51 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 14:06:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2012-03-06 14:27:22 +00:00
|
|
|
GstStateChangeReturn ret;
|
2004-03-29 16:39:18 +00:00
|
|
|
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
|
2003-06-09 15:04:26 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2006-09-08 15:25:51 +00:00
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2012-04-17 13:36:12 +00:00
|
|
|
gst_collect_pads_start (ffmpegmux->collect);
|
2006-09-08 15:25:51 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
2007-02-09 16:17:50 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2012-04-17 13:36:12 +00:00
|
|
|
gst_collect_pads_stop (ffmpegmux->collect);
|
2007-02-09 16:17:50 +00:00
|
|
|
break;
|
2006-09-08 15:25:51 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
|
|
break;
|
2005-09-05 14:06:29 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2008-12-16 15:58:05 +00:00
|
|
|
gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
|
2003-06-09 15:04:26 +00:00
|
|
|
if (ffmpegmux->opened) {
|
|
|
|
ffmpegmux->opened = FALSE;
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpegdata_close (ffmpegmux->context->pb);
|
2003-06-09 15:04:26 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
break;
|
2006-09-08 15:25:51 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
2003-06-09 15:04:26 +00:00
|
|
|
|
2006-09-08 15:25:51 +00:00
|
|
|
return ret;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
static GstCaps *
|
2014-01-03 15:28:44 +00:00
|
|
|
gst_ffmpegmux_get_id_caps (enum AVCodecID *id_list)
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps, *t;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
caps = gst_caps_new_empty ();
|
2013-05-06 22:56:22 +00:00
|
|
|
for (i = 0; id_list[i] != AV_CODEC_ID_NONE; i++) {
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
|
|
|
|
gst_caps_append (caps, t);
|
|
|
|
}
|
2009-05-15 14:48:35 +00:00
|
|
|
if (gst_caps_is_empty (caps)) {
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
return NULL;
|
|
|
|
}
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
2003-06-09 15:04:26 +00:00
|
|
|
|
2007-02-09 17:30:19 +00:00
|
|
|
/* set a list of integer values on the caps, e.g. for sample rates */
|
|
|
|
static void
|
|
|
|
gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
|
|
|
|
guint num, const gint * values)
|
|
|
|
{
|
|
|
|
GValue list = { 0, };
|
|
|
|
GValue val = { 0, };
|
2018-07-01 00:34:41 +00:00
|
|
|
guint i;
|
2007-02-09 17:30:19 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
|
|
|
|
|
|
|
|
g_value_init (&list, GST_TYPE_LIST);
|
|
|
|
g_value_init (&val, G_TYPE_INT);
|
|
|
|
|
|
|
|
for (i = 0; i < num; ++i) {
|
|
|
|
g_value_set_int (&val, values[i]);
|
|
|
|
gst_value_list_append_value (&list, &val);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
|
|
|
|
|
|
|
|
g_value_unset (&val);
|
|
|
|
g_value_unset (&list);
|
|
|
|
}
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
gboolean
|
2004-03-29 16:39:18 +00:00
|
|
|
gst_ffmpegmux_register (GstPlugin * plugin)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
|
|
|
GTypeInfo typeinfo = {
|
2004-03-29 16:39:18 +00:00
|
|
|
sizeof (GstFFMpegMuxClass),
|
|
|
|
(GBaseInitFunc) gst_ffmpegmux_base_init,
|
2002-11-06 23:53:46 +00:00
|
|
|
NULL,
|
2004-03-29 16:39:18 +00:00
|
|
|
(GClassInitFunc) gst_ffmpegmux_class_init,
|
2002-11-06 23:53:46 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-29 16:39:18 +00:00
|
|
|
sizeof (GstFFMpegMux),
|
2002-11-06 23:53:46 +00:00
|
|
|
0,
|
2004-03-29 16:39:18 +00:00
|
|
|
(GInstanceInitFunc) gst_ffmpegmux_init,
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
static const GInterfaceInfo tag_setter_info = {
|
2007-02-09 16:17:50 +00:00
|
|
|
NULL, NULL, NULL
|
ext/ffmpeg/gstffmpeg.c: Enable muxers (only mp4 muxer for now).
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
Enable muxers (only mp4 muxer for now).
* ext/ffmpeg/gstffmpegcodecmap.c:
(gst_ffmpeg_formatid_get_codecids), (gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegcodecmap.h:
Fix a bunch of typos in codec-id lookup (false/true return value
mixup), add a codec-id list retrieval function (because ffmpeg
does not provide one). With that, we can make valid pad templates.
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_init),
(gst_ffmpegmux_connect), (gst_ffmpegmux_loop),
(gst_ffmpegmux_change_state), (gst_ffmpegmux_get_id_caps),
(gst_ffmpegmux_register):
Fix for whatever changed since I last tried this. Works for MP4
muxing.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek), (gst_ffmpegdata_close):
Update obviously-untested write code...
2005-03-14 15:27:43 +00:00
|
|
|
};
|
2002-11-06 23:53:46 +00:00
|
|
|
GType type;
|
2018-06-29 19:38:50 +00:00
|
|
|
const AVOutputFormat *in_plugin;
|
|
|
|
void *i = 0;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Registering muxers");
|
|
|
|
|
2018-06-29 19:38:50 +00:00
|
|
|
while ((in_plugin = av_muxer_iterate (&i))) {
|
2002-11-06 23:53:46 +00:00
|
|
|
gchar *type_name;
|
2010-07-06 09:58:40 +00:00
|
|
|
GstRank rank = GST_RANK_MARGINAL;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2009-02-27 08:40:03 +00:00
|
|
|
if ((!strncmp (in_plugin->name, "u16", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "s16", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "u24", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "s24", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "u8", 2)) ||
|
|
|
|
(!strncmp (in_plugin->name, "s8", 2)) ||
|
|
|
|
(!strncmp (in_plugin->name, "u32", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "s32", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "f32", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "f64", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "raw", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "crc", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "null", 4)) ||
|
|
|
|
(!strncmp (in_plugin->name, "gif", 3)) ||
|
2016-11-12 15:21:59 +00:00
|
|
|
(!strncmp (in_plugin->name, "fifo", 4)) ||
|
2009-02-27 08:40:03 +00:00
|
|
|
(!strncmp (in_plugin->name, "frame", 5)) ||
|
2009-03-10 20:05:52 +00:00
|
|
|
(!strncmp (in_plugin->name, "image", 5)) ||
|
|
|
|
(!strncmp (in_plugin->name, "mulaw", 5)) ||
|
|
|
|
(!strncmp (in_plugin->name, "alaw", 4)) ||
|
2010-01-25 15:40:20 +00:00
|
|
|
(!strncmp (in_plugin->name, "h26", 3)) ||
|
2010-07-02 15:21:27 +00:00
|
|
|
(!strncmp (in_plugin->name, "rtp", 3)) ||
|
2011-01-24 16:43:44 +00:00
|
|
|
(!strncmp (in_plugin->name, "ass", 3)) ||
|
|
|
|
(!strncmp (in_plugin->name, "ffmetadata", 10)) ||
|
2012-06-09 13:37:09 +00:00
|
|
|
(!strncmp (in_plugin->name, "srt", 3)) ||
|
2017-07-10 07:33:03 +00:00
|
|
|
(!strncmp (in_plugin->name, "scc", 3)) ||
|
2015-06-29 11:29:05 +00:00
|
|
|
!strcmp (in_plugin->name, "segment") ||
|
2015-07-01 20:11:52 +00:00
|
|
|
!strcmp (in_plugin->name, "stream_segment,ssegment") ||
|
|
|
|
!strcmp (in_plugin->name, "jacosub") ||
|
|
|
|
!strcmp (in_plugin->name, "webvtt") ||
|
|
|
|
!strcmp (in_plugin->name, "lrc") ||
|
|
|
|
!strcmp (in_plugin->name, "microdvd") ||
|
|
|
|
!strcmp (in_plugin->name, "tee") ||
|
|
|
|
!strncmp (in_plugin->name, "webm", 4)
|
2009-02-27 08:40:03 +00:00
|
|
|
) {
|
|
|
|
GST_LOG ("Ignoring muxer %s", in_plugin->name);
|
2018-06-29 19:38:50 +00:00
|
|
|
continue;
|
2009-02-27 08:40:03 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 22:57:45 +00:00
|
|
|
if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
|
|
|
|
GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
|
2018-06-29 19:38:50 +00:00
|
|
|
continue;
|
2010-06-25 22:57:45 +00:00
|
|
|
}
|
|
|
|
|
2010-07-06 09:58:40 +00:00
|
|
|
if (gst_ffmpegmux_get_replacement (in_plugin->name))
|
|
|
|
rank = GST_RANK_NONE;
|
|
|
|
|
2009-11-02 07:49:43 +00:00
|
|
|
/* FIXME : We need a fast way to know whether we have mappings for this
|
|
|
|
* muxer type. */
|
2003-06-09 15:04:26 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
/* construct the type */
|
2012-04-12 17:41:52 +00:00
|
|
|
type_name = g_strdup_printf ("avmux_%s", in_plugin->name);
|
2016-01-07 17:13:29 +00:00
|
|
|
g_strdelimit (type_name, ".,|-<> ", '_');
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2009-06-05 11:19:03 +00:00
|
|
|
type = g_type_from_name (type_name);
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
/* create the type now */
|
|
|
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
2009-11-02 07:49:43 +00:00
|
|
|
g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
|
2009-06-05 11:19:03 +00:00
|
|
|
g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
|
|
|
|
}
|
2007-02-16 11:48:15 +00:00
|
|
|
|
2010-07-06 09:58:40 +00:00
|
|
|
if (!gst_element_register (plugin, type_name, rank, type)) {
|
2004-09-16 21:14:46 +00:00
|
|
|
g_free (type_name);
|
2003-11-02 19:07:41 +00:00
|
|
|
return FALSE;
|
2004-09-16 21:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (type_name);
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2007-12-17 12:43:06 +00:00
|
|
|
GST_LOG ("Finished registering muxers");
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|