Janus gateway 架构分析

Table of Contents

It is a draft and not been done...

主要流程

  1. 启动 Janus
    1. 启动线程池,来处理来自客户端的请求和数据
    2. 加载事件处理器
    3. 加载所有插件
    4. 加载所有传输

配置文件

.jcfg 是一种传统的 .ini 增强版的格式 libconfig format

Plugin

user->janus: create session
janus-->user: session_123
user->janus: attach to plugin on session_123
janus-->plugin1: new user instance
user->janus: attach handle xyz
janus->plugin1: create_session()
user->janus: send_message
janus->plugin1: handle_message()
plugin1-->janus: ack
janus-->user: ack
plugin1->janus: push_event()
janus->user: event

Plugin initiatialization

  • init()
  • destroy()
  • get_name()
  • get_version()

Plugin Session management

  • create_session()
  • handle_message()
  • handle_admin_message()
  • setup_media()
  • incoming_rtp()
  • incoming_rtcp()
  • incoming_data()
  • slow_link()
  • hangup_media()
  • query_session()
  • destroy_session()

Plugin interact with core

  • push_event()
  • relay_rtp()
  • relay_rtcp()
  • relay_data()
  • close_pc()
  • end_session()
  • event_is_enabled()
  • notify_event()

Plugin events management

  • incoming_event()
  • handle_request()

Echo Test Plugin

Request

{
        "audio" : true|false,
        "audiocodec" : "<optional codec name; only used when creating a PeerConnection>",
        "video" : true|false,
        "videocodec" : "<optional codec name; only used when creating a PeerConnection>",
        "videoprofile" : "<optional codec profile to force; only used when creating a PeerConnection, only valid for VP9 (0 or 2) and H.264 (e.g., 42e01f)>",
        "bitrate" : <numeric bitrate value>,
        "record" : true|false,
        "filename" : <base path/filename to use for the recording>,
        "substream" : <substream to receive (0-2), in case simulcasting is enabled>,
        "temporal" : <temporal layers to receive (0-2), in case simulcasting is enabled>
}

janus_echotest.c

janus_plugin *create(void);
int janus_echotest_init(janus_callbacks *callback, const char *config_path);
void janus_echotest_destroy(void);
int janus_echotest_get_api_compatibility(void);
int janus_echotest_get_version(void);
const char *janus_echotest_get_version_string(void);
const char *janus_echotest_get_description(void);
const char *janus_echotest_get_name(void);
const char *janus_echotest_get_author(void);
const char *janus_echotest_get_package(void);
void janus_echotest_create_session(janus_plugin_session *handle, int *error);
struct janus_plugin_result *janus_echotest_handle_message(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep);
json_t *janus_echotest_handle_admin_message(json_t *message);
void janus_echotest_setup_media(janus_plugin_session *handle);
void janus_echotest_incoming_rtp(janus_plugin_session *handle, janus_plugin_rtp *packet);
void janus_echotest_incoming_rtcp(janus_plugin_session *handle, janus_plugin_rtcp *packet);
void janus_echotest_incoming_data(janus_plugin_session *handle, janus_plugin_data *packet);
void janus_echotest_data_ready(janus_plugin_session *handle);
void janus_echotest_slow_link(janus_plugin_session *handle, int uplink, int video);
void janus_echotest_hangup_media(janus_plugin_session *handle);
void janus_echotest_destroy_session(janus_plugin_session *handle, int *error);
json_t *janus_echotest_query_session(janus_plugin_session *handle);

Protocols

Collaboration graph

Dependencies

Glib

GLib is a general-purpose, portable utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a mainloop abstraction, and so on.

Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Category: Uncategorized