Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit bac7344

Browse files
committed
Use enum for json serialization as well
1 parent b392f4b commit bac7344

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

sendrecv/gst-rust/src/main.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,10 @@ fn send_sdp_offer(app_control: &AppControl, offer: gst_webrtc::WebRTCSessionDesc
152152
) {
153153
return;
154154
}
155-
let message = json!({
156-
"sdp": {
157-
"type": "offer",
158-
"sdp": offer.get_sdp().as_text(),
159-
}
160-
});
155+
let message = serde_json::to_string(&JsonMsg::Sdp {
156+
type_: "offer".to_string(),
157+
sdp: offer.get_sdp().as_text().unwrap(),
158+
}).unwrap();
161159
app_control.send_text_msg(message.to_string());
162160
}
163161

@@ -297,16 +295,13 @@ fn send_ice_candidate_message(app_control: &AppControl, values: &[glib::Value])
297295
if !app_control.app_state_lt(AppState::PeerCallNegotiating, "Can't send ICE, not in call") {
298296
return;
299297
}
300-
301298
let _webrtc = values[0].get::<gst::Element>().expect("Invalid argument");
302299
let mlineindex = values[1].get::<u32>().expect("Invalid argument");
303300
let candidate = values[2].get::<String>().expect("Invalid argument");
304-
let message = json!({
305-
"ice": {
306-
"candidate": candidate,
307-
"sdpMLineIndex": mlineindex,
308-
}
309-
});
301+
let message = serde_json::to_string(&JsonMsg::Ice {
302+
candidate: candidate,
303+
sdp_mline_index: mlineindex,
304+
}).unwrap();
310305
app_control.send_text_msg(message.to_string());
311306
}
312307

0 commit comments

Comments
 (0)