Skip to content

Commit

Permalink
Ad-hoc thread for outgoing media/data
Browse files Browse the repository at this point in the history
Improved SSRC multiplexing (Plan B) in MCU
Per-participant recording in MCU through API
Configurable path for audiobridge recording
Attempt to fix failed replay SRTP error (NACK management)
Other fixes here and there
  • Loading branch information
meetecho committed Oct 9, 2014
1 parent 733724a commit bf24339
Show file tree
Hide file tree
Showing 9 changed files with 598 additions and 212 deletions.
6 changes: 4 additions & 2 deletions conf/janus.plugin.audiobridge.cfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
; description = This is my awesome room
; secret = <password needed for manipulating (e.g. destroying) the room>
; sampling_rate = <sampling rate> (e.g., 16000 for wideband mixing)
; record = yes/no (if yes, a raw mix of the recording will be saved in /tmp)
; record = true|false ( (whether this room should be recorded, default=false)
; record_file = /path/to/recording.wav (where to save the recording)

[1234]
description = Demo Room
secret = adminpwd
sampling_rate = 16000
record = yes
record = false
;record_file = /tmp/janus-audioroom-1234.wav
483 changes: 318 additions & 165 deletions ice.c

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ typedef struct janus_ice_handle janus_ice_handle;
typedef struct janus_ice_stream janus_ice_stream;
/*! \brief Janus ICE component */
typedef struct janus_ice_component janus_ice_component;
/*! \brief Janus enqueued (S)RTP/(S)RTCP packet to send */
typedef struct janus_ice_queued_packet janus_ice_queued_packet;


#define JANUS_ICE_HANDLE_WEBRTC_PROCESSING_OFFER (1 << 0)
Expand Down Expand Up @@ -125,6 +127,10 @@ struct janus_ice_handle {
gchar *local_sdp;
/*! \brief SDP received by the peer (just for debugging purposes) */
gchar *remote_sdp;
/*! \brief Queue of outgoing packets to send */
GAsyncQueue *queued_packets;
/*! \brief GLib thread for sending outgoing packets */
GThread *send_thread;
/*! \brief Mutex to lock/unlock the ICE session */
janus_mutex mutex;
};
Expand Down Expand Up @@ -193,6 +199,23 @@ struct janus_ice_component {
janus_mutex mutex;
};

#define JANUS_ICE_PACKET_AUDIO 0
#define JANUS_ICE_PACKET_VIDEO 1
#define JANUS_ICE_PACKET_DATA 2
/*! \brief Janus enqueued (S)RTP/(S)RTCP packet to send */
struct janus_ice_queued_packet {
/*! \brief Packet data */
char *data;
/*! \brief Packet length */
gint length;
/*! \brief Type of data (audio/video/data, or RTCP related to any of them) */
gint type;
/*! \brief Whether this is an RTCP message or not */
gboolean control;
/*! \brief Whether the data is already encrypted or not */
gboolean encrypted;
};

/** @name Janus ICE handle methods
*/
///@{
Expand Down Expand Up @@ -299,6 +322,8 @@ void janus_ice_incoming_data(janus_ice_handle *handle, char *buffer, int length)
///@{
/*! \brief Janus ICE handle thread */
void *janus_ice_thread(void *data);
/*! \brief Janus ICE thread for sending outgoing packets */
void *janus_ice_send_thread(void *data);
/*! \brief Method to locally set up the ICE candidates (initialization and gathering)
* @param[in] handle The Janus ICE handle this method refers to
* @param[in] offer Whether this is for an OFFER or an ANSWER
Expand Down
20 changes: 19 additions & 1 deletion plugins/janus_audiobridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
description = This is my awesome room
secret = <password needed for manipulating (e.g. destroying) the room>
sampling_rate = <sampling rate> (e.g., 16000 for wideband mixing)
record = yes/no (if yes, a raw mix of the recording will be saved)
record_file = /path/to/recording.wav (where to save the recording)
\endverbatim
*
* \ingroup plugins
Expand Down Expand Up @@ -144,6 +146,7 @@ typedef struct janus_audiobridge_room {
gchar *room_secret; /* Secret needed to manipulate (e.g., destroy) this room */
uint32_t sampling_rate; /* Sampling rate of the mix (e.g., 16000 for wideband) */
gboolean record; /* Whether this room has to be recorded or not */
gchar *record_file; /* Path of the recording file */
FILE *recording; /* File to record the room into */
gboolean destroy; /* Value to flag the room for destruction */
GHashTable *participants; /* Map of participants */
Expand Down Expand Up @@ -274,6 +277,7 @@ int janus_audiobridge_init(janus_callbacks *callback, const char *config_path) {
janus_config_item *sampling = janus_config_get_item(cat, "sampling_rate");
janus_config_item *secret = janus_config_get_item(cat, "secret");
janus_config_item *record = janus_config_get_item(cat, "record");
janus_config_item *recfile = janus_config_get_item(cat, "record_file");
if(sampling == NULL || sampling->value == NULL) {
JANUS_LOG(LOG_ERR, "Can't add the audio room, missing mandatory information...\n");
cat = cat->next;
Expand Down Expand Up @@ -307,6 +311,8 @@ int janus_audiobridge_init(janus_callbacks *callback, const char *config_path) {
audiobridge->record = FALSE;
if(record && record->value && !strcasecmp(record->value, "yes"))
audiobridge->record = TRUE;
if(recfile && recfile->value)
audiobridge->record_file = g_strdup(recfile->value);
audiobridge->recording = NULL;
audiobridge->destroy = 0;
audiobridge->participants = g_hash_table_new(NULL, NULL);
Expand Down Expand Up @@ -670,6 +676,13 @@ static void *janus_audiobridge_handler(void *data) {
g_snprintf(error_cause, 512, "Invalid value (record should be a boolean)");
goto error;
}
json_t *recfile = json_object_get(root, "record_file");
if(recfile && !json_is_string(record)) {
JANUS_LOG(LOG_ERR, "Invalid element (record_file should be a string)\n");
error_code = JANUS_AUDIOBRIDGE_ERROR_INVALID_ELEMENT;
g_snprintf(error_cause, 512, "Invalid value (record_file should be a string)");
goto error;
}
guint64 room_id = 0;
json_t *room = json_object_get(root, "room");
if(room && !json_is_integer(room)) {
Expand Down Expand Up @@ -742,6 +755,8 @@ static void *janus_audiobridge_handler(void *data) {
audiobridge->record = FALSE;
if(record && json_is_true(record))
audiobridge->record = TRUE;
if(recfile)
audiobridge->record_file = g_strdup(json_string_value(recfile));
audiobridge->recording = NULL;
audiobridge->destroy = 0;
audiobridge->participants = g_hash_table_new(NULL, NULL);
Expand Down Expand Up @@ -1218,7 +1233,10 @@ static void *janus_audiobridge_mixer_thread(void *data) {
/* Do we need to record the mix? */
if(audiobridge->record) {
char filename[255];
g_snprintf(filename, 255, "/tmp/janus-audioroom-%"SCNu64".wav", audiobridge->room_id);
if(audiobridge->record_file)
g_snprintf(filename, 255, "%s", audiobridge->record_file);
else
g_snprintf(filename, 255, "/tmp/janus-audioroom-%"SCNu64".wav", audiobridge->room_id);
audiobridge->recording = fopen(filename, "wb");
if(audiobridge->recording == NULL) {
JANUS_LOG(LOG_WARN, "Recording requested, but could NOT open file %s for writing...\n", filename);
Expand Down
2 changes: 0 additions & 2 deletions plugins/janus_echotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ void janus_echotest_incoming_rtcp(janus_plugin_session *handle, int video, char
}
if(session->destroy)
return;
if((!video && !session->audio_active) || (video && !session->video_active))
len = janus_rtcp_remove_nacks(buf, len);
if(session->bitrate > 0)
janus_rtcp_cap_remb(buf, len, session->bitrate);
gateway->relay_rtcp(handle, video, buf, len);
Expand Down
2 changes: 0 additions & 2 deletions plugins/janus_videocall.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ void janus_videocall_incoming_rtcp(janus_plugin_session *handle, int video, char
}
if(session->destroy || session->peer->destroy)
return;
if((!video && !session->audio_active) || (video && !session->video_active))
len = janus_rtcp_remove_nacks(buf, len);
if(session->bitrate > 0)
janus_rtcp_cap_remb(buf, len, session->bitrate);
gateway->relay_rtcp(session->peer->handle, video, buf, len);
Expand Down
Loading

0 comments on commit bf24339

Please sign in to comment.