+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
c · 74 lines · 2.1 KB · SPDX: MIT
main
1 /* Simple Plugin API */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4  
5 #ifndef SPA_PARAM_VIDEO_FORMAT_UTILS_H
6 #define SPA_PARAM_VIDEO_FORMAT_UTILS_H
7  
8 #include <spa/param/format-utils.h>
9 #include <spa/param/video/format.h>
10 #include <spa/param/video/raw-utils.h>
11 #include <spa/param/video/dsp-utils.h>
12 #include <spa/param/video/h264-utils.h>
13 #include <spa/param/video/h265-utils.h>
14 #include <spa/param/video/mjpg-utils.h>
15  
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19  
20 #ifndef SPA_API_VIDEO_FORMAT_UTILS
21 #ifdef SPA_API_IMPL
22 #define SPA_API_VIDEO_FORMAT_UTILS SPA_API_IMPL
23 #else
24 #define SPA_API_VIDEO_FORMAT_UTILS static inline
25 #endif
26 #endif
27  
28 SPA_API_VIDEO_FORMAT_UTILS int
29 spa_format_video_parse(const struct spa_pod *format, struct spa_video_info *info)
30 {
31 int res;
32  
33 if ((res = spa_format_parse(format, &info->media_type, &info->media_subtype)) < 0)
34 return res;
35  
36 if (info->media_type != SPA_MEDIA_TYPE_video)
37 return -EINVAL;
38  
39 switch (info->media_subtype) {
40 case SPA_MEDIA_SUBTYPE_raw:
41 return spa_format_video_raw_parse(format, &info->info.raw);
42 case SPA_MEDIA_SUBTYPE_dsp:
43 return spa_format_video_dsp_parse(format, &info->info.dsp);
44 case SPA_MEDIA_SUBTYPE_h264:
45 return spa_format_video_h264_parse(format, &info->info.h264);
46 case SPA_MEDIA_SUBTYPE_mjpg:
47 return spa_format_video_mjpg_parse(format, &info->info.mjpg);
48 }
49 return -ENOTSUP;
50 }
51  
52 SPA_API_VIDEO_FORMAT_UTILS struct spa_pod *
53 spa_format_video_build(struct spa_pod_builder *builder, uint32_t id,
54 const struct spa_video_info *info)
55 {
56 switch (info->media_subtype) {
57 case SPA_MEDIA_SUBTYPE_raw:
58 return spa_format_video_raw_build(builder, id, &info->info.raw);
59 case SPA_MEDIA_SUBTYPE_dsp:
60 return spa_format_video_dsp_build(builder, id, &info->info.dsp);
61 case SPA_MEDIA_SUBTYPE_h264:
62 return spa_format_video_h264_build(builder, id, &info->info.h264);
63 case SPA_MEDIA_SUBTYPE_mjpg:
64 return spa_format_video_mjpg_build(builder, id, &info->info.mjpg);
65 }
66 errno = ENOTSUP;
67 return NULL;
68 }
69  
70 #ifdef __cplusplus
71 } /* extern "C" */
72 #endif
73  
74 #endif /* SPA_PARAM_VIDEO_FORMAT_UTILS_H */