[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: rtp out: fix AC-3 payload header
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Dec 7 18:17:16 UTC 2021
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
080ba0db by Rémi Denis-Courmont at 2021-12-07T17:34:24+00:00
rtp out: fix AC-3 payload header
This was complete garbage.
(cherry picked from commit 1e902c11902cfb3744b5f7a2d66239ba97459f7f)
- - - - -
42cf4c4c by Rémi Denis-Courmont at 2021-12-07T17:34:24+00:00
sout/rtp: add support for E-AC-3
(cherry picked from commit d41fb4e1d515ec0bd7b923333200c7f0d05169d8)
- - - - -
1 changed file:
- modules/stream_out/rtpfmt.c
Changes:
=====================================
modules/stream_out/rtpfmt.c
=====================================
@@ -42,6 +42,7 @@
static int rtp_packetize_mpa (sout_stream_id_sys_t *, block_t *);
static int rtp_packetize_mpv (sout_stream_id_sys_t *, block_t *);
static int rtp_packetize_ac3 (sout_stream_id_sys_t *, block_t *);
+static int rtp_packetize_eac3(sout_stream_id_sys_t *, block_t *);
static int rtp_packetize_simple(sout_stream_id_sys_t *, block_t *);
static int rtp_packetize_split(sout_stream_id_sys_t *, block_t *);
static int rtp_packetize_pcm(sout_stream_id_sys_t *, block_t *);
@@ -278,6 +279,10 @@ int rtp_get_fmt( vlc_object_t *obj, const es_format_t *p_fmt, const char *mux,
rtp_fmt->ptname = "ac3";
rtp_fmt->pf_packetize = rtp_packetize_ac3;
break;
+ case VLC_CODEC_EAC3:
+ rtp_fmt->ptname = "eac3";
+ rtp_fmt->pf_packetize = rtp_packetize_eac3;
+ break;
case VLC_CODEC_H263:
rtp_fmt->ptname = "H263-1998";
rtp_fmt->pf_packetize = rtp_packetize_h263;
@@ -945,6 +950,16 @@ static int rtp_packetize_ac3( sout_stream_id_sys_t *id, block_t *in )
uint8_t *p_data = in->p_buffer;
int i_data = in->i_buffer;
int i;
+ uint8_t hdr[2];
+
+ if (i_count <= 1)
+ hdr[0] = 0; /* One complete frame */
+ else if (i_data * 5 <= i_max * 8)
+ hdr[0] = 1; /* Initial fragment with at least 5/8th of frame */
+ else
+ hdr[0] = 2; /* Initial fragment with less than 5/8th of frame */
+
+ hdr[1] = i_count;
for( i = 0; i < i_count; i++ )
{
@@ -953,11 +968,8 @@ static int rtp_packetize_ac3( sout_stream_id_sys_t *id, block_t *in )
/* rtp common header */
rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts );
- /* unit count */
- out->p_buffer[12] = 1;
- /* unit header */
- out->p_buffer[13] = 0x00;
/* data */
+ memcpy( &out->p_buffer[12], hdr, 2 );
memcpy( &out->p_buffer[14], p_data, i_payload );
out->i_dts = in->i_dts + i * in->i_length / i_count;
@@ -967,6 +979,33 @@ static int rtp_packetize_ac3( sout_stream_id_sys_t *id, block_t *in )
p_data += i_payload;
i_data -= i_payload;
+ hdr[0] = 3; /* Fragment other than initial fragment */
+ }
+
+ block_Release(in);
+ return VLC_SUCCESS;
+}
+
+static int rtp_packetize_eac3(sout_stream_id_sys_t *id, block_t *in)
+{
+ size_t mtu = rtp_mtu(id) - 2;
+ uint_fast8_t frag_count = (in->i_buffer + mtu - 1) / mtu - 1;
+ uint8_t frame_type = frag_count > 0;
+
+ for (unsigned int i = 0; i < frag_count; i++) {
+ bool last = i == (frag_count - 1);
+ size_t len = last ? in->i_buffer : mtu;
+ block_t *out = block_Alloc(14 + len);
+
+ rtp_packetize_common(id, out, false, in->i_pts);
+ out->p_buffer[12] = frame_type;
+ out->p_buffer[13] = frag_count;
+ memcpy(&out->p_buffer[14], in->p_buffer, len);
+ out->i_dts = in->i_dts + i * in->i_length / frag_count;
+
+ rtp_packetize_send(id, out);
+ in->p_buffer += len;
+ in->i_buffer -= len;
}
block_Release(in);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/22d8f09a881e06d26a0554049538af97330cc3ba...42cf4c4ce7f52aecb9fda3b166c1fb23e9ff8a18
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/22d8f09a881e06d26a0554049538af97330cc3ba...42cf4c4ce7f52aecb9fda3b166c1fb23e9ff8a18
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list