|
@@ -259,7 +259,7 @@ std::optional<string> PeerConnection::remoteAddress() const {
|
|
|
return iceTransport ? iceTransport->getRemoteAddress() : nullopt;
|
|
|
}
|
|
|
|
|
|
-shared_ptr<DataChannel> PeerConnection::addDataChannel(string label, DataChannelInit init) {
|
|
|
+shared_ptr<DataChannel> PeerConnection::createDataChannel(string label, DataChannelInit init) {
|
|
|
// RFC 5763: The answerer MUST use either a setup attribute value of setup:active or
|
|
|
// setup:passive. [...] Thus, setup:active is RECOMMENDED.
|
|
|
// See https://tools.ietf.org/html/rfc5763#section-5
|
|
@@ -268,6 +268,7 @@ shared_ptr<DataChannel> PeerConnection::addDataChannel(string label, DataChannel
|
|
|
auto role = iceTransport ? iceTransport->role() : Description::Role::Passive;
|
|
|
|
|
|
auto channelImpl = impl()->emplaceDataChannel(role, std::move(label), std::move(init));
|
|
|
+ auto channel = std::make_shared<DataChannel>(channelImpl);
|
|
|
|
|
|
if (auto transport = impl()->getSctpTransport())
|
|
|
if (transport->state() == impl::SctpTransport::State::Connected)
|
|
@@ -278,12 +279,8 @@ shared_ptr<DataChannel> PeerConnection::addDataChannel(string label, DataChannel
|
|
|
if (!local || !local->hasApplication())
|
|
|
impl()->negotiationNeeded = true;
|
|
|
|
|
|
- return std::make_shared<DataChannel>(channelImpl);
|
|
|
-}
|
|
|
-
|
|
|
-shared_ptr<DataChannel> PeerConnection::createDataChannel(string label, DataChannelInit init) {
|
|
|
- auto channel = addDataChannel(std::move(label), std::move(init));
|
|
|
setLocalDescription();
|
|
|
+
|
|
|
return channel;
|
|
|
}
|
|
|
|
|
@@ -292,6 +289,20 @@ void PeerConnection::onDataChannel(
|
|
|
impl()->dataChannelCallback = callback;
|
|
|
}
|
|
|
|
|
|
+std::shared_ptr<Track> PeerConnection::addTrack(Description::Media description) {
|
|
|
+ auto trackImpl = impl()->emplaceTrack(std::move(description));
|
|
|
+ auto track = std::make_shared<Track>(trackImpl);
|
|
|
+
|
|
|
+ // Renegotiation is needed for the new or updated track
|
|
|
+ impl()->negotiationNeeded = true;
|
|
|
+
|
|
|
+ return track;
|
|
|
+}
|
|
|
+
|
|
|
+void PeerConnection::onTrack(std::function<void(std::shared_ptr<Track>)> callback) {
|
|
|
+ impl()->trackCallback = callback;
|
|
|
+}
|
|
|
+
|
|
|
void PeerConnection::onLocalDescription(std::function<void(Description description)> callback) {
|
|
|
impl()->localDescriptionCallback = callback;
|
|
|
}
|
|
@@ -312,19 +323,6 @@ void PeerConnection::onSignalingStateChange(std::function<void(SignalingState st
|
|
|
impl()->signalingStateChangeCallback = callback;
|
|
|
}
|
|
|
|
|
|
-std::shared_ptr<Track> PeerConnection::addTrack(Description::Media description) {
|
|
|
- auto trackImpl = impl()->emplaceTrack(std::move(description));
|
|
|
-
|
|
|
- // Renegotiation is needed for the new or updated track
|
|
|
- impl()->negotiationNeeded = true;
|
|
|
-
|
|
|
- return std::make_shared<Track>(trackImpl);
|
|
|
-}
|
|
|
-
|
|
|
-void PeerConnection::onTrack(std::function<void(std::shared_ptr<Track>)> callback) {
|
|
|
- impl()->trackCallback = callback;
|
|
|
-}
|
|
|
-
|
|
|
bool PeerConnection::getSelectedCandidatePair(Candidate *local, Candidate *remote) {
|
|
|
auto iceTransport = impl()->getIceTransport();
|
|
|
return iceTransport ? iceTransport->getSelectedCandidatePair(local, remote) : false;
|