Skip to content

Commit

Permalink
Implement proper multistream scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanreg committed Apr 6, 2024
1 parent 1d0207a commit 2f733a7
Show file tree
Hide file tree
Showing 18 changed files with 617 additions and 179 deletions.
16 changes: 8 additions & 8 deletions draft-avtransport-spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ recovery.
FEC grouping allows for multiple buffered packets and segments from multiple
streams to be FEC corrected in order to ensure no stream is starved of data.

FEC grouped streams MUST be registered first via a special packet:
FEC grouped streams must be registered first via a special packet:

<figure id="table-FECGrouping" class="table">
<table class="complex data longlastcol" dfn-for="#fec-grouping-packets">
Expand Down Expand Up @@ -1580,7 +1580,7 @@ FEC grouped streams MUST be registered first via a special packet:
It is hightly recommended that the common OTI parameters never change once transmitted.
This lets implementations attempt to apply FEC if they miss a [[#fec-grouping-packets]] packet.

The `fec_scheme_oti` field MUST be interpreted as the following, given in [RFC 6330 Section 3.2.3. Common](https://datatracker.ietf.org/doc/html/rfc6330#section-3.3.3):
The [=fec_scheme_oti=] field must be interpreted as the following, given in [[RFC6330#section-3.3.3]]:

All streams in an FEC group must have timestamps that cover the same period
of time.
Expand Down Expand Up @@ -1676,7 +1676,7 @@ FEC groups use a different packet for the FEC data.
</table>
</figure>

The `fec_source` data is defined as follows:
The [=fec_source=] data is defined as follows:

### FEC Group Source ### {#struct-FECSource}

Expand Down Expand Up @@ -3090,7 +3090,7 @@ This section expands on certain aspects of the specification.
The following section lists the supported codecs, along with their encapsulation
definitions. Below, a mapping between [=codec_id=] and encapsulation is listed:

<figure id="table-EOS" class="table">
<figure id="table-codec_id_map" class="table">
<table class="complex data longlastcol" dfn-for="#codec-encapsulation" id="codec_id_map">
<tr>
<th>[=codec_id=]</th>
Expand Down Expand Up @@ -4554,9 +4554,9 @@ The full block, along with the check data, shall be sent to an LDPC decoder.

To ease implementations, only two different lengths are used:
- <dfn>LDPC(288, 224)</dfn>
:: 224-bit message, 64-bit parity, rate of <code>7/9</code>, [[#ldpc_h_matrix_288_224|H₆₄ₓ₂₈₈-matrix]]
:: 224-bit message, 64-bit parity, rate of <code>7/9</code>, [[#ldpc_h_matrix_288_224_def|H₆₄ₓ₂₈₈-matrix]]
- <dfn>LDPC(2784, 2016)</dfn>
:: 2016-bit message, 768-bit parity, rate of <code>21/29</code>, [[#ldpc_h_matrix_2784_2016|H₇₆₈ₓ₂₇₈₄-matrix]]
:: 2016-bit message, 768-bit parity, rate of <code>21/29</code>, [[#ldpc_h_matrix_2784_2016_def|H₇₆₈ₓ₂₇₈₄-matrix]]

For reference, the following code may be used to compute the LDPC parity data:

Expand Down Expand Up @@ -4626,7 +4626,7 @@ This is the format that the reference function above expects.
The matrices are also listed as standard .alist files, directly usable for analysis and simulations.


#### ldpc_h_matrix_288_224 #### {#ldpc_h_matrix_288_224}
#### ldpc_h_matrix_288_224 #### {#ldpc_h_matrix_288_224_def}

Note: Spaceholder, working and optimal tables to be done

Expand Down Expand Up @@ -4716,7 +4716,7 @@ const uint64_t ldpc_h_matrix_288_224[288 /* (64 rows/64) * 288 cols */] = {
</pre>


#### ldpc_h_matrix_2784_2016 #### {#ldpc_h_matrix_2784_2016}
#### ldpc_h_matrix_2784_2016 #### {#ldpc_h_matrix_2784_2016_def}

Note: Spaceholder, working and optimal tables to be done

Expand Down
1 change: 1 addition & 0 deletions libavtransport/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef AVTRANSPORT_ATTRIBUTES_H
#define AVTRANSPORT_ATTRIBUTES_H

#include <assert.h>
#include "config.h"

#ifndef __has_attribute
Expand Down
5 changes: 4 additions & 1 deletion libavtransport/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ AVT_API AVTBuffer *avt_buffer_create(uint8_t *data, size_t len,
buf->data = data;
buf->len = len;
buf->opaque = opaque;
buf->free = free_cb;
if (!free_cb)
buf->free = avt_buffer_default_free;
else
buf->free = free_cb;

return buf;
}
Expand Down
9 changes: 4 additions & 5 deletions libavtransport/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ int avt_connection_create(AVTContext *ctx, AVTConnection **_conn,
goto fail;

/* Get max packet size */
ret = conn->p->get_max_pkt_len(conn->p_ctx);
if (ret < 0)
int64_t max_pkt_size = conn->p->get_max_pkt_len(conn->p_ctx);
if (max_pkt_size < 0)
goto fail;

/* Output scheduler */
ret = avt_scheduler_init(&conn->out_scheduler, ret,
info->output_opts.buffer,
ret = avt_scheduler_init(&conn->out_scheduler, max_pkt_size,
info->output_opts.bandwidth);
if (ret < 0)
goto fail;
Expand Down Expand Up @@ -158,7 +157,7 @@ int avt_connection_process(AVTConnection *conn, int64_t timeout)
if (err < 0)
avt_scheduler_done(&conn->out_scheduler, seq);

return 0;
return err;
}

int avt_connection_flush(AVTConnection *conn, int64_t timeout)
Expand Down
9 changes: 7 additions & 2 deletions libavtransport/io_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <avtransport/avtransport.h>
#include "io_common.h"
#include "attributes.h"

Expand Down Expand Up @@ -115,10 +116,14 @@ COLD int avt_io_init(AVTContext *ctx, const AVTIO **_io, AVTIOCtx **io_ctx,
const AVTIO *io, **io_list = avt_io_list[io_type];
while ((io = *io_list)) {
err = io->init(ctx, io_ctx, addr);
if (err == AVT_ERROR(ENOMEM))
if (err == AVT_ERROR(ENOMEM)) {
return err;
else if (err < 0)
} else if (err < 0) {
avt_log(ctx, AVT_LOG_TRACE, "Unable to open with I/O \"%s\": %i\n",
io->name, err);
continue;
}
avt_log(ctx, AVT_LOG_VERBOSE, "Using I/O \"%s\"\n", io->name);
*_io = io;
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion libavtransport/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ avt_alloc_attrib(2, 3) static inline void *avt_reallocarray(void *ptr,
{
size_t nbytes;

if (ckd_sub(&nbytes, nmemb, size))
if (ckd_mul(&nbytes, nmemb, size))
return NULL;

return realloc(ptr, nbytes);
Expand Down
1 change: 1 addition & 0 deletions libavtransport/output_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ int avt_send_stream_data(AVTOutput *out, AVTStream *st, AVTPacket *pkt)
{
/* Compress payload if necessary */
AVTBuffer *pl = pkt->data;

enum AVTDataCompression data_compression;
int err = avt_payload_compress(out, &pl, AVT_PKT_STREAM_DATA,
&data_compression);
Expand Down
Loading

0 comments on commit 2f733a7

Please sign in to comment.