feat: rust connection implementation

This commit is contained in:
Kingtous
2023-02-06 11:42:25 +08:00
parent a04980fa13
commit b412a7122b
8 changed files with 220 additions and 81 deletions

View File

@@ -5,7 +5,7 @@ use std::{
use hbb_common::{
log,
message_proto::{video_frame, VideoFrame},
message_proto::{video_frame, VideoFrame, Message, VoiceCallRequest, VoiceCallResponse}, get_time,
};
const MAX_LATENCY: i64 = 500;
@@ -115,3 +115,24 @@ pub struct QualityStatus {
pub target_bitrate: Option<i32>,
pub codec_format: Option<CodecFormat>,
}
#[inline]
pub fn new_voice_call_request(is_connect: bool) -> Message {
let mut req = VoiceCallRequest::new();
req.is_connect = is_connect;
req.req_timestamp = get_time();
let mut msg = Message::new();
msg.set_voice_call_request(req);
msg
}
#[inline]
pub fn new_voice_call_response(request_timestamp: i64, accepted: bool) -> Message {
let mut resp = VoiceCallResponse::new();
resp.accepted = accepted;
resp.req_timestamp = request_timestamp;
resp.ack_timestamp = get_time();
let mut msg = Message::new();
msg.set_voice_call_response(resp);
msg
}