mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Cleanup audio format
This commit is contained in:
parent
b901c2c67d
commit
a5f21576fa
6 changed files with 21 additions and 15 deletions
|
|
@ -30,13 +30,13 @@ extern "C" {
|
||||||
typedef struct _SpaFormatAudio SpaFormatAudio;
|
typedef struct _SpaFormatAudio SpaFormatAudio;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SPA_PROP_ID_AUDIO_FORMAT = SPA_PROP_ID_MEDIA_CUSTOM_START,
|
SPA_PROP_ID_AUDIO_INFO = SPA_PROP_ID_MEDIA_CUSTOM_START,
|
||||||
|
SPA_PROP_ID_AUDIO_FORMAT,
|
||||||
SPA_PROP_ID_AUDIO_FLAGS,
|
SPA_PROP_ID_AUDIO_FLAGS,
|
||||||
SPA_PROP_ID_AUDIO_LAYOUT,
|
SPA_PROP_ID_AUDIO_LAYOUT,
|
||||||
SPA_PROP_ID_AUDIO_RATE,
|
SPA_PROP_ID_AUDIO_RATE,
|
||||||
SPA_PROP_ID_AUDIO_CHANNELS,
|
SPA_PROP_ID_AUDIO_CHANNELS,
|
||||||
SPA_PROP_ID_AUDIO_CHANNEL_MASK,
|
SPA_PROP_ID_AUDIO_CHANNEL_MASK,
|
||||||
SPA_PROP_ID_AUDIO_INFO_RAW,
|
|
||||||
} SpaPropIdAudio;
|
} SpaPropIdAudio;
|
||||||
|
|
||||||
SpaResult spa_prop_info_fill_audio (SpaPropInfo *info,
|
SpaResult spa_prop_info_fill_audio (SpaPropInfo *info,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ typedef struct {
|
||||||
* @SPA_PROP_FLAG_WRITABLE: property is writable
|
* @SPA_PROP_FLAG_WRITABLE: property is writable
|
||||||
* @SPA_PROP_FLAG_READWRITE: property is readable and writable
|
* @SPA_PROP_FLAG_READWRITE: property is readable and writable
|
||||||
* @SPA_PROP_FLAG_DEPRECATED: property is deprecated and should not be used
|
* @SPA_PROP_FLAG_DEPRECATED: property is deprecated and should not be used
|
||||||
|
* @SPA_PROP_FLAG_INFO: property is to get/set the complete structure
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SPA_PROP_FLAG_NONE = 0,
|
SPA_PROP_FLAG_NONE = 0,
|
||||||
|
|
@ -80,6 +81,7 @@ typedef enum {
|
||||||
SPA_PROP_FLAG_WRITABLE = (1 << 2),
|
SPA_PROP_FLAG_WRITABLE = (1 << 2),
|
||||||
SPA_PROP_FLAG_READWRITE = SPA_PROP_FLAG_READABLE | SPA_PROP_FLAG_WRITABLE,
|
SPA_PROP_FLAG_READWRITE = SPA_PROP_FLAG_READABLE | SPA_PROP_FLAG_WRITABLE,
|
||||||
SPA_PROP_FLAG_DEPRECATED = (1 << 3),
|
SPA_PROP_FLAG_DEPRECATED = (1 << 3),
|
||||||
|
SPA_PROP_FLAG_INFO = (1 << 4),
|
||||||
} SpaPropFlags;
|
} SpaPropFlags;
|
||||||
|
|
||||||
/* SpaPropRangeType:
|
/* SpaPropRangeType:
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,12 @@ static const SpaPropRangeInfo uint32_range[] = {
|
||||||
|
|
||||||
static const SpaPropInfo format_prop_info[] =
|
static const SpaPropInfo format_prop_info[] =
|
||||||
{
|
{
|
||||||
|
{ SPA_PROP_ID_AUDIO_INFO, 0,
|
||||||
|
"info", "the SpaAudioInfo structure",
|
||||||
|
SPA_PROP_FLAG_READWRITE | SPA_PROP_FLAG_OPTIONAL | SPA_PROP_FLAG_INFO,
|
||||||
|
SPA_PROP_TYPE_POINTER, sizeof (SpaAudioInfoRaw),
|
||||||
|
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||||
|
NULL },
|
||||||
{ SPA_PROP_ID_AUDIO_FORMAT, 0,
|
{ SPA_PROP_ID_AUDIO_FORMAT, 0,
|
||||||
"format", "The media format",
|
"format", "The media format",
|
||||||
SPA_PROP_FLAG_READWRITE,
|
SPA_PROP_FLAG_READWRITE,
|
||||||
|
|
@ -173,12 +179,6 @@ static const SpaPropInfo format_prop_info[] =
|
||||||
SPA_PROP_TYPE_BITMASK, sizeof (uint32_t),
|
SPA_PROP_TYPE_BITMASK, sizeof (uint32_t),
|
||||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||||
NULL },
|
NULL },
|
||||||
{ SPA_PROP_ID_AUDIO_INFO_RAW, 0,
|
|
||||||
"info", "the SpaAudioInfoRaw structure",
|
|
||||||
SPA_PROP_FLAG_READWRITE,
|
|
||||||
SPA_PROP_TYPE_POINTER, sizeof (SpaAudioInfoRaw),
|
|
||||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
|
||||||
NULL },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SpaResult
|
SpaResult
|
||||||
|
|
@ -220,17 +220,17 @@ spa_format_audio_init (SpaMediaType type,
|
||||||
{
|
{
|
||||||
static SpaPropInfo raw_format_prop_info[] =
|
static SpaPropInfo raw_format_prop_info[] =
|
||||||
{
|
{
|
||||||
|
{ SPA_PROP_ID_AUDIO_INFO, offsetof (SpaFormatAudio, info), },
|
||||||
{ SPA_PROP_ID_AUDIO_FORMAT, offsetof (SpaFormatAudio, info.raw.format), },
|
{ SPA_PROP_ID_AUDIO_FORMAT, offsetof (SpaFormatAudio, info.raw.format), },
|
||||||
{ SPA_PROP_ID_AUDIO_FLAGS, offsetof (SpaFormatAudio, info.raw.flags), },
|
{ SPA_PROP_ID_AUDIO_FLAGS, offsetof (SpaFormatAudio, info.raw.flags), },
|
||||||
{ SPA_PROP_ID_AUDIO_LAYOUT, offsetof (SpaFormatAudio, info.raw.layout), },
|
{ SPA_PROP_ID_AUDIO_LAYOUT, offsetof (SpaFormatAudio, info.raw.layout), },
|
||||||
{ SPA_PROP_ID_AUDIO_RATE, offsetof (SpaFormatAudio, info.raw.rate), },
|
{ SPA_PROP_ID_AUDIO_RATE, offsetof (SpaFormatAudio, info.raw.rate), },
|
||||||
{ SPA_PROP_ID_AUDIO_CHANNELS, offsetof (SpaFormatAudio, info.raw.channels), },
|
{ SPA_PROP_ID_AUDIO_CHANNELS, offsetof (SpaFormatAudio, info.raw.channels), },
|
||||||
{ SPA_PROP_ID_AUDIO_CHANNEL_MASK, offsetof (SpaFormatAudio, info.raw.channel_mask), },
|
{ SPA_PROP_ID_AUDIO_CHANNEL_MASK, offsetof (SpaFormatAudio, info.raw.channel_mask), },
|
||||||
{ SPA_PROP_ID_AUDIO_INFO_RAW, offsetof (SpaFormatAudio, info), },
|
|
||||||
};
|
};
|
||||||
prop_info = raw_format_prop_info;
|
prop_info = raw_format_prop_info;
|
||||||
n_prop_info = SPA_N_ELEMENTS (raw_format_prop_info);
|
n_prop_info = SPA_N_ELEMENTS (raw_format_prop_info);
|
||||||
format->format.props.unset_mask = (1 << 0) | (1 << 2) | (1 << 3) | (1 << 4);
|
format->format.props.unset_mask = (1 << 1) | (1 << 3) | (1 << 4) | (1 << 5);
|
||||||
format->info.raw = default_raw_info;
|
format->info.raw = default_raw_info;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -288,7 +288,7 @@ spa_format_audio_parse (const SpaFormat *format,
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
props = &format->props;
|
props = &format->props;
|
||||||
idx = spa_props_index_for_id (props, SPA_PROP_ID_AUDIO_INFO_RAW);
|
idx = spa_props_index_for_id (props, SPA_PROP_ID_AUDIO_INFO);
|
||||||
if ((res = spa_props_get_prop (props, idx, &value)) < 0)
|
if ((res = spa_props_get_prop (props, idx, &value)) < 0)
|
||||||
goto fallback;
|
goto fallback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,8 @@ spa_debug_format (const SpaFormat *format)
|
||||||
|
|
||||||
res = spa_props_get_prop (props, i, &value);
|
res = spa_props_get_prop (props, i, &value);
|
||||||
|
|
||||||
|
if (info->flags & SPA_PROP_FLAG_INFO)
|
||||||
|
continue;
|
||||||
if (res == SPA_RESULT_PROPERTY_UNSET && info->flags & SPA_PROP_FLAG_OPTIONAL)
|
if (res == SPA_RESULT_PROPERTY_UNSET && info->flags & SPA_PROP_FLAG_OPTIONAL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ static const SpaPropInfo format_prop_info[] =
|
||||||
{
|
{
|
||||||
{ SPA_PROP_ID_VIDEO_INFO, 0,
|
{ SPA_PROP_ID_VIDEO_INFO, 0,
|
||||||
"info", "the SpaVideoInfo structure",
|
"info", "the SpaVideoInfo structure",
|
||||||
SPA_PROP_FLAG_READWRITE | SPA_PROP_FLAG_OPTIONAL,
|
SPA_PROP_FLAG_READWRITE | SPA_PROP_FLAG_OPTIONAL | SPA_PROP_FLAG_INFO,
|
||||||
SPA_PROP_TYPE_POINTER, sizeof (SpaVideoInfoRaw),
|
SPA_PROP_TYPE_POINTER, sizeof (SpaVideoInfoRaw),
|
||||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
@ -519,7 +519,7 @@ spa_format_video_init (SpaMediaType type,
|
||||||
};
|
};
|
||||||
prop_info = raw_prop_info;
|
prop_info = raw_prop_info;
|
||||||
n_prop_info = SPA_N_ELEMENTS (raw_prop_info);
|
n_prop_info = SPA_N_ELEMENTS (raw_prop_info);
|
||||||
format->format.props.unset_mask = (1 << 14)-1;
|
format->format.props.unset_mask = (1 << 15)-2;
|
||||||
format->info.raw = default_raw_info;
|
format->info.raw = default_raw_info;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -539,7 +539,7 @@ spa_format_video_init (SpaMediaType type,
|
||||||
};
|
};
|
||||||
prop_info = h264_prop_info;
|
prop_info = h264_prop_info;
|
||||||
n_prop_info = SPA_N_ELEMENTS (h264_prop_info);
|
n_prop_info = SPA_N_ELEMENTS (h264_prop_info);
|
||||||
format->format.props.unset_mask = (1 << 3)-1;
|
format->format.props.unset_mask = (1 << 4)-2;
|
||||||
format->info.h264 = default_h264_info;
|
format->info.h264 = default_h264_info;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +559,7 @@ spa_format_video_init (SpaMediaType type,
|
||||||
};
|
};
|
||||||
prop_info = mjpg_prop_info;
|
prop_info = mjpg_prop_info;
|
||||||
n_prop_info = SPA_N_ELEMENTS (mjpg_prop_info);
|
n_prop_info = SPA_N_ELEMENTS (mjpg_prop_info);
|
||||||
format->format.props.unset_mask = (1 << 3)-1;
|
format->format.props.unset_mask = (1 << 4)-2;
|
||||||
format->info.mjpg = default_mjpg_info;
|
format->info.mjpg = default_mjpg_info;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -682,6 +682,8 @@ have_framerate:
|
||||||
fmt->ranges[i].val.value = &fmt->framerates[i];
|
fmt->ranges[i].val.value = &fmt->framerates[i];
|
||||||
i++;
|
i++;
|
||||||
state->frmival.index++;
|
state->frmival.index++;
|
||||||
|
if (i == 16)
|
||||||
|
break;
|
||||||
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
|
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
|
||||||
state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
|
state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
|
||||||
fmt->framerates[0].num = state->frmival.stepwise.min.denominator;
|
fmt->framerates[0].num = state->frmival.stepwise.min.denominator;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue