• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavfilter/asrc_anullsrc.c

Go to the documentation of this file.
00001 /*
00002  * This file is part of Libav.
00003  *
00004  * Libav is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * Libav is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with Libav; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00017  */
00018 
00024 #include "avfilter.h"
00025 #include "libavutil/audioconvert.h"
00026 
00027 typedef struct {
00028     uint64_t channel_layout;
00029     int64_t sample_rate;
00030 } ANullContext;
00031 
00032 static int init(AVFilterContext *ctx, const char *args, void *opaque)
00033 {
00034     ANullContext *priv = ctx->priv;
00035     char channel_layout_str[128] = "";
00036 
00037     priv->sample_rate = 44100;
00038     priv->channel_layout = AV_CH_LAYOUT_STEREO;
00039 
00040     if (args)
00041         sscanf(args, "%"PRId64":%s", &priv->sample_rate, channel_layout_str);
00042 
00043     if (priv->sample_rate < 0) {
00044         av_log(ctx, AV_LOG_ERROR, "Invalid negative sample rate: %"PRId64"\n", priv->sample_rate);
00045         return AVERROR(EINVAL);
00046     }
00047 
00048     if (*channel_layout_str)
00049         if (!(priv->channel_layout = av_get_channel_layout(channel_layout_str))
00050             && sscanf(channel_layout_str, "%"PRId64, &priv->channel_layout) != 1) {
00051             av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for channel layout\n",
00052                    channel_layout_str);
00053             return AVERROR(EINVAL);
00054         }
00055 
00056     return 0;
00057 }
00058 
00059 static int config_props(AVFilterLink *outlink)
00060 {
00061     ANullContext *priv = outlink->src->priv;
00062     char buf[128];
00063     int chans_nb;
00064 
00065     outlink->sample_rate = priv->sample_rate;
00066     outlink->channel_layout = priv->channel_layout;
00067 
00068     chans_nb = av_get_channel_layout_nb_channels(priv->channel_layout);
00069     av_get_channel_layout_string(buf, sizeof(buf), chans_nb, priv->channel_layout);
00070     av_log(outlink->src, AV_LOG_INFO,
00071            "sample_rate:%"PRId64 " channel_layout:%"PRId64 " channel_layout_description:'%s'\n",
00072            priv->sample_rate, priv->channel_layout, buf);
00073 
00074     return 0;
00075 }
00076 
00077 static int request_frame(AVFilterLink *link)
00078 {
00079     return -1;
00080 }
00081 
00082 AVFilter avfilter_asrc_anullsrc = {
00083     .name        = "anullsrc",
00084     .description = NULL_IF_CONFIG_SMALL("Null audio source, never return audio frames."),
00085 
00086     .init        = init,
00087     .priv_size   = sizeof(ANullContext),
00088 
00089     .inputs      = (AVFilterPad[]) {{ .name = NULL}},
00090 
00091     .outputs     = (AVFilterPad[]) {{ .name = "default",
00092                                       .type = AVMEDIA_TYPE_AUDIO,
00093                                       .config_props = config_props,
00094                                       .request_frame = request_frame, },
00095                                     { .name = NULL}},
00096 };
Generated on Sun Apr 22 2012 21:54:06 for Libav by doxygen 1.7.1