Fork me on GitHub
Data Structures | Macros | Typedefs | Functions
janus_textroom.c File Reference

Janus TextRoom plugin. More...

#include "plugins/plugin.h"
#include <jansson.h>
#include "debug.h"
#include "apierror.h"
#include "config.h"
#include "mutex.h"
#include "utils.h"
Include dependency graph for janus_textroom.c:

Data Structures

struct  janus_textroom_message
 
struct  janus_textroom_room
 
struct  janus_textroom_session
 
struct  janus_textroom_participant
 

Macros

#define JANUS_TEXTROOM_VERSION   2
 
#define JANUS_TEXTROOM_VERSION_STRING   "0.0.2"
 
#define JANUS_TEXTROOM_DESCRIPTION   "This is a plugin implementing a text-only room for Janus, using DataChannels."
 
#define JANUS_TEXTROOM_NAME   "JANUS TextRoom plugin"
 
#define JANUS_TEXTROOM_AUTHOR   "Meetecho s.r.l."
 
#define JANUS_TEXTROOM_PACKAGE   "janus.plugin.textroom"
 
#define sdp_template
 
#define JANUS_TEXTROOM_ERROR_NO_MESSAGE   411
 
#define JANUS_TEXTROOM_ERROR_INVALID_JSON   412
 
#define JANUS_TEXTROOM_ERROR_MISSING_ELEMENT   413
 
#define JANUS_TEXTROOM_ERROR_INVALID_ELEMENT   414
 
#define JANUS_TEXTROOM_ERROR_INVALID_REQUEST   415
 
#define JANUS_TEXTROOM_ERROR_ALREADY_SETUP   416
 
#define JANUS_TEXTROOM_ERROR_NO_SUCH_ROOM   417
 
#define JANUS_TEXTROOM_ERROR_ROOM_EXISTS   418
 
#define JANUS_TEXTROOM_ERROR_UNAUTHORIZED   419
 
#define JANUS_TEXTROOM_ERROR_USERNAME_EXISTS   420
 
#define JANUS_TEXTROOM_ERROR_ALREADY_IN_ROOM   421
 
#define JANUS_TEXTROOM_ERROR_NOT_IN_ROOM   422
 
#define JANUS_TEXTROOM_ERROR_NO_SUCH_USER   423
 
#define JANUS_TEXTROOM_ERROR_UNKNOWN_ERROR   499
 

Typedefs

typedef struct janus_textroom_message janus_textroom_message
 
typedef struct janus_textroom_room janus_textroom_room
 
typedef struct janus_textroom_session janus_textroom_session
 
typedef struct janus_textroom_participant janus_textroom_participant
 

Functions

janus_plugincreate (void)
 
int janus_textroom_init (janus_callbacks *callback, const char *config_path)
 
void janus_textroom_destroy (void)
 
int janus_textroom_get_api_compatibility (void)
 
int janus_textroom_get_version (void)
 
const char * janus_textroom_get_version_string (void)
 
const char * janus_textroom_get_description (void)
 
const char * janus_textroom_get_name (void)
 
const char * janus_textroom_get_author (void)
 
const char * janus_textroom_get_package (void)
 
void janus_textroom_create_session (janus_plugin_session *handle, int *error)
 
struct janus_plugin_resultjanus_textroom_handle_message (janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep)
 
void janus_textroom_setup_media (janus_plugin_session *handle)
 
void janus_textroom_incoming_rtp (janus_plugin_session *handle, int video, char *buf, int len)
 
void janus_textroom_incoming_rtcp (janus_plugin_session *handle, int video, char *buf, int len)
 
void janus_textroom_incoming_data (janus_plugin_session *handle, char *buf, int len)
 
void janus_textroom_slow_link (janus_plugin_session *handle, int uplink, int video)
 
void janus_textroom_hangup_media (janus_plugin_session *handle)
 
void janus_textroom_destroy_session (janus_plugin_session *handle, int *error)
 
json_tjanus_textroom_query_session (janus_plugin_session *handle)
 
janus_plugin_resultjanus_textroom_handle_incoming_request (janus_plugin_session *handle, char *text, json_t *json, gboolean internal)
 

