Line data Source code
1 : /*
2 : * GPAC - Multimedia Framework C SDK
3 : *
4 : * Authors: Deniz Ugur, Romain Bouqueau, Sohaib Larbi
5 : * Copyright (c) Motion Spell
6 : * All rights reserved
7 : *
8 : * This file is part of the GPAC/GStreamer wrapper
9 : *
10 : * This GPAC/GStreamer wrapper is free software; you can redistribute it
11 : * and/or modify it under the terms of the GNU Affero General Public License
12 : * as published by the Free Software Foundation; either version 3, or (at
13 : * your option) any later version.
14 : *
15 : * This GPAC/GStreamer wrapper is distributed in the hope that it will be
16 : * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : * GNU Affero General Public License for more details.
19 : *
20 : * You should have received a copy of the GNU Affero General Public
21 : * License along with this library; see the file LICENSE. If not, write to
22 : * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 : *
24 : */
25 :
26 : #pragma once
27 :
28 : #include "lib/memio.h"
29 :
30 : #include <gpac/filters.h>
31 : #include <gst/gst.h>
32 :
33 : #define GPAC_FILTER_PP_IMPL_DECL(filter_name) \
34 : void filter_name##_ctx_init(void** process_ctx); \
35 : void filter_name##_ctx_free(void* process_ctx); \
36 : GF_Err filter_name##_configure_pid(GF_Filter* filter, GF_FilterPid* pid); \
37 : GF_Err filter_name##_post_process( \
38 : GF_Filter* filter, GF_FilterPid* pid, GF_FilterPacket* pck); \
39 : Bool filter_name##_process_event(GF_Filter* filter, \
40 : const GF_FilterEvent* evt); \
41 : GPAC_FilterPPRet filter_name##_consume( \
42 : GF_Filter* filter, GF_FilterPid* pid, void** outptr);
43 :
44 : #define GPAC_FILTER_PP_IMPL_DEFINE(filter_name) \
45 : { #filter_name, \
46 : filter_name##_ctx_init, \
47 : filter_name##_ctx_free, \
48 : filter_name##_configure_pid, \
49 : filter_name##_post_process, \
50 : filter_name##_process_event, \
51 : filter_name##_consume }
52 :
53 : // Forward declarations
54 : GPAC_FILTER_PP_IMPL_DECL(generic);
55 : GPAC_FILTER_PP_IMPL_DECL(mp4mx);
56 : GPAC_FILTER_PP_IMPL_DECL(dasher);
57 :
58 : typedef struct
59 : {
60 : const gchar* filter_name;
61 :
62 : // Handlers
63 : void (*ctx_init)(void** process_ctx);
64 : void (*ctx_free)(void* process_ctx);
65 : GF_Err (*configure_pid)(GF_Filter* filter, GF_FilterPid* pid);
66 : GF_Err (*post_process)(GF_Filter* filter,
67 : GF_FilterPid* pid,
68 : GF_FilterPacket* pck);
69 : Bool (*process_event)(GF_Filter* filter, const GF_FilterEvent* evt);
70 : GPAC_FilterPPRet (*consume)(GF_Filter* filter,
71 : GF_FilterPid* pid,
72 : void** outptr);
73 : } post_process_registry_entry;
74 :
75 : static post_process_registry_entry pp_registry[] = {
76 : GPAC_FILTER_PP_IMPL_DEFINE(generic),
77 : GPAC_FILTER_PP_IMPL_DEFINE(mp4mx),
78 : GPAC_FILTER_PP_IMPL_DEFINE(dasher),
79 : };
80 :
81 : static inline u32
82 48 : gpac_filter_get_num_supported_post_process()
83 : {
84 48 : return G_N_ELEMENTS(pp_registry);
85 : }
86 :
87 : static inline post_process_registry_entry*
88 19 : gpac_filter_get_post_process_registry_entry(const gchar* filter_name)
89 : {
90 48 : for (u32 i = 0; i < gpac_filter_get_num_supported_post_process(); i++) {
91 48 : if (g_strcmp0(pp_registry[i].filter_name, filter_name) == 0) {
92 19 : return &pp_registry[i];
93 : }
94 : }
95 :
96 : // Not found, return the generic post-process handler
97 0 : return &pp_registry[0];
98 : }
|