summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build24
-rw-r--r--src/gst/gstpipewireformat.c68
-rw-r--r--src/gst/gstpipewireformat.h6
-rw-r--r--src/gst/gstpipewiresink.c25
-rw-r--r--src/gst/gstpipewiresrc.c14
5 files changed, 69 insertions, 68 deletions
diff --git a/meson.build b/meson.build
index 3ceeab2f..df883496 100644
--- a/meson.build
+++ b/meson.build
@@ -146,6 +146,18 @@ dbus_dep = dependency('dbus-1')
#optional dependencies
jack_dep = dependency('jack', version : '>= 1.9.10', required : false)
+if get_option('enable_gstreamer')
+ glib_dep = dependency('glib-2.0', version : '>=2.32.0')
+ gobject_dep = dependency('gobject-2.0')
+ gmodule_dep = dependency('gmodule-2.0')
+ gio_dep = [dependency('gio-2.0'), dependency('gio-unix-2.0')]
+ gst_dep = [dependency('gstreamer-1.0'),
+ dependency('gstreamer-plugins-base-1.0'),
+ dependency('gstreamer-video-1.0'),
+ dependency('gstreamer-audio-1.0'),
+ dependency('gstreamer-allocators-1.0'),]
+endif
+
subdir('spa')
subdir('src')
subdir('pkgconfig')
@@ -163,15 +175,3 @@ if get_option('enable_man')
subdir('man')
endif
endif
-
-if get_option('enable_gstreamer')
- glib_dep = dependency('glib-2.0', version : '>=2.32.0')
- gobject_dep = dependency('gobject-2.0')
- gmodule_dep = dependency('gmodule-2.0')
- gio_dep = [dependency('gio-2.0'), dependency('gio-unix-2.0')]
- gst_dep = [dependency('gstreamer-1.0'),
- dependency('gstreamer-plugins-base-1.0'),
- dependency('gstreamer-video-1.0'),
- dependency('gstreamer-audio-1.0'),
- dependency('gstreamer-allocators-1.0'),]
-endif
diff --git a/src/gst/gstpipewireformat.c b/src/gst/gstpipewireformat.c
index 8ddc4821..5a5d4201 100644
--- a/src/gst/gstpipewireformat.c
+++ b/src/gst/gstpipewireformat.c
@@ -200,8 +200,10 @@ static const uint32_t *audio_format_map[] = {
typedef struct {
struct spa_pod_builder b;
const struct media_type *type;
+ uint32_t id;
const GstCapsFeatures *cf;
const GstStructure *cs;
+ GPtrArray *array;
} ConvertData;
static const struct media_type *
@@ -544,38 +546,31 @@ write_pod (struct spa_pod_builder *b, const void *data, uint32_t size)
}
static struct spa_pod *
-convert_1 (GstCapsFeatures *cf, GstStructure *cs)
+convert_1 (ConvertData *d)
{
- ConvertData d;
-
- spa_zero (d);
- d.cf = cf;
- d.cs = cs;
-
- if (!(d.type = find_media_types (gst_structure_get_name (cs))))
+ if (!(d->type = find_media_types (gst_structure_get_name (d->cs))))
return NULL;
- d.b.write = write_pod;
+ d->b.write = write_pod;
- spa_pod_builder_push_object (&d.b, 0, type.format);
- spa_pod_builder_id(&d.b, *d.type->media_type);
- spa_pod_builder_id(&d.b, *d.type->media_subtype);
+ spa_pod_builder_push_object (&d->b, d->id, type.format);
+ spa_pod_builder_id(&d->b, *d->type->media_type);
+ spa_pod_builder_id(&d->b, *d->type->media_subtype);
- if (*d.type->media_type == type.media_type.video)
- handle_video_fields (&d);
- else if (*d.type->media_type == type.media_type.audio)
- handle_audio_fields (&d);
+ if (*d->type->media_type == type.media_type.video)
+ handle_video_fields (d);
+ else if (*d->type->media_type == type.media_type.audio)
+ handle_audio_fields (d);
- spa_pod_builder_pop (&d.b);
+ spa_pod_builder_pop (&d->b);
- return SPA_MEMBER (d.b.data, 0, struct spa_pod);
+ return SPA_MEMBER (d->b.data, 0, struct spa_pod);
}
struct spa_pod *
-gst_caps_to_format (GstCaps *caps, guint index, struct spa_type_map *map)
+gst_caps_to_format (GstCaps *caps, guint index, uint32_t id, struct spa_type_map *map)
{
- GstCapsFeatures *f;
- GstStructure *s;
+ ConvertData d;
struct spa_pod *res;
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
@@ -583,10 +578,12 @@ gst_caps_to_format (GstCaps *caps, guint index, struct spa_type_map *map)
ensure_types(map);
- f = gst_caps_get_features (caps, index);
- s = gst_caps_get_structure (caps, index);
+ spa_zero (d);
+ d.cf = gst_caps_get_features (caps, index);
+ d.cs = gst_caps_get_structure (caps, index);
+ d.id = id;
- res = convert_1 (f, s);
+ res = convert_1 (&d);
return res;
}
@@ -594,28 +591,35 @@ gst_caps_to_format (GstCaps *caps, guint index, struct spa_type_map *map)
static gboolean
foreach_func (GstCapsFeatures *features,
GstStructure *structure,
- GPtrArray *array)
+ ConvertData *d)
{
struct spa_pod *fmt;
- if ((fmt = convert_1 (features, structure)))
- g_ptr_array_insert (array, -1, fmt);
+ spa_zero(d->b);
+ d->cf = features;
+ d->cs = structure;
+
+ if ((fmt = convert_1 (d)))
+ g_ptr_array_insert (d->array, -1, fmt);
return TRUE;
}
GPtrArray *
-gst_caps_to_format_all (GstCaps *caps, struct spa_type_map *map)
+gst_caps_to_format_all (GstCaps *caps, uint32_t id, struct spa_type_map *map)
{
- GPtrArray *res;
+ ConvertData d;
ensure_types(map);
- res = g_ptr_array_new_full (gst_caps_get_size (caps), (GDestroyNotify)g_free);
- gst_caps_foreach (caps, (GstCapsForeachFunc) foreach_func, res);
+ spa_zero (d);
+ d.id = id;
+ d.array = g_ptr_array_new_full (gst_caps_get_size (caps), (GDestroyNotify)g_free);
- return res;
+ gst_caps_foreach (caps, (GstCapsForeachFunc) foreach_func, &d);
+
+ return d.array;
}
static void
diff --git a/src/gst/gstpipewireformat.h b/src/gst/gstpipewireformat.h
index fd85f8c3..b179d4e6 100644
--- a/src/gst/gstpipewireformat.h
+++ b/src/gst/gstpipewireformat.h
@@ -27,8 +27,10 @@
G_BEGIN_DECLS
-struct spa_pod * gst_caps_to_format (GstCaps *caps, guint index, struct spa_type_map *map);
-GPtrArray * gst_caps_to_format_all (GstCaps *caps, struct spa_type_map *map);
+struct spa_pod * gst_caps_to_format (GstCaps *caps,
+ guint index, uint32_t id,
+ struct spa_type_map *map);
+GPtrArray * gst_caps_to_format_all (GstCaps *caps, uint32_t id, struct spa_type_map *map);
GstCaps * gst_caps_from_format (const struct spa_pod *format, struct spa_type_map *map);
diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c
index 7f1b783a..b22c9d77 100644
--- a/src/gst/gstpipewiresink.c
+++ b/src/gst/gstpipewiresink.c
@@ -224,7 +224,7 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink)
guint size;
guint min_buffers;
guint max_buffers;
- struct spa_pod *port_params[3];
+ struct spa_pod *port_params[2];
struct spa_pod_builder b = { NULL };
uint8_t buffer[1024];
@@ -254,15 +254,6 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink)
":", t->param_meta.type, "I", t->meta.Header,
":", t->param_meta.size, "i", sizeof (struct spa_meta_header));
- port_params[2] = spa_pod_builder_object (&b,
- t->param.idMeta, t->param_meta.Meta,
- ":", t->param_meta.type, "I", t->meta.Ringbuffer,
- ":", t->param_meta.size, "i", sizeof (struct spa_meta_ringbuffer),
- ":", t->param_meta.ringbufferSize, "i", size * SPA_MAX (4,
- SPA_MAX (min_buffers, max_buffers)),
- ":", t->param_meta.ringbufferStride, "i", 0,
- ":", t->param_meta.ringbufferBlocks, "i", 1,
- ":", t->param_meta.ringbufferAlign, "i", 16);
pw_thread_loop_lock (sink->main_loop);
pw_stream_finish_format (sink->stream, 0, 2, port_params);
@@ -448,12 +439,12 @@ on_add_buffer (void *_data,
d->type == t->data.DmaBuf) {
gmem = gst_fd_allocator_alloc (pwsink->allocator, dup (d->fd),
d->mapoffset + d->maxsize, GST_FD_MEMORY_FLAG_NONE);
- gst_memory_resize (gmem, d->chunk->offset + d->mapoffset, d->chunk->size);
+ gst_memory_resize (gmem, d->mapoffset, d->maxsize);
data.offset = d->mapoffset;
}
else if (d->type == t->data.MemPtr) {
- gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, d->chunk->offset,
- d->chunk->size, NULL, NULL);
+ gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, 0,
+ d->maxsize, NULL, NULL);
data.offset = 0;
}
if (gmem)
@@ -535,8 +526,8 @@ do_send_buffer (GstPipeWireSink *pwsink)
for (i = 0; i < data->buf->n_datas; i++) {
struct spa_data *d = &data->buf->datas[i];
GstMemory *mem = gst_buffer_peek_memory (buffer, i);
- d->chunk->offset = mem->offset - data->offset;
- d->chunk->size = mem->size;
+ d->chunk->area.readindex = mem->offset - data->offset;
+ d->chunk->area.writeindex = d->chunk->area.readindex + mem->size;
}
if (!(res = pw_stream_send_buffer (pwsink->stream, data->id))) {
@@ -596,10 +587,12 @@ gst_pipewire_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
enum pw_stream_state state;
const char *error = NULL;
gboolean res = FALSE;
+ struct pw_type *t;
pwsink = GST_PIPEWIRE_SINK (bsink);
+ t = pwsink->type;
- possible = gst_caps_to_format_all (caps, pwsink->type->map);
+ possible = gst_caps_to_format_all (caps, t->param.idEnumFormat, t->map);
pw_thread_loop_lock (pwsink->main_loop);
state = pw_stream_get_state (pwsink->stream, &error);
diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c
index 001c8b17..f328b2ad 100644
--- a/src/gst/gstpipewiresrc.c
+++ b/src/gst/gstpipewiresrc.c
@@ -384,12 +384,12 @@ on_add_buffer (void *_data, guint id)
if (d->type == t->data.MemFd || d->type == t->data.DmaBuf) {
gmem = gst_fd_allocator_alloc (pwsrc->fd_allocator, dup (d->fd),
d->mapoffset + d->maxsize, GST_FD_MEMORY_FLAG_NONE);
- gst_memory_resize (gmem, d->chunk->offset + d->mapoffset, d->chunk->size);
+ gst_memory_resize (gmem, d->mapoffset, d->maxsize);
data.offset = d->mapoffset;
}
else if (d->type == t->data.MemPtr) {
- gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, d->chunk->offset + d->mapoffset,
- d->chunk->size, NULL, NULL);
+ gmem = gst_memory_new_wrapped (0, d->data, d->maxsize, 0,
+ d->maxsize, NULL, NULL);
data.offset = 0;
}
if (gmem)
@@ -464,9 +464,11 @@ on_new_buffer (void *_data,
}
for (i = 0; i < data->buf->n_datas; i++) {
struct spa_data *d = &data->buf->datas[i];
+ uint32_t index;
GstMemory *mem = gst_buffer_peek_memory (buf, i);
- mem->offset = d->chunk->offset + data->offset;
- mem->size = d->chunk->size;
+ mem->size = spa_ringbuffer_get_read_index(&d->chunk->area, &index);
+ mem->offset = index % d->maxsize;
+ spa_ringbuffer_set_avail(&d->chunk->area, 0);
}
if (pwsrc->always_copy)
@@ -633,7 +635,7 @@ gst_pipewire_src_negotiate (GstBaseSrc * basesrc)
GST_DEBUG_OBJECT (basesrc, "have common caps: %" GST_PTR_FORMAT, caps);
/* open a connection with these caps */
- possible = gst_caps_to_format_all (caps, pwsrc->type->map);
+ possible = gst_caps_to_format_all (caps, pwsrc->type->param.idEnumFormat, pwsrc->type->map);
gst_caps_unref (caps);
/* first disconnect */