/src/vlc/src/input/es_out_source.c
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * es_out_source.c: Es Out Source handle |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2020 VLC authors, VideoLAN and Videolabs SAS |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | |
21 | | /***************************************************************************** |
22 | | * Preamble |
23 | | *****************************************************************************/ |
24 | | #ifdef HAVE_CONFIG_H |
25 | | # include "config.h" |
26 | | #endif |
27 | | |
28 | | #include <stdio.h> |
29 | | #include <assert.h> |
30 | | #include <vlc_common.h> |
31 | | |
32 | | #include <vlc_atomic.h> |
33 | | #include <vlc_es_out.h> |
34 | | #include <vlc_block.h> |
35 | | |
36 | | #include "input_internal.h" |
37 | | #include "es_out.h" |
38 | | |
39 | | typedef struct |
40 | | { |
41 | | es_out_t out; |
42 | | input_source_t *in; |
43 | | es_out_t *parent_out; |
44 | | } es_out_sys_t; |
45 | | |
46 | | static es_out_id_t *EsOutSourceAdd(es_out_t *out, input_source_t *in, |
47 | | const es_format_t *fmt) |
48 | 0 | { |
49 | 0 | assert(in == NULL); |
50 | 0 | es_out_sys_t *sys = container_of(out, es_out_sys_t, out); |
51 | 0 | return sys->parent_out->cbs->add(sys->parent_out, sys->in, fmt); |
52 | 0 | } |
53 | | |
54 | | static int EsOutSourceSend(es_out_t *out, es_out_id_t *es, block_t *block) |
55 | 0 | { |
56 | 0 | es_out_sys_t *sys = container_of(out, es_out_sys_t, out); |
57 | 0 | return es_out_Send(sys->parent_out, es, block); |
58 | 0 | } |
59 | | |
60 | | static void EsOutSourceDel(es_out_t *out, es_out_id_t *es) |
61 | 0 | { |
62 | 0 | es_out_sys_t *sys = container_of(out, es_out_sys_t, out); |
63 | 0 | es_out_Del(sys->parent_out, es); |
64 | 0 | } |
65 | | |
66 | | static int EsOutSourceControl(es_out_t *out, input_source_t *in, int query, |
67 | | va_list args) |
68 | 0 | { |
69 | 0 | assert(in == NULL); |
70 | 0 | es_out_sys_t *sys = container_of(out, es_out_sys_t, out); |
71 | 0 | return sys->parent_out->cbs->control(sys->parent_out, sys->in, query, args); |
72 | 0 | } |
73 | | |
74 | | static void EsOutSourceDestroy(es_out_t *out) |
75 | 0 | { |
76 | 0 | es_out_sys_t *sys = container_of(out, es_out_sys_t, out); |
77 | 0 | free(sys); |
78 | 0 | } |
79 | | |
80 | | es_out_t *input_EsOutSourceNew(es_out_t *parent_out, input_source_t *in) |
81 | 0 | { |
82 | 0 | assert(parent_out && in); |
83 | | |
84 | 0 | static const struct es_out_callbacks es_out_cbs = |
85 | 0 | { |
86 | 0 | .add = EsOutSourceAdd, |
87 | 0 | .send = EsOutSourceSend, |
88 | 0 | .del = EsOutSourceDel, |
89 | 0 | .control = EsOutSourceControl, |
90 | 0 | .destroy = EsOutSourceDestroy, |
91 | 0 | }; |
92 | |
|
93 | 0 | es_out_sys_t *sys = malloc(sizeof(*sys)); |
94 | 0 | if (!sys) |
95 | 0 | return NULL; |
96 | | |
97 | 0 | sys->in = in; |
98 | 0 | sys->out.cbs = &es_out_cbs; |
99 | 0 | sys->parent_out = parent_out; |
100 | |
|
101 | 0 | return &sys->out; |
102 | 0 | } |