-
Notifications
You must be signed in to change notification settings - Fork 2
/
rtsp.h
150 lines (133 loc) · 5.57 KB
/
rtsp.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
Header file for RTSP protocol
Copyright (C) 2016-2024 Michele Campus <[email protected]>
Based on code from https://github.com/moonlight-stream/moonlight-common-c/blob/master/src/RtspParser.c
This file is part of decoder.
decoder is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
decoder is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
decoder. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef RTSP_H
#define RTSP_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define RTSP_SUCCESS 0
#define RTSP_ERROR_NO_MEMORY -1
#define RTSP_ERROR_MALFORMED -2
#define MAGIC 0x24
/**
:: RTSP message type ::
There are two types of message:
- Request (from Client to Server)
- Response (from Server to Client)
**/
#define REQUEST 0
#define RESPONSE 1
/**
:: Command definition::
The command token indicates the method to be performed on the resource
identified by the Request-URI
**/
/*
command direction object requirement
DESCRIBE C->S P,S recommended
ANNOUNCE C->S, S->C P,S optional
GET_PARAMETER C->S, S->C P,S optional
OPTIONS C->S, S->C P,S required (S->C: optional)
PAUSE C->S P,S recommended
PLAY C->S P,S required
RECORD C->S P,S optional
REDIRECT S->C P,S optional
SETUP C->S S required
SET_PARAMETER C->S, S->C P,S optional
TEARDOWN C->S P,S required
*/
/**
:: Header Field Definitions ::
Summary of the header fields used by RTSP (RFC 2326 RTSP 1.0)
- type "g" designates general request headers to be found in both requests and responses
- type "R" designates request headers
- type "r" designates response headers
- type "e" designates entity header fields
**/
/*
Header type support methods
Accept R opt. entity
Accept-Encoding R opt. entity
Accept-Language R opt. all
Allow r opt. all
Authorization R opt. all
Bandwidth R opt. all
Blocksize R opt. all but OPTIONS, TEARDOWN
Cache-Control g opt. SETUP
Conference R opt. SETUP
Connection g req. all
Content-Base e opt. entity
Content-Encoding e req. SET_PARAMETER
Content-Encoding e req. DESCRIBE, ANNOUNCE
Content-Language e req. DESCRIBE, ANNOUNCE
Content-Length e req. SET_PARAMETER, ANNOUNCE
Content-Length e req. entity
Content-Location e opt. entity
Content-Type e req. SET_PARAMETER, ANNOUNCE
Content-Type r req. entity
CSeq g req. all
Date g opt. all
Expires e opt. DESCRIBE, ANNOUNCE
From R opt. all
If-Modified-Since R opt. DESCRIBE, SETUP
Last-Modified e opt. entity
Proxy-Authenticate
Proxy-Require R req. all
Public r opt. all
Range R opt. PLAY, PAUSE, RECORD
Range r opt. PLAY, PAUSE, RECORD
Referer R opt. all
Require R req. all
Retry-After r opt. all
RTP-Info r req. PLAY
Scale Rr opt. PLAY, RECORD
Session Rr req. all but SETUP, OPTIONS
Server r opt. all
Speed Rr opt. PLAY
Transport Rr req. SETUP
Unsupported r req. all
User-Agent R opt. all
Via g opt. all
WWW-Authenticate r opt. all
*/
typedef struct _RTSP_MESSAGE {
char *cache_control; //
char *content_base; //
char *content_len; //
char *content_type; //
char *command; //
char *last_mod;
char *range;
char *protocol;
char *seq_num; //
char *server; //
char *session; //
char *status_code; //
char *transport; //
char *ua; //
char *uri; //
char msg_type;
/* list not complete: add new in needed */
char *sdp;
} rtsp_message;
/* Prototype of functions */
int rtsp_parser(const u_char *packet, int size_payload, char *json_buffer, int buffer_len);
int rtsp_message_parser(rtsp_message *msg, char *rtspMessage, int length);
void create_rtsp_message(rtsp_message *msg, char *protocol, char *uri, char *command, char *seq_num,
char *status_code, char *server, char *ua, char *cache_control, char *content_len,
char *content_type, char *content_base, char *last_mod, char *range, char *session,
char *transport, char msg_type, char *sdp);
#endif