mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
format: make helper function to parse media type
This commit is contained in:
parent
5976beb149
commit
80de83f38a
24 changed files with 127 additions and 100 deletions
|
|
@ -26,7 +26,9 @@ extern "C" {
|
|||
|
||||
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/pod/builder.h>
|
||||
#include <spa/param/audio/format.h>
|
||||
#include <spa/param/format-utils.h>
|
||||
|
||||
static inline int
|
||||
spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
|
||||
|
|
@ -40,6 +42,19 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
|
|||
":", SPA_FORMAT_AUDIO_channelMask, "?i", &info->channel_mask, NULL);
|
||||
}
|
||||
|
||||
static inline struct spa_pod *
|
||||
spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_raw *info)
|
||||
{
|
||||
return spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, id,
|
||||
"I", SPA_MEDIA_TYPE_audio,
|
||||
"I", SPA_MEDIA_SUBTYPE_raw,
|
||||
":", SPA_FORMAT_AUDIO_format, "I", info->format,
|
||||
":", SPA_FORMAT_AUDIO_layout, "I", info->layout,
|
||||
":", SPA_FORMAT_AUDIO_rate, "i", info->rate,
|
||||
":", SPA_FORMAT_AUDIO_channels, "i", info->channels);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
43
spa/include/spa/param/format-utils.h
Normal file
43
spa/include/spa/param/format-utils.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_PARAM_FORMAT_UTILS_H__
|
||||
#define __SPA_PARAM_FORMAT_UTILS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/param/format.h>
|
||||
|
||||
static inline int
|
||||
spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)
|
||||
{
|
||||
return spa_pod_object_parse(format,
|
||||
"I", media_type,
|
||||
"I", media_subtype, NULL);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_PARAM_FORMAT_UTILS */
|
||||
|
|
@ -28,6 +28,7 @@ extern "C" {
|
|||
|
||||
/** media type for SPA_TYPE_OBJECT_Format */
|
||||
enum spa_media_type {
|
||||
SPA_MEDIA_TYPE_START,
|
||||
SPA_MEDIA_TYPE_audio,
|
||||
SPA_MEDIA_TYPE_video,
|
||||
SPA_MEDIA_TYPE_image,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ extern "C" {
|
|||
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/param/video/format.h>
|
||||
#include <spa/param/format-utils.h>
|
||||
|
||||
static inline int
|
||||
spa_format_video_raw_parse(const struct spa_pod *format,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue