-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved WebRTC code to trash temorarly
- Loading branch information
1 parent
5f0c3aa
commit 45cf93e
Showing
29 changed files
with
248 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
HttpServer/Resources/include/HttpServer/Resources/GenericRtpController.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <drogon/HttpController.h> | ||
|
||
#include <memory> | ||
|
||
namespace HttpServer | ||
{ | ||
namespace Resources | ||
{ | ||
class GenericRtpController; | ||
using GenericRtpControllerSharedPtr_t = std::shared_ptr<GenericRtpController>; | ||
|
||
class GenericRtpController : public drogon::HttpController<GenericRtpController, false> | ||
{ | ||
public: | ||
static GenericRtpControllerSharedPtr_t Create(); | ||
|
||
GenericRtpController(); | ||
~GenericRtpController() override; | ||
|
||
METHOD_LIST_BEGIN | ||
ADD_METHOD_TO(GenericRtpController::PostResource, "/api/v1/resources/generic-rtp/{resource}", drogon::Post); | ||
METHOD_LIST_END | ||
|
||
void PostResource(const drogon::HttpRequestPtr &req, std::function<void(const drogon::HttpResponsePtr &)> &&callback, std::string&& resource); | ||
|
||
private: | ||
}; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
HttpServer/Resources/include/HttpServer/Resources/WebRtcController.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <MediaServer/MediaManager/MediaManager.hpp> | ||
|
||
#include <drogon/HttpController.h> | ||
|
||
#include <memory> | ||
|
||
namespace HttpServer | ||
{ | ||
namespace Resources | ||
{ | ||
class WebRtcController; | ||
using WebRtcControllerSharedPtr_t = std::shared_ptr<WebRtcController>; | ||
|
||
class WebRtcController : public drogon::HttpController<WebRtcController, false> | ||
{ | ||
public: | ||
static WebRtcControllerSharedPtr_t Create(MediaServer::MediaManagerSharedPtr_t pMediaManager); | ||
|
||
explicit WebRtcController(MediaServer::MediaManagerSharedPtr_t pMediaManager); | ||
~WebRtcController() override = default; | ||
|
||
METHOD_LIST_BEGIN | ||
ADD_METHOD_TO(WebRtcController::PostResource, "/api/v1/resources/webrtc/{resource}", drogon::Post); | ||
ADD_METHOD_TO(WebRtcController::GetResource, "/api/v1/resources/webrtc/{resource}", drogon::Get); | ||
METHOD_LIST_END | ||
|
||
void PostResource(const drogon::HttpRequestPtr &req, std::function<void(const drogon::HttpResponsePtr &)> &&callback, std::string&& resource); | ||
|
||
void GetResource(const drogon::HttpRequestPtr &req, std::function<void(const drogon::HttpResponsePtr &)> &&callback, std::string&& resource); | ||
|
||
private: | ||
MediaServer::MediaManagerSharedPtr_t m_pMediaManager; | ||
}; | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
HttpServer/Resources/include/Resources/WebRtcController.hpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <HttpServer/Resources/GenericRtpController.hpp> | ||
|
||
#include <iostream> | ||
|
||
namespace HttpServer | ||
{ | ||
namespace Resources | ||
{ | ||
GenericRtpControllerSharedPtr_t GenericRtpController::Create() | ||
{ | ||
return std::make_shared<GenericRtpController>(); | ||
} | ||
|
||
GenericRtpController::GenericRtpController() | ||
{ | ||
std::cout << "Creating GenericRtpController" << std::endl; | ||
} | ||
|
||
GenericRtpController::~GenericRtpController() | ||
{ | ||
std::cout << "Terminating GenericRtpController" << std::endl; | ||
} | ||
|
||
void GenericRtpController::PostResource(const drogon::HttpRequestPtr& pHttpRequest, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback, | ||
std::string&& resource) | ||
{ | ||
std::cout << "GenericRtpController::PostResource" << std::endl; | ||
|
||
|
||
|
||
auto pHttpResponse = drogon::HttpResponse::newHttpResponse(); | ||
pHttpResponse->setStatusCode(drogon::HttpStatusCode::k200OK); | ||
|
||
callback(pHttpResponse); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,43 @@ | ||
#include <Resources/PeerConnection.hpp> | ||
#include <Resources/WebRtcController.hpp> | ||
#include <Resources/WhepSignalingHandler.hpp> | ||
#include <Resources/WhipSignalingHandler.hpp> | ||
|
||
#include <Resources/VideoEndpointRx.hpp> | ||
#include <Resources/VideoEndpointTx.hpp> | ||
#include <HttpServer/Resources/WebRtcController.hpp> | ||
|
||
#include <MediaServer/MediaManager/MediaResource.hpp> | ||
|
||
#include <rtc/rtc.hpp> | ||
|
||
#include <memory> | ||
|
||
namespace Http | ||
namespace HttpServer | ||
{ | ||
WebRtcControllerSharedPtr_t WebRtcController::Create(MediaServer::MediaManagerSharedPtr_t pMediaManager) | ||
namespace Resources | ||
{ | ||
return std::make_shared<WebRtcController>(pMediaManager); | ||
WebRtcControllerSharedPtr_t WebRtcController::Create(MediaServer::MediaManagerSharedPtr_t pMediaManager) | ||
{ | ||
return std::make_shared<WebRtcController>(pMediaManager); | ||
} | ||
|
||
WebRtcController::WebRtcController(MediaServer::MediaManagerSharedPtr_t pMediaManager) | ||
: m_pMediaManager{std::move(pMediaManager)} | ||
{ | ||
std::cout << "Creating WebRtcController" << std::endl; | ||
} | ||
|
||
void WebRtcController::PostResource(const drogon::HttpRequestPtr& req, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback, | ||
std::string&& resource) | ||
{ | ||
auto pHttpResponse = drogon::HttpResponse::newHttpResponse(); | ||
pHttpResponse->setStatusCode(drogon::HttpStatusCode::k501NotImplemented); | ||
|
||
callback(pHttpResponse); | ||
} | ||
|
||
void WebRtcController::GetResource(const drogon::HttpRequestPtr& req, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback, | ||
std::string&& resource) | ||
{ | ||
auto pHttpResponse = drogon::HttpResponse::newHttpResponse(); | ||
pHttpResponse->setStatusCode(drogon::HttpStatusCode::k501NotImplemented); | ||
|
||
callback(pHttpResponse); | ||
} | ||
} | ||
|
||
WebRtcController::WebRtcController(MediaServer::MediaManagerSharedPtr_t pMediaManager) | ||
: m_pMediaManager{std::move(pMediaManager)} | ||
{ | ||
std::cout << "Creating WebRtcController" << std::endl; | ||
} | ||
|
||
void WebRtcController::PostResource(const drogon::HttpRequestPtr& req, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback, | ||
std::string&& resource) | ||
{ | ||
std::cout << "WebRtcController::PostResource" << std::endl; | ||
|
||
std::string body{req->body()}; | ||
|
||
rtc::Configuration config; | ||
config.iceServers.emplace_back("stun:stun.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun1.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun2.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun3.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun4.l.google.com:19302"); | ||
|
||
auto pMediaResource = MediaServer::MediaResource::Create(std::move(resource)); | ||
m_pMediaManager->AddMediaResource(pMediaResource); | ||
|
||
auto onTrackCallback = [pMediaResource](std::shared_ptr<rtc::Track> pTrack) { | ||
std::cout << "onTrackCallback - " << pTrack->direction() << std::endl; | ||
|
||
auto pVideoTrack = WebRTC::VideoEndpointRx::Create(std::move(pTrack)); | ||
pMediaResource->AddTrack(pVideoTrack); | ||
}; | ||
|
||
auto pRTCPeerConnection = std::make_shared<rtc::PeerConnection>(); | ||
auto pPeerConnection = WebRTC::PeerConnection::Create(pRTCPeerConnection, onTrackCallback); | ||
|
||
auto pWhepSignalingHandler = WebRTC::WhepSignalingHandler::Create(std::move(callback)); | ||
pPeerConnection->InitiateSignaling(std::move(pWhepSignalingHandler), body); | ||
} | ||
|
||
void WebRtcController::GetResource(const drogon::HttpRequestPtr& req, | ||
std::function<void(const drogon::HttpResponsePtr&)>&& callback, | ||
std::string&& resource) | ||
{ | ||
std::cout << "WebRtcController::PostResource" << std::endl; | ||
|
||
std::string body{req->body()}; | ||
|
||
rtc::Configuration config; | ||
config.iceServers.emplace_back("stun:stun.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun1.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun2.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun3.l.google.com:19302"); | ||
config.iceServers.emplace_back("stun:stun4.l.google.com:19302"); | ||
|
||
auto pMediaResource = m_pMediaManager->GetMediaResource(resource); | ||
|
||
auto onTrackCallback = [pMediaResource](std::shared_ptr<rtc::Track> pTrack) { | ||
std::cout << "onTrackCallback - " << pTrack->direction() << std::endl; | ||
|
||
auto pVideoEndpointTx = WebRTC::VideoEndpointTx::Create(std::move(pTrack)); | ||
|
||
auto pVideoEndpointRx = pMediaResource->GetTrack(""); | ||
|
||
pVideoEndpointRx->Attach(pVideoEndpointTx); | ||
}; | ||
|
||
auto pRTCPeerConnection = std::make_shared<rtc::PeerConnection>(); | ||
|
||
auto pPeerConnection = WebRTC::PeerConnection::Create(pRTCPeerConnection, onTrackCallback); | ||
|
||
auto pWhipSignalingHandler = WebRTC::WhipSignalingHandler::Create(std::move(callback)); | ||
pPeerConnection->InitiateSignaling(std::move(pWhipSignalingHandler), body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.