Detailed Description

Janus TextRoom plugin.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

This is a plugin implementing a DataChannel only text room. As such, it does NOT support or negotiate audio or video, but only data channels, in order to provide text broadcasting features. The plugin allows users to join multiple text-only rooms via a single PeerConnection. Users can send messages either to a room in general (broadcasting), or to individual users (whispers). This plugin can be used within the context of any application that needs real-time text broadcasting (e.g., chatrooms, but not only).

The only message that is typically sent to the plugin through the Janus API is a "setup" message, by which the user initializes the PeerConnection itself. Apart from that, all other messages can be exchanged directly via Data Channels. For room management purposes, though, requests like "create", "edit", "destroy", "list" and "exists" are available through the Janus API as well: notice that in this case you'll have to use "request" and not "textroom" as the name of the request.

Each room can also be configured with an HTTP backend to contact for incoming messages. If configured, messages addressed to that room will also be forwarded, by means of an HTTP POST, to the specified address. Notice that this will only work if libcurl was available when configuring and installing Janus.

Note
This plugin is only meant to showcase what you can do with data channels involving multiple participants at the same time. While functional, it's not inherently better or faster than doing the same thing using the Janus API messaging itself (e.g., as part of the plugin API messaging) or using existing instant messaging protocols (e.g., Jabber). In fact, while data channels are being used, you're still going through a server, so it's not really peer-to-peer. That said, the plugin can be useful if you don't plan to use any other infrastructure than Janus, and yet you also want to have text-based communication (e.g., to add a chatroom to an audio or video conference).

Notice that, in general, all users can create rooms. If you want to limit this functionality, you can configure an admin admin_key in the plugin settings. When configured, only "create" requests that include the correct admin_key value in an "admin_key" property will succeed, and will be rejected otherwise.

Text Room API

TBD.

plugins

Macro Definition Documentation

◆ JANUS_TEXTROOM_AUTHOR

#define JANUS_TEXTROOM_AUTHOR   "Meetecho s.r.l."

◆ JANUS_TEXTROOM_DESCRIPTION

#define JANUS_TEXTROOM_DESCRIPTION   "This is a plugin implementing a text-only room for Janus, using DataChannels."

◆ JANUS_TEXTROOM_ERROR_ALREADY_IN_ROOM

#define JANUS_TEXTROOM_ERROR_ALREADY_IN_ROOM   421

◆ JANUS_TEXTROOM_ERROR_ALREADY_SETUP

#define JANUS_TEXTROOM_ERROR_ALREADY_SETUP   416

◆ JANUS_TEXTROOM_ERROR_INVALID_ELEMENT

#define JANUS_TEXTROOM_ERROR_INVALID_ELEMENT   414

◆ JANUS_TEXTROOM_ERROR_INVALID_JSON

#define JANUS_TEXTROOM_ERROR_INVALID_JSON   412

◆ JANUS_TEXTROOM_ERROR_INVALID_REQUEST

#define JANUS_TEXTROOM_ERROR_INVALID_REQUEST   415

◆ JANUS_TEXTROOM_ERROR_MISSING_ELEMENT

#define JANUS_TEXTROOM_ERROR_MISSING_ELEMENT   413

◆ JANUS_TEXTROOM_ERROR_NO_MESSAGE

#define JANUS_TEXTROOM_ERROR_NO_MESSAGE   411

◆ JANUS_TEXTROOM_ERROR_NO_SUCH_ROOM

#define JANUS_TEXTROOM_ERROR_NO_SUCH_ROOM   417

◆ JANUS_TEXTROOM_ERROR_NO_SUCH_USER

#define JANUS_TEXTROOM_ERROR_NO_SUCH_USER   423

◆ JANUS_TEXTROOM_ERROR_NOT_IN_ROOM

#define JANUS_TEXTROOM_ERROR_NOT_IN_ROOM   422

◆ JANUS_TEXTROOM_ERROR_ROOM_EXISTS

#define JANUS_TEXTROOM_ERROR_ROOM_EXISTS   418

◆ JANUS_TEXTROOM_ERROR_UNAUTHORIZED

