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) {

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值