forked from catalinii/minisatip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream.h
85 lines (77 loc) · 2.3 KB
/
stream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef STREAM_H
#define STREAM_H
#include <sys/socket.h>
#include "socketworks.h"
#include "dvb.h"
#define MAX_STREAMS 100
#define DVB_FRAME 188
#define STREAMS_BUFFER 7*DVB_FRAME
#define STREAM_HTTP 1
#define STREAM_RTSP_UDP 2
#define STREAM_RTSP_TCP 3
#define MAX_PACK 7 // maximum rtp packets to buffer
#define LEN_PIDS (MAX_PIDS * 5 + 1)
typedef struct struct_streams
{
char enabled;
SMutex mutex;
int sid; // socket - <0 for invalid/not used, 0 for end of the list
int adapter;
struct sockaddr_in sa;//remote address - set on accept or recvfrom on udp sockets
int rsock;// return socket handle, for rtsp over tcp, rtsp over udp or http
int rsock_id;
int rtcp, rtcp_sock, st_sock;
int type;
unsigned char buf[STREAMS_BUFFER + 10];
int len, total_len;
uint16_t seq; //rtp seq id
int ssrc; // rtp seq id
int64_t wtime;
int64_t rtime; // stream timeout
int64_t rtcp_wtime;
int do_play;
int start_streaming;
transponder tp;
char apids[LEN_PIDS + 1], dpids[LEN_PIDS + 1], pids[LEN_PIDS + 1],
x_pmt[LEN_PIDS + 1];
struct iovec iov[MAX_PACK + 2];
int iiov;
uint32_t sp, sb;
int timeout;
char useragent[40];
} streams;
#define TYPE_MCAST 1
#define TYPE_UNICAST 2
typedef struct struct_rtp_prop
{
int type;
int port;
char dest[50];
int ttl;
} rtp_prop;
char *describe_streams(sockets *s, char *req, char *sbuf, int size);
streams *setup_stream(char *str, sockets * s);
int start_play(streams * sid, sockets * s);
int decode_transport(sockets * s, char *arg, char *default_rtp, int start_rtp);
int streams_add();
int read_dmx(sockets * s);
int stream_timeout(sockets *s);
int close_streams_for_adapter(int ad, int except);
int close_stream(int i);
void dump_streams();
streams *get_sid1(int sid, char *file, int line);
int get_session_id(int i);
void set_session_id(int i, int id);
int fix_master_sid(int adapter);
int rtcp_confirm(sockets *s);
char *get_stream_rhost(int s_id, char *dest, int ld);
int get_stream_rport(int s_id);
int get_streams_for_adapter(int aid);
int find_session_id(int id);
int calculate_bw(sockets *s);
int lock_streams_for_adapter(int aid);
int unlock_streams_for_adapter(int aid);
#define get_sid(a) get_sid1(a, __FILE__, __LINE__)
#define get_sid_for(i) ((st[i] && st[i]->enabled)?st[i]:NULL)
#define get_sid_nw(i) ((i>=0 && i<MAX_STREAMS && st[i] && st[i]->enabled)?st[i]:NULL)
#endif