1 | /********** |
2 | This library is free software; you can redistribute it and/or modify it under |
3 | the terms of the GNU Lesser General Public License as published by the |
4 | Free Software Foundation; either version 3 of the License, or (at your |
5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
6 | |
7 | This library is distributed in the hope that it will be useful, but WITHOUT |
8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
10 | more details. |
11 | |
12 | You should have received a copy of the GNU Lesser General Public License |
13 | along with this library; if not, write to the Free Software Foundation, Inc., |
14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
15 | **********/ |
16 | // "liveMedia" |
17 | // Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved. |
18 | // A server that supports both RTSP, and HTTP streaming (using Apple's "HTTP Live Streaming" protocol) |
19 | // C++ header |
20 | |
21 | #ifndef _RTSP_SERVER_SUPPORTING_HTTP_STREAMING_HH |
22 | #define _RTSP_SERVER_SUPPORTING_HTTP_STREAMING_HH |
23 | |
24 | #ifndef _RTSP_SERVER_HH |
25 | #include "RTSPServer.hh" |
26 | #endif |
27 | #ifndef _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH |
28 | #include "ByteStreamMemoryBufferSource.hh" |
29 | #endif |
30 | #ifndef _TCP_STREAM_SINK_HH |
31 | #include "TCPStreamSink.hh" |
32 | #endif |
33 | |
34 | class RTSPServerSupportingHTTPStreaming: public RTSPServer { |
35 | public: |
36 | static RTSPServerSupportingHTTPStreaming* createNew(UsageEnvironment& env, Port rtspPort = 554, |
37 | UserAuthenticationDatabase* authDatabase = NULL, |
38 | unsigned reclamationTestSeconds = 65); |
39 | |
40 | Boolean setHTTPPort(Port httpPort) { return setUpTunnelingOverHTTP(httpPort); } |
41 | |
42 | protected: |
43 | RTSPServerSupportingHTTPStreaming(UsageEnvironment& env, |
44 | int ourSocket, Port ourPort, |
45 | UserAuthenticationDatabase* authDatabase, |
46 | unsigned reclamationTestSeconds); |
47 | // called only by createNew(); |
48 | virtual ~RTSPServerSupportingHTTPStreaming(); |
49 | |
50 | protected: // redefined virtual functions |
51 | virtual ClientConnection* createNewClientConnection(int clientSocket, struct sockaddr_in clientAddr); |
52 | |
53 | public: // should be protected, but some old compilers complain otherwise |
54 | class RTSPClientConnectionSupportingHTTPStreaming: public RTSPServer::RTSPClientConnection { |
55 | public: |
56 | RTSPClientConnectionSupportingHTTPStreaming(RTSPServer& ourServer, int clientSocket, struct sockaddr_in clientAddr); |
57 | virtual ~RTSPClientConnectionSupportingHTTPStreaming(); |
58 | |
59 | protected: // redefined virtual functions |
60 | virtual void handleHTTPCmd_StreamingGET(char const* urlSuffix, char const* fullRequestStr); |
61 | |
62 | protected: |
63 | static void afterStreaming(void* clientData); |
64 | |
65 | private: |
66 | u_int32_t fClientSessionId; |
67 | FramedSource* fStreamSource; |
68 | ByteStreamMemoryBufferSource* fPlaylistSource; |
69 | TCPStreamSink* fTCPSink; |
70 | }; |
71 | }; |
72 | |
73 | #endif |
74 | |