Commit 4996d4c7 authored by Wim Taymans's avatar Wim Taymans

Release early.. try to wrap more ffmpeg stuff, like muxers and demuxers.

Original commit message from CVS:
Release early.. try to wrap more ffmpeg stuff, like muxers and demuxers.
This thing needs a fix in ffmpeg (which I will send to the ffmpeg authors
eventually)
parent 4af5086d
common @ 1ca7d9a2
Subproject commit 2f6d9cfdaaa83ab454d263d6eba88046debadc2d
Subproject commit 1ca7d9a20180cab830f4383cde5ba932338e50b1
......@@ -2,9 +2,16 @@ plugindir = $(libdir)/gst
plugin_LTLIBRARIES = libgstffmpeg.la
libgstffmpeg_la_SOURCES = gstffmpeg.c gstffmpegenc.c gstffmpegdec.c
libgstffmpeg_la_CFLAGS = $(GST_CFLAGS) -I/opt/src/sourceforge/ffmpeg/
libgstffmpeg_la_SOURCES = gstffmpeg.c \
gstffmpegenc.c \
gstffmpegdec.c \
gstffmpegdemux.c \
gstffmpegmux.c \
gstffmpegprotocol.c \
gstffmpegcodecmap.c
libgstffmpeg_la_CFLAGS = $(GST_CFLAGS) -I/opt/src/sourceforge/ffmpeg/ -I/opt/src/sourceforge/ffmpeg/libavcodec/
libgstffmpeg_la_LIBADD =
libgstffmpeg_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -L/opt/src/sourceforge/ffmpeg/libavcodec -lavcodec -L/opt/src/sourceforge/ffmpeg/libav -lavformat
noinst_HEADERS = gstffmpegenc.h gstffmpegdec.h
noinst_HEADERS =
......@@ -20,17 +20,29 @@
/* First, include the header file for the plugin, to bring in the
* object definition and other useful things.
*/
#include "gstffmpegdec.h"
#include "gstffmpegenc.h"
#include <libavcodec/avcodec.h>
#include <libav/avformat.h>
#include <gst/gst.h>
extern gboolean gst_ffmpegdemux_register (GstPlugin *plugin);
extern gboolean gst_ffmpegdec_register (GstPlugin *plugin);
extern gboolean gst_ffmpegenc_register (GstPlugin *plugin);
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
avcodec_init ();
avcodec_register_all ();
av_register_all ();
if (!gst_library_load ("gstbytestream"))
return FALSE;
gst_ffmpegenc_register (plugin);
gst_ffmpegdec_register (plugin);
gst_ffmpegdemux_register (plugin);
/* Now we can return the pointer to the newly created Plugin object. */
return TRUE;
......
/* 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
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libavcodec/avcodec.h>
#include <gst/gst.h>
GstCaps *
gst_ffmpegcodec_codec_context_to_caps (AVCodecContext *context)
{
switch (context->codec_id) {
case CODEC_ID_NONE:
return GST_CAPS_NEW ("ffmpeg_none",
"unkown/unkown",
NULL);
break;
case CODEC_ID_MPEG1VIDEO:
return GST_CAPS_NEW ("ffmpeg_mpeg1video",
"video/mpeg",
"mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
);
break;
case CODEC_ID_H263:
return GST_CAPS_NEW ("ffmpeg_h263",
"video/H263",
NULL);
break;
case CODEC_ID_RV10:
return GST_CAPS_NEW ("ffmpeg_rv10",
"video/x-rv10",
NULL);
break;
case CODEC_ID_MP2:
return GST_CAPS_NEW ("ffmpeg_mp2",
"audio/mp3",
NULL);
break;
case CODEC_ID_MP3LAME:
return GST_CAPS_NEW ("ffmpeg_mp3",
"audio/mp3",
NULL);
break;
case CODEC_ID_VORBIS:
return GST_CAPS_NEW ("ffmpeg_vorbis",
"application/x-ogg",
NULL);
break;
case CODEC_ID_AC3:
return GST_CAPS_NEW ("ffmpeg_ac3",
"audio/ac3",
NULL);
break;
case CODEC_ID_MJPEG:
return GST_CAPS_NEW ("ffmpeg_mjpeg",
"video/x-mjpeg",
NULL);
break;
case CODEC_ID_MPEG4:
return GST_CAPS_NEW ("ffmpeg_mpeg4",
"video/avi",
"format", GST_PROPS_STRING ("strf_vids"),
"fourcc", GST_PROPS_FOURCC (context->fourcc),
"width", GST_PROPS_INT (context->width),
"height", GST_PROPS_INT (context->height)
);
break;
case CODEC_ID_RAWVIDEO:
return GST_CAPS_NEW ("ffmpeg_rawvideo",
"video/raw",
NULL);
break;
case CODEC_ID_MSMPEG4V1:
return GST_CAPS_NEW ("ffmpeg_msmpeg4v1",
"video/avi",
"format", GST_PROPS_STRING ("strf_vids"),
"fourcc", GST_PROPS_FOURCC (context->fourcc),
"width", GST_PROPS_INT (context->width),
"height", GST_PROPS_INT (context->height)
);
break;
case CODEC_ID_MSMPEG4V2:
return GST_CAPS_NEW ("ffmpeg_msmpeg4v2",
"video/avi",
"format", GST_PROPS_STRING ("strf_vids"),
"fourcc", GST_PROPS_FOURCC (context->fourcc),
"width", GST_PROPS_INT (context->width),
"height", GST_PROPS_INT (context->height)
);
break;
case CODEC_ID_MSMPEG4V3:
return GST_CAPS_NEW ("ffmpeg_msmpeg4v3",
"video/avi",
"format", GST_PROPS_STRING ("strf_vids"),
"fourcc", GST_PROPS_FOURCC (context->fourcc),
"width", GST_PROPS_INT (context->width),
"height", GST_PROPS_INT (context->height)
);
break;
case CODEC_ID_WMV1:
return GST_CAPS_NEW ("ffmpeg_wmv1",
"video/avi",
"format", GST_PROPS_STRING ("strf_vids"),
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("WMV1")),
"width", GST_PROPS_INT (context->width),
"height", GST_PROPS_INT (context->height)
);
break;
case CODEC_ID_WMV2:
return GST_CAPS_NEW ("ffmpeg_wmv2",
"unkown/unkown",
NULL);
break;
case CODEC_ID_H263P:
return GST_CAPS_NEW ("ffmpeg_h263p",
"unkown/unkown",
NULL);
break;
case CODEC_ID_H263I:
return GST_CAPS_NEW ("ffmpeg_h263i",
"unkown/unkown",
NULL);
break;
case CODEC_ID_SVQ1:
return GST_CAPS_NEW ("ffmpeg_svq1",
"unkown/unkown",
NULL);
break;
case CODEC_ID_DVVIDEO:
return GST_CAPS_NEW ("ffmpeg_dvvideo",
"unkown/unkown",
NULL);
break;
case CODEC_ID_DVAUDIO:
return GST_CAPS_NEW ("ffmpeg_dvaudio",
"unkown/unkown",
NULL);
break;
case CODEC_ID_WMAV1:
return GST_CAPS_NEW ("ffmpeg_wmav1",
"unkown/unkown",
NULL);
break;
case CODEC_ID_WMAV2:
return GST_CAPS_NEW ("ffmpeg_wmav2",
"unkown/unkown",
NULL);
break;
case CODEC_ID_MACE3:
return GST_CAPS_NEW ("ffmpeg_mace3",
"unkown/unkown",
NULL);
break;
case CODEC_ID_MACE6:
return GST_CAPS_NEW ("ffmpeg_mace6",
"unkown/unkown",
NULL);
break;
/* various pcm "codecs" */
case CODEC_ID_PCM_S16LE:
return GST_CAPS_NEW ("ffmpeg_s16le",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_S16BE:
return GST_CAPS_NEW ("ffmpeg_s16be",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_U16LE:
return GST_CAPS_NEW ("ffmpeg_u16le",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_U16BE:
return GST_CAPS_NEW ("ffmpeg_u16be",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_S8:
return GST_CAPS_NEW ("ffmpeg_s8",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_U8:
return GST_CAPS_NEW ("ffmpeg_u8",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_MULAW:
return GST_CAPS_NEW ("ffmpeg_mulaw",
"unkown/unkown",
NULL);
break;
case CODEC_ID_PCM_ALAW:
return GST_CAPS_NEW ("ffmpeg_alaw",
"unkown/unkown",
NULL);
break;
/* various adpcm codecs */
case CODEC_ID_ADPCM_IMA_QT:
return GST_CAPS_NEW ("ffmpeg_adpcm_ima_qt",
"unkown/unkown",
NULL);
break;
case CODEC_ID_ADPCM_IMA_WAV:
return GST_CAPS_NEW ("ffmpeg_adpcm_ima_wav",
"unkown/unkown",
NULL);
break;
case CODEC_ID_ADPCM_MS:
return GST_CAPS_NEW ("ffmpeg_adpcm_ms",
"unkown/unkown",
NULL);
break;
default:
g_warning ("no caps found for codec id %d\n", context->codec_id);
break;
}
return NULL;
}
......@@ -17,9 +17,43 @@
* Boston, MA 02111-1307, USA.
*/
#include "gstffmpegdec.h"
#include <assert.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#include <gst/gst.h>
typedef struct _GstFFMpegDec GstFFMpegDec;
struct _GstFFMpegDec {
GstElement element;
/* We need to keep track of our pads, so we do so here. */
GstPad *srcpad;
GstPad *sinkpad;
AVCodecContext *context;
AVPicture *picture;
};
typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
struct _GstFFMpegDecClass {
GstElementClass parent_class;
AVCodec *in_plugin;
};
#define GST_TYPE_FFMPEGDEC \
(gst_ffmpegdec_get_type())
#define GST_FFMPEGDEC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
#define GST_FFMPEGDEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
#define GST_IS_FFMPEGDEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
#define GST_IS_FFMPEGDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
enum {
/* FILL ME */
......@@ -341,7 +375,7 @@ gst_ffmpegdec_register (GstPlugin *plugin)
goto next;
}
/* construct the type */
type_name = g_strdup_printf("ffmpeg%s_%s", codec_type, in_plugin->name);
type_name = g_strdup_printf("ff%s_%s", codec_type, in_plugin->name);
/* if it's already registered, drop it */
if (g_type_from_name(type_name)) {
......@@ -370,6 +404,8 @@ gst_ffmpegdec_register (GstPlugin *plugin)
factory = gst_element_factory_new(type_name,type,details);
g_return_val_if_fail(factory != NULL, FALSE);
gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_NONE);
gst_element_factory_add_pad_template (factory,
GST_PAD_TEMPLATE_GET (gst_ffmpegdec_sink_factory));
......
/* 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
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_FFMPEGDEC_H__
#define __GST_FFMPEGDEC_H__
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef __GST_FFMPEG_AV_H__
#define __GST_FFMPEG_AV_H__
#undef ABS
#undef MAX
#undef MIN
#include <assert.h>
#include <libavcodec/avcodec.h>
#endif /* __GST_FFMPEG_AV_H__ */
/* This is the definition of the element's object structure. */
typedef struct _GstFFMpegDec GstFFMpegDec;
/* The structure itself is derived from GstElement, as can be seen by the
* fact that there's a complete instance of the GstElement structure at
* the beginning of the object. This allows the element to be cast to
* an Element or even an Object.
*/
struct _GstFFMpegDec {
GstElement element;
/* We need to keep track of our pads, so we do so here. */
GstPad *srcpad;
GstPad *sinkpad;
AVCodecContext *context;
AVPicture *picture;
};
/* The other half of the object is its class. The class also derives from
* the same parent, though it must be the class structure this time.
* Function pointers for polymophic methods and signals are placed in this
* structure. */
typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
struct _GstFFMpegDecClass {
GstElementClass parent_class;
AVCodec *in_plugin;
};
/* Five standard preprocessing macros are used in the Gtk+ object system.
* The first uses the object's _get_type function to return the GType
* of the object.
*/
#define GST_TYPE_FFMPEGDEC \
(gst_ffmpegdec_get_type())
/* The second is a checking cast to the correct type. If the object passed
* is not the right type, a warning will be generated on stderr.
*/
#define GST_FFMPEGDEC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
/* The third is a checking cast of the class instead of the object. */
#define GST_FFMPEGDEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
/* The last two simply check to see if the passed pointer is an object or
* class of the correct type. */
#define GST_IS_FFMPEGDEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
#define GST_IS_FFMPEGDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
gboolean gst_ffmpegdec_register (GstPlugin *plugin);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_FFMPEGDEC_H__ */
This diff is collapsed.
......@@ -17,9 +17,50 @@
* Boston, MA 02111-1307, USA.
*/
#include "gstffmpegenc.h"
#include <string.h>
#include <assert.h>
#include <libavcodec/avcodec.h>
#include <gst/gst.h>
typedef struct _GstFFMpegEnc GstFFMpegEnc;
struct _GstFFMpegEnc {
GstElement element;
/* We need to keep track of our pads, so we do so here. */
GstPad *srcpad;
GstPad *sinkpad;
gboolean need_resample;
gint in_width, in_height;
gint out_width, out_height;
guchar *buffer;
gint buffer_pos;
AVCodecContext *context;
ImgReSampleContext *resample;
};
typedef struct _GstFFMpegEncClass GstFFMpegEncClass;
struct _GstFFMpegEncClass {
GstElementClass parent_class;
AVCodec *in_plugin;
};
#define GST_TYPE_FFMPEGENC \
(gst_ffmpegenc_get_type())
#define GST_FFMPEGENC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGENC,GstFFMpegEnc))
#define GST_FFMPEGENC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGENC,GstFFMpegEncClass))
#define GST_IS_FFMPEGENC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGENC))
#define GST_IS_FFMPEGENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGENC))
#define VIDEO_BUFFER_SIZE (1024*1024)
......@@ -515,7 +556,7 @@ gst_ffmpegenc_register (GstPlugin *plugin)
goto next;
}
/* construct the type */
type_name = g_strdup_printf("ffmpeg%s_%s", codec_type, in_plugin->name);
type_name = g_strdup_printf("ff%s_%s", codec_type, in_plugin->name);
/* if it's already registered, drop it */
if (g_type_from_name(type_name)) {
......
/* 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
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_FFMPEGENC_H__
#define __GST_FFMPEGENC_H__
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef __GST_FFMPEG_AV_H__
#define __GST_FFMPEG_AV_H__
#undef ABS
#undef MAX
#undef MIN
#include <assert.h>
#include <libavcodec/avcodec.h>
#endif /* __GST_FFMPEG_AV_H__ */
/* This is the definition of the element's object structure. */
typedef struct _GstFFMpegEnc GstFFMpegEnc;
/* The structure itself is derived from GstElement, as can be seen by the
* fact that there's a complete instance of the GstElement structure at
* the beginning of the object. This allows the element to be cast to
* an Element or even an Object.
*/
struct _GstFFMpegEnc {
GstElement element;
/* We need to keep track of our pads, so we do so here. */
GstPad *srcpad;
GstPad *sinkpad;
gboolean need_resample;
gint in_width, in_height;
gint out_width, out_height;
guchar *buffer;
gint buffer_pos;
AVCodecContext *context;
ImgReSampleContext *resample;
};
/* The other half of the object is its class. The class also derives from
* the same parent, though it must be the class structure this time.
* Function pointers for polymophic methods and signals are placed in this
* structure. */
typedef struct _GstFFMpegEncClass GstFFMpegEncClass;
struct _GstFFMpegEncClass {
GstElementClass parent_class;
AVCodec *in_plugin;
};
/* Five standard preprocessing macros are used in the Gtk+ object system.
* The first uses the object's _get_type function to return the GType
* of the object.
*/
#define GST_TYPE_FFMPEGENC \
(gst_ffmpegenc_get_type())
/* The second is a checking cast to the correct type. If the object passed
* is not the right type, a warning will be generated on stderr.
*/
#define GST_FFMPEGENC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGENC,GstFFMpegEnc))
/* The third is a checking cast of the class instead of the object. */
#define GST_FFMPEGENC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGENC,GstFFMpegEnc))
/* The last two simply check to see if the passed pointer is an object or
* class of the correct type. */
#define GST_IS_FFMPEGENC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGENC))
#define GST_IS_FFMPEGENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGENC))
gboolean gst_ffmpegenc_register (GstPlugin *plugin);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_FFMPEGENC_H__ */
This diff is collapsed.
/* 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
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <errno.h>
#include <libav/avformat.h>
#include <gst/gst.h>
#include <gst/bytestream/bytestream.h>
typedef struct _GstProtocolInfo GstProtocolInfo;
struct _GstProtocolInfo
{
GstPad *pad;
int flags;
GstByteStream *bs;
};
static int
gst_open (URLContext *h, const char *filename, int flags)
{
GstProtocolInfo *info;
GstPad *pad;
info = g_new0 (GstProtocolInfo, 1);
info->flags = flags;
if (sscanf (&filename[12], "%p", &pad) != 1) {
g_warning ("could not decode pad from %s", &filename[12]);
return -EIO;
}
if (!GST_IS_PAD (pad)) {
g_warning ("decoded string is not a pad, %s", &filename[12]);
return -EIO;
}
info->bs = gst_bytestream_new (pad);
h->priv_data = (void *) info;
return 0;
}
static int
gst_read (URLContext *h, unsigned char *buf, int size)
{
GstByteStream *bs;
guint32 total;
guint8 *data;
GstProtocolInfo *info;
info = (GstProtocolInfo *) h->priv_data;
bs = info->bs;
total = gst_bytestream_peek_bytes (bs, &data, size);
memcpy (buf, data, total);
gst_bytestream_flush_fast (bs, total);
return total;
}
static int gst_write(URLContext *h, unsigned char *buf, int size)
{
g_print ("write %p, %d\n", buf, size);
return 0;
}
static int gst_close(URLContext *h)
{
return 0;
}
URLProtocol gstreamer_protocol = {
"gstreamer",
gst_open,
gst_read,
gst_write,
NULL,
gst_close,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment