Skip to content

Commit

Permalink
Works a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanreg committed Nov 8, 2023
1 parent 1c5a8c9 commit 3937bf7
Show file tree
Hide file tree
Showing 28 changed files with 803 additions and 580 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ Currently, the protocol is a draft, and its syntax is subject to change.

You can read the current rendered draft by opening the [autogenerated webpage](https://cyanreg.github.io/avtransport/).

## Features

- **64 bit presentation and duration timestamps** (465.66129 picosecond accuracy)
- **Actual timebase** (allows accurate representation of rational framerates)
- Only container to include mandatory error correction data on the headers themselves
- Large FEC range, using RaptorQ
- Extra resilient headers (each FEC segment carries a piece of the main header)
- Flexible keyframe indexing (indexes for seeking carry additional information)
- Lossless cutting of compressed video (any frame dependencies can be made invisible)
- Stream packet data compression
- Uncompressed video and audio encapsulation
- For H264 and HEVC, a real 64-bit dts timestamp.
- ICC profile support
- Color lookup table support (Adobe .cube)
- Raw DNG support
- Timestamp clock, allowing for jitter compensation
- Unified, cycle-accurate clock for exact synchronization between multiple streams.

## Provisional information

### URI Scheme
Expand Down
131 changes: 124 additions & 7 deletions draft-avtransport-spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Shortname: avtransport
URL: https://cyanreg.github.io/avtransport/
Repository: https://github.com/cyanreg/avtransport
Inline Github Issues: no
Date: 2023-10-18
Date: 2023-11-08
Status: LD
Group: FFmpeg
Abstract: The AVTransport protocol is a new standardized mechanism for multimedia transport and storage.
Expand Down Expand Up @@ -3031,7 +3031,7 @@ For AAC encapsulation, the [=codec_id=] in
[[#stream-registration-packets]]
MUST be 0x41414300 (''AAC0'').

The [[#stream-configuration-packets]] payload MUST be the
The [[#stream-configuration-packets]] payload must be the
codec's ''AudioSpecificConfig'', as defined in MPEG-4.

The [=packet_data=] MUST contain regular AAC ADTS packtes. Note that ''LATM'' is
Expand All @@ -3050,10 +3050,93 @@ must be ''0x41432d33'' (''AC-3'').

AC-3 streams require no [[#stream-configuration-packets]].

THe `packet_data` MUST contain regular AC-3 OR E-AC-3 frames, starting from the
THe `packet_data` must contain regular AC-3 or E-AC-3 frames, starting from the
`syncinfo` header defined in the specifications.


### FLAC encapsulation ### {#flac-encapsulation}

For FLAC encapsulation, the [=codec_id=] in
[[#stream-registration-packets]]
must be ''0x664c6143'' (''fLaC'').

FLAC streams require [[#stream-configuration-packets]] packets,
to contain the stream info header, which is defined as follows:

<figure id="table-FlacConfig" class="table">
<table class="complex data longlastcol" dfn-for="#flac-encapsulation">
<tr>
<th>Type</th>
<th>Name</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td><code>u(16)</code></td>
<td><dfn>flac_min_blocksize</dfn></td>
<td></td>
<td>Minimum block size in samples.</td>
</tr>
<tr>
<td><code>u(16)</code></td>
<td><dfn>flac_max_blocksize</dfn></td>
<td></td>
<td>Maximum number of samples in a block. Must be larger than [=flac_min_blocksize=].</td>
</tr>
<tr>
<td><code>u(24)</code></td>
<td><dfn>flac_min_framesize</dfn></td>
<td></td>
<td>Minimum framesize in bytes.</td>
</tr>
<tr>
<td><code>u(24)</code></td>
<td><dfn>flac_max_framesize</dfn></td>
<td></td>
<td>Maximum framesize in bytes. Must be larger than [=flac_min_framesize=].</td>
</tr>
<tr>
<td><code>u(20)</code></td>
<td><dfn>flac_samplerate</dfn></td>
<td></td>
<td>Samplerate of the signal.</td>
</tr>
<tr>
<td><code>u(3)</code></td>
<td><dfn>flac_channels</dfn></td>
<td></td>
<td>Number of channels.</td>
</tr>
<tr>
<td><code>u(5)</code></td>
<td><dfn>flac_bitdepth</dfn></td>
<td></td>
<td>Bit depth of the signal.</td>
</tr>
<tr>
<td><code>u(24)</code></td>
<td><dfn>flac_nb_samples_1</dfn></td>
<td></td>
<td>Top 24 bits of the total number of samples in the stream, if known.</td>
</tr>
<tr>
<td><code>u(12)</code></td>
<td><dfn>flac_nb_samples_2</dfn></td>
<td></td>
<td>Bottom 12 bits of the number of samples in the stream, if known.</td>
</tr>
<tr>
<td><code>b(16)</code></td>
<td><dfn>flac_streaminfo_md5</dfn></td>
<td></td>
<td>MD5 ([[RFC1321]]) checksum of the previous 34 bytes.</td>
</tr>
</table>
</figure>

The `packet_data` must contain raw FLAC frames, with their frame header untouched.


### AV1 encapsulation ### {#av1-encapsulation}

For [[AV1]] encapsulation, the [=codec_id=] in
Expand Down Expand Up @@ -3092,7 +3175,7 @@ The [=packet_data=] must contain the following elements, in order:
- ''Annex-B'' formatted NAL units, with startcode emulation bits included.

A [[#stream-configuration-packets]] may be sent, to
speed up stream initialization. If they are present, they MUST contain an
speed up stream initialization. If they are present, they must contain an
`AVCDecoderConfigurationRecord` structure, as defined in ''ISO/IEC 14496-15''.


Expand All @@ -3109,7 +3192,7 @@ The [=packet_data=] must contain the following elements, in order:
''Annex-B'' formatted packets must be used, with startcode emulation bits included.

A [[#stream-configuration-packets]] may be sent, to
speed up stream initialization. If they are present, they MUST contain an
speed up stream initialization. If they are present, they must contain an
''HEVCDecoderConfigurationRecord'' structure, as defined in ''ISO/IEC 23008''.


Expand All @@ -3119,12 +3202,24 @@ For Dirac or VC-2 encapsulation, the [=codec_id=] in
[[#stream-registration-packets]]
MUST be ''0x42424344'' (''BBCD'').

Dirac streams require no [[#stream-configuration-packets).
Dirac streams require no [[#stream-configuration-packets]].

The [=packet_data=] MUST contain raw sequences,
The [=packet_data=] must contain raw sequences,
with one sequence being a picture.


### FFv1 encapsulation ### {#ffv1-encapsulation}

For [[RFC9043|FFv1]] encapsulation, the [=codec_id=] in
[[#stream-registration-packets]]
MUST be ''0x46467631'' (''FFv1'').

Stream configuration data is required for FFv1. [[#stream-configuration-packets]] must
contain a "Parameters" structure, as defined in [[RFC9043#name-parameters]].

The [=packet_data=] must contain raw FFv1 packets.


### ASS encapsulation ### {#ass-encapsulation}

For ASS encapsulation, the [=codec_id=] in
Expand Down Expand Up @@ -3436,6 +3531,25 @@ The [=packet_data=] field can be any length and contain any sequence of data.

This section describes and suggests behavior for realtime AVTransport streams.

The protocol supports four different streaming arrangements:
- Unidirectional (Sender to Receiver)
- Bidirectional (Sender to Receiver and Receiver to Sender)
- Multidirectional prompted (Sender to Multiple Active Receivers)
- Multicast (Sender to Multiple Receivers)

In the first case (Unidirectional), the sender initializes the session by sending a [[#session-start-packets]]
to the receiver, and proceeds with sending more packets.

In the second case (Bidirectional), the sender initializes the session by sending a [[#session-start-packets]]
packet with a {{SESSION_REVERSE_SIGNAL_READY}} flag, and on the same connection, the receiver sends another
[[#session-start-packets]] packet to initialize reverse connectivity.

In the third case (Multidirectional prompted) case, the sender listens for any [[#session-start-packets]]
sent by clients on a given port. If received, the server begins to send information back to the client address
on the same connection it received the session start packet.

In the fourth case (Multicast), the server binds to a multicast UDP address and begins to send data.

In general, implementations should emit the following packet types
at the given frequencies.

Expand Down Expand Up @@ -3537,6 +3651,9 @@ Note: Data packets may be padded by appending random data or zeroes after the [=
field up to the maximum MTU size. This permits constant bitrate operation,
as well as preventing metadata leakage in the form of a packet size.

Note: When operating at higher MTUs, implementations should consider adding FEC or parity,
as the 16-bit UDP datagram CRC may be inadequate to detect errors.

If [[#reverse-signalling]] is used, the receiver must send packets over to the
sender using the same port number that the receiver is listening on.

Expand Down
11 changes: 4 additions & 7 deletions libavtransport/common.c → libavtransport/avtransport.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
#include <arpa/inet.h>
#include <netdb.h>

#include <libavtransport/common.h>
#include <libavtransport/avtransport.h>

#include "common.h"
#include "reorder.h"

int avt_init(AVTContext **ctx, AVTContextOptions *opts)
{
Expand All @@ -45,8 +44,8 @@ int avt_init(AVTContext **ctx, AVTContextOptions *opts)
if (opts)
tmp->opts = *opts;

atomic_init(&tmp->dst.seq, 0);
atomic_init(&tmp->src.seq, 0);
atomic_init(&tmp->output.seq, 0);
atomic_init(&tmp->input.seq, 0);

*ctx = tmp;
return 0;
Expand All @@ -55,8 +54,6 @@ int avt_init(AVTContext **ctx, AVTContextOptions *opts)
void avt_close(AVTContext **ctx)
{
if (ctx) {
avt_reorder_uninit(*ctx);

free(*ctx);
*ctx = NULL;
}
Expand Down Expand Up @@ -171,7 +168,7 @@ int avt_parse_address(const char *path, enum AVTProtocolType *proto,

AVTStream *avt_alloc_stream(AVTContext *ctx, uint16_t id)
{
if (!ctx->dst.ctx)
if (!ctx->output.ctx)
return NULL;

AVTStream *ret = NULL;
Expand Down
1 change: 0 additions & 1 deletion libavtransport/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <stdlib.h>
#include <string.h>

#include "common.h"
#include "buffer.h"

AVTBuffer *avt_buffer_create(uint8_t *data, size_t len,
Expand Down
Loading

0 comments on commit 3937bf7

Please sign in to comment.