2002-03-20 21:44:42 +00:00
|
|
|
/* GStreamer
|
2001-12-23 13:25:04 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First, include the header file for the plugin, to bring in the
|
|
|
|
* object definition and other useful things.
|
|
|
|
*/
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2004-01-12 04:15:46 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2002-11-26 14:50:05 +00:00
|
|
|
#include "config.h"
|
2004-01-12 04:15:46 +00:00
|
|
|
#endif
|
2003-10-26 11:30:18 +00:00
|
|
|
#include <gst/gst.h>
|
2002-11-26 14:50:05 +00:00
|
|
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
|
|
|
#include <avcodec.h>
|
|
|
|
#include <avformat.h>
|
|
|
|
#else
|
|
|
|
#include <ffmpeg/avcodec.h>
|
|
|
|
#include <ffmpeg/avformat.h>
|
|
|
|
#endif
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2004-12-18 20:53:55 +00:00
|
|
|
#include "gstffmpeg.h"
|
2004-07-07 15:12:02 +00:00
|
|
|
|
2004-12-18 20:53:55 +00:00
|
|
|
GST_DEBUG_CATEGORY (ffmpeg_debug);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2005-12-16 16:23:05 +00:00
|
|
|
static GStaticMutex gst_avcodec_mutex = G_STATIC_MUTEX_INIT;
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
gst_ffmpeg_avcodec_open (AVCodecContext *avctx, AVCodec *codec) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
g_static_mutex_lock (&gst_avcodec_mutex);
|
|
|
|
ret = avcodec_open (avctx, codec);
|
|
|
|
g_static_mutex_unlock (&gst_avcodec_mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gst_ffmpeg_avcodec_close (AVCodecContext *avctx) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
g_static_mutex_lock (&gst_avcodec_mutex);
|
|
|
|
ret = avcodec_close (avctx);
|
|
|
|
g_static_mutex_unlock (&gst_avcodec_mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-01-27 10:21:07 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2004-07-07 15:12:02 +00:00
|
|
|
static void
|
|
|
|
gst_ffmpeg_log_callback (void * ptr, int level, const char * fmt, va_list vl)
|
|
|
|
{
|
|
|
|
GstDebugLevel gst_level;
|
|
|
|
|
2005-09-13 12:16:32 +00:00
|
|
|
if (_shut_up_I_am_probing)
|
|
|
|
return;
|
|
|
|
|
2004-07-07 15:12:02 +00:00
|
|
|
switch (level) {
|
|
|
|
case AV_LOG_QUIET:
|
|
|
|
gst_level = GST_LEVEL_NONE;
|
|
|
|
break;
|
|
|
|
case AV_LOG_ERROR:
|
|
|
|
gst_level = GST_LEVEL_ERROR;
|
|
|
|
break;
|
|
|
|
case AV_LOG_INFO:
|
|
|
|
gst_level = GST_LEVEL_INFO;
|
|
|
|
break;
|
|
|
|
case AV_LOG_DEBUG:
|
|
|
|
gst_level = GST_LEVEL_DEBUG;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gst_level = GST_LEVEL_INFO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_debug_log_valist (ffmpeg_debug, gst_level, "", "", 0, NULL, fmt, vl);
|
|
|
|
}
|
2005-01-27 10:21:07 +00:00
|
|
|
#endif
|
2004-07-07 15:12:02 +00:00
|
|
|
|
2005-09-13 12:16:32 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
gboolean _shut_up_I_am_probing = FALSE;
|
|
|
|
#endif
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
static gboolean
|
2004-03-29 16:39:18 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
2004-07-07 15:12:02 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (ffmpeg_debug, "ffmpeg", 0, "FFmpeg elements");
|
2005-01-27 10:21:07 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2005-09-13 12:16:32 +00:00
|
|
|
|
2004-07-07 15:12:02 +00:00
|
|
|
av_log_set_callback (gst_ffmpeg_log_callback);
|
2005-01-27 10:21:07 +00:00
|
|
|
#endif
|
2002-11-06 23:53:46 +00:00
|
|
|
av_register_all ();
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
gst_ffmpegenc_register (plugin);
|
|
|
|
gst_ffmpegdec_register (plugin);
|
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
|
|
|
gst_ffmpegdemux_register (plugin);
|
ext/ffmpeg/: Port of ffvideoscale to 0.10.
Original commit message from CVS:
Reviewed by : Edward Hervey <edward@fluendo.com>
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegscale.c: (gst_ffmpegscale_base_init),
(gst_ffmpegscale_class_init), (gst_ffmpegscale_init),
(gst_ffmpegscale_finalize), (gst_ffmpegscale_transform_caps),
(gst_ffmpegscale_fixate_caps), (gst_ffmpegscale_get_unit_size),
(gst_ffmpegscale_set_caps), (gst_ffmpegscale_transform),
(gst_ffmpegscale_handle_src_event), (gst_ffmpegscale_register):
Port of ffvideoscale to 0.10.
Closes #332557
2006-03-01 15:08:08 +00:00
|
|
|
gst_ffmpegdeinterlace_register (plugin);
|
|
|
|
gst_ffmpegscale_register (plugin);
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
#if 0
|
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
|
|
|
gst_ffmpegmux_register (plugin);
|
2003-10-25 16:29:13 +00:00
|
|
|
gst_ffmpegcsp_register (plugin);
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
#endif
|
2002-11-25 21:37:26 +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
|
|
|
register_protocol (&gstreamer_protocol);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
/* Now we can return the pointer to the newly created Plugin object. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"ffmpeg",
|
|
|
|
"All FFMPEG codecs",
|
|
|
|
plugin_init,
|
2006-02-11 22:16:43 +00:00
|
|
|
GST_FFMPEG_VERSION, "LGPL", "FFMpeg", "http://ffmpeg.sourceforge.net/")
|
2004-07-07 15:12:02 +00:00
|
|
|
|
|
|
|
|