vlc/vlc-3.0 | branch: master | Sergio Ammirata <ser...@ammirata.net> | Mon Nov 2 15:42:29 2020 -0500| [df6cf9ed63285dbe4792feb47b182e7363f10cb2] | committer: Pierre Ynard
Remove external bitstream dependencies from rist modules > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=df6cf9ed63285dbe4792feb47b182e7363f10cb2 --- modules/access/rist.c | 4 - modules/access/rist.h | 230 ++++++++++++++++++++++++++++++++++++++++++- modules/access_output/rist.c | 5 - 3 files changed, 229 insertions(+), 10 deletions(-) diff --git a/modules/access/rist.c b/modules/access/rist.c index 6b06542cab..8e81383b68 100644 --- a/modules/access/rist.c +++ b/modules/access/rist.c @@ -35,10 +35,6 @@ #include <vlc_block.h> #include <vlc_url.h> #include <poll.h> -#include <bitstream/ietf/rtcp_rr.h> -#include <bitstream/ietf/rtcp_sdes.h> -#include <bitstream/ietf/rtcp_fb.h> -#include <bitstream/ietf/rtp.h> #include "rist.h" diff --git a/modules/access/rist.h b/modules/access/rist.h index 263b43cb2e..cc48a31f61 100644 --- a/modules/access/rist.h +++ b/modules/access/rist.h @@ -366,4 +366,232 @@ static bool is_multicast_address(char *psz_dst_server) freeaddrinfo(res); return ismulticast; -} \ No newline at end of file +} + +// imported from bitstream +#define RTP_HEADER_SIZE 12 +#define RTCP_SR_SIZE 28 +#define RTCP_SDES_SIZE 10 +#define RTCP_FB_HEADER_SIZE 12 +#define RTCP_FB_FCI_GENERIC_NACK_SIZE 4 +#define RTCP_PT_SR 200 +#define RTCP_PT_RR 201 +#define RTCP_PT_SDES 202 +#define RTCP_PT_RTPFB 205 + +static inline uint32_t rtp_get_timestamp(const uint8_t *p_rtp) +{ + return (p_rtp[4] << 24) | (p_rtp[5] << 16) | (p_rtp[6] << 8) | p_rtp[7]; +} + +static inline void rtp_set_timestamp(uint8_t *p_rtp, uint32_t i_timestamp) +{ + p_rtp[4] = (i_timestamp >> 24) & 0xff; + p_rtp[5] = (i_timestamp >> 16) & 0xff; + p_rtp[6] = (i_timestamp >> 8) & 0xff; + p_rtp[7] = i_timestamp & 0xff; +} + +static inline uint16_t rtp_get_seqnum(const uint8_t *p_rtp) +{ + return (p_rtp[2] << 8) | p_rtp[3]; +} + +static inline void rtp_set_seqnum(uint8_t *p_rtp, uint16_t i_seqnum) +{ + p_rtp[2] = i_seqnum >> 8; + p_rtp[3] = i_seqnum & 0xff; +} + +static inline int8_t rtcp_sdes_get_name_length(const uint8_t *p_rtcp_sdes) +{ + return p_rtcp_sdes[9]; +} + +static inline uint16_t rtcp_get_length(const uint8_t *p_rtcp) +{ + return (p_rtcp[2] << 8) | p_rtcp[3]; +} + +static inline void rtcp_set_length(uint8_t *p_rtcp, + uint16_t length) +{ + p_rtcp[2] = length >> 8; + p_rtcp[3] = length & 0xff; +} + +static inline uint8_t rtcp_get_pt(const uint8_t *p_rtcp) +{ + return p_rtcp[1]; +} + +static inline void rtcp_set_pt(uint8_t *p_rtcp, uint8_t pt) +{ + p_rtcp[1] = pt; +} + +static inline bool rtp_check_hdr(const uint8_t *p_rtp) +{ + return (p_rtp[0] & 0xc0) == 0x80; +} + +static inline void rtp_set_hdr(uint8_t *p_rtp) +{ + p_rtp[0] = 0x80; +} + +static inline void rtcp_rr_set_pt(uint8_t *p_rtcp_rr) +{ + rtcp_set_pt(p_rtcp_rr, RTCP_PT_RR); +} + +static inline void rtcp_fb_set_int_ssrc_pkt_sender(uint8_t *p_rtcp_fb, uint32_t i_ssrc) +{ + p_rtcp_fb[4] = (i_ssrc >> 24) & 0xff; + p_rtcp_fb[5] = (i_ssrc >> 16) & 0xff; + p_rtcp_fb[6] = (i_ssrc >> 8) & 0xff; + p_rtcp_fb[7] = i_ssrc & 0xff; +} + +static inline void rtp_set_cc(uint8_t *p_rtp, uint8_t i_cc) +{ + p_rtp[0] &= 0xf0; + p_rtp[0] |= i_cc & 0xf; +} + +static inline void rtcp_sdes_set_pt(uint8_t *p_rtcp_rr) +{ + rtcp_set_pt(p_rtcp_rr, RTCP_PT_SDES); +} + +static inline void rtcp_sdes_set_cname(uint8_t *p_rtcp_sdes, uint8_t cname) +{ + p_rtcp_sdes[8] = cname; +} + +static inline void rtcp_sdes_set_name_length(uint8_t *p_rtcp_sdes, + int8_t name_length) +{ + p_rtcp_sdes[9] = name_length; +} + +static inline uint8_t rtcp_fb_get_fmt(const uint8_t *p_rtcp) +{ + return p_rtcp[0] & 0x1f; +} + +static inline void rtcp_fb_set_fmt(uint8_t *p_rtcp, uint8_t fmt) +{ + p_rtcp[0] |= fmt & 0x1f; +} + +static inline uint16_t rtcp_fb_nack_get_packet_id(const uint8_t *p_rtcp_fb_nack) +{ + return (p_rtcp_fb_nack[0] << 8) | p_rtcp_fb_nack[1]; +} + +static inline void rtcp_fb_nack_set_packet_id(uint8_t *p_rtcp_fb_nack, + uint16_t packet_id) +{ + p_rtcp_fb_nack[0] = (packet_id >> 8) & 0xff; + p_rtcp_fb_nack[1] = packet_id & 0xff; +} + +static inline uint16_t rtcp_fb_nack_get_bitmask_lost(const uint8_t *p_rtcp_fb_nack) +{ + return (p_rtcp_fb_nack[2] << 8) | p_rtcp_fb_nack[3]; +} + +static inline void rtcp_fb_nack_set_bitmask_lost(uint8_t *p_rtcp_fb_nack, + uint16_t bitmask) +{ + p_rtcp_fb_nack[2] = (bitmask >> 8) & 0xff; + p_rtcp_fb_nack[3] = bitmask & 0xff; +} + +static inline void rtcp_fb_get_ssrc_media_src(const uint8_t *p_rtcp_fb, + uint8_t pi_ssrc[4]) +{ + pi_ssrc[0] = p_rtcp_fb[8]; + pi_ssrc[1] = p_rtcp_fb[9]; + pi_ssrc[2] = p_rtcp_fb[10]; + pi_ssrc[3] = p_rtcp_fb[11]; +} + +static inline void rtcp_fb_set_ssrc_media_src(uint8_t *p_rtcp_fb, + const uint8_t pi_ssrc[4]) +{ + p_rtcp_fb[8] = pi_ssrc[0]; + p_rtcp_fb[9] = pi_ssrc[1]; + p_rtcp_fb[10] = pi_ssrc[2]; + p_rtcp_fb[11] = pi_ssrc[3]; +} + +static inline void rtcp_sr_set_pt(uint8_t *p_rtcp_sr) +{ + rtcp_set_pt(p_rtcp_sr, RTCP_PT_SR); +} + +static inline void rtcp_sr_set_length(uint8_t *p_rtcp_sr, + uint16_t length) +{ + rtcp_set_length(p_rtcp_sr, length); +} + +static inline void rtcp_sr_set_ntp_time_msw(uint8_t *p_rtcp_sr, + uint32_t ntp_time_msw) +{ + p_rtcp_sr[8] = (ntp_time_msw >> 24) & 0xff; + p_rtcp_sr[9] = (ntp_time_msw >> 16) & 0xff; + p_rtcp_sr[10] = (ntp_time_msw >> 8) & 0xff; + p_rtcp_sr[11] = ntp_time_msw & 0xff; +} + +static inline void rtcp_sr_set_ntp_time_lsw(uint8_t *p_rtcp_sr, + uint32_t ntp_time_lsw) +{ + p_rtcp_sr[12] = (ntp_time_lsw >> 24) & 0xff; + p_rtcp_sr[13] = (ntp_time_lsw >> 16) & 0xff; + p_rtcp_sr[14] = (ntp_time_lsw >> 8) & 0xff; + p_rtcp_sr[15] = ntp_time_lsw & 0xff; +} + +static inline void rtcp_sr_set_rtp_time(uint8_t *p_rtcp_sr, + uint32_t rtp_time) +{ + p_rtcp_sr[16] = (rtp_time >> 24) & 0xff; + p_rtcp_sr[17] = (rtp_time >> 16) & 0xff; + p_rtcp_sr[18] = (rtp_time >> 8) & 0xff; + p_rtcp_sr[19] = rtp_time & 0xff; +} + +static inline void rtcp_sr_set_packet_count(uint8_t *p_rtcp_sr, + uint32_t packet_count) +{ + p_rtcp_sr[20] = (packet_count >> 24) & 0xff; + p_rtcp_sr[21] = (packet_count >> 16) & 0xff; + p_rtcp_sr[22] = (packet_count >> 8) & 0xff; + p_rtcp_sr[23] = packet_count & 0xff; +} + +static inline void rtcp_sr_set_octet_count(uint8_t *p_rtcp_sr, + uint32_t octet_count) +{ + p_rtcp_sr[24] = (octet_count >> 24) & 0xff; + p_rtcp_sr[25] = (octet_count >> 16) & 0xff; + p_rtcp_sr[26] = (octet_count >> 8) & 0xff; + p_rtcp_sr[27] = octet_count & 0xff; +} + +static inline void rtp_set_type(uint8_t *p_rtp, uint8_t i_type) +{ + p_rtp[1] = i_type & 0x7f; +} + +static inline void rtp_set_int_ssrc(uint8_t *p_rtp, uint32_t i_ssrc) +{ + p_rtp[8] = (i_ssrc >> 24) & 0xff; + p_rtp[9] = (i_ssrc >> 16) & 0xff; + p_rtp[10] = (i_ssrc >> 8) & 0xff; + p_rtp[11] = i_ssrc & 0xff; +} diff --git a/modules/access_output/rist.c b/modules/access_output/rist.c index bf22e42e1f..e090321df4 100644 --- a/modules/access_output/rist.c +++ b/modules/access_output/rist.c @@ -38,11 +38,6 @@ #include <poll.h> #include <sys/time.h> #include <sys/socket.h> -#include <bitstream/ietf/rtcp_rr.h> -#include <bitstream/ietf/rtcp_sr.h> -#include <bitstream/ietf/rtcp_fb.h> -#include <bitstream/ietf/rtcp_sdes.h> -#include <bitstream/ietf/rtp.h> #include "../access/rist.h" _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits