Skip to content

Commit 1e412cf

Browse files
committed
fix: failed to connet with sfu
1 parent 6c134bd commit 1e412cf

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

src/args.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct Args {
104104

105105
// ipc
106106
std::string ipc_channel = "none";
107-
int ipc_channel_mode = 0;
107+
int ipc_channel_mode = -1;
108108
std::string socket_path = "/tmp/pi-webrtc-ipc.sock";
109109

110110
// webrtc

src/parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static const std::unordered_map<std::string, int> v4l2_fmt_table = {
1616
};
1717

1818
static const std::unordered_map<std::string, int> ipc_mode_table = {
19-
{"none", 0},
19+
{"none", -1},
2020
{"lossy", ChannelMode::Lossy},
2121
{"reliable", ChannelMode::Reliable},
2222
};

src/rtc/conductor.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,15 @@ rtc::scoped_refptr<RtcPeer> Conductor::CreatePeerConnection(PeerConfig config) {
137137

138138
peer->SetPeer(result.MoveValue());
139139

140-
if (config.is_sfu_peer && !config.is_publisher) {
141-
return peer;
142-
}
143-
144-
if (config.is_sfu_peer || args.ipc_channel_mode == ChannelMode::Lossy) {
140+
if (config.is_sfu_peer) {
141+
if (!config.is_publisher) {
142+
return peer;
143+
}
144+
peer->CreateDataChannel(ChannelMode::Lossy);
145+
peer->CreateDataChannel(ChannelMode::Reliable);
146+
} else if (args.ipc_channel_mode == ChannelMode::Lossy) {
145147
SetupIpcDataChannel(peer, ChannelMode::Lossy);
146-
}
147-
if (config.is_sfu_peer || args.ipc_channel_mode == ChannelMode::Reliable) {
148+
} else if (args.ipc_channel_mode == ChannelMode::Reliable) {
148149
SetupIpcDataChannel(peer, ChannelMode::Reliable);
149150
}
150151

src/rtc/data_channel_subject.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ void DataChannelSubject::OnStateChange() {
2626
webrtc::DataChannelInterface::DataState state = data_channel_->state();
2727
DEBUG_PRINT("[%s] OnStateChange => %s", data_channel_->label().c_str(),
2828
webrtc::DataChannelInterface::DataStateString(state));
29-
if (state == webrtc::DataChannelInterface::DataState::kClosed) {
30-
on_closed_func_(label());
31-
}
3229
}
3330

3431
void DataChannelSubject::Terminate() {

src/rtc/rtc_peer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ rtc::scoped_refptr<webrtc::PeerConnectionInterface> RtcPeer::GetPeer() { return
7373
std::shared_ptr<DataChannelSubject> RtcPeer::CreateDataChannel(ChannelMode mode) {
7474
struct webrtc::DataChannelInit init;
7575
init.ordered = true;
76-
init.negotiated = true;
7776
init.id = static_cast<int>(mode);
78-
auto label = id_ + ChannelModeToString(mode);
79-
77+
if (!config_.is_sfu_peer) {
78+
init.negotiated = true;
79+
}
8080
if (mode == ChannelMode::Lossy) {
8181
init.maxRetransmits = 0;
8282
}
8383

84+
auto label = ChannelModeToString(mode);
8485
auto result = peer_connection_->CreateDataChannelOrError(label, &init);
8586

8687
if (!result.ok()) {

src/rtc/rtc_peer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum ChannelMode {
2121
static inline std::string ChannelModeToString(ChannelMode id) {
2222
switch (id) {
2323
case Command:
24-
return "cmd_channel";
24+
return "command";
2525
case Lossy:
2626
return "_lossy";
2727
case Reliable:

0 commit comments

Comments
 (0)