2023-02-08 18:12:00 +01:00
|
|
|
/* GStreamer */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
2017-05-23 19:15:33 +02:00
|
|
|
|
|
|
|
|
#ifndef __GST_PIPEWIRE_POOL_H__
|
|
|
|
|
#define __GST_PIPEWIRE_POOL_H__
|
|
|
|
|
|
2024-06-01 17:15:09 +03:00
|
|
|
#include "gstpipewirestream.h"
|
|
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
2025-03-20 21:13:03 -04:00
|
|
|
#include <gst/audio/audio.h>
|
2023-02-03 13:02:49 +08:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
|
2017-07-11 15:57:20 +02:00
|
|
|
#include <pipewire/pipewire.h>
|
2017-05-23 19:15:33 +02:00
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
2024-06-01 18:01:42 +03:00
|
|
|
#define GST_TYPE_PIPEWIRE_POOL (gst_pipewire_pool_get_type())
|
|
|
|
|
G_DECLARE_FINAL_TYPE (GstPipeWirePool, gst_pipewire_pool, GST, PIPEWIRE_POOL, GstBufferPool)
|
2017-05-23 19:15:33 +02:00
|
|
|
|
2025-03-26 11:55:13 -04:00
|
|
|
#define PIPEWIRE_POOL_MIN_BUFFERS 2u
|
|
|
|
|
#define PIPEWIRE_POOL_MAX_BUFFERS 16u
|
|
|
|
|
|
2025-04-16 19:47:40 -04:00
|
|
|
/* Only available in GStreamer 1.22+ */
|
|
|
|
|
#ifndef GST_VIDEO_FORMAT_INFO_IS_VALID_RAW
|
|
|
|
|
#define GST_VIDEO_FORMAT_INFO_IS_VALID_RAW(info) \
|
|
|
|
|
(info != NULL && (info)->format > GST_VIDEO_FORMAT_ENCODED)
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-03-22 16:40:27 +01:00
|
|
|
typedef struct _GstPipeWirePoolData GstPipeWirePoolData;
|
|
|
|
|
struct _GstPipeWirePoolData {
|
|
|
|
|
GstPipeWirePool *pool;
|
|
|
|
|
void *owner;
|
|
|
|
|
struct spa_meta_header *header;
|
|
|
|
|
guint flags;
|
|
|
|
|
struct pw_buffer *b;
|
|
|
|
|
GstBuffer *buf;
|
2020-05-05 13:07:12 +02:00
|
|
|
gboolean queued;
|
2020-07-31 11:44:46 +02:00
|
|
|
struct spa_meta_region *crop;
|
2022-12-03 23:20:52 +01:00
|
|
|
struct spa_meta_videotransform *videotransform;
|
2018-03-22 16:40:27 +01:00
|
|
|
};
|
|
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
struct _GstPipeWirePool {
|
|
|
|
|
GstBufferPool parent;
|
|
|
|
|
|
2024-06-01 17:15:09 +03:00
|
|
|
GWeakRef stream;
|
2024-05-28 17:34:45 +03:00
|
|
|
guint n_buffers;
|
2018-03-22 16:40:27 +01:00
|
|
|
|
2025-03-20 21:13:03 -04:00
|
|
|
gboolean has_video;
|
2025-04-16 19:47:40 -04:00
|
|
|
gboolean has_rawvideo;
|
2023-02-03 13:02:49 +08:00
|
|
|
gboolean add_metavideo;
|
2025-03-20 21:13:03 -04:00
|
|
|
GstAudioInfo audio_info;
|
2023-02-03 13:02:49 +08:00
|
|
|
GstVideoInfo video_info;
|
2025-03-20 21:13:03 -04:00
|
|
|
GstVideoAlignment video_align;
|
2023-02-03 13:02:49 +08:00
|
|
|
|
2018-03-22 16:40:27 +01:00
|
|
|
GstAllocator *fd_allocator;
|
|
|
|
|
GstAllocator *dmabuf_allocator;
|
2025-03-20 21:13:03 -04:00
|
|
|
GstAllocator *shm_allocator;
|
2018-03-22 16:40:27 +01:00
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
GCond cond;
|
2025-01-17 16:33:15 +01:00
|
|
|
gboolean paused;
|
2025-03-20 21:13:03 -04:00
|
|
|
gboolean allocate_memory;
|
2017-05-23 19:15:33 +02:00
|
|
|
};
|
|
|
|
|
|
2025-01-24 21:07:55 +05:30
|
|
|
enum GstPipeWirePoolMode {
|
|
|
|
|
USE_BUFFERPOOL_NO = 0,
|
|
|
|
|
USE_BUFFERPOOL_AUTO,
|
|
|
|
|
USE_BUFFERPOOL_YES
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-01 17:15:09 +03:00
|
|
|
GstPipeWirePool * gst_pipewire_pool_new (GstPipeWireStream *stream);
|
2017-05-23 19:15:33 +02:00
|
|
|
|
2018-03-22 16:40:27 +01:00
|
|
|
void gst_pipewire_pool_wrap_buffer (GstPipeWirePool *pool, struct pw_buffer *buffer);
|
2024-05-28 16:47:15 +03:00
|
|
|
void gst_pipewire_pool_remove_buffer (GstPipeWirePool *pool, struct pw_buffer *buffer);
|
2018-03-22 16:40:27 +01:00
|
|
|
|
2024-05-28 17:34:45 +03:00
|
|
|
static inline gboolean
|
|
|
|
|
gst_pipewire_pool_has_buffers (GstPipeWirePool *pool)
|
|
|
|
|
{
|
|
|
|
|
return pool->n_buffers > 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 16:40:27 +01:00
|
|
|
GstPipeWirePoolData *gst_pipewire_pool_get_data (GstBuffer *buffer);
|
|
|
|
|
|
2025-01-17 16:33:15 +01:00
|
|
|
void gst_pipewire_pool_set_paused (GstPipeWirePool *pool, gboolean paused);
|
|
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
|
|
#endif /* __GST_PIPEWIRE_POOL_H__ */
|