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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 /* First, include the header file for the plugin, to bring in the
21 * object definition and other useful things.
31 #include <libavcodec/avcodec.h>
32 #include <libavformat/avformat.h>
35 #include "gstavutils.h"
37 GST_DEBUG_CATEGORY (ffmpeg_debug);
39 static GStaticMutex gst_avcodec_mutex = G_STATIC_MUTEX_INIT;
43 gst_ffmpeg_avcodec_open (AVCodecContext * avctx, AVCodec * codec)
47 g_static_mutex_lock (&gst_avcodec_mutex);
48 ret = avcodec_open2 (avctx, codec, NULL);
49 g_static_mutex_unlock (&gst_avcodec_mutex);
55 gst_ffmpeg_avcodec_close (AVCodecContext * avctx)
59 g_static_mutex_lock (&gst_avcodec_mutex);
60 ret = avcodec_close (avctx);
61 g_static_mutex_unlock (&gst_avcodec_mutex);
67 gst_ffmpeg_av_find_stream_info (AVFormatContext * ic)
71 g_static_mutex_lock (&gst_avcodec_mutex);
72 ret = avformat_find_stream_info (ic, NULL);
73 g_static_mutex_unlock (&gst_avcodec_mutex);
78 #ifndef GST_DISABLE_GST_DEBUG
80 gst_ffmpeg_log_callback (void *ptr, int level, const char *fmt, va_list vl)
82 GstDebugLevel gst_level;
83 gint len = strlen (fmt);
88 gst_level = GST_LEVEL_NONE;
91 gst_level = GST_LEVEL_ERROR;
94 gst_level = GST_LEVEL_INFO;
97 gst_level = GST_LEVEL_DEBUG;
100 gst_level = GST_LEVEL_INFO;
104 /* remove trailing newline as it gets already appended by the logger */
105 if (fmt[len - 1] == '\n') {
106 fmt2 = g_strdup (fmt);
107 fmt2[len - 1] = '\0';
110 gst_debug_log_valist (ffmpeg_debug, gst_level, "", "", 0, NULL,
111 fmt2 ? fmt2 : fmt, vl);
118 plugin_init (GstPlugin * plugin)
120 GST_DEBUG_CATEGORY_INIT (ffmpeg_debug, "libav", 0, "libav elements");
121 #ifndef GST_DISABLE_GST_DEBUG
123 av_log_set_callback (gst_ffmpeg_log_callback);
126 gst_ffmpeg_init_pix_fmt_info ();
130 gst_ffmpegaudenc_register (plugin);
131 gst_ffmpegvidenc_register (plugin);
132 gst_ffmpegauddec_register (plugin);
133 gst_ffmpegviddec_register (plugin);
134 gst_ffmpegdemux_register (plugin);
135 gst_ffmpegmux_register (plugin);
136 gst_ffmpegdeinterlace_register (plugin);
138 gst_ffmpegscale_register (plugin);
141 gst_ffmpegaudioresample_register (plugin);
144 /* Now we can return the pointer to the newly created Plugin object. */
148 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
151 "All libav codecs and formats (" LIBAV_SOURCE ")",
152 plugin_init, PACKAGE_VERSION,
153 #ifdef GST_LIBAV_ENABLE_LGPL
158 "libav", "http://www.libav.org")