本文整理汇总了C++中JANUS_LOG函数的典型用法代码示例。如果您正苦于以下问题:C++ JANUS_LOG函数的具体用法?C++ JANUS_LOG怎么用?C++ JANUS_LOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JANUS_LOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: janus_rabbitmq_destroy
void janus_rabbitmq_destroy(void) {
if(!g_atomic_int_get(&initialized))
return;
g_atomic_int_set(&stopping, 1);
if(rmq_client) {
rmq_client->destroy = 1;
g_async_queue_push(rmq_client->messages, &exit_message);
if(rmq_client->in_thread)
g_thread_join(rmq_client->in_thread);
if(rmq_client->out_thread)
g_thread_join(rmq_client->out_thread);
if(rmq_client->rmq_conn && rmq_client->rmq_channel) {
amqp_channel_close(rmq_client->rmq_conn, rmq_client->rmq_channel, AMQP_REPLY_SUCCESS);
amqp_connection_close(rmq_client->rmq_conn, AMQP_REPLY_SUCCESS);
amqp_destroy_connection(rmq_client->rmq_conn);
}
}
g_free(rmq_client);
janus_transport_session_destroy(rmq_session);
g_free(rmqhost);
g_free(vhost);
g_free(username);
g_free(password);
g_free(janus_exchange);
g_free(to_janus);
g_free(from_janus);
g_free(to_janus_admin);
g_free(from_janus_admin);
g_free(ssl_cacert_file);
g_free(ssl_cert_file);
g_free(ssl_key_file);
g_atomic_int_set(&initialized, 0);
g_atomic_int_set(&stopping, 0);
JANUS_LOG(LOG_INFO, "%s destroyed!\n", JANUS_RABBITMQ_NAME);
}
示例2: g_snprintf
const char *janus_rtp_header_extension_get_from_id(const char *sdp, int id) {
if(!sdp || id < 0)
return NULL;
/* Look for the mapping */
char extmap[100];
g_snprintf(extmap, 100, "a=extmap:%d ", id);
const char *line = strstr(sdp, "m=");
while(line) {
char *next = strchr(line, '\n');
if(next) {
*next = '\0';
if(strstr(line, extmap)) {
/* Gotcha! */
char extension[100];
if(sscanf(line, "a=extmap:%d %s", &id, extension) == 2) {
*next = '\n';
if(strstr(extension, JANUS_RTP_EXTMAP_AUDIO_LEVEL))
return JANUS_RTP_EXTMAP_AUDIO_LEVEL;
if(strstr(extension, JANUS_RTP_EXTMAP_VIDEO_ORIENTATION))
return JANUS_RTP_EXTMAP_VIDEO_ORIENTATION;
if(strstr(extension, JANUS_RTP_EXTMAP_PLAYOUT_DELAY))
return JANUS_RTP_EXTMAP_PLAYOUT_DELAY;
if(strstr(extension, JANUS_RTP_EXTMAP_TOFFSET))
return JANUS_RTP_EXTMAP_TOFFSET;
if(strstr(extension, JANUS_RTP_EXTMAP_ABS_SEND_TIME))
return JANUS_RTP_EXTMAP_ABS_SEND_TIME;
if(strstr(extension, JANUS_RTP_EXTMAP_CC_EXTENSIONS))
return JANUS_RTP_EXTMAP_CC_EXTENSIONS;
JANUS_LOG(LOG_ERR, "Unsupported extension '%s'\n", extension);
return NULL;
}
}
*next = '\n';
}
line = next ? (next+1) : NULL;
}
return NULL;
}
示例3: janus_source_do_codec_negotiation
static gchar * janus_source_do_codec_negotiation(janus_source_session * session, gchar * orig_sdp)
{
gchar * sdp = NULL;
idilia_codec preferred_codec = janus_source_select_video_codec_by_priority_list(orig_sdp);
sdp = sdp_set_video_codec(orig_sdp, preferred_codec);
g_free(orig_sdp);
for (int stream = 0; stream < JANUS_SOURCE_STREAM_MAX; stream++)
{
if (stream == JANUS_SOURCE_STREAM_VIDEO) {
session->codec[stream] = sdp_get_video_codec(sdp);
}
else if (stream == JANUS_SOURCE_STREAM_AUDIO) {
session->codec[stream] = sdp_get_audio_codec(sdp);
}
session->codec_pt[stream] = sdp_get_codec_pt(sdp, session->codec[stream]);
JANUS_LOG(LOG_INFO, "Codec used: %s\n", get_codec_name(session->codec[stream]));
}
return sdp;
}
示例4: janus_videocall_destroy
void janus_videocall_destroy(void) {
if(!g_atomic_int_get(&initialized))
return;
g_atomic_int_set(&stopping, 1);
if(handler_thread != NULL) {
g_thread_join(handler_thread);
handler_thread = NULL;
}
if(watchdog != NULL) {
g_thread_join(watchdog);
watchdog = NULL;
}
/* FIXME We should destroy the sessions cleanly */
janus_mutex_lock(&sessions_mutex);
g_hash_table_destroy(sessions);
janus_mutex_unlock(&sessions_mutex);
g_async_queue_unref(messages);
messages = NULL;
sessions = NULL;
g_atomic_int_set(&initialized, 0);
g_atomic_int_set(&stopping, 0);
JANUS_LOG(LOG_INFO, "%s destroyed!\n", JANUS_VIDEOCALL_NAME);
}
示例5: janus_echotest_create_session
void janus_echotest_create_session(janus_plugin_session *handle, int *error) {
if(stopping || !initialized) {
*error = -1;
return;
}
janus_echotest_session *session = (janus_echotest_session *)calloc(1, sizeof(janus_echotest_session));
if(session == NULL) {
JANUS_LOG(LOG_FATAL, "Memory error!\n");
*error = -2;
return;
}
session->handle = handle;
session->audio_active = TRUE;
session->video_active = TRUE;
session->bitrate = 0; /* No limit */
session->destroyed = 0;
handle->plugin_handle = session;
janus_mutex_lock(&sessions_mutex);
g_hash_table_insert(sessions, handle, session);
janus_mutex_unlock(&sessions_mutex);
return;
}
示例6: janus_serial_incoming_rtp
void janus_serial_incoming_rtp(janus_plugin_session *handle, int video, char *buf, int len) {
if(handle == NULL || handle->stopped || g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized))
return;
/* Simple echo test */
if(gateway) {
/* Honour the audio/video active flags */
janus_serial_session *session = (janus_serial_session *)handle->plugin_handle;
if(!session) {
JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
return;
}
if(session->destroyed)
return;
if((!video && session->audio_active) || (video && session->video_active)) {
/* Save the frame if we're recording */
if(video && session->vrc)
janus_recorder_save_frame(session->vrc, buf, len);
else if(!video && session->arc)
janus_recorder_save_frame(session->arc, buf, len);
/* Send the frame back */
gateway->relay_rtp(handle, video, buf, len);
}
}
}
示例7: janus_serial_hangup_media
void janus_serial_hangup_media(janus_plugin_session *handle) {
JANUS_LOG(LOG_INFO, "No WebRTC media anymore\n");
if(g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized))
return;
janus_serial_session *session = (janus_serial_session *)handle->plugin_handle;
if(!session) {
JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
return;
}
if(session->destroyed)
return;
if(g_atomic_int_add(&session->hangingup, 1))
return;
/* Send an event to the browser and tell it's over */
json_t *event = json_object();
json_object_set_new(event, "serial", json_string("event"));
json_object_set_new(event, "result", json_string("done"));
char *event_text = json_dumps(event, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
json_decref(event);
JANUS_LOG(LOG_VERB, "Pushing event: %s\n", event_text);
int ret = gateway->push_event(handle, &janus_serial_plugin, NULL, event_text, NULL, NULL);
JANUS_LOG(LOG_VERB, " >> %d (%s)\n", ret, janus_get_api_error(ret));
g_free(event_text);
/* Get rid of the recorders, if available */
if(session->arc) {
janus_recorder_close(session->arc);
JANUS_LOG(LOG_INFO, "Closed audio recording %s\n", session->arc->filename ? session->arc->filename : "??");
janus_recorder_free(session->arc);
}
session->arc = NULL;
if(session->vrc) {
janus_recorder_close(session->vrc);
JANUS_LOG(LOG_INFO, "Closed video recording %s\n", session->vrc->filename ? session->vrc->filename : "??");
janus_recorder_free(session->vrc);
}
session->vrc = NULL;
/* Reset controls */
session->has_audio = FALSE;
session->has_video = FALSE;
session->audio_active = TRUE;
session->video_active = TRUE;
session->bitrate = 0;
}
示例8: janus_dtls_callback
/* DTLS alert callback */
void janus_dtls_callback(const SSL *ssl, int where, int ret) {
/* We only care about alerts */
if (!(where & SSL_CB_ALERT)) {
return;
}
janus_dtls_srtp *dtls = SSL_get_ex_data(ssl, 0);
if(!dtls) {
JANUS_LOG(LOG_ERR, "No DTLS session related to this alert...\n");
return;
}
janus_ice_component *component = dtls->component;
if(component == NULL) {
JANUS_LOG(LOG_ERR, "No ICE component related to this alert...\n");
return;
}
janus_ice_stream *stream = component->stream;
if(!stream) {
JANUS_LOG(LOG_ERR, "No ICE stream related to this alert...\n");
return;
}
janus_ice_handle *handle = stream->handle;
if(!handle) {
JANUS_LOG(LOG_ERR, "No ICE handle related to this alert...\n");
return;
}
JANUS_LOG(LOG_VERB, "[%"SCNu64"] DTLS alert triggered on stream %"SCNu16" (component %"SCNu16"), closing...\n", handle->handle_id, stream->stream_id, component->component_id);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING);
if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT)) {
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT);
if(handle->iceloop)
g_main_loop_quit(handle->iceloop);
janus_plugin *plugin = (janus_plugin *)handle->app;
if(plugin != NULL) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Telling the plugin about it (%s)\n", handle->handle_id, plugin->get_name());
if(plugin && plugin->hangup_media)
plugin->hangup_media(handle->app_handle);
janus_ice_notify_hangup(handle, "DTLS alert");
}
}
}
示例9: janus_pfunix_create_socket
/* Helper to create a named Unix Socket out of the path to link to */
static int janus_pfunix_create_socket(char *pfname, gboolean use_dgram) {
if(pfname == NULL)
return -1;
int fd = -1;
if(strlen(pfname) > UNIX_PATH_MAX) {
JANUS_LOG(LOG_WARN, "The provided path name (%s) is longer than %lu characters, it will be truncated\n", pfname, UNIX_PATH_MAX);
pfname[UNIX_PATH_MAX] = '\0';
}
/* Create socket */
int flags = use_dgram ? SOCK_DGRAM | SOCK_NONBLOCK : SOCK_SEQPACKET | SOCK_NONBLOCK;
fd = socket(use_dgram ? AF_UNIX : PF_UNIX, flags, 0);
if(fd < 0) {
JANUS_LOG(LOG_FATAL, "Unix Sockets %s creation failed: %d, %s\n", pfname, errno, strerror(errno));
} else {
/* Unlink before binding */
unlink(pfname);
/* Let's bind to the provided path now */
struct sockaddr_un address;
memset(&address, 0, sizeof(address));
address.sun_family = AF_UNIX;
g_snprintf(address.sun_path, UNIX_PATH_MAX, "%s", pfname);
JANUS_LOG(LOG_VERB, "Binding Unix Socket %s... (Janus API)\n", pfname);
if(bind(fd, (struct sockaddr *)&address, sizeof(address)) != 0) {
JANUS_LOG(LOG_FATAL, "Bind for Unix Socket %s failed: %d, %s\n", pfname, errno, strerror(errno));
close(fd);
fd = -1;
return fd;
}
if(!use_dgram) {
JANUS_LOG(LOG_VERB, "Listening on Unix Socket %s...\n", pfname);
if(listen(fd, 128) != 0) {
JANUS_LOG(LOG_FATAL, "Listening on Unix Socket %s failed: %d, %s\n", pfname, errno, strerror(errno));
close(fd);
fd = -1;
}
}
}
return fd;
}
示例10: janus_sctp_handle_send_failed_event
void janus_sctp_handle_send_failed_event(struct sctp_send_failed_event *ssfe) {
size_t i, n;
if(ssfe->ssfe_flags & SCTP_DATA_UNSENT) {
JANUS_LOG(LOG_VERB, "Unsent ");
}
if(ssfe->ssfe_flags & SCTP_DATA_SENT) {
JANUS_LOG(LOG_VERB, "Sent ");
}
if(ssfe->ssfe_flags & ~(SCTP_DATA_SENT | SCTP_DATA_UNSENT)) {
JANUS_LOG(LOG_VERB, "(flags = %x) ", ssfe->ssfe_flags);
}
JANUS_LOG(LOG_VERB, "message with PPID = %d, SID = %d, flags: 0x%04x due to error = 0x%08x",
ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
ssfe->ssfe_info.snd_flags, ssfe->ssfe_error);
n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event);
for(i = 0; i < n; i++) {
JANUS_LOG(LOG_VERB, " 0x%02x", ssfe->ssfe_data[i]);
}
JANUS_LOG(LOG_VERB, ".\n");
return;
}
示例11: JANUS_LOG
/* Transport creator */
janus_transport *create(void) {
JANUS_LOG(LOG_VERB, "%s created!\n", JANUS_WEBSOCKETS_NAME);
return &janus_websockets_transport;
}
示例12: janus_serial_slow_link
void janus_serial_slow_link(janus_plugin_session *handle, int uplink, int video) {
/* The core is informing us that our peer got or sent too many NACKs, are we pushing media too hard? */
if(handle == NULL || handle->stopped || g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized))
return;
janus_serial_session *session = (janus_serial_session *)handle->plugin_handle;
if(!session) {
JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
return;
}
if(session->destroyed)
return;
session->slowlink_count++;
if(uplink && !video && !session->audio_active) {
/* We're not relaying audio and the peer is expecting it, so NACKs are normal */
JANUS_LOG(LOG_VERB, "Getting a lot of NACKs (slow uplink) for audio, but that's expected, a configure disabled the audio forwarding\n");
} else if(uplink && video && !session->video_active) {
/* We're not relaying video and the peer is expecting it, so NACKs are normal */
JANUS_LOG(LOG_VERB, "Getting a lot of NACKs (slow uplink) for video, but that's expected, a configure disabled the video forwarding\n");
} else {
/* Slow uplink or downlink, maybe we set the bitrate cap too high? */
if(video) {
/* Halve the bitrate, but don't go too low... */
session->bitrate = session->bitrate > 0 ? session->bitrate : 512*1024;
session->bitrate = session->bitrate/2;
if(session->bitrate < 64*1024)
session->bitrate = 64*1024;
JANUS_LOG(LOG_WARN, "Getting a lot of NACKs (slow %s) for %s, forcing a lower REMB: %"SCNu64"\n",
uplink ? "uplink" : "downlink", video ? "video" : "audio", session->bitrate);
/* ... and send a new REMB back */
char rtcpbuf[200];
memset(rtcpbuf, 0, 200);
/* FIXME First put a RR (fake)... */
int rrlen = 32;
rtcp_rr *rr = (rtcp_rr *)&rtcpbuf;
rr->header.version = 2;
rr->header.type = RTCP_RR;
rr->header.rc = 1;
rr->header.length = htons((rrlen/4)-1);
/* ... then put a SDES... */
int sdeslen = janus_rtcp_sdes((char *)(&rtcpbuf)+rrlen, 200-rrlen, "janusvideo", 10);
if(sdeslen > 0) {
/* ... and then finally a REMB */
janus_rtcp_remb((char *)(&rtcpbuf)+rrlen+sdeslen, 24, session->bitrate);
gateway->relay_rtcp(handle, 1, rtcpbuf, rrlen+sdeslen+24);
}
/* As a last thing, notify the user about this */
json_t *event = json_object();
json_object_set_new(event, "serial", json_string("event"));
json_t *result = json_object();
json_object_set_new(result, "status", json_string("slow_link"));
json_object_set_new(result, "bitrate", json_integer(session->bitrate));
json_object_set_new(event, "result", result);
char *event_text = json_dumps(event, JSON_INDENT(3) | JSON_PRESERVE_ORDER);
json_decref(event);
json_decref(result);
event = NULL;
gateway->push_event(session->handle, &janus_serial_plugin, NULL, event_text, NULL, NULL);
g_free(event_text);
}
}
}
示例13: janus_serial_init
/* Plugin implementation */
int janus_serial_init(janus_callbacks *callback, const char *config_path) {
if(g_atomic_int_get(&stopping)) {
/* Still stopping from before */
return -1;
}
if(callback == NULL || config_path == NULL) {
/* Invalid arguments */
return -1;
}
/* Read configuration */
char filename[255];
g_snprintf(filename, 255, "%s/%s.cfg", config_path, JANUS_SERIAL_PACKAGE);
JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename);
janus_config *config = janus_config_parse(filename);
if(config != NULL)
janus_config_print(config);
/* This plugin actually has nothing to configure... */
janus_config_destroy(config);
config = NULL;
sessions = g_hash_table_new(NULL, NULL);
janus_mutex_init(&sessions_mutex);
messages = g_async_queue_new_full((GDestroyNotify) janus_serial_message_free);
/* This is the callback we'll need to invoke to contact the gateway */
gateway = callback;
g_atomic_int_set(&initialized, 1);
GError *error = NULL;
/* Start the sessions watchdog */
watchdog = g_thread_try_new("serial watchdog", &janus_serial_watchdog, NULL, &error);
if(error != NULL) {
g_atomic_int_set(&initialized, 0);
JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the Serial watchdog thread...\n", error->code, error->message ? error->message : "??");
return -1;
}
/* Launch the thread that will handle incoming messages */
handler_thread = g_thread_try_new("janus serial handler", janus_serial_handler, NULL, &error);
if(error != NULL) {
g_atomic_int_set(&initialized, 0);
JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the serial handler thread...\n", error->code, error->message ? error->message : "??");
return -1;
}
// init part
/* Open the file descriptor in non-blocking mode */
if(fd = open(portname,O_RDWR | O_NOCTTY | O_NONBLOCK)){
//printf("stream aperto\n");
JANUS_LOG(LOG_INFO, "stream aperto - Janus Serial\n");
}else{
//printf("errora nell'apertura dello stream\n");
JANUS_LOG(LOG_INFO, "errore nell'apertura dello stream\n");
return 0;
}
/* Set up the control structure */
struct termios toptions;
/* Get currently set options for the tty */
tcgetattr(fd, &toptions);
/* Set custom options */
/* 9600 baud */
cfsetispeed(&toptions, B9600);
cfsetospeed(&toptions, B9600);
/* 8 bits, no parity, no stop bits */
toptions.c_cflag &= ~PARENB;
toptions.c_cflag &= ~CSTOPB;
toptions.c_cflag &= ~CSIZE;
toptions.c_cflag |= CS8;
/* no hardware flow control */
toptions.c_cflag &= ~CRTSCTS;
/* enable receiver, ignore status lines */
toptions.c_cflag |= CREAD | CLOCAL;
/* disable input/output flow control, disable restart chars */
toptions.c_iflag &= ~(IXON | IXOFF | IXANY);
/* disable canonical input, disable echo,
disable visually erase chars,
disable terminal-generated signals */
toptions.c_iflag &= ~(ICANON | ECHO | ECHOE | ISIG);
/* disable output processing */
toptions.c_oflag &= ~OPOST;
/* wait for 24 characters to come in before read returns */
toptions.c_cc[VMIN] = 12;
/* no minimum time to wait before read returns */
toptions.c_cc[VTIME] = 0;
/* commit the options */
tcsetattr(fd, TCSANOW, &toptions);
/* Wait for the Arduino to reset */
usleep(1000*1000);
/* Flush anything already in the serial buffer */
tcflush(fd, TCIFLUSH);
write(fd,"k",1);
//.........这里部分代码省略.........
示例14: JANUS_LOG
/* Thread to handle incoming messages */
static void *janus_streaming_handler(void *data) {
JANUS_LOG(LOG_VERB, "Joining thread\n");
janus_streaming_message *msg = NULL;
int error_code = 0;
char *error_cause = calloc(1024, sizeof(char));
if(error_cause == NULL) {
JANUS_LOG(LOG_FATAL, "Memory error!\n");
return NULL;
}
while(initialized && !stopping) {
if(!messages || (msg = g_queue_pop_head(messages)) == NULL) {
usleep(50000);
continue;
}
janus_streaming_session *session = (janus_streaming_session *)msg->handle->plugin_handle;
if(!session) {
JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
janus_streaming_message_free(msg);
continue;
}
if(session->destroy) {
janus_streaming_message_free(msg);
continue;
}
/* Handle request */
error_code = 0;
JANUS_LOG(LOG_VERB, "Handling message: %s\n", msg->message);
if(msg->message == NULL) {
JANUS_LOG(LOG_ERR, "No message??\n");
error_code = JANUS_STREAMING_ERROR_NO_MESSAGE;
sprintf(error_cause, "%s", "No message??");
goto error;
}
json_error_t error;
json_t *root = json_loads(msg->message, 0, &error);
if(!root) {
JANUS_LOG(LOG_ERR, "JSON error: on line %d: %s\n", error.line, error.text);
error_code = JANUS_STREAMING_ERROR_INVALID_JSON;
sprintf(error_cause, "JSON error: on line %d: %s", error.line, error.text);
goto error;
}
if(!json_is_object(root)) {
JANUS_LOG(LOG_ERR, "JSON error: not an object\n");
error_code = JANUS_STREAMING_ERROR_INVALID_JSON;
sprintf(error_cause, "JSON error: not an object");
goto error;
}
json_t *request = json_object_get(root, "request");
if(!request) {
JANUS_LOG(LOG_ERR, "Missing element (request)\n");
error_code = JANUS_STREAMING_ERROR_MISSING_ELEMENT;
sprintf(error_cause, "Missing element (request)");
goto error;
}
if(!json_is_string(request)) {
JANUS_LOG(LOG_ERR, "Invalid element (request should be a string)\n");
error_code = JANUS_STREAMING_ERROR_INVALID_ELEMENT;
sprintf(error_cause, "Invalid element (request should be a string)");
goto error;
}
const char *request_text = json_string_value(request);
json_t *result = NULL;
char *sdp_type = NULL, *sdp = NULL;
if(!strcasecmp(request_text, "list")) {
result = json_object();
json_t *list = json_array();
JANUS_LOG(LOG_VERB, "Request for the list of mountpoints\n");
/* Return a list of all available mountpoints */
GList *mountpoints_list = g_hash_table_get_values(mountpoints);
GList *m = mountpoints_list;
while(m) {
janus_streaming_mountpoint *mp = (janus_streaming_mountpoint *)m->data;
json_t *ml = json_object();
json_object_set_new(ml, "id", json_integer(mp->id));
json_object_set_new(ml, "description", json_string(mp->description));
json_object_set_new(ml, "type", json_string(mp->streaming_type == janus_streaming_type_live ? "live" : "on demand"));
json_array_append_new(list, ml);
m = m->next;
}
json_object_set_new(result, "list", list);
g_list_free(mountpoints_list);
} else if(!strcasecmp(request_text, "watch")) {
json_t *id = json_object_get(root, "id");
if(id && !json_is_integer(id)) {
JANUS_LOG(LOG_ERR, "Invalid element (id should be an integer)\n");
error_code = JANUS_STREAMING_ERROR_INVALID_ELEMENT;
sprintf(error_cause, "Invalid element (id should be an integer)");
goto error;
}
gint64 id_value = json_integer_value(id);
janus_streaming_mountpoint *mp = g_hash_table_lookup(mountpoints, GINT_TO_POINTER(id_value));
if(mp == NULL) {
JANUS_LOG(LOG_VERB, "No such mountpoint/stream %"SCNu64"\n", id_value);
error_code = JANUS_STREAMING_ERROR_NO_SUCH_MOUNTPOINT;
sprintf(error_cause, "No such mountpoint/stream %"SCNu64"", id_value);
goto error;
}
JANUS_LOG(LOG_VERB, "Request to watch mountpoint/stream %"SCNu64"\n", id_value);
session->stopping = FALSE;
//.........这里部分代码省略.........
示例15: janus_streaming_init
/* Plugin implementation */
int janus_streaming_init(janus_callbacks *callback, const char *config_path) {
if(stopping) {
/* Still stopping from before */
return -1;
}
if(callback == NULL || config_path == NULL) {
/* Invalid arguments */
return -1;
}
/* Read configuration */
char filename[255];
sprintf(filename, "%s/%s.cfg", config_path, JANUS_STREAMING_PACKAGE);
JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename);
janus_config *config = janus_config_parse(filename);
if(config != NULL)
janus_config_print(config);
mountpoints = g_hash_table_new(NULL, NULL);
/* Parse configuration to populate the mountpoints */
if(config != NULL) {
janus_config_category *cat = janus_config_get_categories(config);
while(cat != NULL) {
if(cat->name == NULL) {
cat = cat->next;
continue;
}
JANUS_LOG(LOG_VERB, "Adding stream '%s'\n", cat->name);
janus_config_item *type = janus_config_get_item(cat, "type");
if(type == NULL || type->value == NULL) {
JANUS_LOG(LOG_VERB, " -- Invalid type, skipping stream...\n");
cat = cat->next;
continue;
}
if(!strcasecmp(type->value, "rtp")) {
/* RTP live source (e.g., from gstreamer/ffmpeg/vlc/etc.) */
janus_config_item *id = janus_config_get_item(cat, "id");
janus_config_item *desc = janus_config_get_item(cat, "description");
janus_config_item *audio = janus_config_get_item(cat, "audio");
janus_config_item *video = janus_config_get_item(cat, "video");
janus_config_item *aport = janus_config_get_item(cat, "audioport");
janus_config_item *acodec = janus_config_get_item(cat, "audiopt");
janus_config_item *artpmap = janus_config_get_item(cat, "audiortpmap");
janus_config_item *vport = janus_config_get_item(cat, "videoport");
janus_config_item *vcodec = janus_config_get_item(cat, "videopt");
janus_config_item *vrtpmap = janus_config_get_item(cat, "videortpmap");
janus_streaming_mountpoint *live_rtp = calloc(1, sizeof(janus_streaming_mountpoint));
if(live_rtp == NULL) {
JANUS_LOG(LOG_FATAL, "Memory error!\n");
continue;
}
if(id == NULL || id->value == NULL) {
JANUS_LOG(LOG_ERR, "Can't add 'rtp' stream, missing mandatory information...\n");
cat = cat->next;
continue;
}
gboolean doaudio = audio && audio->value && !strcasecmp(audio->value, "yes");
gboolean dovideo = video && video->value && !strcasecmp(video->value, "yes");
if(!doaudio && !dovideo) {
JANUS_LOG(LOG_ERR, "Can't add 'rtp' stream, no audio or video have to be streamed...\n");
g_free(live_rtp);
cat = cat->next;
continue;
}
if(doaudio &&
(aport == NULL || aport->value == NULL ||
acodec == NULL || acodec->value == NULL ||
artpmap == NULL || artpmap->value == NULL)) {
JANUS_LOG(LOG_ERR, "Can't add 'rtp' stream, missing mandatory information for audio...\n");
cat = cat->next;
continue;
}
if(dovideo &&
(vport == NULL || vport->value == NULL ||
vcodec == NULL || vcodec->value == NULL ||
vrtpmap == NULL || vrtpmap->value == NULL)) {
JANUS_LOG(LOG_ERR, "Can't add 'rtp' stream, missing mandatory information for video...\n");
cat = cat->next;
continue;
}
JANUS_LOG(LOG_VERB, "Audio %s, Video %s\n", doaudio ? "enabled" : "NOT enabled", dovideo ? "enabled" : "NOT enabled");
live_rtp->name = g_strdup(cat->name);
live_rtp->id = atoi(id->value);
char *description = NULL;
if(desc != NULL && desc->value != NULL)
description = g_strdup(desc->value);
else
description = g_strdup(cat->name);
live_rtp->description = description;
live_rtp->active = FALSE;
live_rtp->streaming_type = janus_streaming_type_live;
live_rtp->streaming_source = janus_streaming_source_rtp;
janus_streaming_rtp_source *live_rtp_source = calloc(1, sizeof(janus_streaming_rtp_source));
if(live_rtp->name == NULL || description == NULL || live_rtp_source == NULL) {
JANUS_LOG(LOG_FATAL, "Memory error!\n");
if(live_rtp->name)
g_free(live_rtp->name);
if(description)
g_free(description);
//.........这里部分代码省略.........