Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
libavfilter
asrc_anullsrc.c
Go to the documentation of this file.
1
/*
2
* This file is part of Libav.
3
*
4
* Libav is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* Libav 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
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with Libav; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
24
#include <inttypes.h>
25
#include <stdio.h>
26
27
#include "
libavutil/channel_layout.h
"
28
#include "
libavutil/internal.h
"
29
#include "
avfilter.h
"
30
#include "
internal.h
"
31
32
typedef
struct
{
33
uint64_t
channel_layout
;
34
int64_t
sample_rate
;
35
}
ANullContext
;
36
37
static
int
init
(
AVFilterContext
*ctx,
const
char
*args)
38
{
39
ANullContext
*priv = ctx->
priv
;
40
char
channel_layout_str[128] =
""
;
41
42
priv->
sample_rate
= 44100;
43
priv->
channel_layout
=
AV_CH_LAYOUT_STEREO
;
44
45
if
(args)
46
sscanf(args,
"%"
PRId64
":%s"
, &priv->
sample_rate
, channel_layout_str);
47
48
if
(priv->
sample_rate
< 0) {
49
av_log
(ctx,
AV_LOG_ERROR
,
"Invalid negative sample rate: %"
PRId64
"\n"
, priv->
sample_rate
);
50
return
AVERROR
(EINVAL);
51
}
52
53
if
(*channel_layout_str)
54
if
(!(priv->
channel_layout
=
av_get_channel_layout
(channel_layout_str))
55
&& sscanf(channel_layout_str,
"%"
PRId64, &priv->
channel_layout
) != 1) {
56
av_log
(ctx,
AV_LOG_ERROR
,
"Invalid value '%s' for channel layout\n"
,
57
channel_layout_str);
58
return
AVERROR
(EINVAL);
59
}
60
61
return
0;
62
}
63
64
static
int
config_props
(
AVFilterLink
*outlink)
65
{
66
ANullContext
*priv = outlink->
src
->
priv
;
67
char
buf[128];
68
int
chans_nb;
69
70
outlink->
sample_rate
= priv->
sample_rate
;
71
outlink->
channel_layout
= priv->
channel_layout
;
72
73
chans_nb =
av_get_channel_layout_nb_channels
(priv->
channel_layout
);
74
av_get_channel_layout_string
(buf,
sizeof
(buf), chans_nb, priv->
channel_layout
);
75
av_log
(outlink->
src
,
AV_LOG_VERBOSE
,
76
"sample_rate:%"
PRId64
" channel_layout:%"
PRId64
" channel_layout_description:'%s'\n"
,
77
priv->
sample_rate
, priv->
channel_layout
, buf);
78
79
return
0;
80
}
81
82
static
int
request_frame
(
AVFilterLink
*link)
83
{
84
return
-1;
85
}
86
87
static
const
AVFilterPad
avfilter_asrc_anullsrc_outputs
[] = {
88
{
89
.
name
=
"default"
,
90
.type =
AVMEDIA_TYPE_AUDIO
,
91
.config_props =
config_props
,
92
.request_frame =
request_frame
,
93
},
94
{
NULL
}
95
};
96
97
AVFilter
avfilter_asrc_anullsrc
= {
98
.
name
=
"anullsrc"
,
99
.description =
NULL_IF_CONFIG_SMALL
(
"Null audio source, never return audio frames."
),
100
101
.init =
init
,
102
.priv_size =
sizeof
(
ANullContext
),
103
104
.
inputs
=
NULL
,
105
106
.
outputs
= avfilter_asrc_anullsrc_outputs,
107
};