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

Janus EchoTest plugin. More...

#include "plugin.h"
#include <jansson.h>
#include "../debug.h"
#include "../apierror.h"
#include "../config.h"
#include "../mutex.h"
#include "../record.h"
#include "../rtp.h"
#include "../rtcp.h"
#include "../sdp-utils.h"
#include "../utils.h"
Include dependency graph for janus_echotest.c:

Data Structures

struct  janus_echotest_message
 
struct  janus_echotest_session
 

Macros

#define JANUS_ECHOTEST_VERSION   7
 
#define JANUS_ECHOTEST_VERSION_STRING   "0.0.7"
 
#define JANUS_ECHOTEST_DESCRIPTION   "This is a trivial EchoTest plugin for Janus, just used to showcase the plugin interface."
 
#define JANUS_ECHOTEST_NAME   "JANUS EchoTest plugin"
 
#define JANUS_ECHOTEST_AUTHOR   "Meetecho s.r.l."
 
#define JANUS_ECHOTEST_PACKAGE   "janus.plugin.echotest"
 
#define JANUS_ECHOTEST_ERROR_NO_MESSAGE   411
 
#define JANUS_ECHOTEST_ERROR_INVALID_JSON   412
 
#define JANUS_ECHOTEST_ERROR_INVALID_ELEMENT   413
 
#define JANUS_ECHOTEST_ERROR_INVALID_SDP   414
 

Typedefs

typedef struct janus_echotest_message janus_echotest_message
 
typedef struct janus_echotest_session janus_echotest_session
 

Functions

janus_plugincreate (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_resultjanus_echotest_handle_message (janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep)
 
void janus_echotest_setup_media (janus_plugin_session *handle)
 
void janus_echotest_incoming_rtp (janus_plugin_session *handle, int video, char *buf, int len)
 
void janus_echotest_incoming_rtcp (janus_plugin_session *handle, int video, char *buf, int len)
 
void janus_echotest_incoming_data (janus_plugin_session *handle, char *buf, int len)
 
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_tjanus_echotest_query_session (janus_plugin_session *handle)
 

Detailed Description

Janus EchoTest plugin.

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

This is a trivial EchoTest plugin for Janus, just used to showcase the plugin interface. A peer attaching to this plugin will receive back the same RTP packets and RTCP messages he sends: the RTCP messages, of course, would be modified on the way by the gateway to make sure they are coherent with the involved SSRCs. In order to demonstrate how peer-provided messages can change the behaviour of a plugin, this plugin implements a simple API based on three messages:

  1. a message to enable/disable audio (that is, to tell the plugin whether incoming audio RTP packets need to be sent back or discarded);
  2. a message to enable/disable video (that is, to tell the plugin whether incoming video RTP packets need to be sent back or discarded);
  3. a message to cap the bitrate (which would modify incoming RTCP REMB messages before sending them back, in order to trick the peer into thinking the available bandwidth is different).

Echo Test API

There's a single unnamed request you can send and it's asynchronous, which means all responses (successes and errors) will be delivered as events with the same transaction.

The request has to be formatted as follows. All the attributes are optional, so any request can contain a subset of them:

{
        "audio" : true|false,
        "video" : true|false,
        "bitrate" : <numeric bitrate value>,
        "record" : true|false,
        "filename" : <base path/filename to use for the recording>
}

audio instructs the plugin to do or do not bounce back audio frames; video does the same for video; bitrate caps the bandwidth to force on the browser encoding side (e.g., 128000 for 128kbps).

The first request must be sent together with a JSEP offer to negotiate a PeerConnection: a JSEP answer will be provided with the asynchronous response notification. Subsequent requests (e.g., to dynamically manipulate the bitrate while testing) have to be sent without any JSEP payload attached.

A successful request will result in an ok event:

{
        "echotest" : "event",
        "result": "ok"
}

An error instead will provide both an error code and a more verbose description of the cause of the issue:

{
        "echotest" : "event",
        "error_code" : <numeric ID, check Macros below>,
        "error" : "<error description as a string>"
}

If the plugin detects a loss of the associated PeerConnection, a "done" notification is triggered to inform the application the Echo Test session is over:

{
        "echotest" : "event",
        "result": "done"
}

plugins

Macro Definition Documentation

◆ JANUS_ECHOTEST_AUTHOR

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

◆ JANUS_ECHOTEST_DESCRIPTION

#define JANUS_ECHOTEST_DESCRIPTION   "This is a trivial EchoTest plugin for Janus, just used to showcase the plugin interface."

◆ JANUS_ECHOTEST_ERROR_INVALID_ELEMENT

#define JANUS_ECHOTEST_ERROR_INVALID_ELEMENT   413

◆ JANUS_ECHOTEST_ERROR_INVALID_JSON

#define JANUS_ECHOTEST_ERROR_INVALID_JSON   412

◆ JANUS_ECHOTEST_ERROR_INVALID_SDP

#define JANUS_ECHOTEST_ERROR_INVALID_SDP   414

◆ JANUS_ECHOTEST_ERROR_NO_MESSAGE

#define JANUS_ECHOTEST_ERROR_NO_MESSAGE   411

◆ JANUS_ECHOTEST_NAME

#define JANUS_ECHOTEST_NAME   "JANUS EchoTest plugin"

◆ JANUS_ECHOTEST_PACKAGE

#define JANUS_ECHOTEST_PACKAGE   "janus.plugin.echotest"

◆ JANUS_ECHOTEST_VERSION

#define JANUS_ECHOTEST_VERSION   7

◆ JANUS_ECHOTEST_VERSION_STRING

#define JANUS_ECHOTEST_VERSION_STRING   "0.0.7"

Typedef Documentation

◆ janus_echotest_message

◆ janus_echotest_session

Function Documentation

◆ create()

janus_plugin* create ( void  )

◆ janus_echotest_create_session()

void janus_echotest_create_session ( janus_plugin_session handle,
int *  error 
)

◆ janus_echotest_destroy()

void janus_echotest_destroy ( void  )

◆ janus_echotest_destroy_session()

void janus_echotest_destroy_session ( janus_plugin_session handle,
int *  error 
)

◆ janus_echotest_get_api_compatibility()

int janus_echotest_get_api_compatibility ( void  )

◆ janus_echotest_get_author()

const char * janus_echotest_get_author ( void  )

◆ janus_echotest_get_description()

const char * janus_echotest_get_description ( void  )

◆ janus_echotest_get_name()

const char * janus_echotest_get_name ( void  )

◆ janus_echotest_get_package()

const char * janus_echotest_get_package ( void  )

◆ janus_echotest_get_version()

int janus_echotest_get_version ( void  )

◆ janus_echotest_get_version_string()

const char * janus_echotest_get_version_string ( void  )

◆ janus_echotest_handle_message()

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

◆ janus_echotest_hangup_media()

void janus_echotest_hangup_media ( janus_plugin_session handle)

◆ janus_echotest_incoming_data()

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

◆ janus_echotest_incoming_rtcp()

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

◆ janus_echotest_incoming_rtp()

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

◆ janus_echotest_init()

int janus_echotest_init ( janus_callbacks callback,
const char *  config_path 
)

◆ janus_echotest_query_session()

json_t * janus_echotest_query_session ( janus_plugin_session handle)

◆ janus_echotest_setup_media()

void janus_echotest_setup_media ( janus_plugin_session handle)

◆ janus_echotest_slow_link()

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