Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M120 #173

Merged
merged 11 commits into from
Jun 19, 2024
Merged

M120 #173

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ compile_commands.json
# Vim temporal files.
*.swp
*.swo
deps
.vscode
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog


### NEXT

* Update to libwebrtc M120/6099 ([#173](https://github.com/versatica/libmediasoupclient/pull/173)). Thanks @Poldraunic, @janreyho, @copiltembel.

### 3.4.2

* Fix explicit codec selection ([#164](https://github.com/versatica/libmediasoupclient/pull/164)). Thanks @fedulvtubudul.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configure_file (
)

# C++ standard requirements.
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Project options.
Expand Down
5 changes: 3 additions & 2 deletions include/Handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace mediasoupclient
class PrivateListener
{
public:
virtual ~PrivateListener() = default;
virtual ~PrivateListener() = default;
virtual void OnConnect(nlohmann::json& dtlsParameters) = 0;
virtual void OnConnectionStateChange(
webrtc::PeerConnectionInterface::IceConnectionState connectionState) = 0;
Expand Down Expand Up @@ -69,7 +69,8 @@ namespace mediasoupclient
// Got transport local and remote parameters.
bool transportReady{ false };
// Map of RTCTransceivers indexed by MID.
std::unordered_map<std::string, webrtc::RtpTransceiverInterface*> mapMidTransceiver{};
std::unordered_map<std::string, rtc::scoped_refptr<webrtc::RtpTransceiverInterface>>
mapMidTransceiver{};
// PeerConnection instance.
std::unique_ptr<PeerConnection> pc{ nullptr };
bool hasDataChannelMediaSection = false;
Expand Down
2 changes: 1 addition & 1 deletion include/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace mediasoupclient
class LogHandlerInterface
{
public:
virtual ~LogHandlerInterface() = default;
virtual ~LogHandlerInterface() = default;
virtual void OnLog(LogLevel level, char* payload, size_t len) = 0;
};

Expand Down
36 changes: 35 additions & 1 deletion include/PeerConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,40 @@ namespace mediasoupclient
void OnInterestingUsage(int usagePattern) override;
};

class SetLocalDescriptionObserver : public webrtc::SetLocalDescriptionObserverInterface
{
public:
SetLocalDescriptionObserver() = default;
~SetLocalDescriptionObserver() override = default;

std::future<void> GetFuture();
void Reject(const std::string& error);

/* Virtual methods inherited from webrtc::SetLocalDescriptionObserver. */
public:
void OnSetLocalDescriptionComplete(webrtc::RTCError error) override;

private:
std::promise<void> promise;
};

class SetRemoteDescriptionObserver : public webrtc::SetRemoteDescriptionObserverInterface
{
public:
SetRemoteDescriptionObserver() = default;
~SetRemoteDescriptionObserver() override = default;

std::future<void> GetFuture();
void Reject(const std::string& error);

/* Virtual methods inherited from webrtc::SetRemoteDescriptionObserver. */
public:
void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override;

private:
std::promise<void> promise;
};

class SetSessionDescriptionObserver : public webrtc::SetSessionDescriptionObserver
{
public:
Expand Down Expand Up @@ -126,7 +160,7 @@ namespace mediasoupclient
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track,
webrtc::RtpTransceiverInit rtpTransceiverInit);
std::vector<rtc::scoped_refptr<webrtc::RtpSenderInterface>> GetSenders();
bool RemoveTrack(webrtc::RtpSenderInterface* sender);
bool RemoveTrack(rtc::scoped_refptr<webrtc::RtpSenderInterface> sender);
nlohmann::json GetStats();
nlohmann::json GetStats(rtc::scoped_refptr<webrtc::RtpSenderInterface> selector);
nlohmann::json GetStats(rtc::scoped_refptr<webrtc::RtpReceiverInterface> selector);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"clang-tools-prebuilt": "^0.1.4",
"gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27"
},
"dependencies": {}
}
}
42 changes: 22 additions & 20 deletions src/Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ namespace mediasoupclient
if (encodings && !encodings->empty())
transceiverInit.send_encodings = *encodings;

webrtc::RtpTransceiverInterface* transceiver = this->pc->AddTransceiver(track, transceiverInit);
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> scopedTrack{ track };
auto transceiver = this->pc->AddTransceiver(scopedTrack, transceiverInit);

