mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
format: improve format parsing
This commit is contained in:
parent
94019fb1f5
commit
29cb7bf39a
30 changed files with 459 additions and 406 deletions
|
|
@ -50,8 +50,21 @@ spa_type_format_audio_map (SpaTypeMap *map, SpaTypeFormatAudio *type)
|
|||
}
|
||||
}
|
||||
|
||||
SpaResult spa_format_audio_parse (const SpaFormat *format,
|
||||
SpaAudioInfo *info);
|
||||
static inline bool
|
||||
spa_format_audio_raw_parse (const SpaFormat *format,
|
||||
SpaAudioInfoRaw *info,
|
||||
SpaTypeFormatAudio *type)
|
||||
{
|
||||
spa_format_query (format,
|
||||
type->format, SPA_POD_TYPE_ID, &info->format,
|
||||
type->flags, SPA_POD_TYPE_INT, &info->flags,
|
||||
type->layout, SPA_POD_TYPE_INT, &info->layout,
|
||||
type->rate, SPA_POD_TYPE_INT, &info->rate,
|
||||
type->channels, SPA_POD_TYPE_INT, &info->channels,
|
||||
type->channel_mask, SPA_POD_TYPE_INT, &info->channel_mask,
|
||||
0);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ spa_type_media_subtype_audio_map (SpaTypeMap *map, SpaTypeMediaSubtypeAudio *typ
|
|||
#define SPA_FORMAT_FOREACH(format, iter) \
|
||||
SPA_FORMAT_BODY_FOREACH(&format->body, SPA_POD_BODY_SIZE(format), iter)
|
||||
|
||||
#define SPA_FORMAT_MEDIA_TYPE(f) SPA_POD_VALUE (SpaPODId, &f->body.media_type)
|
||||
#define SPA_FORMAT_MEDIA_SUBTYPE(f) SPA_POD_VALUE (SpaPODId, &f->body.media_subtype)
|
||||
|
||||
static inline SpaPODProp *
|
||||
spa_format_find_prop (const SpaFormat *format, uint32_t key)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ struct _SpaTypeMap {
|
|||
SpaType (*get_id) (SpaTypeMap *map,
|
||||
const char *type);
|
||||
|
||||
const char * (*get_type) (SpaTypeMap *map,
|
||||
const char * (*get_type) (const SpaTypeMap *map,
|
||||
SpaType id);
|
||||
|
||||
size_t (*get_size) (SpaTypeMap *map);
|
||||
size_t (*get_size) (const SpaTypeMap *map);
|
||||
};
|
||||
|
||||
#define spa_type_map_get_id(n,...) (n)->get_id((n),__VA_ARGS__)
|
||||
|
|
|
|||
|
|
@ -74,8 +74,57 @@ spa_type_format_video_map (SpaTypeMap *map, SpaTypeFormatVideo *type)
|
|||
}
|
||||
}
|
||||
|
||||
SpaResult spa_format_video_parse (const SpaFormat *format,
|
||||
SpaVideoInfo *info);
|
||||
static inline bool
|
||||
spa_format_video_raw_parse (const SpaFormat *format,
|
||||
SpaVideoInfoRaw *info,
|
||||
SpaTypeFormatVideo *type)
|
||||
{
|
||||
spa_format_query (format,
|
||||
type->format, SPA_POD_TYPE_ID, &info->format,
|
||||
type->size, SPA_POD_TYPE_RECTANGLE, &info->size,
|
||||
type->framerate, SPA_POD_TYPE_FRACTION, &info->framerate,
|
||||
type->max_framerate, SPA_POD_TYPE_FRACTION, &info->max_framerate,
|
||||
type->views, SPA_POD_TYPE_INT, &info->views,
|
||||
type->interlace_mode, SPA_POD_TYPE_INT, &info->interlace_mode,
|
||||
type->pixel_aspect_ratio, SPA_POD_TYPE_FRACTION, &info->pixel_aspect_ratio,
|
||||
type->multiview_mode, SPA_POD_TYPE_INT, &info->multiview_mode,
|
||||
type->multiview_flags, SPA_POD_TYPE_INT, &info->multiview_flags,
|
||||
type->chroma_site, SPA_POD_TYPE_INT, &info->chroma_site,
|
||||
type->color_range, SPA_POD_TYPE_INT, &info->color_range,
|
||||
type->color_matrix, SPA_POD_TYPE_INT, &info->color_matrix,
|
||||
type->transfer_function, SPA_POD_TYPE_INT, &info->transfer_function,
|
||||
type->color_primaries, SPA_POD_TYPE_INT, &info->color_primaries,
|
||||
0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
spa_format_video_h264_parse (const SpaFormat *format,
|
||||
SpaVideoInfoH264 *info,
|
||||
SpaTypeFormatVideo *type)
|
||||
{
|
||||
spa_format_query (format,
|
||||
type->size, SPA_POD_TYPE_RECTANGLE, &info->size,
|
||||
type->framerate, SPA_POD_TYPE_FRACTION, &info->framerate,
|
||||
type->max_framerate, SPA_POD_TYPE_FRACTION, &info->max_framerate,
|
||||
type->stream_format, SPA_POD_TYPE_INT , &info->stream_format,
|
||||
type->alignment , SPA_POD_TYPE_INT , &info->alignment,
|
||||
0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
spa_format_video_mjpg_parse (const SpaFormat *format,
|
||||
SpaVideoInfoMJPG *info,
|
||||
SpaTypeFormatVideo *type)
|
||||
{
|
||||
spa_format_query (format,
|
||||
type->size, SPA_POD_TYPE_RECTANGLE, &info->size,
|
||||
type->framerate, SPA_POD_TYPE_FRACTION, &info->framerate,
|
||||
type->max_framerate, SPA_POD_TYPE_FRACTION, &info->max_framerate,
|
||||
0);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue