Skip to content

Commit

Permalink
Cleaning up a little the RTSP server code
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jun 18, 2024
1 parent 52671fe commit 54da498
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 83 deletions.
4 changes: 0 additions & 4 deletions src/rtsp/bufpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
extern "C" {
#endif

/******************************************************************************
* DEFINITIONS
******************************************************************************/

/******************************************************************************
* DATA STRUCTURES
******************************************************************************/
Expand Down
1 change: 0 additions & 1 deletion src/rtsp/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ static inline struct global_state_t *gbl_create()
return nh;
}


static inline void gbl_delete(struct global_state_t *h)
{
if(h) {
Expand Down
15 changes: 0 additions & 15 deletions src/rtsp/mime.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@
/******************************************************************************
* PRIVATE DATA
******************************************************************************/
#ifdef I_THOUGHT_THIS_IS_NECESSARY_BUT_NOT_SO_KEEP_IT_FOR_GOODNESS
static unsigned char __byte_adjust_table[256] =
{0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255};

static inline char __byte_adjust(unsigned char x)
{
char ret = x;
#ifndef __RTSP_BIG_ENDIAN
ret = __byte_adjust_table[x];

#endif
return ret;
}
#endif

static char __base64_charmap[64] =
{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'};

Expand Down
4 changes: 0 additions & 4 deletions src/rtsp/mime.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ extern "C" {
#if defined (__cplusplus)
}
#endif
/******************************************************************************
* DEFINITIONS
******************************************************************************/

/******************************************************************************
* DATA STRUCTURES
Expand All @@ -33,7 +30,6 @@ static inline void mime_encoded_delete(mime_encoded_handle h);
/******************************************************************************
* INLINE FUNCTIONS
******************************************************************************/

static inline void mime_encoded_delete(mime_encoded_handle h)
{
if(h) {
Expand Down
75 changes: 19 additions & 56 deletions src/rtsp/rfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
#define __RTSP_RFC_H
#include <sys/types.h>

/*
* The type definitions below are valid for 32-bit architectures and
* may have to be adjusted for 16- or 64-bit architectures.
*/
typedef unsigned char u_int8;
typedef unsigned short u_int16;
typedef unsigned int u_int32;
typedef short int16;

/*
* Current protocol version.
*/
Expand Down Expand Up @@ -39,9 +30,6 @@ typedef enum {
typedef enum {
RTCP_SDES_END = 0,
RTCP_SDES_CNAME = 1,



RTCP_SDES_NAME = 2,
RTCP_SDES_EMAIL = 3,
RTCP_SDES_PHONE = 4,
Expand All @@ -65,7 +53,7 @@ typedef struct {
unsigned int version:2; /* protocol version */
#endif
unsigned int pt:8; /* RTCP packet type */
u_int16 length; /* pkt len in words, w/o this word */
unsigned short length; /* pkt len in words, w/o this word */
} rtcp_common_t;

/*
Expand All @@ -78,30 +66,24 @@ typedef struct {
* Reception report block
*/
typedef struct {
u_int32 ssrc; /* data source being reported */
unsigned int ssrc; /* data source being reported */
unsigned int fraction:8; /* fraction lost since last SR/RR */



int lost:24; /* cumul. no. pkts lost (signed!) */
u_int32 last_seq; /* extended last seq. no. received */
u_int32 jitter; /* interarrival jitter */
u_int32 lsr; /* last SR packet from this source */
u_int32 dlsr; /* delay since last SR packet */
unsigned int last_seq; /* extended last seq. no. received */
unsigned int jitter; /* interarrival jitter */
unsigned int lsr; /* last SR packet from this source */
unsigned int dlsr; /* delay since last SR packet */
} rtcp_rr_t;



/*
* SDES item
*/
typedef struct {
u_int8 type; /* type of item (rtcp_sdes_type_t) */
u_int8 length; /* length of item (in octets) */
unsigned char type; /* type of item (rtcp_sdes_type_t) */
unsigned char length; /* length of item (in octets) */
char data[1]; /* text, not null-terminated */
} rtcp_sdes_item_t;


/*
* One RTCP packet
*/
Expand All @@ -110,54 +92,35 @@ typedef struct {
union {
/* sender report (SR) */
struct {
u_int32 ssrc; /* sender generating this report */
u_int32 ntp_sec; /* NTP timestamp */
u_int32 ntp_frac;
u_int32 rtp_ts; /* RTP timestamp */
u_int32 psent; /* packets sent */
u_int32 osent; /* octets sent */
rtcp_rr_t rr[1]; /* variable-length list */
unsigned int ssrc; /* sender generating this report */
unsigned int ntp_sec; /* NTP timestamp */
unsigned int ntp_frac;
unsigned int rtp_ts; /* RTP timestamp */
unsigned int psent; /* packets sent */
unsigned int osent; /* octets sent */
rtcp_rr_t rr[1]; /* variable-length list */
} sr;

/* reception report (RR) */
struct {
u_int32 ssrc; /* receiver generating this report */
rtcp_rr_t rr[1]; /* variable-length list */
unsigned int ssrc; /* receiver generating this report */
rtcp_rr_t rr[1]; /* variable-length list */
} rr;

/* source description (SDES) */
struct rtcp_sdes {
u_int32 src; /* first SSRC/CSRC */
unsigned int src; /* first SSRC/CSRC */
rtcp_sdes_item_t item[1]; /* list of SDES items */
} sdes;

/* BYE */
struct {
u_int32 src[1]; /* list of sources */

unsigned int src[1]; /* list of sources */
/* can't express trailing text for reason */
} bye;
} r;
} rtcp_t;

typedef struct rtcp_sdes rtcp_sdes_t;

/*
* Per-source state information
*/
typedef struct {
u_int16 max_seq; /* highest seq. number seen */
u_int32 cycles; /* shifted count of seq. number cycles */
u_int32 base_seq; /* base seq number */
u_int32 bad_seq; /* last 'bad' seq number + 1 */
u_int32 probation; /* sequ. packets till source is valid */
u_int32 received; /* packets received */
u_int32 expected_prior; /* packet expected at last interval */
u_int32 received_prior; /* packet received at last interval */
u_int32 transit; /* relative trans time for prev pkt */
u_int32 jitter; /* estimated jitter */
/* ... */
} source;


#endif
6 changes: 3 additions & 3 deletions src/rtsp/rtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ typedef struct {
unsigned int m:1; /* marker bit */
#endif
unsigned int seq:16; /* sequence number */
u_int32 ts; /* timestamp */
u_int32 ssrc; /* synchronization source */
//u_int32 csrc[1]; /* optional CSRC list */
unsigned int ts; /* timestamp */
unsigned int ssrc; /* synchronization source */
//unsigned int csrc[1]; /* optional CSRC list */
} rtp_hdr_t;

struct nal_rtp_t {
Expand Down

0 comments on commit 54da498

Please sign in to comment.