/src/gstreamer/subprojects/gst-plugins-base/gst-libs/gst/video/gsth274.c
Line | Count | Source |
1 | | /* GStreamer |
2 | | * Copyright (C) 2026 Fluendo S.A. |
3 | | * Author: Diego Nieto <dnieto@fluendo.com> |
4 | | * |
5 | | * This library is free software; you can redistribute it and/or |
6 | | * modify it under the terms of the GNU Library General Public |
7 | | * License as published by the Free Software Foundation; either |
8 | | * version 2 of the License, or (at your option) any later version. |
9 | | * |
10 | | * This library is distributed in the hope that it will be useful, |
11 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | | * Library General Public License for more details. |
14 | | * |
15 | | * You should have received a copy of the GNU Library General Public |
16 | | * License along with this library; if not, write to the |
17 | | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
18 | | * Boston, MA 02110-1301, USA. |
19 | | */ |
20 | | |
21 | | #ifdef HAVE_CONFIG_H |
22 | | #include "config.h" |
23 | | #endif |
24 | | |
25 | | #include "gsth274.h" |
26 | | |
27 | | GType |
28 | | gst_h274_registered_user_data_get_type (void) |
29 | 0 | { |
30 | 0 | static GType gst_h274_registered_user_data_type = 0; |
31 | |
|
32 | 0 | if (g_once_init_enter (&gst_h274_registered_user_data_type)) { |
33 | 0 | GType type = g_boxed_type_register_static ("GstH274RegisteredUserData", |
34 | 0 | (GBoxedCopyFunc) gst_h274_user_data_registered_copy, |
35 | 0 | (GBoxedFreeFunc) gst_h274_user_data_registered_free); |
36 | 0 | g_once_init_leave (&gst_h274_registered_user_data_type, type); |
37 | 0 | } |
38 | 0 | return gst_h274_registered_user_data_type; |
39 | 0 | } |
40 | | |
41 | | GType |
42 | | gst_h274_user_data_unregistered_get_type (void) |
43 | 0 | { |
44 | 0 | static GType gst_h274_user_data_unregistered_type = 0; |
45 | |
|
46 | 0 | if (g_once_init_enter (&gst_h274_user_data_unregistered_type)) { |
47 | 0 | GType type = g_boxed_type_register_static ("GstH274UserDataUnregistered", |
48 | 0 | (GBoxedCopyFunc) gst_h274_user_data_unregistered_copy, |
49 | 0 | (GBoxedFreeFunc) gst_h274_user_data_unregistered_free); |
50 | 0 | g_once_init_leave (&gst_h274_user_data_unregistered_type, type); |
51 | 0 | } |
52 | 0 | return gst_h274_user_data_unregistered_type; |
53 | 0 | } |
54 | | |
55 | | GType |
56 | | gst_h274_digitally_signed_content_initialization_get_type (void) |
57 | 0 | { |
58 | 0 | static GType gst_h274_dsc_init_type = 0; |
59 | |
|
60 | 0 | if (g_once_init_enter (&gst_h274_dsc_init_type)) { |
61 | 0 | GType type = |
62 | 0 | g_boxed_type_register_static |
63 | 0 | ("GstH274DigitallySignedContentInitialization", |
64 | 0 | (GBoxedCopyFunc) gst_h274_dsc_initialization_copy, |
65 | 0 | (GBoxedFreeFunc) gst_h274_dsc_initialization_free); |
66 | 0 | g_once_init_leave (&gst_h274_dsc_init_type, type); |
67 | 0 | } |
68 | 0 | return gst_h274_dsc_init_type; |
69 | 0 | } |
70 | | |
71 | | GType |
72 | | gst_h274_digitally_signed_content_selection_get_type (void) |
73 | 0 | { |
74 | 0 | static GType gst_h274_dsc_sel_type = 0; |
75 | |
|
76 | 0 | if (g_once_init_enter (&gst_h274_dsc_sel_type)) { |
77 | 0 | GType type = |
78 | 0 | g_boxed_type_register_static ("GstH274DigitallySignedContentSelection", |
79 | 0 | (GBoxedCopyFunc) gst_h274_dsc_selection_copy, |
80 | 0 | (GBoxedFreeFunc) gst_h274_dsc_selection_free); |
81 | 0 | g_once_init_leave (&gst_h274_dsc_sel_type, type); |
82 | 0 | } |
83 | 0 | return gst_h274_dsc_sel_type; |
84 | 0 | } |
85 | | |
86 | | GType |
87 | | gst_h274_digitally_signed_content_verification_get_type (void) |
88 | 0 | { |
89 | 0 | static GType gst_h274_dsc_ver_type = 0; |
90 | |
|
91 | 0 | if (g_once_init_enter (&gst_h274_dsc_ver_type)) { |
92 | 0 | GType type = |
93 | 0 | g_boxed_type_register_static |
94 | 0 | ("GstH274DigitallySignedContentVerification", |
95 | 0 | (GBoxedCopyFunc) gst_h274_dsc_verification_copy, |
96 | 0 | (GBoxedFreeFunc) gst_h274_dsc_verification_free); |
97 | 0 | g_once_init_leave (&gst_h274_dsc_ver_type, type); |
98 | 0 | } |
99 | 0 | return gst_h274_dsc_ver_type; |
100 | 0 | } |
101 | | |
102 | | void |
103 | | gst_h274_user_data_registered_copy (GstH274RegisteredUserData * dst_rud, |
104 | | const GstH274RegisteredUserData * src_rud) |
105 | 0 | { |
106 | 0 | g_return_if_fail (dst_rud != NULL); |
107 | 0 | g_return_if_fail (src_rud != NULL); |
108 | | |
109 | 0 | dst_rud->country_code = src_rud->country_code; |
110 | 0 | dst_rud->country_code_extension = src_rud->country_code_extension; |
111 | 0 | dst_rud->size = src_rud->size; |
112 | |
|
113 | 0 | if (src_rud->size) { |
114 | 0 | dst_rud->data = g_memdup2 (src_rud->data, src_rud->size); |
115 | 0 | } else { |
116 | 0 | dst_rud->data = NULL; |
117 | 0 | } |
118 | 0 | } |
119 | | |
120 | | void |
121 | | gst_h274_user_data_unregistered_copy (GstH274UserDataUnregistered * dst_udu, |
122 | | const GstH274UserDataUnregistered * src_udu) |
123 | 0 | { |
124 | 0 | g_return_if_fail (dst_udu != NULL); |
125 | 0 | g_return_if_fail (src_udu != NULL); |
126 | | |
127 | 0 | memcpy (dst_udu->uuid, src_udu->uuid, 16); |
128 | 0 | dst_udu->size = src_udu->size; |
129 | |
|
130 | 0 | if (src_udu->size) { |
131 | 0 | dst_udu->data = g_memdup2 (src_udu->data, src_udu->size); |
132 | 0 | } else { |
133 | 0 | dst_udu->data = NULL; |
134 | 0 | } |
135 | 0 | } |
136 | | |
137 | | void |
138 | | gst_h274_dsc_initialization_copy (GstH274DigitallySignedContentInitialization * |
139 | | dst_dsc_init, |
140 | | const GstH274DigitallySignedContentInitialization * src_dsc_init) |
141 | 0 | { |
142 | 0 | g_return_if_fail (dst_dsc_init != NULL); |
143 | 0 | g_return_if_fail (src_dsc_init != NULL); |
144 | | |
145 | 0 | dst_dsc_init->id = src_dsc_init->id; |
146 | 0 | dst_dsc_init->hash_method_type = src_dsc_init->hash_method_type; |
147 | 0 | dst_dsc_init->key_retrieval_mode_idc = src_dsc_init->key_retrieval_mode_idc; |
148 | 0 | dst_dsc_init->use_key_register_idx_flag = |
149 | 0 | src_dsc_init->use_key_register_idx_flag; |
150 | 0 | dst_dsc_init->key_register_idx = src_dsc_init->key_register_idx; |
151 | 0 | dst_dsc_init->content_uuid_present_flag = |
152 | 0 | src_dsc_init->content_uuid_present_flag; |
153 | 0 | memcpy (dst_dsc_init->content_uuid, src_dsc_init->content_uuid, 16); |
154 | 0 | dst_dsc_init->num_verification_substreams = |
155 | 0 | src_dsc_init->num_verification_substreams; |
156 | 0 | dst_dsc_init->vss_implicit_association_mode_flag = |
157 | 0 | src_dsc_init->vss_implicit_association_mode_flag; |
158 | 0 | dst_dsc_init->signed_content_start_flag = |
159 | 0 | src_dsc_init->signed_content_start_flag; |
160 | 0 | dst_dsc_init->sei_signing_flag = src_dsc_init->sei_signing_flag; |
161 | |
|
162 | 0 | dst_dsc_init->ref_substream_flag_len = src_dsc_init->ref_substream_flag_len; |
163 | 0 | if (src_dsc_init->ref_substream_flag && |
164 | 0 | src_dsc_init->ref_substream_flag_len > 0) { |
165 | 0 | dst_dsc_init->ref_substream_flag = |
166 | 0 | g_memdup2 (src_dsc_init->ref_substream_flag, |
167 | 0 | src_dsc_init->ref_substream_flag_len); |
168 | 0 | } else { |
169 | 0 | dst_dsc_init->ref_substream_flag = NULL; |
170 | 0 | dst_dsc_init->ref_substream_flag_len = 0; |
171 | 0 | } |
172 | |
|
173 | 0 | dst_dsc_init->key_source_uri = NULL; |
174 | 0 | if (src_dsc_init->key_source_uri) { |
175 | 0 | dst_dsc_init->key_source_uri = |
176 | 0 | g_strdup ((const char *) src_dsc_init->key_source_uri); |
177 | 0 | } |
178 | 0 | } |
179 | | |
180 | | void |
181 | | gst_h274_dsc_selection_copy (GstH274DigitallySignedContentSelection * |
182 | | dst_dsc_sel, const GstH274DigitallySignedContentSelection * src_dsc_sel) |
183 | 0 | { |
184 | 0 | g_return_if_fail (dst_dsc_sel != NULL); |
185 | 0 | g_return_if_fail (src_dsc_sel != NULL); |
186 | | |
187 | 0 | dst_dsc_sel->id = src_dsc_sel->id; |
188 | 0 | dst_dsc_sel->verification_substream_id = |
189 | 0 | src_dsc_sel->verification_substream_id; |
190 | 0 | } |
191 | | |
192 | | void |
193 | | gst_h274_dsc_verification_copy (GstH274DigitallySignedContentVerification * |
194 | | dst_dsc_ver, const GstH274DigitallySignedContentVerification * src_dsc_ver) |
195 | 0 | { |
196 | 0 | g_return_if_fail (dst_dsc_ver != NULL); |
197 | 0 | g_return_if_fail (src_dsc_ver != NULL); |
198 | | |
199 | 0 | dst_dsc_ver->id = src_dsc_ver->id; |
200 | 0 | dst_dsc_ver->verification_substream_id = |
201 | 0 | src_dsc_ver->verification_substream_id; |
202 | 0 | dst_dsc_ver->signature_length_in_octets_minus1 = |
203 | 0 | src_dsc_ver->signature_length_in_octets_minus1; |
204 | |
|
205 | 0 | if (src_dsc_ver->signature |
206 | 0 | && src_dsc_ver->signature_length_in_octets_minus1 + 1 > 0) { |
207 | 0 | dst_dsc_ver->signature = |
208 | 0 | g_memdup2 (src_dsc_ver->signature, |
209 | 0 | src_dsc_ver->signature_length_in_octets_minus1 + 1); |
210 | 0 | } else { |
211 | 0 | dst_dsc_ver->signature = NULL; |
212 | 0 | } |
213 | |
|
214 | 0 | dst_dsc_ver->signed_content_end_flag = src_dsc_ver->signed_content_end_flag; |
215 | 0 | } |
216 | | |
217 | | void |
218 | | gst_h274_user_data_registered_free (GstH274RegisteredUserData * rud) |
219 | 0 | { |
220 | 0 | g_free ((gpointer) rud->data); |
221 | 0 | rud->data = NULL; |
222 | 0 | rud->size = 0; |
223 | 0 | } |
224 | | |
225 | | void |
226 | | gst_h274_user_data_unregistered_free (GstH274UserDataUnregistered * udu) |
227 | 0 | { |
228 | 0 | g_free ((gpointer) udu->data); |
229 | 0 | udu->data = NULL; |
230 | 0 | udu->size = 0; |
231 | 0 | } |
232 | | |
233 | | void |
234 | | gst_h274_dsc_initialization_free (GstH274DigitallySignedContentInitialization * |
235 | | dsci) |
236 | 0 | { |
237 | 0 | g_free (dsci->ref_substream_flag); |
238 | 0 | dsci->ref_substream_flag = NULL; |
239 | 0 | dsci->ref_substream_flag_len = 0; |
240 | |
|
241 | 0 | g_free (dsci->key_source_uri); |
242 | 0 | dsci->key_source_uri = NULL; |
243 | 0 | } |
244 | | |
245 | | void |
246 | | gst_h274_dsc_selection_free (GstH274DigitallySignedContentSelection * dscs) |
247 | 0 | { |
248 | | /* Nothing to free */ |
249 | 0 | } |
250 | | |
251 | | void |
252 | | gst_h274_dsc_verification_free (GstH274DigitallySignedContentVerification * |
253 | | dscv) |
254 | 0 | { |
255 | 0 | g_free (dscv->signature); |
256 | | dscv->signature = NULL; |
257 | 0 | dscv->signature_length_in_octets_minus1 = 0; |
258 | 0 | } |