服务器和客户端通信方式支持:http、ws、RabbitMQ--消息队列。

插件接口如下:初始化、销毁、创建会话、处理消息--跟client通信、开始媒体、处理rtp包、rtcp包、结束媒体、销毁会话等。
- /* Plugin setup */
- static janus_plugin janus_videoroom_plugin =
- JANUS_PLUGIN_INIT (
- .init = janus_videoroom_init,
- .destroy = janus_videoroom_destroy,
- ...
-
- .create_session = janus_videoroom_create_session,
- .handle_message = janus_videoroom_handle_message,
- .setup_media = janus_videoroom_setup_media,
- .incoming_rtp = janus_videoroom_incoming_rtp,
- .incoming_rtcp = janus_videoroom_incoming_rtcp,
- .incoming_data = janus_videoroom_incoming_data,
- .slow_link = janus_videoroom_slow_link,
- .hangup_media = janus_videoroom_hangup_media,
- .destroy_session = janus_videoroom_destroy_session,
- );
P2P用了libnice库,创建线程、请求消息放到队列,用了glib库。
主线程、"timeout watchdog"--2秒检测session存活周期、"sessions requests"--派发请求、
线程池--处理"message"消息,新起线程。(是处理sdp复杂,需要起线程?)
比如:{"janus":"message","body":{"audio":true,"video":true,"videocodec":"h264"},"transaction":"f4p3bK72QD3e","jsep":{"type":"offer","sdp":"v=..."}
一般请求,直接处理了。
janus_ice_handle_thread:janus.jcfg的event_loops,默认是注掉的。
收到attach消息,新起一个janus_ice_handle_thread。
个数也可以限制。实际中当然要限制个数啊,比如100个用户就100个线程。
创建Room,插入队列:g_hash_table_insert(rooms, videoroom->room_id_str,videoroom);
创建会话,获得session_id,插入队列:g_hash_table_insert(sessions, handle, session);
传入session_id,会获取ice的handle_id,处理音视频流的。
handle_id = janus_ice_handle_create(session, opaque_id, token_value);
在一个Room,如何区分发送的流,和接收的多路流?
{GHashTable *participants;
}janus_videoroom;
- typedef struct janus_videoroom_session {
- janus_plugin_session *handle;
- janus_videoroom_p_type participant_type;
- gpointer participant;
- ...
- janus_mutex mutex;
- janus_refcount ref;
- } janus_videoroom_session;
-
- typedef struct janus_videoroom_publisher {
- janus_videoroom_session *session;
- janus_videoroom *room;
- ...
- }janus_videoroom_publisher;
-
- typedef struct janus_videoroom {
- guint64 room_id;
- }
-
- typedef struct janus_videoroom_publisher_stream {
- janus_videoroom_publisher *publisher; /* Publisher instance this stream belongs to */
- janus_videoroom_media type;
- ...
- GHashTable *rtp_forwarders;
- }
-
- typedef struct janus_videoroom_subscriber {
- janus_videoroom_session *session;
- janus_videoroom *room; /* Room */
- }
-
- typedef struct janus_videoroom_subscriber_stream {
- janus_videoroom_subscriber *subscriber; /* Subscriber instance this stream belongs to */
- GSList *publisher_streams;
- }
-
1 单端口的问题:所有推拉流,DTLS和音视频流都用一个端口。
因为暴露多个端口不安全,而且多端口不好负载均衡。
用ice-ufrag、ice-pwd区分音视频的流。如果用ssrc,一般音视频ssrc不同。
2 集群:信令和媒体需要分离。
容错处理、负载均衡、级联。