mirror of
https://github.com/mpromonet/v4l2rtspserver
synced 2024-11-03 23:15:56 +00:00
allow srtp using rtsp
This commit is contained in:
parent
6ad245806c
commit
85f6e8dcb9
57
.vscode/settings.json
vendored
Normal file
57
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RTSPServer.hh"
|
// hacking private members RTSPServer::fWeServeSRTP & RTSPServer::fWeEncryptSRTP
|
||||||
|
#define private protected
|
||||||
|
#include "liveMedia.hh"
|
||||||
#include "RTSPCommon.hh"
|
#include "RTSPCommon.hh"
|
||||||
#include <GroupsockHelper.hh> // for "ignoreSigPipeOnSocket()"
|
#include <GroupsockHelper.hh> // for "ignoreSigPipeOnSocket()"
|
||||||
|
|
||||||
@ -162,7 +164,7 @@ class HTTPServer : public RTSPServer
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static HTTPServer* createNew(UsageEnvironment& env, Port rtspPort, UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds, unsigned int hlsSegment, const std::string & webroot, const std::string & sslCert, bool weServeSRTP)
|
static HTTPServer* createNew(UsageEnvironment& env, Port rtspPort, UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds, unsigned int hlsSegment, const std::string & webroot, const std::string & sslCert, bool enableRTSPS)
|
||||||
{
|
{
|
||||||
HTTPServer* httpServer = NULL;
|
HTTPServer* httpServer = NULL;
|
||||||
#if LIVEMEDIA_LIBRARY_VERSION_INT < 1610928000
|
#if LIVEMEDIA_LIBRARY_VERSION_INT < 1610928000
|
||||||
@ -178,17 +180,17 @@ class HTTPServer : public RTSPServer
|
|||||||
|
|
||||||
if (ourSocketIPv4 != -1)
|
if (ourSocketIPv4 != -1)
|
||||||
{
|
{
|
||||||
httpServer = new HTTPServer(env, ourSocketIPv4, ourSocketIPv6, rtspPort, authDatabase, reclamationTestSeconds, hlsSegment, webroot, sslCert, weServeSRTP);
|
httpServer = new HTTPServer(env, ourSocketIPv4, ourSocketIPv6, rtspPort, authDatabase, reclamationTestSeconds, hlsSegment, webroot, sslCert, enableRTSPS);
|
||||||
}
|
}
|
||||||
return httpServer;
|
return httpServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIVEMEDIA_LIBRARY_VERSION_INT < 1611187200
|
#if LIVEMEDIA_LIBRARY_VERSION_INT < 1611187200
|
||||||
HTTPServer(UsageEnvironment& env, int ourSocketIPv4, int ourSocketIPv6, Port rtspPort, UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds, unsigned int hlsSegment, const std::string & webroot, const std::string & sslCert, bool weServeSRTP)
|
HTTPServer(UsageEnvironment& env, int ourSocketIPv4, int ourSocketIPv6, Port rtspPort, UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds, unsigned int hlsSegment, const std::string & webroot, const std::string & sslCert, bool enableRTSPS)
|
||||||
: RTSPServer(env, ourSocketIPv4, rtspPort, authDatabase, reclamationTestSeconds), m_hlsSegment(hlsSegment), m_webroot(webroot), m_sslCert(sslCert)
|
: RTSPServer(env, ourSocketIPv4, rtspPort, authDatabase, reclamationTestSeconds), m_hlsSegment(hlsSegment), m_webroot(webroot), m_sslCert(sslCert)
|
||||||
#else
|
#else
|
||||||
HTTPServer(UsageEnvironment& env, int ourSocketIPv4, int ourSocketIPv6, Port rtspPort, UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds, unsigned int hlsSegment, const std::string & webroot, const std::string & sslCert, bool weServeSRTP)
|
HTTPServer(UsageEnvironment& env, int ourSocketIPv4, int ourSocketIPv6, Port rtspPort, UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds, unsigned int hlsSegment, const std::string & webroot, const std::string & sslCert, bool enableRTSPS)
|
||||||
: RTSPServer(env, ourSocketIPv4, ourSocketIPv6, rtspPort, authDatabase, reclamationTestSeconds), m_hlsSegment(hlsSegment), m_webroot(webroot), m_sslCert(sslCert), m_weServeSRTP(weServeSRTP)
|
: RTSPServer(env, ourSocketIPv4, ourSocketIPv6, rtspPort, authDatabase, reclamationTestSeconds), m_hlsSegment(hlsSegment), m_webroot(webroot), m_sslCert(sslCert), m_enableRTSPS(enableRTSPS)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if ( (!m_webroot.empty()) && (*m_webroot.rend() != '/') ) {
|
if ( (!m_webroot.empty()) && (*m_webroot.rend() != '/') ) {
|
||||||
@ -196,14 +198,20 @@ class HTTPServer : public RTSPServer
|
|||||||
}
|
}
|
||||||
#if LIVEMEDIA_LIBRARY_VERSION_INT >= 1642723200
|
#if LIVEMEDIA_LIBRARY_VERSION_INT >= 1642723200
|
||||||
if (this->isSSL()) {
|
if (this->isSSL()) {
|
||||||
this->setTLSState(m_sslCert.c_str(), m_sslCert.c_str(), m_weServeSRTP);
|
if (m_enableRTSPS) {
|
||||||
|
this->setTLSState(m_sslCert.c_str(), m_sslCert.c_str());
|
||||||
|
} else {
|
||||||
|
this->setTLSFileNames(m_sslCert.c_str(), m_sslCert.c_str());
|
||||||
|
this->fWeServeSRTP = true;
|
||||||
|
this->fWeEncryptSRTP = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual RTSPServer::ClientConnection* createNewClientConnection(int clientSocket, struct SOCKETCLIENT clientAddr)
|
virtual RTSPServer::ClientConnection* createNewClientConnection(int clientSocket, struct SOCKETCLIENT clientAddr)
|
||||||
{
|
{
|
||||||
return new HTTPClientConnection(*this, clientSocket, clientAddr, this->isSSL());
|
return new HTTPClientConnection(*this, clientSocket, clientAddr, this->isSSL() && m_enableRTSPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual RTSPServer::ClientSession* createNewClientSession(u_int32_t sessionId) {
|
virtual RTSPServer::ClientSession* createNewClientSession(u_int32_t sessionId) {
|
||||||
@ -216,6 +224,6 @@ class HTTPServer : public RTSPServer
|
|||||||
const unsigned int m_hlsSegment;
|
const unsigned int m_hlsSegment;
|
||||||
std::string m_webroot;
|
std::string m_webroot;
|
||||||
std::string m_sslCert;
|
std::string m_sslCert;
|
||||||
bool m_weServeSRTP;
|
bool m_enableRTSPS;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,20 +17,20 @@
|
|||||||
#include <BasicUsageEnvironment.hh>
|
#include <BasicUsageEnvironment.hh>
|
||||||
#include <GroupsockHelper.hh>
|
#include <GroupsockHelper.hh>
|
||||||
|
|
||||||
|
#include "HTTPServer.h"
|
||||||
#include "UnicastServerMediaSubsession.h"
|
#include "UnicastServerMediaSubsession.h"
|
||||||
#include "MulticastServerMediaSubsession.h"
|
#include "MulticastServerMediaSubsession.h"
|
||||||
#include "TSServerMediaSubsession.h"
|
#include "TSServerMediaSubsession.h"
|
||||||
#include "HTTPServer.h"
|
|
||||||
|
|
||||||
class V4l2RTSPServer {
|
class V4l2RTSPServer {
|
||||||
public:
|
public:
|
||||||
V4l2RTSPServer(unsigned short rtspPort, unsigned short rtspOverHTTPPort = 0, int timeout = 10, unsigned int hlsSegment = 0, const std::list<std::string> & userPasswordList = std::list<std::string>(), const char* realm = NULL, const std::string & webroot = "", const std::string & sslkeycert = "", bool weServeSRTP = true)
|
V4l2RTSPServer(unsigned short rtspPort, unsigned short rtspOverHTTPPort = 0, int timeout = 10, unsigned int hlsSegment = 0, const std::list<std::string> & userPasswordList = std::list<std::string>(), const char* realm = NULL, const std::string & webroot = "", const std::string & sslkeycert = "", bool enableRTSPS = false)
|
||||||
: m_stop(0)
|
: m_stop(0)
|
||||||
, m_env(BasicUsageEnvironment::createNew(*BasicTaskScheduler::createNew()))
|
, m_env(BasicUsageEnvironment::createNew(*BasicTaskScheduler::createNew()))
|
||||||
, m_rtspPort(rtspPort)
|
, m_rtspPort(rtspPort)
|
||||||
{
|
{
|
||||||
UserAuthenticationDatabase* auth = createUserAuthenticationDatabase(userPasswordList, realm);
|
UserAuthenticationDatabase* auth = createUserAuthenticationDatabase(userPasswordList, realm);
|
||||||
m_rtspServer = HTTPServer::createNew(*m_env, rtspPort, auth, timeout, hlsSegment, webroot, sslkeycert, weServeSRTP);
|
m_rtspServer = HTTPServer::createNew(*m_env, rtspPort, auth, timeout, hlsSegment, webroot, sslkeycert, enableRTSPS);
|
||||||
if (m_rtspServer != NULL)
|
if (m_rtspServer != NULL)
|
||||||
{
|
{
|
||||||
if (rtspOverHTTPPort)
|
if (rtspOverHTTPPort)
|
||||||
|
12
main.cpp
12
main.cpp
@ -31,8 +31,8 @@
|
|||||||
#include "V4l2Device.h"
|
#include "V4l2Device.h"
|
||||||
#include "V4l2Output.h"
|
#include "V4l2Output.h"
|
||||||
|
|
||||||
#include "DeviceSourceFactory.h"
|
|
||||||
#include "V4l2RTSPServer.h"
|
#include "V4l2RTSPServer.h"
|
||||||
|
#include "DeviceSourceFactory.h"
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
@ -97,7 +97,7 @@ int main(int argc, char** argv)
|
|||||||
int defaultHlsSegment = 2;
|
int defaultHlsSegment = 2;
|
||||||
unsigned int hlsSegment = 0;
|
unsigned int hlsSegment = 0;
|
||||||
std::string sslKeyCert;
|
std::string sslKeyCert;
|
||||||
bool weServeSRTP = true;
|
bool enableRTSPS = true;
|
||||||
const char* realm = NULL;
|
const char* realm = NULL;
|
||||||
std::list<std::string> userPasswordList;
|
std::list<std::string> userPasswordList;
|
||||||
std::string webroot;
|
std::string webroot;
|
||||||
@ -135,7 +135,7 @@ int main(int argc, char** argv)
|
|||||||
case 'S': hlsSegment = optarg ? atoi(optarg) : defaultHlsSegment; break;
|
case 'S': hlsSegment = optarg ? atoi(optarg) : defaultHlsSegment; break;
|
||||||
#ifndef NO_OPENSSL
|
#ifndef NO_OPENSSL
|
||||||
case 'x': sslKeyCert = optarg; break;
|
case 'x': sslKeyCert = optarg; break;
|
||||||
case 'X': weServeSRTP = false; break;
|
case 'X': enableRTSPS = true; break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// users
|
// users
|
||||||
@ -191,8 +191,8 @@ int main(int argc, char** argv)
|
|||||||
std::cout << "\t -c : don't repeat config (default repeat config before IDR frame)" << std::endl;
|
std::cout << "\t -c : don't repeat config (default repeat config before IDR frame)" << std::endl;
|
||||||
std::cout << "\t -t <timeout> : RTCP expiration timeout in seconds (default " << timeout << ")" << std::endl;
|
std::cout << "\t -t <timeout> : RTCP expiration timeout in seconds (default " << timeout << ")" << std::endl;
|
||||||
std::cout << "\t -S[<duration>] : enable HLS & MPEG-DASH with segment duration in seconds (default " << defaultHlsSegment << ")" << std::endl;
|
std::cout << "\t -S[<duration>] : enable HLS & MPEG-DASH with segment duration in seconds (default " << defaultHlsSegment << ")" << std::endl;
|
||||||
std::cout << "\t -x <sslkeycert> : enable RTSPS & SRTP" << std::endl;
|
std::cout << "\t -x <sslkeycert> : enable SRTP" << std::endl;
|
||||||
std::cout << "\t -X : disable SRTP" << std::endl;
|
std::cout << "\t -X : enable RTSPS" << std::endl;
|
||||||
|
|
||||||
std::cout << "\t V4L2 options" << std::endl;
|
std::cout << "\t V4L2 options" << std::endl;
|
||||||
std::cout << "\t -r : V4L2 capture using read interface (default use memory mapped buffers)" << std::endl;
|
std::cout << "\t -r : V4L2 capture using read interface (default use memory mapped buffers)" << std::endl;
|
||||||
@ -253,7 +253,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
|
|
||||||
// create RTSP server
|
// create RTSP server
|
||||||
V4l2RTSPServer rtspServer(rtspPort, rtspOverHTTPPort, timeout, hlsSegment, userPasswordList, realm, webroot, sslKeyCert, weServeSRTP);
|
V4l2RTSPServer rtspServer(rtspPort, rtspOverHTTPPort, timeout, hlsSegment, userPasswordList, realm, webroot, sslKeyCert, enableRTSPS);
|
||||||
if (!rtspServer.available())
|
if (!rtspServer.available())
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "Failed to create RTSP server: " << rtspServer.getResultMsg();
|
LOG(ERROR) << "Failed to create RTSP server: " << rtspServer.getResultMsg();
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "RTSPServer.hh"
|
|
||||||
#include "RTSPCommon.hh"
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "ByteStreamMemoryBufferSource.hh"
|
#include "ByteStreamMemoryBufferSource.hh"
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "V4l2Capture.h"
|
#include "V4l2Capture.h"
|
||||||
#include "V4l2Output.h"
|
#include "V4l2Output.h"
|
||||||
#include "DeviceSourceFactory.h"
|
|
||||||
#include "V4l2RTSPServer.h"
|
#include "V4l2RTSPServer.h"
|
||||||
|
#include "DeviceSourceFactory.h"
|
||||||
#include "VideoCaptureAccess.h"
|
#include "VideoCaptureAccess.h"
|
||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
|
Loading…
Reference in New Issue
Block a user