Janus VoiceMail plugin. More...
#include "plugin.h"
#include <jansson.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <ogg/ogg.h>
#include "../debug.h"
#include "../apierror.h"
#include "../config.h"
#include "../mutex.h"
#include "../rtp.h"
#include "../utils.h"
Data Structures | |
struct | janus_voicemail_message |
struct | janus_voicemail_session |
Macros | |
#define | JANUS_VOICEMAIL_VERSION 6 |
#define | JANUS_VOICEMAIL_VERSION_STRING "0.0.6" |
#define | JANUS_VOICEMAIL_DESCRIPTION "This is a plugin implementing a very simple VoiceMail service for Janus, recording Opus streams." |
#define | JANUS_VOICEMAIL_NAME "JANUS VoiceMail plugin" |
#define | JANUS_VOICEMAIL_AUTHOR "Meetecho s.r.l." |
#define | JANUS_VOICEMAIL_PACKAGE "janus.plugin.voicemail" |
#define | sdp_template |
#define | JANUS_VOICEMAIL_ERROR_UNKNOWN_ERROR 499 |
#define | JANUS_VOICEMAIL_ERROR_NO_MESSAGE 460 |
#define | JANUS_VOICEMAIL_ERROR_INVALID_JSON 461 |
#define | JANUS_VOICEMAIL_ERROR_INVALID_REQUEST 462 |
#define | JANUS_VOICEMAIL_ERROR_MISSING_ELEMENT 463 |
#define | JANUS_VOICEMAIL_ERROR_INVALID_ELEMENT 464 |
#define | JANUS_VOICEMAIL_ERROR_ALREADY_RECORDING 465 |
#define | JANUS_VOICEMAIL_ERROR_IO_ERROR 466 |
#define | JANUS_VOICEMAIL_ERROR_LIBOGG_ERROR 467 |
#define | JANUS_VOICEMAIL_ERROR_INVALID_STATE 468 |
Typedefs | |
typedef struct janus_voicemail_message | janus_voicemail_message |
typedef struct janus_voicemail_session | janus_voicemail_session |
Janus VoiceMail plugin.
This is a plugin implementing a very simple VoiceMail service for Janus, specifically recording Opus streams. This means that it replies by providing in the SDP only support for Opus, and disabling video. When a peer contacts the plugin, the plugin starts recording the audio frames it receives and, after 10 seconds, it shuts the PeerConnection down and returns an URL to the recorded file.
Since an URL is returned, the plugin allows you to configure where the recordings whould be stored (e.g., a folder in your web server, writable by the plugin) and the base path to use when returning URLs (e.g., /my/recordings/ or http://www.example.com/my/recordings).
By default the plugin saves the recordings in the html
folder of this project, meaning that it can work out of the box with the VoiceMail demo we provide in the same folder.
The VoiceMail API supports just two requests, record
and stop
and they're both asynchronous, which means all responses (successes and errors) will be delivered as events with the same transaction.
record
will instruct the plugin to start recording, while stop
will make the recording stop before the 10 seconds have passed. Never send a JSEP offer with any of these requests: it's always the VoiceMail plugin that originates a JSEP offer, in response to a record
request, which means your application will only have to send a JSEP answer when that happens.
The record
request has to be formatted as follows:
{ "request" : "record" }
A successful request will result in an starting
status event:
{ "voicemail" : "event", "status": "starting" }
which will be followed by a started
as soon as the associated PeerConnection has been made available to the plugin:
{ "voicemail" : "event", "status": "started" }
An error instead would provide both an error code and a more verbose description of the cause of the issue:
{ "voicemail" : "event", "error_code" : <numeric ID, check Macros below>, "error" : "<error description as a string>" }
The stop
request instead has to be formatted as follows:
{ "request" : "stop" }
If the plugin detects a loss of the associated PeerConnection, whether as a result of a stop
request or because the 10 seconds passed, a done
status notification is triggered to inform the application the recording session is over, together with the path to the recording file itself:
{ "voicemail" : "event", "status" : "done", "recording : "<path to the .opus file>" }
#define JANUS_VOICEMAIL_AUTHOR "Meetecho s.r.l." |
#define JANUS_VOICEMAIL_DESCRIPTION "This is a plugin implementing a very simple VoiceMail service for Janus, recording Opus streams." |
#define JANUS_VOICEMAIL_ERROR_ALREADY_RECORDING 465 |
#define JANUS_VOICEMAIL_ERROR_INVALID_ELEMENT 464 |
#define JANUS_VOICEMAIL_ERROR_INVALID_JSON 461 |
#define JANUS_VOICEMAIL_ERROR_INVALID_REQUEST 462 |
#define JANUS_VOICEMAIL_ERROR_INVALID_STATE 468 |
#define JANUS_VOICEMAIL_ERROR_IO_ERROR 466 |
#define JANUS_VOICEMAIL_ERROR_LIBOGG_ERROR 467 |
#define JANUS_VOICEMAIL_ERROR_MISSING_ELEMENT 463 |
#define JANUS_VOICEMAIL_ERROR_NO_MESSAGE 460 |
#define JANUS_VOICEMAIL_ERROR_UNKNOWN_ERROR 499 |
#define JANUS_VOICEMAIL_NAME "JANUS VoiceMail plugin" |
#define JANUS_VOICEMAIL_PACKAGE "janus.plugin.voicemail" |
#define JANUS_VOICEMAIL_VERSION 6 |
#define JANUS_VOICEMAIL_VERSION_STRING "0.0.6" |
#define sdp_template |
typedef struct janus_voicemail_message janus_voicemail_message |
typedef struct janus_voicemail_session janus_voicemail_session |
janus_plugin* create | ( | void | ) |
void janus_voicemail_create_session | ( | janus_plugin_session * | handle, |
int * | error | ||
) |
void janus_voicemail_destroy | ( | void | ) |
void janus_voicemail_destroy_session | ( | janus_plugin_session * | handle, |
int * | error | ||
) |
int janus_voicemail_get_api_compatibility | ( | void | ) |
const char * janus_voicemail_get_author | ( | void | ) |
const char * janus_voicemail_get_description | ( | void | ) |
const char * janus_voicemail_get_name | ( | void | ) |
const char * janus_voicemail_get_package | ( | void | ) |
int janus_voicemail_get_version | ( | void | ) |
const char * janus_voicemail_get_version_string | ( | void | ) |
struct janus_plugin_result * janus_voicemail_handle_message | ( | janus_plugin_session * | handle, |
char * | transaction, | ||
json_t * | message, | ||
json_t * | jsep | ||
) |
void janus_voicemail_hangup_media | ( | janus_plugin_session * | handle | ) |
void janus_voicemail_incoming_rtcp | ( | janus_plugin_session * | handle, |
int | video, | ||
char * | buf, | ||
int | len | ||
) |
void janus_voicemail_incoming_rtp | ( | janus_plugin_session * | handle, |
int | video, | ||
char * | buf, | ||
int | len | ||
) |
int janus_voicemail_init | ( | janus_callbacks * | callback, |
const char * | config_path | ||
) |
json_t * janus_voicemail_query_session | ( | janus_plugin_session * | handle | ) |
void janus_voicemail_setup_media | ( | janus_plugin_session * | handle | ) |
void le16 | ( | unsigned char * | p, |
int | v | ||
) |
void le32 | ( | unsigned char * | p, |
int | v | ||
) |
int ogg_flush | ( | janus_voicemail_session * | session | ) |
int ogg_write | ( | janus_voicemail_session * | session | ) |
void op_free | ( | ogg_packet * | op | ) |
ogg_packet * op_from_pkt | ( | const unsigned char * | pkt, |
int | len | ||
) |
ogg_packet * op_opushead | ( | void | ) |
ogg_packet * op_opustags | ( | void | ) |