forked from TzuHuanTai/RaspberryPi-WebRTC
-
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.
refactor: make signaling service base
- Loading branch information
1 parent
c7387ff
commit 183561e
Showing
10 changed files
with
292 additions
and
292 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
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 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,7 @@ | ||
project(signaling) | ||
|
||
aux_source_directory(${PROJECT_SOURCE_DIR} TRACK_FILES) | ||
|
||
add_library(${PROJECT_NAME} ${TRACK_FILES}) | ||
|
||
target_link_libraries(${PROJECT_NAME}) |
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,28 @@ | ||
#include "signaling_service.h" | ||
|
||
SignalingService::SignalingService(std::shared_ptr<Conductor> conductor) | ||
: conductor_(conductor) { | ||
InitIceCallback(); | ||
} | ||
|
||
void SignalingService::OnRemoteSdp(std::string sdp) { | ||
conductor_->SetOfferSDP(sdp, [this]() { | ||
conductor_->CreateAnswer([this](webrtc::SessionDescriptionInterface *desc) { | ||
std::string answer_sdp; | ||
desc->ToString(&answer_sdp); | ||
AnswerLocalSdp(answer_sdp); | ||
}, nullptr); | ||
}, nullptr); | ||
} | ||
|
||
void SignalingService::OnRemoteIce(std::string sdp_mid, int sdp_mline_index, std::string candidate) { | ||
// bug: Failed to apply the received candidate. connect but without datachannel!? | ||
// conductor_->AddIceCandidate(sdp_mid, sdp_mline_index, candidate); | ||
} | ||
|
||
void SignalingService::InitIceCallback() { | ||
conductor_->invoke_answer_ice = | ||
[this](std::string sdp_mid, int sdp_mline_index, std::string candidate) { | ||
AnswerLocalIce(sdp_mid, sdp_mline_index, candidate); | ||
}; | ||
} |
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,28 @@ | ||
#ifndef SIGNALING_SERVICE_H_ | ||
#define SIGNALING_SERVICE_H_ | ||
|
||
#include "conductor.h" | ||
|
||
#include <string> | ||
|
||
class SignalingService { | ||
public: | ||
SignalingService(std::shared_ptr<Conductor> conductor); | ||
virtual ~SignalingService() {}; | ||
|
||
protected: | ||
std::shared_ptr<Conductor> conductor_; | ||
void OnRemoteSdp(std::string sdp); | ||
void OnRemoteIce(std::string sdp_mid, int sdp_mline_index, std::string candidate); | ||
virtual void AnswerLocalSdp(std::string sdp) = 0; | ||
virtual void AnswerLocalIce(std::string sdp_mid, | ||
int sdp_mline_index, | ||
std::string candidate) = 0; | ||
virtual void Connect() = 0; | ||
virtual void Disconnect() = 0; | ||
|
||
private: | ||
void InitIceCallback(); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.