Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
1e5014c7
Commit
1e5014c7
authored
Aug 28, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter: Add command passing support
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
4becc861
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
1 deletion
+83
-1
avfilter.c
libavfilter/avfilter.c
+12
-0
avfilter.h
libavfilter/avfilter.h
+24
-1
avfiltergraph.c
libavfilter/avfiltergraph.c
+30
-0
avfiltergraph.h
libavfilter/avfiltergraph.h
+17
-0
No files found.
libavfilter/avfilter.c
View file @
1e5014c7
...
...
@@ -26,6 +26,7 @@
#include "libavutil/audioconvert.h"
#include "libavutil/imgutils.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "avfilter.h"
#include "internal.h"
...
...
@@ -616,6 +617,17 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
draw_slice
(
link
,
y
,
h
,
slice_dir
);
}
int
avfilter_process_command
(
AVFilterContext
*
filter
,
const
char
*
cmd
,
const
char
*
arg
,
char
*
res
,
int
res_len
,
int
flags
)
{
if
(
!
strcmp
(
cmd
,
"ping"
)){
av_strlcatf
(
res
,
res_len
,
"pong from:%s %s
\n
"
,
filter
->
filter
->
name
,
filter
->
name
);
return
0
;
}
else
if
(
filter
->
filter
->
process_command
)
{
return
filter
->
filter
->
process_command
(
filter
,
cmd
,
arg
,
res
,
res_len
,
flags
);
}
return
AVERROR
(
ENOSYS
);
}
void
avfilter_filter_samples
(
AVFilterLink
*
link
,
AVFilterBufferRef
*
samplesref
)
{
void
(
*
filter_samples
)(
AVFilterLink
*
,
AVFilterBufferRef
*
);
...
...
libavfilter/avfilter.h
View file @
1e5014c7
...
...
@@ -29,7 +29,7 @@
#include "libavutil/rational.h"
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 3
5
#define LIBAVFILTER_VERSION_MINOR 3
6
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
...
...
@@ -552,6 +552,20 @@ typedef struct AVFilter {
* NULL_IF_CONFIG_SMALL() macro to define it.
*/
const
char
*
description
;
/**
* Make the filter instance process a command.
*
* @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
* @param arg the argument for the command
* @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported.
* @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
* timeconsuming then a filter should treat it like an unsupported command
*
* @returns >=0 on success otherwise an error code.
* AVERROR(ENOSYS) on unsupported commands
*/
int
(
*
process_command
)(
AVFilterContext
*
,
const
char
*
cmd
,
const
char
*
arg
,
char
*
res
,
int
res_len
,
int
flags
);
}
AVFilter
;
/** An instance of a filter */
...
...
@@ -791,6 +805,15 @@ void avfilter_end_frame(AVFilterLink *link);
*/
void
avfilter_draw_slice
(
AVFilterLink
*
link
,
int
y
,
int
h
,
int
slice_dir
);
#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
/**
* Make the filter instance process a command.
* It is recommanded to use avfilter_graph_send_command().
*/
int
avfilter_process_command
(
AVFilterContext
*
filter
,
const
char
*
cmd
,
const
char
*
arg
,
char
*
res
,
int
res_len
,
int
flags
);
/**
* Send a buffer of audio samples to the next filter.
*
...
...
libavfilter/avfiltergraph.c
View file @
1e5014c7
...
...
@@ -253,3 +253,33 @@ int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
return
0
;
}
int
avfilter_graph_send_command
(
AVFilterGraph
*
graph
,
const
char
*
target
,
const
char
*
cmd
,
const
char
*
arg
,
char
*
res
,
int
res_len
,
int
flags
)
{
int
i
,
r
=
AVERROR
(
ENOSYS
);
if
(
!
graph
)
return
r
;
if
((
flags
&
AVFILTER_CMD_FLAG_ONE
)
&&
!
(
flags
&
AVFILTER_CMD_FLAG_FAST
))
{
r
=
avfilter_graph_send_command
(
graph
,
target
,
cmd
,
arg
,
res
,
res_len
,
flags
|
AVFILTER_CMD_FLAG_FAST
);
if
(
r
!=
AVERROR
(
ENOSYS
))
return
r
;
}
if
(
res_len
&&
res
)
res
[
0
]
=
0
;
for
(
i
=
0
;
i
<
graph
->
filter_count
;
i
++
)
{
AVFilterContext
*
filter
=
graph
->
filters
[
i
];
if
(
!
strcmp
(
target
,
"all"
)
||
!
strcmp
(
target
,
filter
->
name
)
||
!
strcmp
(
target
,
filter
->
filter
->
name
)){
r
=
avfilter_process_command
(
filter
,
cmd
,
arg
,
res
,
res_len
,
flags
);
if
(
r
!=
AVERROR
(
ENOSYS
))
{
if
((
flags
&
AVFILTER_CMD_FLAG_ONE
)
||
r
<
0
)
return
r
;
}
}
}
return
r
;
}
libavfilter/avfiltergraph.h
View file @
1e5014c7
...
...
@@ -136,4 +136,21 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
AVFilterInOut
**
inputs
,
AVFilterInOut
**
outputs
,
void
*
log_ctx
);
/**
* Send a command to one or more filter instances.
*
* @param graph the filter graph
* @param target the filter(s) to which the command should be sent
* "all" sends to all filters
* otherwise it can be a filter or filter instance name
* which will send the command to all matching filters.
* @param cmd the command to sent, for handling simplicity all commands must be alphanumeric only
* @param arg the argument for the command
* @param res a buffer with size res_size where the filter(s) can return a response.
*
* @returns >=0 on success otherwise an error code.
* AVERROR(ENOSYS) on unsupported commands
*/
int
avfilter_graph_send_command
(
AVFilterGraph
*
graph
,
const
char
*
target
,
const
char
*
cmd
,
const
char
*
arg
,
char
*
res
,
int
res_len
,
int
flags
);
#endif
/* AVFILTER_AVFILTERGRAPH_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment