Coverage Report

Created: 2025-10-10 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/include/vlc_video_splitter.h
Line
Count
Source
1
/*****************************************************************************
2
 * vlc_video_splitter.h: "video splitter" related structures and functions
3
 *****************************************************************************
4
 * Copyright (C) 2009 Laurent Aimar
5
 *
6
 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
7
 *
8
 * This program is free software; you can redistribute it and/or modify it
9
 * under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation; either version 2.1 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program; if not, write to the Free Software Foundation,
20
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21
 *****************************************************************************/
22
23
#ifndef VLC_VIDEO_SPLITTER_H
24
#define VLC_VIDEO_SPLITTER_H 1
25
26
#include <vlc_es.h>
27
#include <vlc_picture.h>
28
#include <vlc_mouse.h>
29
#include <vlc_vout_display.h>
30
31
/**
32
 * \file
33
 * This file defines the structure and types used by video splitter filters.
34
 */
35
36
typedef struct video_splitter_t video_splitter_t;
37
38
struct vlc_window_mouse_event;
39
40
/** Structure describing a video splitter output properties
41
 */
42
typedef struct
43
{
44
    /* Video format of the output */
45
    video_format_t fmt;
46
47
    /* Video output module
48
     * Use NULL for default
49
     */
50
    char *psz_module;
51
52
} video_splitter_output_t;
53
54
/** Structure describing a video splitter
55
 */
56
struct video_splitter_t
57
{
58
    struct vlc_object_t obj;
59
60
    /* Module properties */
61
    module_t        *p_module;
62
63
    /* configuration */
64
    config_chain_t  *p_cfg;
65
66
    /* Input format
67
     * It is filled by the creator and cannot be modified.
68
     */
69
    video_format_t  fmt;
70
71
    /* Output formats
72
     *
73
     * It can only be set in the open() function and must remain
74
     * constant.
75
     * The module is responsible for the allocation and deallocation.
76
     */
77
    int                     i_output;
78
    video_splitter_output_t *p_output;
79
80
    int             (*pf_filter)( video_splitter_t *, picture_t *pp_dst[],
81
                                  picture_t *p_src );
82
    int (*mouse)(video_splitter_t *, int idx,
83
                 struct vlc_window_mouse_event *);
84
85
    void *p_sys;
86
};
87
88
/**
89
 * It will create an array of pictures suitable as output.
90
 *
91
 * You must either returned them through pf_filter or by calling
92
 * video_splitter_DeletePicture.
93
 *
94
 * If VLC_SUCCESS is not returned, pp_picture values are undefined.
95
 */
96
static inline int video_splitter_NewPicture(video_splitter_t *splitter,
97
                                            picture_t *pics[])
98
0
{
99
0
    for (int i = 0; i < splitter->i_output; i++) {
100
0
        pics[i] = picture_NewFromFormat(&splitter->p_output[i].fmt);
101
0
        if (pics[i] == NULL) {
102
0
            for (int j = 0; j < i; j++)
103
0
                picture_Release(pics[j]);
104
0
105
0
            msg_Warn(splitter, "can't get output pictures");
106
0
            return VLC_EGENERIC;
107
0
        }
108
0
    }
109
0
    return VLC_SUCCESS;
110
0
}
111
112
/**
113
 * It will release an array of pictures created by video_splitter_NewPicture.
114
 * Provided for convenience.
115
 */
116
static inline void video_splitter_DeletePicture( video_splitter_t *p_splitter,
117
                                                 picture_t *pp_picture[] )
118
0
{
119
0
    for (int i = 0; i < p_splitter->i_output; i++)
120
0
        picture_Release(pp_picture[i]);
121
0
}
122
123
/* */
124
video_splitter_t * video_splitter_New( vlc_object_t *, const char *psz_name, const video_format_t * );
125
void video_splitter_Delete( video_splitter_t * );
126
127
static inline int video_splitter_Filter( video_splitter_t *p_splitter,
128
                                         picture_t *pp_dst[], picture_t *p_src )
129
0
{
130
0
    return p_splitter->pf_filter( p_splitter, pp_dst, p_src );
131
0
}
132
133
static inline int video_splitter_Mouse(video_splitter_t *splitter, int index,
134
                                       struct vlc_window_mouse_event *ev)
135
0
{
136
0
    return (splitter->mouse != NULL)
137
0
        ? splitter->mouse(splitter, index, ev) : VLC_SUCCESS;
138
0
}
139
140
#endif /* VLC_VIDEO_SPLITTER_H */
141