2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 /* First, include the header file for the plugin, to bring in the
21 * object definition and other useful things.
30 #ifdef HAVE_FFMPEG_UNINSTALLED
34 #include <libavcodec/avcodec.h>
35 #include <libavformat/avformat.h>
38 #include "gstffmpeg.h"
39 #include "gstffmpegutils.h"
41 GST_DEBUG_CATEGORY (ffmpeg_debug);
43 static GStaticMutex gst_avcodec_mutex = G_STATIC_MUTEX_INIT;
47 gst_ffmpeg_avcodec_open (AVCodecContext * avctx, AVCodec * codec)
51 g_static_mutex_lock (&gst_avcodec_mutex);
52 ret = avcodec_open (avctx, codec);
53 g_static_mutex_unlock (&gst_avcodec_mutex);
59 gst_ffmpeg_avcodec_close (AVCodecContext * avctx)
63 g_static_mutex_lock (&gst_avcodec_mutex);
64 ret = avcodec_close (avctx);
65 g_static_mutex_unlock (&gst_avcodec_mutex);
71 gst_ffmpeg_av_find_stream_info (AVFormatContext * ic)
75 g_static_mutex_lock (&gst_avcodec_mutex);
76 ret = av_find_stream_info (ic);
77 g_static_mutex_unlock (&gst_avcodec_mutex);
82 #ifndef GST_DISABLE_GST_DEBUG
84 gst_ffmpeg_log_callback (void *ptr, int level, const char *fmt, va_list vl)
86 GstDebugLevel gst_level;
87 gint len = strlen (fmt);
90 if (_shut_up_I_am_probing)
95 gst_level = GST_LEVEL_NONE;
98 gst_level = GST_LEVEL_ERROR;
101 gst_level = GST_LEVEL_INFO;
104 gst_level = GST_LEVEL_DEBUG;
107 gst_level = GST_LEVEL_INFO;
111 /* remove trailing newline as it gets already appended by the logger */
112 if (fmt[len - 1] == '\n') {
113 fmt2 = g_strdup (fmt);
114 fmt2[len - 1] = '\0';
117 gst_debug_log_valist (ffmpeg_debug, gst_level, "", "", 0, NULL,
118 fmt2 ? fmt2 : fmt, vl);
124 #ifndef GST_DISABLE_GST_DEBUG
125 gboolean _shut_up_I_am_probing = FALSE;
129 plugin_init (GstPlugin * plugin)
131 GST_DEBUG_CATEGORY_INIT (ffmpeg_debug, "ffmpeg", 0, "FFmpeg elements");
132 #ifndef GST_DISABLE_GST_DEBUG
134 av_log_set_callback (gst_ffmpeg_log_callback);
137 gst_ffmpeg_init_pix_fmt_info ();
141 gst_ffmpegenc_register (plugin);
142 gst_ffmpegdec_register (plugin);
143 gst_ffmpegdemux_register (plugin);
144 gst_ffmpegmux_register (plugin);
145 gst_ffmpegdeinterlace_register (plugin);
147 gst_ffmpegscale_register (plugin);
150 gst_ffmpegcsp_register (plugin);
152 gst_ffmpegaudioresample_register (plugin);
154 register_protocol (&gstreamer_protocol);
155 register_protocol (&gstpipe_protocol);
157 /* Now we can return the pointer to the newly created Plugin object. */
161 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
164 "All FFmpeg codecs and formats (" FFMPEG_SOURCE ")",
165 plugin_init, PACKAGE_VERSION, "LGPL", "FFmpeg", "http://ffmpeg.org/")