2023-02-08 18:12:00 +01:00
|
|
|
/* PipeWire */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2020 Wim Taymans */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
2021-06-18 23:36:35 +02:00
|
|
|
|
|
|
|
|
#ifndef PULSER_SERVER_STREAM_H
|
|
|
|
|
#define PULSER_SERVER_STREAM_H
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include <spa/utils/hook.h>
|
|
|
|
|
#include <spa/utils/ringbuffer.h>
|
|
|
|
|
#include <pipewire/pipewire.h>
|
|
|
|
|
|
|
|
|
|
#include "format.h"
|
|
|
|
|
#include "volume.h"
|
|
|
|
|
|
|
|
|
|
struct impl;
|
|
|
|
|
struct client;
|
|
|
|
|
struct spa_io_rate_match;
|
|
|
|
|
|
|
|
|
|
struct buffer_attr {
|
|
|
|
|
uint32_t maxlength;
|
|
|
|
|
uint32_t tlength;
|
|
|
|
|
uint32_t prebuf;
|
|
|
|
|
uint32_t minreq;
|
|
|
|
|
uint32_t fragsize;
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-16 13:08:47 +01:00
|
|
|
enum stream_type {
|
|
|
|
|
STREAM_TYPE_RECORD,
|
|
|
|
|
STREAM_TYPE_PLAYBACK,
|
|
|
|
|
STREAM_TYPE_UPLOAD,
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-18 23:36:35 +02:00
|
|
|
struct stream {
|
|
|
|
|
uint32_t create_tag;
|
|
|
|
|
uint32_t channel; /* index in map */
|
|
|
|
|
uint32_t id; /* id of global */
|
2022-01-17 11:28:40 +01:00
|
|
|
uint32_t index; /* index */
|
2021-06-18 23:36:35 +02:00
|
|
|
|
2022-06-03 16:59:08 +02:00
|
|
|
uint32_t peer_index;
|
|
|
|
|
|
2021-06-18 23:36:35 +02:00
|
|
|
struct impl *impl;
|
|
|
|
|
struct client *client;
|
2021-11-16 13:08:47 +01:00
|
|
|
enum stream_type type;
|
2021-06-18 23:36:35 +02:00
|
|
|
enum pw_direction direction;
|
|
|
|
|
|
|
|
|
|
struct pw_properties *props;
|
|
|
|
|
|
|
|
|
|
struct pw_stream *stream;
|
|
|
|
|
struct spa_hook stream_listener;
|
|
|
|
|
|
2021-12-14 15:48:54 +01:00
|
|
|
struct spa_io_position *position;
|
2021-06-18 23:36:35 +02:00
|
|
|
struct spa_ringbuffer ring;
|
|
|
|
|
void *buffer;
|
|
|
|
|
|
|
|
|
|
int64_t read_index;
|
|
|
|
|
int64_t write_index;
|
|
|
|
|
uint64_t underrun_for;
|
|
|
|
|
uint64_t playing_for;
|
|
|
|
|
uint64_t ticks_base;
|
|
|
|
|
uint64_t timestamp;
|
2022-11-20 16:13:22 +01:00
|
|
|
uint64_t idle_time;
|
2021-06-18 23:36:35 +02:00
|
|
|
int64_t delay;
|
|
|
|
|
|
2021-12-14 15:48:54 +01:00
|
|
|
uint32_t last_quantum;
|
|
|
|
|
int64_t requested;
|
2021-06-18 23:36:35 +02:00
|
|
|
|
2022-01-22 16:17:09 +01:00
|
|
|
struct spa_fraction min_req;
|
|
|
|
|
struct spa_fraction default_req;
|
|
|
|
|
struct spa_fraction min_frag;
|
|
|
|
|
struct spa_fraction default_frag;
|
|
|
|
|
struct spa_fraction default_tlength;
|
|
|
|
|
struct spa_fraction min_quantum;
|
2022-11-20 16:13:22 +01:00
|
|
|
uint32_t idle_timeout_sec;
|
2022-01-22 16:17:09 +01:00
|
|
|
|
2021-06-18 23:36:35 +02:00
|
|
|
struct sample_spec ss;
|
|
|
|
|
struct channel_map map;
|
|
|
|
|
struct buffer_attr attr;
|
|
|
|
|
uint32_t frame_size;
|
|
|
|
|
uint32_t rate;
|
2022-06-03 16:58:37 +02:00
|
|
|
uint64_t lat_usec;
|
2021-06-18 23:36:35 +02:00
|
|
|
|
|
|
|
|
struct volume volume;
|
|
|
|
|
bool muted;
|
|
|
|
|
|
|
|
|
|
uint32_t drain_tag;
|
|
|
|
|
unsigned int corked:1;
|
|
|
|
|
unsigned int draining:1;
|
|
|
|
|
unsigned int volume_set:1;
|
|
|
|
|
unsigned int muted_set:1;
|
|
|
|
|
unsigned int early_requests:1;
|
|
|
|
|
unsigned int adjust_latency:1;
|
|
|
|
|
unsigned int is_underrun:1;
|
|
|
|
|
unsigned int in_prebuf:1;
|
|
|
|
|
unsigned int killed:1;
|
2021-12-14 14:39:38 +01:00
|
|
|
unsigned int pending:1;
|
2022-11-20 16:13:22 +01:00
|
|
|
unsigned int is_idle:1;
|
2022-11-20 15:07:44 +01:00
|
|
|
unsigned int is_paused:1;
|
2021-06-18 23:36:35 +02:00
|
|
|
};
|
|
|
|
|
|
2021-11-16 13:08:47 +01:00
|
|
|
struct stream *stream_new(struct client *client, enum stream_type type, uint32_t create_tag,
|
|
|
|
|
const struct sample_spec *ss, const struct channel_map *map,
|
|
|
|
|
const struct buffer_attr *attr);
|
2021-06-18 23:36:35 +02:00
|
|
|
void stream_free(struct stream *stream);
|
|
|
|
|
void stream_flush(struct stream *stream);
|
|
|
|
|
uint32_t stream_pop_missing(struct stream *stream);
|
|
|
|
|
|
2022-11-20 15:07:44 +01:00
|
|
|
void stream_set_paused(struct stream *stream, bool paused, const char *reason);
|
|
|
|
|
|
2022-01-14 10:41:11 +01:00
|
|
|
int stream_send_underflow(struct stream *stream, int64_t offset);
|
2021-06-18 23:36:35 +02:00
|
|
|
int stream_send_overflow(struct stream *stream);
|
|
|
|
|
int stream_send_killed(struct stream *stream);
|
|
|
|
|
int stream_send_started(struct stream *stream);
|
|
|
|
|
int stream_send_request(struct stream *stream);
|
2021-12-14 15:48:54 +01:00
|
|
|
int stream_update_minreq(struct stream *stream, uint32_t minreq);
|
2022-06-03 16:59:08 +02:00
|
|
|
int stream_send_moved(struct stream *stream, uint32_t peer_index, const char *peer_name);
|
2023-10-11 15:17:13 +02:00
|
|
|
int stream_update_tag_param(struct stream *stream);
|
2021-06-18 23:36:35 +02:00
|
|
|
|
|
|
|
|
#endif /* PULSER_SERVER_STREAM_H */
|