mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
module-rtp: send journal feedback
Parse the journal and send feedback. Handle the NO and RS commands.
This commit is contained in:
parent
1276c946fd
commit
f841a0d3f1
7 changed files with 124 additions and 8 deletions
|
|
@ -30,11 +30,18 @@ struct rtp_apple_midi_ck {
|
|||
uint32_t ts3_l;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct rtp_apple_midi_rs {
|
||||
uint32_t cmd;
|
||||
uint32_t ssrc;
|
||||
uint32_t seqnum;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define APPLE_MIDI_CMD_IN ((0xffff << 16) | 'I'<<8 | 'N')
|
||||
#define APPLE_MIDI_CMD_NO ((0xffff << 16) | 'N'<<8 | 'O')
|
||||
#define APPLE_MIDI_CMD_OK ((0xffff << 16) | 'O'<<8 | 'K')
|
||||
#define APPLE_MIDI_CMD_CK ((0xffff << 16) | 'C'<<8 | 'K')
|
||||
#define APPLE_MIDI_CMD_BY ((0xffff << 16) | 'B'<<8 | 'Y')
|
||||
#define APPLE_MIDI_CMD_RS ((0xffff << 16) | 'R'<<8 | 'S')
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static int receive_rtp_audio(struct impl *impl, uint8_t *buffer, ssize_t len)
|
|||
|
||||
if (!impl->have_sync) {
|
||||
pw_log_info("sync to timestamp:%u seq:%u ts_offset:%u SSRC:%u target:%u direct:%u",
|
||||
write, impl->seq-1, impl->ts_offset, impl->ssrc,
|
||||
timestamp, seq, impl->ts_offset, impl->ssrc,
|
||||
impl->target_buffer, impl->direct_timestamp);
|
||||
|
||||
/* we read from timestamp, keeping target_buffer of data
|
||||
|
|
|
|||
|
|
@ -126,6 +126,13 @@ static int get_midi_size(uint8_t *p, uint32_t avail)
|
|||
}
|
||||
return size;
|
||||
}
|
||||
static int parse_journal(struct impl *impl, uint8_t *packet, uint16_t seq, uint32_t len)
|
||||
{
|
||||
struct rtp_midi_journal *j = (struct rtp_midi_journal*)packet;
|
||||
uint16_t seqnum = ntohs(j->checkpoint_seqnum);
|
||||
rtp_stream_emit_send_feedback(impl, seqnum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static double get_time(struct impl *impl)
|
||||
{
|
||||
|
|
@ -143,8 +150,8 @@ static double get_time(struct impl *impl)
|
|||
return t;
|
||||
}
|
||||
|
||||
static int receive_midi(struct impl *impl, uint8_t *packet,
|
||||
uint32_t timestamp, uint32_t payload_offset, uint32_t plen)
|
||||
static int receive_midi(struct impl *impl, uint8_t *packet, uint32_t timestamp,
|
||||
uint16_t seq, uint32_t payload_offset, uint32_t plen)
|
||||
{
|
||||
uint32_t write;
|
||||
struct rtp_midi_header *hdr;
|
||||
|
|
@ -160,7 +167,7 @@ static int receive_midi(struct impl *impl, uint8_t *packet,
|
|||
* midi events and render them in the corresponding cycle */
|
||||
if (!impl->have_sync) {
|
||||
pw_log_info("sync to timestamp:%u seq:%u ts_offset:%u SSRC:%u direct:%d",
|
||||
timestamp, impl->seq-1, impl->ts_offset, impl->ssrc,
|
||||
timestamp, seq, impl->ts_offset, impl->ssrc,
|
||||
impl->direct_timestamp);
|
||||
impl->have_sync = true;
|
||||
}
|
||||
|
|
@ -186,7 +193,7 @@ static int receive_midi(struct impl *impl, uint8_t *packet,
|
|||
spa_dll_set_bw(&impl->dll, SPA_DLL_BW_MIN, 256, impl->rate);
|
||||
|
||||
pw_log_info("sync to timestamp:%u seq:%u ts_offset:%u SSRC:%u direct:%d",
|
||||
timestamp, impl->seq-1, impl->ts_offset, impl->ssrc,
|
||||
timestamp, seq, impl->ts_offset, impl->ssrc,
|
||||
impl->direct_timestamp);
|
||||
impl->have_sync = true;
|
||||
impl->ring.readindex = impl->ring.writeindex;
|
||||
|
|
@ -221,6 +228,8 @@ static int receive_midi(struct impl *impl, uint8_t *packet,
|
|||
pw_log_warn("invalid packet %d > %d", end, plen);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (hdr->j)
|
||||
parse_journal(impl, &packet[end], seq, plen - end);
|
||||
|
||||
ptr = SPA_PTROFF(impl->buffer, write & BUFFER_MASK2, void);
|
||||
|
||||
|
|
@ -258,6 +267,8 @@ static int receive_midi(struct impl *impl, uint8_t *packet,
|
|||
|
||||
write += b.state.offset;
|
||||
spa_ringbuffer_write_update(&impl->ring, write);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +308,7 @@ static int receive_rtp_midi(struct impl *impl, uint8_t *buffer, ssize_t len)
|
|||
|
||||
impl->receiving = true;
|
||||
|
||||
return receive_midi(impl, buffer, timestamp, hlen, len);
|
||||
return receive_midi(impl, buffer, timestamp, seq, hlen, len);
|
||||
|
||||
short_packet:
|
||||
pw_log_warn("short packet received");
|
||||
|
|
|
|||
|
|
@ -58,17 +58,34 @@ struct rtp_midi_header {
|
|||
unsigned z:1;
|
||||
unsigned j:1;
|
||||
unsigned b:1;
|
||||
uint8_t len_b;
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
unsigned b:1;
|
||||
unsigned j:1;
|
||||
unsigned z:1;
|
||||
unsigned p:1;
|
||||
unsigned len:4;
|
||||
uint8_t len_b;
|
||||
#endif
|
||||
uint8_t len_b;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct rtp_midi_journal {
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
unsigned totchan:4;
|
||||
unsigned H:1;
|
||||
unsigned A:1;
|
||||
unsigned Y:1;
|
||||
unsigned S:1;
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
unsigned S:1;
|
||||
unsigned Y:1;
|
||||
unsigned A:1;
|
||||
unsigned H:1;
|
||||
unsigned totchan:4;
|
||||
#endif
|
||||
uint16_t checkpoint_seqnum;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#define rtp_stream_emit_destroy(s) rtp_stream_emit(s, destroy, 0)
|
||||
#define rtp_stream_emit_state_changed(s,n,e) rtp_stream_emit(s, state_changed,0,n,e)
|
||||
#define rtp_stream_emit_send_packet(s,i,l) rtp_stream_emit(s, send_packet,0,i,l)
|
||||
#define rtp_stream_emit_send_feedback(s,seq) rtp_stream_emit(s, send_feedback,0,seq)
|
||||
|
||||
struct impl {
|
||||
struct spa_audio_info info;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ struct rtp_stream_events {
|
|||
void (*state_changed) (void *data, bool started, const char *error);
|
||||
|
||||
void (*send_packet) (void *data, struct iovec *iov, size_t iovlen);
|
||||
|
||||
void (*send_feedback) (void *data, uint32_t senum);
|
||||
};
|
||||
|
||||
struct rtp_stream *rtp_stream_new(struct pw_core *core,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue