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

Commit

Permalink
Use enum for json serialization as well
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmcd committed Jun 15, 2018
1 parent b392f4b commit bac7344
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions sendrecv/gst-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,10 @@ fn send_sdp_offer(app_control: &AppControl, offer: gst_webrtc::WebRTCSessionDesc
) {
return;
}
let message = json!({
"sdp": {
"type": "offer",
"sdp": offer.get_sdp().as_text(),
}
});
let message = serde_json::to_string(&JsonMsg::Sdp {
type_: "offer".to_string(),
sdp: offer.get_sdp().as_text().unwrap(),
}).unwrap();
app_control.send_text_msg(message.to_string());
}

Expand Down Expand Up @@ -297,16 +295,13 @@ fn send_ice_candidate_message(app_control: &AppControl, values: &[glib::Value])
if !app_control.app_state_lt(AppState::PeerCallNegotiating, "Can't send ICE, not in call") {
return;
}

let _webrtc = values[0].get::<gst::Element>().expect("Invalid argument");
let mlineindex = values[1].get::<u32>().expect("Invalid argument");
let candidate = values[2].get::<String>().expect("Invalid argument");
let message = json!({
"ice": {
"candidate": candidate,
"sdpMLineIndex": mlineindex,
}
});
let message = serde_json::to_string(&JsonMsg::Ice {
candidate: candidate,
sdp_mline_index: mlineindex,
}).unwrap();
app_control.send_text_msg(message.to_string());
}

Expand Down

0 comments on commit bac7344

Please sign in to comment.