if (!transceiver)
MSC_THROW_ERROR("error creating transceiver");
Expand Down Expand Up @@ -359,7 +360,7 @@ namespace mediasoupclient
SendResult sendResult;

sendResult.localId = localId;
sendResult.rtpSender = transceiver->sender();
sendResult.rtpSender = transceiver->sender().get();
sendResult.rtpParameters = sendingRtpParameters;

return sendResult;
Expand Down Expand Up @@ -413,10 +414,10 @@ namespace mediasoupclient
const Sdp::RemoteSdp::MediaSectionIdx mediaSectionIdx =
this->remoteSdp->GetNextMediaSectionIdx();

auto offerMediaObject =
find_if(localSdpObject["media"].begin(), localSdpObject["media"].end(), [](const json& m) {
return m.at("type").get<std::string>() == "application";
});
auto offerMediaObject = find_if(
localSdpObject["media"].begin(),
localSdpObject["media"].end(),
[](const json& m) { return m.at("type").get<std::string>() == "application"; });

if (offerMediaObject == localSdpObject["media"].end())
{
Expand Down Expand Up @@ -461,7 +462,7 @@ namespace mediasoupclient
if (locaIdIt == this->mapMidTransceiver.end())
MSC_THROW_ERROR("associated RtpTransceiver not found");

auto* transceiver = locaIdIt->second;
auto transceiver = locaIdIt->second;
jmillan marked this conversation as resolved.
Show resolved Hide resolved

transceiver->sender()->SetTrack(nullptr);
this->pc->RemoveTrack(transceiver->sender());
Expand Down Expand Up @@ -500,7 +501,7 @@ namespace mediasoupclient
if (localIdIt == this->mapMidTransceiver.end())
MSC_THROW_ERROR("associated RtpTransceiver not found");

auto* transceiver = localIdIt->second;
auto transceiver = localIdIt->second;

transceiver->sender()->SetTrack(track);
}
Expand All @@ -516,8 +517,8 @@ namespace mediasoupclient
if (localIdIt == this->mapMidTransceiver.end())
MSC_THROW_ERROR("associated RtpTransceiver not found");

auto* transceiver = localIdIt->second;
auto parameters = transceiver->sender()->GetParameters();
auto transceiver = localIdIt->second;
auto parameters = transceiver->sender()->GetParameters();

bool hasLowEncoding{ false };
bool hasMediumEncoding{ false };
Expand Down Expand Up @@ -583,8 +584,8 @@ namespace mediasoupclient
if (localIdIt == this->mapMidTransceiver.end())
MSC_THROW_ERROR("associated RtpTransceiver not found");

auto* transceiver = localIdIt->second;
auto stats = this->pc->GetStats(transceiver->sender());
auto transceiver = localIdIt->second;
auto stats = this->pc->GetStats(transceiver->sender());

return stats;
}
Expand Down Expand Up @@ -667,9 +668,9 @@ namespace mediasoupclient
auto answer = this->pc->CreateAnswer(options);
auto localSdpObject = sdptransform::parse(answer);
auto mediaIt = find_if(
localSdpObject["media"].begin(), localSdpObject["media"].end(), [&localId](const json& m) {
return m["mid"].get<std::string>() == localId;
});
localSdpObject["media"].begin(),
localSdpObject["media"].end(),
[&localId](const json& m) { return m["mid"].get<std::string>() == localId; });

auto& answerMediaObject = *mediaIt;

Expand All @@ -690,9 +691,10 @@ namespace mediasoupclient

auto transceivers = this->pc->GetTransceivers();
auto transceiverIt = std::find_if(
transceivers.begin(), transceivers.end(), [&localId](webrtc::RtpTransceiverInterface* t) {
return t->mid() == localId;
});
transceivers.begin(),
transceivers.end(),
[&localId](rtc::scoped_refptr<webrtc::RtpTransceiverInterface> t)
{ return t->mid() == localId; });

if (transceiverIt == transceivers.end())
MSC_THROW_ERROR("new RTCRtpTransceiver not found");
Expand All @@ -705,8 +707,8 @@ namespace mediasoupclient
RecvResult recvResult;

recvResult.localId = localId;
recvResult.rtpReceiver = transceiver->receiver();
recvResult.track = transceiver->receiver()->track();
recvResult.rtpReceiver = transceiver->receiver().get();
recvResult.track = transceiver->receiver()->track().get();

return recvResult;
}
Expand Down
Loading