Commit 1cc19d76 authored by Sebastian Ramacher's avatar Sebastian Ramacher

New upstream version 1.4

parent 106569f3
PREFIX ?= /usr/local
INCLUDEDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib
DATADIR = $(PREFIX)/share
INCLUDE = $(DESTDIR)$(INCLUDEDIR)/bitstream
PKGCONFIG = $(DESTDIR)$(LIBDIR)/pkgconfig
VERSION = 1.3
PKGCONFIG = $(DESTDIR)$(DATADIR)/pkgconfig
VERSION = 1.4
all:
ln -nsf .. examples/bitstream
$(MAKE) -C examples
bitstream.pc: bitstream.pc.in
bitstream.pc: bitstream.pc.in Makefile
@echo "GEN $@"
@sed -e 's|@PREFIX@|$(PREFIX)|' \
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
......
1.4 (not released yet)
=================
- Add RTCP helpers
1.3 (29 Jan 2018)
=================
- Add support for avcC and hvcC structures
......
......@@ -72,10 +72,10 @@ static inline void desc48_set_provider(uint8_t *p_desc,
memcpy(p + 1, p_provider, i_length);
}
static inline const uint8_t *desc48_get_provider(const uint8_t *p_desc,
static inline uint8_t *desc48_get_provider(const uint8_t *p_desc,
uint8_t *pi_length)
{
const uint8_t *p = p_desc + DESC48_HEADER_SIZE;
uint8_t *p = (uint8_t *)p_desc + DESC48_HEADER_SIZE;
*pi_length = p[0];
return p + 1;
}
......
......@@ -98,32 +98,31 @@ static inline void eit_print(uint8_t *p_eit,
while ((p_event = eit_get_event(p_eit, j)) != NULL) {
j++;
char start_str[24], duration_str[10];
char start_str[24];
int duration, hour, min, sec;
time_t start_ts;
start_ts = dvb_time_format_UTC(eitn_get_start_time(p_event), NULL, start_str);
dvb_time_decode_bcd(eitn_get_duration_bcd(p_event), &duration, &hour, &min, &sec);
sprintf(duration_str, "%02d:%02d:%02d", hour, min, sec);
switch (i_print_type) {
case PRINT_XML:
pf_print(print_opaque, "<EVENT id=\"%u\" start_time=\"%ld\" start_time_dec=\"%s\""
" duration=\"%u\" duration_dec=\"%s\""
" duration=\"%u\" duration_dec=\"%u:%02u:%02u\""
" running=\"%d\" free_CA=\"%d\">",
eitn_get_event_id(p_event),
start_ts, start_str,
duration, duration_str,
duration, hour, min, sec,
eitn_get_running(p_event),
eitn_get_ca(p_event)
);
break;
default:
pf_print(print_opaque, " * EVENT id=%u start_time=%ld start_time_dec=\"%s\" duration=%u duration_dec=%s running=%d free_CA=%d",
pf_print(print_opaque, " * EVENT id=%u start_time=%ld start_time_dec=\"%s\" duration=%u duration_dec=%u:%02u:%02u running=%d free_CA=%d",
eitn_get_event_id(p_event),
start_ts, start_str,
duration, duration_str,
duration, hour, min, sec,
eitn_get_running(p_event),
eitn_get_ca(p_event)
);
......
PREFIX ?= /usr/local
WARN = -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare
CPPFLAGS = -I.
CPPFLAGS = -I. -I.. -I../..
CFLAGS := $(WARN) -O2 -g $(CFLAGS)
LDFLAGS := -lrt $(LDFLAGS)
OBJ = dvb_print_si dvb_gen_si dvb_ecmg dvb_ecmg_test mpeg_print_pcr rtp_check_seqnum mpeg_restamp
ifeq "$(shell uname -s)" "Linux"
LDFLAGS += -lrt
endif
ifeq "$(shell uname -s)" "Darwin"
LDLIBS += -liconv
# Prevent generation of .dSYM debug directories
CFLAGS += -gstabs
LDFLAGS += -liconv
endif
all: $(OBJ)
......@@ -21,4 +22,4 @@ install: $(OBJ)
install -m 755 $(OBJ) "$(DESTDIR)$(PREFIX)/bin"
clean:
$(RM) $(OBJ)
$(RM) -rf $(OBJ) *.dSYM
/*
* Copyright (C) 2018 OpenHeadend S.A.R.L.
*
* Authors: Arnaud de Turckheim
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __BITSTREAM_IETF_RTCP_H__
# define __BITSTREAM_IETF_RTCP_H__
......@@ -10,6 +35,16 @@ static inline void rtcp_set_rtp_version(uint8_t *p_rtcp)
p_rtcp[0] = RTCP_RTP_VERSION << 6;
}
static inline uint8_t rtcp_get_rc(uint8_t *p_rtcp)
{
return p_rtcp[0] & 0x1f;
}
static inline void rtcp_set_rc(uint8_t *p_rtcp, uint8_t rc)
{
p_rtcp[0] |= rc & 0x1f;
}
static inline uint8_t rtcp_get_pt(const uint8_t *p_rtcp)
{
return p_rtcp[1];
......
/*****************************************************************************
* rtp3611.h: RTP Control Protocol Extended Reports (RTCP XR)
*****************************************************************************
* Copyright (C) 2018 Open Broadcast Systems Ltd.
*
* Authors: Rafaël Carré <funman@videolam.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - IETF RFC 3611
*/
#ifndef __BITSTREAM_IETF_RTCP3611_H__
#define __BITSTREAM_IETF_RTCP3611_H__
#include <stdint.h> /* uint8_t, uint16_t, etc... */
#ifdef __cplusplus
extern "C"
{
#endif
#define RTCP_PT_XR 207
#define RTCP_XR_HEADER_SIZE 8
/* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |V=2|P|reserved | PT=XR=207 | length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | SSRC |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* : report blocks :
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
static inline void rtcp_xr_set_ssrc_sender(uint8_t *p_rtcp_xr,
const uint8_t pi_ssrc[4])
{
p_rtcp_xr[4] = pi_ssrc[0];
p_rtcp_xr[5] = pi_ssrc[1];
p_rtcp_xr[6] = pi_ssrc[2];
p_rtcp_xr[7] = pi_ssrc[3];
}
static inline void rtcp_xr_get_ssrc_sender(const uint8_t *p_rtcp_xr,
uint8_t pi_ssrc[4])
{
pi_ssrc[0] = p_rtcp_xr[4];
pi_ssrc[1] = p_rtcp_xr[5];
pi_ssrc[2] = p_rtcp_xr[6];
pi_ssrc[3] = p_rtcp_xr[7];
}
static inline uint8_t rtcp_xr_get_bt(const uint8_t *p_rtcp_xr_b)
{
return p_rtcp_xr_b[0];
}
static inline void rtcp_xr_set_bt(uint8_t *p_rtcp_xr_b,
uint8_t bt)
{
p_rtcp_xr_b[0] = bt;
}
static inline uint16_t rtcp_xr_get_length(const uint8_t *p_rtcp_xr_b)
{
return (p_rtcp_xr_b[2] << 8) | p_rtcp_xr_b[3];
}
static inline void rtcp_xr_set_length(uint8_t *p_rtcp_xr_b,
uint16_t length)
{
p_rtcp_xr_b[2] = length >> 8;
p_rtcp_xr_b[3] = length & 0xff;
}
/* Loss RLE Report Block
* TODO */
#define RTCP_XR_LRLER_BT 1
/* Duplicate RLE Report Block
* TODO */
#define RTCP_XR_DRLER_BT 2
/* Packet Receipt Times Report Block
* TODO */
#define RTCP_XR_PRTR_BT 3
/* Receiver Reference Time Report Block */
#define RTCP_XR_RRTP_BT 4
#define RTCP_XR_RRTP_SIZE 12
static inline void rtcp_xr_rrtp_set_reserved(uint8_t *p_rtcp_xr_rrtp)
{
p_rtcp_xr_rrtp[1] = 0;
}
static inline uint64_t rtcp_xr_rrtp_get_ntp(const uint8_t *p_rtcp_xr_b)
{
return ((uint64_t)p_rtcp_xr_b[4] << 56) | ((uint64_t)p_rtcp_xr_b[5] << 48) |
((uint64_t)p_rtcp_xr_b[6] << 40) | ((uint64_t)p_rtcp_xr_b[7] << 32) |
((uint64_t)p_rtcp_xr_b[8] << 24) | ((uint64_t)p_rtcp_xr_b[9] << 16) |
((uint64_t)p_rtcp_xr_b[10] << 8) | (uint64_t)p_rtcp_xr_b[11];
}
static inline void rtcp_xr_rrtp_set_ntp(uint8_t *p_rtcp_xr_b,
uint64_t ntp)
{
p_rtcp_xr_b[4] = (ntp >> 56) & 0xff;
p_rtcp_xr_b[5] = (ntp >> 48) & 0xff;
p_rtcp_xr_b[6] = (ntp >> 40) & 0xff;
p_rtcp_xr_b[7] = (ntp >> 32) & 0xff;
p_rtcp_xr_b[8] = (ntp >> 24) & 0xff;
p_rtcp_xr_b[9] = (ntp >> 16) & 0xff;
p_rtcp_xr_b[10] = (ntp >> 8) & 0xff;
p_rtcp_xr_b[11] = (ntp ) & 0xff;
}
/* DLRR Report Block */
#define RTCP_XR_DLRR_BT 5
#define RTCP_XR_DLRR_SIZE 16
static inline void rtcp_xr_dlrr_set_reserved(uint8_t *p_rtcp_xr_dlrr)
{
p_rtcp_xr_dlrr[1] = 0;
}
static inline void rtcp_xr_dlrr_set_ssrc_receiver(uint8_t *p_rtcp_xr_dlrr,
const uint8_t pi_ssrc[4])
{
p_rtcp_xr_dlrr[4] = pi_ssrc[0];
p_rtcp_xr_dlrr[5] = pi_ssrc[1];
p_rtcp_xr_dlrr[6] = pi_ssrc[2];
p_rtcp_xr_dlrr[7] = pi_ssrc[3];
}
static inline void rtcp_xr_dlrr_get_ssrc_receiver(const uint8_t *p_rtcp_xr_dlrr,
uint8_t pi_ssrc[4])
{
pi_ssrc[0] = p_rtcp_xr_dlrr[4];
pi_ssrc[1] = p_rtcp_xr_dlrr[5];
pi_ssrc[2] = p_rtcp_xr_dlrr[6];
pi_ssrc[3] = p_rtcp_xr_dlrr[7];
}
static inline uint32_t rtcp_xr_dlrr_get_lrr(const uint8_t *p_rtcp_xr_dlrr)
{
return (p_rtcp_xr_dlrr[8] << 24) | (p_rtcp_xr_dlrr[9] << 16) |
(p_rtcp_xr_dlrr[10] << 8) | p_rtcp_xr_dlrr[11];
}
static inline void rtcp_xr_dlrr_set_lrr(uint8_t *p_rtcp_xr_dlrr,
uint32_t lrr)
{
p_rtcp_xr_dlrr[8] = (lrr >> 24) & 0xff;
p_rtcp_xr_dlrr[9] = (lrr >> 16) & 0xff;
p_rtcp_xr_dlrr[10] = (lrr >> 8) & 0xff;
p_rtcp_xr_dlrr[11] = (lrr ) & 0xff;
}
static inline uint32_t rtcp_xr_dlrr_get_dlrr(const uint8_t *p_rtcp_xr_dlrr)
{
return (p_rtcp_xr_dlrr[12] << 24) | (p_rtcp_xr_dlrr[13] << 16) |
(p_rtcp_xr_dlrr[14] << 8) | p_rtcp_xr_dlrr[15];
}
static inline void rtcp_xr_dlrr_set_dlrr(uint8_t *p_rtcp_xr_dlrr,
uint32_t lrr)
{
p_rtcp_xr_dlrr[12] = (lrr >> 24) & 0xff;
p_rtcp_xr_dlrr[13] = (lrr >> 16) & 0xff;
p_rtcp_xr_dlrr[14] = (lrr >> 8) & 0xff;
p_rtcp_xr_dlrr[15] = (lrr ) & 0xff;
}
/* Statistics Summary Report Block
* TODO */
#define RTCP_XR_SSR_BT 6
/* VoIP Metrics Report Block
* TODO */
#define RTCP_XR_VMR_BT 7
#ifdef __cplusplus
}
#endif
#endif
/*****************************************************************************
* rtp7587.h: RFC Profile for Opus
*****************************************************************************
* Copyright (C) 2015 Open Broadcast Systems Ltd.
*
* Authors: Kieran Kunhya <kierank@obe.tv>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* RTP Payload Format for the Opus Speech and Audio Codec
*/
......
......@@ -99,6 +99,18 @@ static inline uint8_t smpte_fec_get_pt_recovery(const uint8_t *p_fec)
return p_fec[4] & 0x7f;
}
static inline void smpte_fec_set_mask(uint8_t *p_fec, uint32_t mask)
{
p_fec[5] = (mask >> 16) & 0xff;
p_fec[6] = (mask >> 8) & 0xff;
p_fec[7] = (mask ) & 0xff;
}
static inline uint32_t smpte_fec_get_mask(const uint8_t *p_fec)
{
return (p_fec[5] << 16) | (p_fec[6] << 8) | p_fec[7];
}
static inline void smpte_fec_set_ts_recovery(uint8_t *p_fec, uint32_t snbase)
{
p_fec[8] = (snbase >> 24) & 0xff;
......@@ -112,6 +124,26 @@ static inline uint32_t smpte_fec_get_ts_recovery(const uint8_t *p_fec)
return (p_fec[8] << 24) | (p_fec[9] << 16) | (p_fec[10] << 8) | p_fec[11];
}
static inline void smpte_fec_clear_n(uint8_t *p_fec)
{
p_fec[12] &= ~0x80;
}
static inline void smpte_fec_set_n(uint8_t *p_fec)
{
p_fec[12] |= 0x80;
}
static inline bool smpte_fec_check_n(const uint8_t *p_fec)
{
return !!(p_fec[12] & 0x80);
}
static inline void smpte_fec_clear_d(uint8_t *p_fec)
{
p_fec[12] &= ~0x40;
}
static inline void smpte_fec_set_d(uint8_t *p_fec)
{
p_fec[12] |= 0x40;
......@@ -122,6 +154,28 @@ static inline bool smpte_fec_check_d(const uint8_t *p_fec)
return !!(p_fec[12] & 0x40);
}
static inline void smpte_fec_set_type(uint8_t *p_fec, uint8_t type)
{
type &= 0x7;
p_fec[12] = (p_fec[12] & 0xc7) | (type << 3);
}
static inline uint8_t smpte_fec_get_type(uint8_t *p_fec)
{
return (p_fec[12] >> 3) & 0x7;
}
static inline void smpte_fec_set_index(uint8_t *p_fec, uint8_t index)
{
index &= 0x7;
p_fec[12] = (p_fec[12] & 0xf8) | index;
}
static inline uint8_t smpte_fec_get_index(uint8_t *p_fec)
{
return p_fec[12] & 0x7;
}
static inline void smpte_fec_set_offset(uint8_t *p_fec, uint8_t offset)
{
p_fec[13] = offset;
......
/*****************************************************************************
* 352.h
*****************************************************************************
* Copyright (C) 2018 Open Broadcast Systems Ltd
*
* Authors: Kieran Kunhya <kierank@obe.tv>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/*
* Normative references:
* - SMPTE 352
*/
#ifndef __BITSTREAM_SMPTE_352_H__
#define __BITSTREAM_SMPTE_352_H__
/* Payload and Digital Device Interface Identification */
#define S352_PAYLOAD_SD 0x81
#define S352_PAYLOAD_720_INTERFACE_1_POINT_5_GBPS 0x84
#define S352_PAYLOAD_1080_INTERFACE_1_POINT_5_GBPS 0x85
#define S352_PAYLOAD_1080_INTERFACE_1_POINT_5_GBPS_DUAL_LINK 0x87
#define S352_PAYLOAD_720_INTERFACE_3_GBPS_LEVEL_A 0x88
#define S352_PAYLOAD_1080_INTERFACE_3_GBPS_LEVEL_A 0x89
#define S352_PAYLOAD_1080_INTERFACE_3_GBPS_LEVEL_B 0x8a
/* Scanning Method */
#define S352_TRANSPORT_INTERLACED 0
#define S352_TRANSPORT_PROGRESSIVE 1
#define S352_STRUCTURE_INTERLACED 0
#define S352_STRUCTURE_PROGRESSIVE 1
/* Picture Rate */
#define S352_PICTURE_RATE_UNDEFINED 0
#define S352_PICTURE_RATE_24000_1001 2
#define S352_PICTURE_RATE_24 3
#define S352_PICTURE_RATE_48000_1001 4
#define S352_PICTURE_RATE_25 5
#define S352_PICTURE_RATE_30000_1001 6
#define S352_PICTURE_RATE_30 7
#define S352_PICTURE_RATE_48 8
#define S352_PICTURE_RATE_50 9
#define S352_PICTURE_RATE_60000_1001 10
#define S352_PICTURE_RATE_60 11
/* Sampling Structure Identification */
#define S352_ASPECT_RATIO_4_3 0
#define S352_ASPECT_RATIO_16_9 1
#define S352_SAMPLING_422_YCBCR 0
#define S352_SAMPLING_444_YCBCR 1
#define S352_SAMPLING_444_GBR 2
#define S352_SAMPLING_420 3
#define S352_SAMPLING_4224_YCBCRA 4
#define S352_SAMPLING_4444_YCBCRA 5
#define S352_SAMPLING_4444_GBRA 6
#define S352_SAMPLING_2048_2_FS 7
#define S352_SAMPLING_4224_YCBCRD 8 /* D = data channel */
#define S352_SAMPLING_4444_YCBCRD 9
#define S352_SAMPLING_4444_GBRD 10
#define S352_SAMPLING_444_XYZ 14 /* X'Y'Z' */
/* Bit Depth */
#define S352_BIT_DEPTH_8 0
#define S352_BIT_DEPTH_10 1
#define S352_BIT_DEPTH_12 2 /* mapped into 10-bit interface */
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment