Debian Codegraph @

src/lib/tsreader/MepoRTSPClient.h

raw
1 #pragma once
2 /*
3 * Copyright (C) 2005-2013 Team Kodi
4 * https://kodi.tv
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 *************************************************************************
20 * This file is a modified version from Team MediaPortal's
21 * TsReader DirectShow filter
22 * MediaPortal is a GPL'ed HTPC-Application
23 * Copyright (C) 2005-2012 Team MediaPortal
24 * http://www.team-mediaportal.com
25 *
26 * Changes compared to Team MediaPortal's version:
27 * - Code cleanup for PVR addon usage
28 * - Code refactoring for cross platform usage
29 *************************************************************************
30 */
31
32 #ifdef LIVE555
33
34 #include <atomic>
35 #include <thread>
36 #include "lib/tsreader/MemoryBuffer.h"
37
38 #include "liveMedia.hh"
39 #include "BasicUsageEnvironment.hh"
40 #include "GroupsockHelper.hh"
41
42
43 #define RTSP_URL_BUFFERSIZE 2048
44
45 class CRTSPClient
46 {
47 public:
48 CRTSPClient();
49 virtual ~CRTSPClient(void);
50 bool Initialize(CMemoryBuffer* buffer);
51 bool OpenStream(const char* url);
52 bool Play(double fStart,double fDuration);
53 void Stop();
54 bool IsRunning();
55 long Duration();
56 bool Pause();
57 bool IsPaused();
58 void Continue();
59 void FillBuffer(unsigned long byteCount);
60
61 char* getSDPDescription();
62 bool UpdateDuration();
63
64 protected:
65 CMemoryBuffer* m_buffer;
66 Medium* createClient(UsageEnvironment& env,int verbosityLevel, char const* applicationName);
67 char* getSDPDescriptionFromURL(Medium* client, char const* url,
68 char const* username, char const* password,
69 char const* /*proxyServerName*/,
70 unsigned short /*proxyServerPortNum*/,
71 unsigned short /*clientStartPort*/);
72 bool clientSetupSubsession(Medium* client, MediaSubsession* subsession, bool streamUsingTCP);
73 bool clientStartPlayingSession(Medium* client, MediaSession* session);
74 bool clientTearDownSession(Medium* client, MediaSession* session);
75 void closeMediaSinks();
76 void tearDownStreams();
77 bool setupStreams();
78 //void checkForPacketArrival(void* /*clientData*/);
79 MediaSession* m_session;
80
81 bool allowProxyServers;
82 bool controlConnectionUsesTCP;
83 bool supportCodecSelection;
84 char const* clientProtocolName;
85 portNumBits tunnelOverHTTPPortNum;
86 unsigned statusCode;
87 char const* singleMedium;
88 unsigned short desiredPortNum;
89 bool createReceivers;
90 int simpleRTPoffsetArg;
91 unsigned socketInputBufferSize;
92 bool streamUsingTCP;
93 size_t fileSinkBufferSize;
94 bool oneFilePerFrame;
95
96 public:
97 UsageEnvironment* m_env;
98 Medium* m_ourClient;
99 char* getOptionsResponse(Medium* client, char const* url,char* username, char* password);
100 void shutdown();
101 bool startPlayingStreams();
102
103 // Thread
104 private:
105 void Process();
106 void StartBufferThread();
107 void StopBufferThread();
108 bool m_BufferThreadActive;
109
110 long m_duration;
111 double m_fStart;
112 double m_fDuration;
113 char m_url[RTSP_URL_BUFFERSIZE];
114 bool m_bRunning;
115 bool m_bPaused;
116 char m_outFileName[1000];
117
118 std::atomic<bool> m_running = {false};
119 std::thread m_thread;
120 };
121 #endif //LIVE555