ESP_IOT v2.5
IOT ESP Coding
CRtspSession.h
Go to the documentation of this file.
1#pragma once
2#include "../../../Defines.h"
3
4#ifdef USE_CAMERA_MODULE
5
6#include "CStreamer.h"
7#include "platglue.h"
8
9// supported command types
10enum RTSP_CMD_TYPES
11{
12 RTSP_OPTIONS,
13 RTSP_DESCRIBE,
14 RTSP_SETUP,
15 RTSP_PLAY,
16 RTSP_TEARDOWN,
17 RTSP_UNKNOWN
18};
19
20#define RTSP_BUFFER_SIZE 10000 // for incoming requests, and outgoing responses
21#define RTSP_PARAM_STRING_MAX 200
22#define MAX_HOSTNAME_LEN 256
23
24class CRtspSession
25{
26public:
27 CRtspSession(SOCKET aRtspClient, CStreamer * aStreamer);
28 ~CRtspSession();
29
30 RTSP_CMD_TYPES Handle_RtspRequest(char const * aRequest, unsigned aRequestSize);
31 int GetStreamID();
32
33 /**
34 Read from our socket, parsing commands as possible.
35
36 return false if the read timed out
37 */
38 bool handleRequests(uint32_t readTimeoutMs);
39
40 /**
41 broadcast a current frame
42 */
43 void broadcastCurrentFrame(uint32_t curMsec);
44
45 bool m_streaming;
46 bool m_stopped;
47
48private:
49 void Init();
50 bool ParseRtspRequest(char const * aRequest, unsigned aRequestSize);
51 char const * DateHeader();
52
53 // RTSP request command handlers
54 void Handle_RtspOPTION();
55 void Handle_RtspDESCRIBE();
56 void Handle_RtspSETUP();
57 void Handle_RtspPLAY();
58
59 // global session state parameters
60 int m_RtspSessionID;
61 SOCKET m_RtspClient; // RTSP socket of that session
62 int m_StreamID; // number of simulated stream of that session
63 IPPORT m_ClientRTPPort; // client port for UDP based RTP transport
64 IPPORT m_ClientRTCPPort; // client port for UDP based RTCP transport
65 bool m_TcpTransport; // if Tcp based streaming was activated
66 CStreamer * m_Streamer; // the UDP or TCP streamer of that session
67
68 // parameters of the last received RTSP request
69
70 RTSP_CMD_TYPES m_RtspCmdType; // command type (if any) of the current request
71 char m_URLPreSuffix[RTSP_PARAM_STRING_MAX]; // stream name pre suffix
72 char m_URLSuffix[RTSP_PARAM_STRING_MAX]; // stream name suffix
73 char m_CSeq[RTSP_PARAM_STRING_MAX]; // RTSP command sequence number
74 char m_URLHostPort[MAX_HOSTNAME_LEN]; // host:port part of the URL
75 unsigned m_ContentLength; // SDP string size
76};
77
78
79#endif