mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Rework formats
Use a POD for the format body. This allows us to more easily build and copy the formats. Remove obsolete code to make video and audio formats. Use SpaVideo/AudioInfo to keep track of formats. Make functions to parse the format into the structures. Update plugins
This commit is contained in:
parent
7fc73953cd
commit
16b62de53a
34 changed files with 1096 additions and 1579 deletions
|
|
@ -95,24 +95,19 @@ pinos_serialize_format_get_size (const SpaFormat *format)
|
|||
if (format == NULL)
|
||||
return 0;
|
||||
|
||||
return pinos_serialize_props_get_size (&format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
|
||||
return SPA_FORMAT_SIZE (format);
|
||||
}
|
||||
|
||||
size_t
|
||||
pinos_serialize_format_serialize (void *dest, const SpaFormat *format)
|
||||
{
|
||||
SpaFormat *tf;
|
||||
size_t size;
|
||||
|
||||
if (format == NULL)
|
||||
return 0;
|
||||
|
||||
tf = dest;
|
||||
tf->media_type = format->media_type;
|
||||
tf->media_subtype = format->media_subtype;
|
||||
|
||||
dest = SPA_MEMBER (tf, offsetof (SpaFormat, props), void);
|
||||
size = pinos_serialize_props_serialize (dest, &format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
|
||||
size = SPA_FORMAT_SIZE (format);
|
||||
memcpy (dest, format, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
@ -120,12 +115,7 @@ pinos_serialize_format_serialize (void *dest, const SpaFormat *format)
|
|||
SpaFormat *
|
||||
pinos_serialize_format_deserialize (void *src, off_t offset)
|
||||
{
|
||||
SpaFormat *f;
|
||||
|
||||
f = SPA_MEMBER (src, offset, SpaFormat);
|
||||
pinos_serialize_props_deserialize (f, offsetof (SpaFormat, props));
|
||||
|
||||
return f;
|
||||
return SPA_MEMBER (src, offset, SpaFormat);
|
||||
}
|
||||
|
||||
SpaFormat *
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "gstpinosformat.h"
|
||||
|
||||
#if 0
|
||||
static guint
|
||||
calc_range_size (const GValue *val)
|
||||
{
|
||||
|
|
@ -278,10 +279,12 @@ handle_video_framerate (ConvertData *d)
|
|||
d->pi++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static SpaFormat *
|
||||
convert_1 (GstCapsFeatures *cf, GstStructure *cs)
|
||||
{
|
||||
#if 0
|
||||
const GValue *val;
|
||||
guint size, n_infos = 0, n_ranges = 0, n_datas = 0;
|
||||
ConvertData d;
|
||||
|
|
@ -425,6 +428,8 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
|
|||
handle_video_framerate (&d);
|
||||
}
|
||||
return d.f;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SpaFormat *
|
||||
|
|
@ -471,12 +476,12 @@ gst_caps_to_format_all (GstCaps *caps)
|
|||
}
|
||||
|
||||
GstCaps *
|
||||
gst_caps_from_format (SpaFormat *format)
|
||||
gst_caps_from_format (const SpaFormat *format)
|
||||
{
|
||||
GstCaps *res = NULL;
|
||||
|
||||
if (format->media_type == SPA_MEDIA_TYPE_VIDEO) {
|
||||
SpaFormatVideo f;
|
||||
SpaVideoInfo f;
|
||||
|
||||
if (spa_format_video_parse (format, &f) < 0)
|
||||
return NULL;
|
||||
|
|
@ -506,7 +511,7 @@ gst_caps_from_format (SpaFormat *format)
|
|||
NULL);
|
||||
}
|
||||
} else if (format->media_type == SPA_MEDIA_TYPE_AUDIO) {
|
||||
SpaFormatAudio f;
|
||||
SpaAudioInfo f;
|
||||
|
||||
if (spa_format_audio_parse (format, &f) < 0)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ G_BEGIN_DECLS
|
|||
SpaFormat * gst_caps_to_format (GstCaps *caps, guint index);
|
||||
GPtrArray * gst_caps_to_format_all (GstCaps *caps);
|
||||
|
||||
GstCaps * gst_caps_from_format (SpaFormat *format);
|
||||
GstCaps * gst_caps_from_format (const SpaFormat *format);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <pinos/server/core.h>
|
||||
#include <pinos/server/data-loop.h>
|
||||
#include <pinos/server/client-node.h>
|
||||
#include <spa/lib/debug.h>
|
||||
|
||||
typedef struct {
|
||||
PinosGlobal this;
|
||||
|
|
|
|||
|
|
@ -59,9 +59,10 @@ pinos_link_update_state (PinosLink *link,
|
|||
PinosLinkState old = link->state;
|
||||
|
||||
if (state != old) {
|
||||
pinos_log_debug ("link %p: update state %s -> %s", link,
|
||||
pinos_log_debug ("link %p: update state %s -> %s (%s)", link,
|
||||
pinos_link_state_as_string (old),
|
||||
pinos_link_state_as_string (state));
|
||||
pinos_link_state_as_string (state),
|
||||
error);
|
||||
|
||||
link->state = state;
|
||||
if (link->error)
|
||||
|
|
@ -97,8 +98,10 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
0,
|
||||
NULL,
|
||||
&error);
|
||||
if (format == NULL)
|
||||
if (format == NULL) {
|
||||
asprintf (&error, "no common format found");
|
||||
goto error;
|
||||
}
|
||||
|
||||
pinos_log_debug ("link %p: doing set format", this);
|
||||
if (pinos_log_level_enabled (SPA_LOG_LEVEL_DEBUG))
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <pinos/client/pinos.h>
|
||||
#include <pinos/client/sig.h>
|
||||
#include <spa/lib/debug.h>
|
||||
|
||||
typedef struct {
|
||||
bool running;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue