Cleanup
This commit is contained in:
@@ -1 +1,112 @@
|
||||
void init_pipewire();
|
||||
#ifndef __GSR_PIPEWIRE_HPP__
|
||||
#define __GSR_PIPEWIRE_HPP__
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/debug/types.h>
|
||||
#include <spa/param/audio/type-info.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
struct capture_config {
|
||||
// The node_name to look for. If not set, then every node_name matches.
|
||||
std::optional<std::string> name;
|
||||
|
||||
// Wether to look for an match (false) or match everything that does not
|
||||
// match name (true).
|
||||
bool exclude;
|
||||
|
||||
// Whether name refers to an application (false) or an input device (true).
|
||||
bool device;
|
||||
|
||||
// The amount of channels to create.
|
||||
int channels;
|
||||
};
|
||||
|
||||
struct target_port {
|
||||
uint32_t id;
|
||||
uint32_t node_id;
|
||||
const char *channel_name;
|
||||
};
|
||||
|
||||
struct target_node {
|
||||
uint32_t client_id;
|
||||
uint32_t id;
|
||||
const char *app_name;
|
||||
};
|
||||
|
||||
struct target_input {
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
struct sink_port {
|
||||
uint32_t id;
|
||||
const char* channel;
|
||||
};
|
||||
|
||||
struct capture_stream {
|
||||
struct pw_core *core;
|
||||
|
||||
// The stream we will capture
|
||||
struct pw_stream *stream;
|
||||
|
||||
// The context to use.
|
||||
struct pw_context *context;
|
||||
|
||||
// Object to accessing global events.
|
||||
struct pw_registry *registry;
|
||||
|
||||
// Listener for global events.
|
||||
struct spa_hook registry_listener;
|
||||
|
||||
// The capture sink.
|
||||
struct pw_proxy *sink_proxy;
|
||||
|
||||
// Listener for the sink events.
|
||||
struct spa_hook sink_proxy_listener;
|
||||
|
||||
// The event loop to use.
|
||||
struct pw_thread_loop *thread_loop;
|
||||
|
||||
// The id of the sink that we created.
|
||||
uint32_t sink_id;
|
||||
|
||||
// The serial of the sink.
|
||||
uint32_t sink_serial;
|
||||
|
||||
// Sequence number for forcing a server round trip
|
||||
int seq;
|
||||
|
||||
std::vector<struct sink_port> sink_ports;
|
||||
std::vector<struct target_node> nodes;
|
||||
std::vector<struct target_port> ports;
|
||||
std::vector<struct target_input> inputs;
|
||||
|
||||
struct capture_config config;
|
||||
|
||||
struct spa_audio_info format;
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns whether the capture stream is ready to have other ports attached to it.
|
||||
**/
|
||||
bool capture_stream_is_ready(struct capture_stream *data);
|
||||
|
||||
/*
|
||||
* Initialises the PipeWire API.
|
||||
**/
|
||||
void init_pipewire();
|
||||
|
||||
/*
|
||||
* Creates a capture stream using the provided config.
|
||||
**/
|
||||
struct capture_stream create_capture_stream(struct capture_config config);
|
||||
|
||||
/*
|
||||
* Frees the resources held by the capture stream.
|
||||
**/
|
||||
void free_capture_stream(struct capture_stream *data);
|
||||
|
||||
#endif /*__GSR_PIPEWIRE_HPP__*/
|
||||
|
||||
Reference in New Issue
Block a user