FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
v4l2_m2m.h
Go to the documentation of this file.
1
/*
2
* V4L2 mem2mem helper functions
3
*
4
* Copyright (C) 2017 Alexis Ballier <aballier@gentoo.org>
5
* Copyright (C) 2017 Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
6
*
7
* This file is part of FFmpeg.
8
*
9
* FFmpeg is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
13
*
14
* FFmpeg is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
18
*
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with FFmpeg; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
*/
23
24
#ifndef AVCODEC_V4L2_M2M_H
25
#define AVCODEC_V4L2_M2M_H
26
27
#include <
semaphore.h
>
28
#include <unistd.h>
29
#include <dirent.h>
30
#include <linux/videodev2.h>
31
32
#include "
libavcodec/avcodec.h
"
33
#include "
v4l2_context.h
"
34
35
#define container_of(ptr, type, member) ({ \
36
const __typeof__(((type *)0)->member ) *__mptr = (ptr); \
37
(type *)((char *)__mptr - offsetof(type,member) );})
38
39
#define V4L_M2M_DEFAULT_OPTS \
40
{ "num_output_buffers", "Number of buffers in the output context",\
41
OFFSET(output.num_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 6, INT_MAX, FLAGS }
42
43
typedef
struct
V4L2m2mContext
44
{
45
AVClass
*
class
;
46
char
devname
[PATH_MAX];
47
int
fd
;
48
49
/* the codec context queues */
50
V4L2Context
capture
;
51
V4L2Context
output
;
52
53
/* refcount of buffers held by the user */
54
atomic_uint
refcount
;
55
56
/* dynamic stream reconfig */
57
AVCodecContext
*
avctx
;
58
sem_t
refsync
;
59
int
reinit
;
60
61
/* null frame/packet received */
62
int
draining
;
63
}
V4L2m2mContext
;
64
65
/**
66
* Probes the video nodes looking for the required codec capabilities.
67
*
68
* @param[in] ctx The AVCodecContext instantiated by the encoder/decoder.
69
*
70
* @returns 0 if a driver is found, a negative number otherwise.
71
*/
72
int
ff_v4l2_m2m_codec_init
(
AVCodecContext
*avctx);
73
74
/**
75
* Releases all the codec resources if all AVBufferRefs have been returned to the
76
* ctx. Otherwise keep the driver open.
77
*
78
* @param[in] The AVCodecContext instantiated by the encoder/decoder.
79
*
80
* @returns 0
81
*
82
*/
83
int
ff_v4l2_m2m_codec_end
(
AVCodecContext
*avctx);
84
85
/**
86
* Reinitializes the V4L2m2mContext when the driver cant continue processing
87
* with the capture parameters.
88
*
89
* @param[in] ctx The V4L2m2mContext instantiated by the encoder/decoder.
90
*
91
* @returns 0 in case of success, negative number otherwise
92
*/
93
int
ff_v4l2_m2m_codec_reinit
(
V4L2m2mContext
*
ctx
);
94
95
/**
96
* Reinitializes the V4L2m2mContext when the driver cant continue processing
97
* with the any of the current V4L2Contexts (ie, changes in output and capture).
98
*
99
* @param[in] ctx The V4L2m2mContext instantiated by the encoder/decoder.
100
*
101
* @returns 0 in case of success, negative number otherwise
102
*/
103
int
ff_v4l2_m2m_codec_full_reinit
(
V4L2m2mContext
*
ctx
);
104
105
#endif
/* AVCODEC_V4L2_M2M_H */
V4L2m2mContext
Definition:
v4l2_m2m.h:43
V4L2m2mContext::avctx
AVCodecContext * avctx
Definition:
v4l2_m2m.h:57
V4L2m2mContext::reinit
int reinit
Definition:
v4l2_m2m.h:59
V4L2m2mContext::fd
int fd
Definition:
v4l2_m2m.h:47
V4L2m2mContext::draining
int draining
Definition:
v4l2_m2m.h:62
sem_t
#define sem_t
Definition:
semaphore.h:25
ff_v4l2_m2m_codec_end
int ff_v4l2_m2m_codec_end(AVCodecContext *avctx)
Releases all the codec resources if all AVBufferRefs have been returned to the ctx.
Definition:
v4l2_m2m.c:314
v4l2_context.h
V4L2m2mContext::devname
char devname[PATH_MAX]
Definition:
v4l2_m2m.h:46
ctx
AVFormatContext * ctx
Definition:
movenc.c:48
V4L2m2mContext::capture
V4L2Context capture
Definition:
v4l2_m2m.h:50
avcodec.h
Libavcodec external API header.
V4L2m2mContext::refcount
atomic_uint refcount
Definition:
v4l2_m2m.h:54
AVCodecContext
main external API structure.
Definition:
avcodec.h:1761
semaphore.h
AVClass
Describe the class of an AVClass context structure.
Definition:
log.h:67
atomic_uint
intptr_t atomic_uint
Definition:
stdatomic.h:56
V4L2m2mContext::output
V4L2Context output
Definition:
v4l2_m2m.h:51
ff_v4l2_m2m_codec_init
int ff_v4l2_m2m_codec_init(AVCodecContext *avctx)
Probes the video nodes looking for the required codec capabilities.
Definition:
v4l2_m2m.c:344
ff_v4l2_m2m_codec_full_reinit
int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *ctx)
Reinitializes the V4L2m2mContext when the driver cant continue processing with the any of the current...
Definition:
v4l2_m2m.c:233
V4L2Context
Definition:
v4l2_context.h:36
V4L2m2mContext::refsync
sem_t refsync
Definition:
v4l2_m2m.h:58
ff_v4l2_m2m_codec_reinit
int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx)
Reinitializes the V4L2m2mContext when the driver cant continue processing with the capture parameters...
Definition:
v4l2_m2m.c:189
Generated on Fri Jan 12 2018 01:47:51 for FFmpeg by
1.8.6