PipeWire: spa/param/video/format-utils.h Source File

PipeWire 1.6.5

Loading...
Searching...
No Matches
format-utils.h
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
17extern "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
28SPA_API_VIDEO_FORMAT_UTILS int
29spa_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
52SPA_API_VIDEO_FORMAT_UTILS struct spa_pod *
53spa_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 */
format-utils.h
res
uint32_t int int res
Definition core.h:433
spa_format_video_h264_build
SPA_API_VIDEO_H264_UTILS struct spa_pod * spa_format_video_h264_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_h264 *info)
Definition h264-utils.h:50
spa_format_video_mjpg_build
SPA_API_VIDEO_MJPG_UTILS struct spa_pod * spa_format_video_mjpg_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_mjpg *info)
Definition mjpg-utils.h:48
spa_format_video_mjpg_parse
SPA_API_VIDEO_MJPG_UTILS int spa_format_video_mjpg_parse(const struct spa_pod *format, struct spa_video_info_mjpg *info)
Definition mjpg-utils.h:37
spa_format_video_raw_parse
SPA_API_VIDEO_RAW_UTILS int spa_format_video_raw_parse(const struct spa_pod *format, struct spa_video_info_raw *info)
Definition raw-utils.h:38
spa_format_video_h264_parse
SPA_API_VIDEO_H264_UTILS int spa_format_video_h264_parse(const struct spa_pod *format, struct spa_video_info_h264 *info)
Definition h264-utils.h:37
spa_format_video_dsp_parse
SPA_API_VIDEO_DSP_UTILS int spa_format_video_dsp_parse(const struct spa_pod *format, struct spa_video_info_dsp *info)
Definition dsp-utils.h:38
spa_format_parse
SPA_API_FORMAT_UTILS int spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)
Definition format-utils.h:37
spa_format_video_raw_build
SPA_API_VIDEO_RAW_UTILS struct spa_pod * spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_raw *info)
Definition raw-utils.h:69
spa_format_video_dsp_build
SPA_API_VIDEO_DSP_UTILS struct spa_pod * spa_format_video_dsp_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_dsp *info)
Definition dsp-utils.h:56
SPA_MEDIA_TYPE_video
@ SPA_MEDIA_TYPE_video
Definition format.h:28
SPA_MEDIA_SUBTYPE_h264
@ SPA_MEDIA_SUBTYPE_h264
Definition format.h:67
SPA_MEDIA_SUBTYPE_mjpg
@ SPA_MEDIA_SUBTYPE_mjpg
Definition format.h:68
SPA_MEDIA_SUBTYPE_dsp
@ SPA_MEDIA_SUBTYPE_dsp
Definition format.h:39
SPA_MEDIA_SUBTYPE_raw
@ SPA_MEDIA_SUBTYPE_raw
Definition format.h:38
h264-utils.h
h265-utils.h
mjpg-utils.h
format.h
spa/param/video/format.h
spa_pod_builder
Definition builder.h:63
spa_pod
Definition pod.h:57
spa_video_info
Definition format.h:27
dsp-utils.h
raw-utils.h