VLC  4.0.0-dev
vlc_video_splitter.h
Go to the documentation of this file.
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 
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 
53 
54 /** Structure describing a video splitter
55  */
56 struct video_splitter_t
57 {
58  struct vlc_object_t obj;
59 
60  /* Module properties */
62 
63  /* configuration */
65 
66  /* Input format
67  * It is filled by the creator and cannot be modified.
68  */
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;
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,
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 {
99  for (int i = 0; i < splitter->i_output; i++) {
100  pics[i] = picture_NewFromFormat(&splitter->p_output[i].fmt);
101  if (pics[i] == NULL) {
102  for (int j = 0; j < i; j++)
103  picture_Release(pics[j]);
104 
105  msg_Warn(splitter, "can't get output pictures");
106  return VLC_EGENERIC;
107  }
108  }
109  return VLC_SUCCESS;
110 }
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 {
119  for (int i = 0; i < p_splitter->i_output; i++)
120  picture_Release(pp_picture[i]);
121 }
122 
123 /* */
126 
127 static inline int video_splitter_Filter( video_splitter_t *p_splitter,
128  picture_t *pp_dst[], picture_t *p_src )
129 {
130  return p_splitter->pf_filter( p_splitter, pp_dst, p_src );
131 }
132 
133 static inline int video_splitter_Mouse(video_splitter_t *splitter, int index,
135 {
136  return (splitter->mouse != NULL)
137  ? splitter->mouse(splitter, index, ev) : VLC_SUCCESS;
138 }
139 
140 #endif /* VLC_VIDEO_SPLITTER_H */
141 
This file defines picture structures and functions in vlc.
video_format_t fmt
Definition: vlc_video_splitter.h:70
void video_splitter_Delete(video_splitter_t *)
Definition: filter.c:204
Video picture.
Definition: vlc_picture.h:127
Structure describing a video splitter.
Definition: vlc_video_splitter.h:57
int(* mouse)(video_splitter_t *, int idx, struct vout_window_mouse_event_t *)
Definition: vlc_video_splitter.h:83
void * p_sys
Definition: vlc_video_splitter.h:86
Internal module descriptor.
Definition: modules.h:75
#define msg_Warn(p_this,...)
Definition: vlc_messages.h:104
const char * psz_name
Definition: text_style.c:33
Definition: vlc_configuration.h:331
video_splitter_t * video_splitter_New(vlc_object_t *, const char *psz_name, const video_format_t *)
Definition: filter.c:182
static void picture_Release(picture_t *picture)
Decrements the picture reference count.
Definition: vlc_picture.h:241
#define VLC_SUCCESS
No error.
Definition: vlc_common.h:470
video format description
Definition: vlc_es.h:349
video_format_t fmt
Definition: vlc_video_splitter.h:46
picture_t * picture_NewFromFormat(const video_format_t *restrict fmt)
Definition: picture.c:259
Video output display modules interface.
video_splitter_output_t * p_output
Definition: vlc_video_splitter.h:79
module_t * p_module
Definition: vlc_video_splitter.h:62
int(* pf_filter)(video_splitter_t *, picture_t *pp_dst[], picture_t *p_src)
Definition: vlc_video_splitter.h:81
static void video_splitter_DeletePicture(video_splitter_t *p_splitter, picture_t *pp_picture[])
It will release an array of pictures created by video_splitter_NewPicture.
Definition: vlc_video_splitter.h:117
#define VLC_EGENERIC
Unspecified error.
Definition: vlc_common.h:472
static int video_splitter_Mouse(video_splitter_t *splitter, int index, struct vout_window_mouse_event_t *ev)
Definition: vlc_video_splitter.h:134
static int video_splitter_Filter(video_splitter_t *p_splitter, picture_t *pp_dst[], picture_t *p_src)
Definition: vlc_video_splitter.h:128
config_chain_t * p_cfg
Definition: vlc_video_splitter.h:65
Window mouse event.
Definition: vlc_vout_window.h:99
static int video_splitter_NewPicture(video_splitter_t *splitter, picture_t *pics[])
It will create an array of pictures suitable as output.
Definition: vlc_video_splitter.h:97
Structure describing a video splitter output properties.
Definition: vlc_video_splitter.h:43
This file defines the elementary streams format types.
VLC object common members.
Definition: vlc_objects.h:43
int i_output
Definition: vlc_video_splitter.h:78