forked from zanjie1999/esp32-cam-rtsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCRtspSession.h
73 lines (59 loc) · 2.44 KB
/
CRtspSession.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
#pragma once
#include "CStreamer.h"
#include "platglue.h"
// supported command types
enum RTSP_CMD_TYPES
{
RTSP_OPTIONS,
RTSP_DESCRIBE,
RTSP_SETUP,
RTSP_PLAY,
RTSP_TEARDOWN,
RTSP_UNKNOWN
};
#define RTSP_BUFFER_SIZE 10000 // for incoming requests, and outgoing responses
#define RTSP_PARAM_STRING_MAX 200
#define MAX_HOSTNAME_LEN 256
class CRtspSession
{
public:
CRtspSession(SOCKET aRtspClient, CStreamer * aStreamer);
~CRtspSession();
RTSP_CMD_TYPES Handle_RtspRequest(char const * aRequest, unsigned aRequestSize);
int GetStreamID();
/**
Read from our socket, parsing commands as possible.
return false if the read timed out
*/
bool handleRequests(uint32_t readTimeoutMs);
/**
broadcast a current frame
*/
void broadcastCurrentFrame(uint32_t curMsec);
bool m_streaming;
bool m_stopped;
private:
void Init();
bool ParseRtspRequest(char const * aRequest, unsigned aRequestSize);
char const * DateHeader();
// RTSP request command handlers
void Handle_RtspOPTION();
void Handle_RtspDESCRIBE();
void Handle_RtspSETUP();
void Handle_RtspPLAY();
// global session state parameters
int m_RtspSessionID;
SOCKET m_RtspClient; // RTSP socket of that session
int m_StreamID; // number of simulated stream of that session
IPPORT m_ClientRTPPort; // client port for UDP based RTP transport
IPPORT m_ClientRTCPPort; // client port for UDP based RTCP transport
bool m_TcpTransport; // if Tcp based streaming was activated
CStreamer * m_Streamer; // the UDP or TCP streamer of that session
// parameters of the last received RTSP request
RTSP_CMD_TYPES m_RtspCmdType; // command type (if any) of the current request
char m_URLPreSuffix[RTSP_PARAM_STRING_MAX]; // stream name pre suffix
char m_URLSuffix[RTSP_PARAM_STRING_MAX]; // stream name suffix
char m_CSeq[RTSP_PARAM_STRING_MAX]; // RTSP command sequence number
char m_URLHostPort[MAX_HOSTNAME_LEN]; // host:port part of the URL
unsigned m_ContentLength; // SDP string size
};