#define JANUS_TEXTROOM_ERROR_UNAUTHORIZED   419

◆ JANUS_TEXTROOM_ERROR_UNKNOWN_ERROR

#define JANUS_TEXTROOM_ERROR_UNKNOWN_ERROR   499

◆ JANUS_TEXTROOM_ERROR_USERNAME_EXISTS

#define JANUS_TEXTROOM_ERROR_USERNAME_EXISTS   420

◆ JANUS_TEXTROOM_NAME

#define JANUS_TEXTROOM_NAME   "JANUS TextRoom plugin"

◆ JANUS_TEXTROOM_PACKAGE

#define JANUS_TEXTROOM_PACKAGE   "janus.plugin.textroom"

◆ JANUS_TEXTROOM_VERSION

#define JANUS_TEXTROOM_VERSION   2

◆ JANUS_TEXTROOM_VERSION_STRING

#define JANUS_TEXTROOM_VERSION_STRING   "0.0.2"

◆ sdp_template

#define sdp_template
Value:
"v=0\r\n" \
"o=- %"SCNu64" %"SCNu64" IN IP4 127.0.0.1\r\n" /* We need current time here */ \
"s=Janus TextRoom plugin\r\n" \
"t=0 0\r\n" \
"m=application 1 DTLS/SCTP 5000\r\n" \
"c=IN IP4 1.1.1.1\r\n" \
"a=sctpmap:5000 webrtc-datachannel 16\r\n"

Typedef Documentation

◆ janus_textroom_message

◆ janus_textroom_participant

◆ janus_textroom_room

◆ janus_textroom_session

Function Documentation

◆ create()

janus_plugin* create ( void  )

◆ janus_textroom_create_session()

void janus_textroom_create_session ( janus_plugin_session handle,
int *  error 
)

◆ janus_textroom_destroy()

void janus_textroom_destroy ( void  )

◆ janus_textroom_destroy_session()

void janus_textroom_destroy_session ( janus_plugin_session handle,
int *  error 
)

◆ janus_textroom_get_api_compatibility()

int janus_textroom_get_api_compatibility ( void  )

◆ janus_textroom_get_author()

const char * janus_textroom_get_author ( void  )

◆ janus_textroom_get_description()

const char * janus_textroom_get_description ( void  )

◆ janus_textroom_get_name()

const char * janus_textroom_get_name ( void  )

◆ janus_textroom_get_package()

const char * janus_textroom_get_package ( void  )

◆ janus_textroom_get_version()

int janus_textroom_get_version ( void  )

◆ janus_textroom_get_version_string()

const char * janus_textroom_get_version_string ( void  )

◆ janus_textroom_handle_incoming_request()

janus_plugin_result * janus_textroom_handle_incoming_request ( janus_plugin_session handle,
char *  text,
json_t json,
gboolean  internal 
)

◆ janus_textroom_handle_message()

struct janus_plugin_result * janus_textroom_handle_message ( janus_plugin_session handle,
char *  transaction,
json_t message,
json_t jsep 
)

◆ janus_textroom_hangup_media()

void janus_textroom_hangup_media ( janus_plugin_session handle)

◆ janus_textroom_incoming_data()

void janus_textroom_incoming_data ( janus_plugin_session handle,
char *  buf,
int  len 
)

◆ janus_textroom_incoming_rtcp()

void janus_textroom_incoming_rtcp ( janus_plugin_session handle,
int  video,
char *  buf,
int  len 
)

◆ janus_textroom_incoming_rtp()

void janus_textroom_incoming_rtp ( janus_plugin_session handle,
int  video,
char *  buf,
int  len 
)

◆ janus_textroom_init()

int janus_textroom_init ( janus_callbacks callback,
const char *  config_path 
)

◆ janus_textroom_query_session()

json_t * janus_textroom_query_session ( janus_plugin_session handle)

◆ janus_textroom_setup_media()

void janus_textroom_setup_media ( janus_plugin_session handle)

◆ janus_textroom_slow_link()

void janus_textroom_slow_link ( janus_plugin_session handle,
int  uplink,
int  video 
)