janus源码跟踪学习

 

//janus 录像转mkv方式
sudo /opt/janus/bin/janus-pp-rec  videoroom-1234-user-2366082808229993-1619080276011939-video.mjr hello.mp4 

sudo ffmpeg -strict -2 -i hello2.mp4 -i hello2.opus -map 0:0 -map 1:0 out.mkv

//录像视频帧的获取
static void janus_videoroom_recorder_create(janus_videoroom_publisher *participant, gboolean audio, gboolean video, gboolean data)

void janus_videoroom_incoming_rtp(janus_plugin_session *handle, janus_plugin_rtp *pkt) 

janus_recorder_save_frame(video ? participant->vrc : participant->arc, buf, len);

janus 发送消息流程:

发送json格式数据:
const char *type = session->recorder ? "answer" : "offer";
json_t *jsep = json_pack("{ssss}", "type", type, "sdp", sdp);
if(sdp_update)
	json_object_set_new(jsep, "restart", json_true());
if(e2ee)
	json_object_set_new(jsep, "e2ee", json_true());
/* How long will the gateway take to push the event? */
g_atomic_int_set(&session->hangingup, 0);
gint64 start = janus_get_monotonic_time();
int res = gateway->push_event(msg->handle, &janus_recordplay_plugin, msg->transaction, event, jsep);

//再回调
int janus_plugin_push_event(janus_plugin_session *plugin_session, janus_plugin *plugin, const char *transaction, json_t *message, json_t *jsep) 

//再调用
janus_session_notify_event(session, event);

//发送
source->transport->send_message(source->instance, NULL, FALSE, event);

 http请求和视频流获取关键代码:

//http请求
static void *janus_transport_requests(void *data) {
int janus_process_incoming_request(janus_request *request)
handle = janus_ice_handle_create(session, opaque_id, token_value);

//看视频:
static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint component_id, guint len, gchar *buf, gpointer ice) {
janus_dtls_srtp_incoming_msg(component->dtls, buf, len);
janus_ice_dtls_handshake_done(handle, component);
void janus_ice_dtls_handshake_done(janus_ice_handle *handle, janus_ice_component *component) 
plugin->setup_media(handle->app_handle);
void janus_videoroom_setup_media(janus_plugin_session *handle) {
    

 

你可能感兴趣的:(janus-gateway)