static void _gck_call_base_init (GckCallClass *klass) { GckCallSource *source; GMainContext *context; GError *err = NULL; klass->thread_pool = g_thread_pool_new ((GFunc)process_async_call, klass, 16, FALSE, &err); if (!klass->thread_pool) { g_critical ("couldn't create thread pool: %s", err && err->message ? err->message : ""); return; } klass->completed_queue = g_async_queue_new_full (g_object_unref); g_assert (klass->completed_queue); context = g_main_context_default (); g_assert (context); /* Add our idle handler which processes other tasks */ source = (GckCallSource*)g_source_new (&completed_functions, sizeof (GckCallSource)); source->klass = klass; klass->completed_id = g_source_attach ((GSource*)source, context); g_source_set_callback ((GSource*)source, NULL, NULL, NULL); g_source_unref ((GSource*)source); }
static App * app_new (void) { App *app; app = g_slice_new0 (App); if (!app) return NULL; g_mutex_init (&app->mutex); g_cond_init (&app->event_cond); g_cond_init (&app->decoder_ready); g_cond_init (&app->render_ready); app_set_framerate (app, 60, 1); app->window_width = 640; app->window_height = 480; app->decoder_queue = g_async_queue_new_full ( (GDestroyNotify) render_frame_free); if (!app->decoder_queue) goto error; app->timer = g_timer_new (); if (!app->timer) goto error; return app; error: app_free (app); return NULL; }
int ps_gstsink_init (ps_callbacks * callback, const char * config_path) { if (g_atomic_int_get(&stopping)) return -1; //if (callback == NULL || config_path == NULL) return -1; if (callback == NULL) return -1; /* Initialize GSTREAMER */ gst_init (NULL, NULL); sessions = g_hash_table_new (NULL, NULL); ps_mutex_init (&sessions_mutex); messages = g_async_queue_new_full ((GDestroyNotify) ps_gstsink_message_free); gateway = callback; g_atomic_int_set (&initialized, 1); GError * error = NULL; watchdog = g_thread_try_new ("streaming watchdog", &ps_gstsink_watchdog, NULL, &error); if (!watchdog) { g_atomic_int_set(&initialized, 0); PS_LOG (LOG_ERR, "Got error %d (%s) trying to launch the GstSink watchdog thread...\n", error->code, error->message ? error->message : "??"); return -1; } handler_thread = g_thread_try_new ("streaming handler", &ps_gstsink_handler, NULL, &error); if (!handler_thread) { g_atomic_int_set(&initialized, 0); PS_LOG (LOG_ERR, "Got error %d (%s) trying to launch the GstSink handler thread...\n", error->code, error->message ? error->message : "??"); return -1; } PS_LOG (LOG_INFO, "%s initialized\n", PS_GSTSINK_NAME); return 0; }
static void init_intercom (APP_STATE_T * state) { state->queue = g_async_queue_new_full ((GDestroyNotify) gst_mini_object_unref); state->queue_lock = g_mutex_new (); state->cond = g_cond_new (); }
/* Plugin implementation */ int janus_videocall_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_VIDEOCALL_PACKAGE); JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename); janus_config *config = janus_config_parse(filename); if(config != NULL) { janus_config_print(config); janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events"); if(events != NULL && events->value != NULL) notify_events = janus_is_true(events->value); if(!notify_events && callback->events_is_enabled()) { JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_VIDEOCALL_NAME); } } janus_config_destroy(config); config = NULL; sessions = g_hash_table_new(g_str_hash, g_str_equal); janus_mutex_init(&sessions_mutex); messages = g_async_queue_new_full((GDestroyNotify) janus_videocall_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("videocall watchdog", &janus_videocall_watchdog, NULL, &error); if(error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the VideoCall 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("videocall handler", janus_videocall_handler, NULL, &error); if(error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the VideoCall handler thread...\n", error->code, error->message ? error->message : "??"); return -1; } JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_VIDEOCALL_NAME); return 0; }
static gboolean gst_vaapi_decoder_init (GstVaapiDecoder * decoder, GstVaapiDisplay * display, GstCaps * caps) { const GstVaapiDecoderClass *const klass = GST_VAAPI_DECODER_GET_CLASS (decoder); GstVideoCodecState *codec_state; guint sub_size; parser_state_init (&decoder->parser_state); codec_state = g_slice_new0 (GstVideoCodecState); codec_state->ref_count = 1; gst_video_info_init (&codec_state->info); decoder->user_data = NULL; decoder->display = gst_vaapi_display_ref (display); decoder->va_display = GST_VAAPI_DISPLAY_VADISPLAY (display); decoder->context = NULL; decoder->va_context = VA_INVALID_ID; decoder->codec = 0; decoder->codec_state = codec_state; decoder->codec_state_changed_func = NULL; decoder->codec_state_changed_data = NULL; decoder->buffers = g_async_queue_new_full ((GDestroyNotify) gst_buffer_unref); decoder->frames = g_async_queue_new_full ((GDestroyNotify) gst_video_codec_frame_unref); if (!set_caps (decoder, caps)) return FALSE; sub_size = GST_VAAPI_MINI_OBJECT_CLASS (klass)->size - sizeof (*decoder); if (sub_size > 0) memset (((guchar *) decoder) + sizeof (*decoder), 0, sub_size); if (klass->create && !klass->create (decoder)) return FALSE; return TRUE; }
/* Base encoder initialization (internal) */ static gboolean gst_vaapi_encoder_init (GstVaapiEncoder * encoder, GstVaapiDisplay * display) { GstVaapiEncoderClass *const klass = GST_VAAPI_ENCODER_GET_CLASS (encoder); g_return_val_if_fail (display != NULL, FALSE); #define CHECK_VTABLE_HOOK(FUNC) do { \ if (!klass->FUNC) \ goto error_invalid_vtable; \ } while (0) CHECK_VTABLE_HOOK (init); CHECK_VTABLE_HOOK (finalize); CHECK_VTABLE_HOOK (get_default_properties); CHECK_VTABLE_HOOK (reconfigure); CHECK_VTABLE_HOOK (encode); CHECK_VTABLE_HOOK (reordering); CHECK_VTABLE_HOOK (flush); #undef CHECK_VTABLE_HOOK encoder->display = gst_vaapi_display_ref (display); encoder->va_display = gst_vaapi_display_get_display (display); encoder->va_context = VA_INVALID_ID; gst_video_info_init (&encoder->video_info); g_mutex_init (&encoder->mutex); g_cond_init (&encoder->surface_free); g_cond_init (&encoder->codedbuf_free); encoder->codedbuf_queue = g_async_queue_new_full ((GDestroyNotify) gst_vaapi_coded_buffer_proxy_unref); if (!encoder->codedbuf_queue) return FALSE; if (!klass->init (encoder)) return FALSE; if (!gst_vaapi_encoder_init_properties (encoder)) return FALSE; return TRUE; /* ERRORS */ error_invalid_vtable: { GST_ERROR ("invalid subclass hook (internal error)"); return FALSE; } }
void Ekiga::Runtime::init () { // here we get a ref to the queue, which we'll release in quit queue = g_async_queue_new_full ((GDestroyNotify)free_message); struct source* source = (struct source *)g_source_new (&source_funcs, sizeof (struct source)); source->queue = queue; g_async_queue_ref (queue); // give a ref to the source g_source_attach ((GSource *)source, g_main_context_default ()); loop = g_main_loop_new (NULL, FALSE); }
static void gst_dtmf_src_init (GstDTMFSrc * dtmfsrc) { /* we operate in time */ gst_base_src_set_format (GST_BASE_SRC (dtmfsrc), GST_FORMAT_TIME); gst_base_src_set_live (GST_BASE_SRC (dtmfsrc), TRUE); dtmfsrc->interval = DEFAULT_PACKET_INTERVAL; dtmfsrc->event_queue = g_async_queue_new_full ((GDestroyNotify) event_free); dtmfsrc->last_event = NULL; dtmfsrc->sample_rate = DEFAULT_SAMPLE_RATE; GST_DEBUG_OBJECT (dtmfsrc, "init done"); }
/* Plugin implementation */ int janus_echotest_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_ECHOTEST_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_echotest_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("etest watchdog", &janus_echotest_watchdog, NULL, &error); if(error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the EchoTest 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 echotest handler", janus_echotest_handler, NULL, &error); if(error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the EchoTest handler thread...\n", error->code, error->message ? error->message : "??"); return -1; } JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_ECHOTEST_NAME); return 0; }
static void gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object) { gst_base_src_set_format (GST_BASE_SRC (object), GST_FORMAT_TIME); gst_base_src_set_live (GST_BASE_SRC (object), TRUE); object->ssrc = DEFAULT_SSRC; object->seqnum_offset = DEFAULT_SEQNUM_OFFSET; object->ts_offset = DEFAULT_TIMESTAMP_OFFSET; object->pt = DEFAULT_PT; object->clock_rate = DEFAULT_CLOCK_RATE; object->ptime = DEFAULT_PTIME; object->packet_redundancy = DEFAULT_PACKET_REDUNDANCY; object->event_queue = g_async_queue_new_full ((GDestroyNotify) gst_rtp_dtmf_src_event_free); object->payload = NULL; GST_DEBUG_OBJECT (object, "init done"); }
static gboolean egl_display_init (EglDisplay * display) { display->gl_queue = g_async_queue_new_full ((GDestroyNotify) gst_vaapi_mini_object_unref); if (!display->gl_queue) return FALSE; g_mutex_init (&display->mutex); g_cond_init (&display->gl_thread_ready); display->gl_thread = g_thread_try_new ("OpenGL Thread", egl_display_thread, display, NULL); if (!display->gl_thread) return FALSE; g_mutex_lock (&display->mutex); g_cond_wait (&display->gl_thread_ready, &display->mutex); g_mutex_unlock (&display->mutex); return display->base.is_valid; }
/* Plugin implementation */ int janus_videocall_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_VIDEOCALL_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(g_str_hash, g_str_equal); janus_mutex_init(&sessions_mutex); messages = g_async_queue_new_full((GDestroyNotify) janus_videocall_message_free); /* This is the callback we'll need to invoke to contact the gateway */ gateway = callback; initialized = 1; /* Launch the thread that will handle incoming messages */ GError *error = NULL; handler_thread = g_thread_try_new("janus videocall handler", janus_videocall_handler, NULL, &error); if(error != NULL) { initialized = 0; /* Something went wrong... */ JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch thread...\n", error->code, error->message ? error->message : "??"); return -1; } JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_VIDEOCALL_NAME); return 0; }
RmHasher *rm_hasher_new(RmDigestType digest_type, guint num_threads, gboolean use_buffered_read, gsize buf_size, guint64 cache_quota_bytes, RmHasherCallback joiner, gpointer session_user_data) { RmHasher *self = g_slice_new0(RmHasher); self->digest_type = digest_type; self->use_buffered_read = use_buffered_read; self->buf_size = buf_size; self->cache_quota_bytes = cache_quota_bytes; if(joiner) { self->callback = joiner; } else { self->callback = (RmHasherCallback)rm_hasher_joiner; self->return_queue = g_async_queue_new(); } self->session_user_data = session_user_data; /* initialise mutex & cond */ g_mutex_init(&self->lock); g_cond_init(&self->cond); /* Create buffer mem pool */ self->mem_pool = rm_buffer_pool_init(buf_size, cache_quota_bytes); /* Create a pool of hashing thread "pools" - each "pool" can only have * one thread because hashing must be done in order */ self->hashpipe_pool = g_async_queue_new_full((GDestroyNotify)rm_hasher_hashpipe_free); rm_assert_gentle(num_threads > 0); self->unalloc_hashpipes = num_threads; return self; }
/** * Initialize scheduler resources. */ int sched_init(struct sched_res_t *sched_res, const action_scheduler_t *sched_desc, void *sched_cfg, policy_run_config_t *run_cfg) { int rc; if (!sched_res) return -EINVAL; sched_res->sched_desc = sched_desc; sched_res->sched_data = NULL; sched_res->terminate = false; sched_res->run_cfg = run_cfg; /* initialize the scheduler */ if (sched_desc->sched_init_func != NULL) { rc = sched_desc->sched_init_func(sched_cfg, &sched_res->sched_data); if (rc) return rc; } sched_res->sched_queue = g_async_queue_new_full(free); /* start the enqueuer thread now everything is initialized */ if (pthread_create(&sched_res->sched_thread, NULL, enqueue_thr, sched_res) != 0) { rc = -errno; goto err_free; } return 0; err_free: /* TODO destroy scheduler resources */ g_async_queue_unref(sched_res->sched_queue); return rc; }
/* 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); JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_SERIAL_NAME); return 0; }
/* Plugin implementation */ int janus_source_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_SOURCE_PACKAGE); JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename); janus_config *config = janus_config_parse(filename); if (config != NULL) janus_config_print(config); /* Parse configuration */ if (config != NULL) { GList *cl = janus_config_get_categories(config); while (cl != NULL) { janus_config_category *cat = (janus_config_category *)cl->data; if (cat->name == NULL) { cl = cl->next; continue; } JANUS_LOG(LOG_VERB, "Parsing category '%s'\n", cat->name); janus_source_parse_ports_range(janus_config_get_item(cat, "udp_port_range"), &udp_min_port, &udp_max_port); janus_source_parse_keepalive_interval(janus_config_get_item(cat, "keepalive_interval"), &keepalive_interval); janus_source_parse_status_service_url(janus_config_get_item(cat, "keepalive_service_url"), &keepalive_service_url); janus_source_parse_status_service_url(janus_config_get_item(cat,"status_service_url"),&status_service_url); janus_source_parse_video_codec_priority(janus_config_get_item(cat, "video_codec_priority")); janus_source_parse_rtsp_interface_ip(janus_config_get_item(cat, "interface"),&rtsp_interface_ip); cl = cl->next; } janus_config_destroy(config); config = NULL; } if (udp_min_port <= 0 || udp_max_port <= 0) { udp_min_port = 4000; udp_max_port = 5000; JANUS_LOG(LOG_WARN, "Using default port range: %d-%d\n", udp_min_port, udp_max_port); } sessions = g_hash_table_new(NULL, NULL); janus_mutex_init(&sessions_mutex); messages = g_async_queue_new_full((GDestroyNotify)janus_source_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("source watchdog", &janus_source_watchdog, NULL, &error); if (error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the SourcePlugin watchdog thread...\n", error->code, error->message ? error->message : "??"); return -1; } gst_init(NULL, NULL); gst_debug_set_threshold_from_string(gst_debug_str, FALSE); curl_handle = curl_init(); socket_utils_init(udp_min_port, udp_max_port); /* Launch the thread that will handle incoming messages */ handler_thread = g_thread_try_new("janus source handler", janus_source_handler, NULL, &error); if (error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the Source handler thread...\n", error->code, error->message ? error->message : "??"); return -1; } /* Launch the thread that will handle rtsp clients */ handler_rtsp_thread = g_thread_try_new("rtsp server", janus_source_rtsp_server_thread, NULL, &error); if (error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the Source rtsp server thread...\n", error->code, error->message ? error->message : "??"); return -1; } /* Set PID */ memset(&PID, 0, JANUS_PID_SIZE); if (0 > janus_set_pid()) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got an error while plugin id initialize."); return -1; } /*Start the keepalive thread */ keepalive = g_thread_try_new("source keepalive", &janus_source_keepalive, NULL, &error); if (error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the SourcePlugin keepalive thread...\n", error->code, error->message ? error->message : "??"); return -1; } JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_SOURCE_NAME); return 0; }
void remmina_rdp_event_init(RemminaProtocolWidget* gp) { gchar* s; gint flags; rfContext* rfi; GtkClipboard* clipboard; rfi = GET_DATA(gp); rfi->drawing_area = gtk_drawing_area_new(); gtk_widget_show(rfi->drawing_area); gtk_container_add(GTK_CONTAINER(gp), rfi->drawing_area); gtk_widget_add_events(rfi->drawing_area, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK | GDK_FOCUS_CHANGE_MASK); gtk_widget_set_can_focus(rfi->drawing_area, TRUE); remmina_plugin_service->protocol_plugin_register_hostkey(gp, rfi->drawing_area); s = remmina_plugin_service->pref_get_value("rdp_use_client_keymap"); rfi->use_client_keymap = (s && s[0] == '1' ? TRUE : FALSE); g_free(s); #if GTK_VERSION == 3 g_signal_connect(G_OBJECT(rfi->drawing_area), "draw", G_CALLBACK(remmina_rdp_event_on_draw), gp); #elif GTK_VERSION == 2 g_signal_connect(G_OBJECT(rfi->drawing_area), "expose-event", G_CALLBACK(remmina_rdp_event_on_expose), gp); #endif g_signal_connect(G_OBJECT(rfi->drawing_area), "configure-event", G_CALLBACK(remmina_rdp_event_on_configure), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "motion-notify-event", G_CALLBACK(remmina_rdp_event_on_motion), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "button-press-event", G_CALLBACK(remmina_rdp_event_on_button), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "button-release-event", G_CALLBACK(remmina_rdp_event_on_button), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "scroll-event", G_CALLBACK(remmina_rdp_event_on_scroll), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "key-press-event", G_CALLBACK(remmina_rdp_event_on_key), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "key-release-event", G_CALLBACK(remmina_rdp_event_on_key), gp); g_signal_connect(G_OBJECT(rfi->drawing_area), "focus-in-event", G_CALLBACK(remmina_rdp_event_on_focus_in), gp); RemminaFile* remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); if (!remmina_plugin_service->file_get_int(remminafile, "disableclipboard", FALSE)) { clipboard = gtk_widget_get_clipboard(rfi->drawing_area, GDK_SELECTION_CLIPBOARD); rfi->clipboard_handler = g_signal_connect(clipboard, "owner-change", G_CALLBACK(remmina_rdp_event_on_clipboard), gp); } rfi->pressed_keys = g_array_new(FALSE, TRUE, sizeof (gint)); rfi->event_queue = g_async_queue_new_full(g_free); rfi->ui_queue = g_async_queue_new(); if (pipe(rfi->event_pipe)) { g_print("Error creating pipes.\n"); rfi->event_pipe[0] = -1; rfi->event_pipe[1] = -1; } else { flags = fcntl(rfi->event_pipe[0], F_GETFL, 0); fcntl(rfi->event_pipe[0], F_SETFL, flags | O_NONBLOCK); } rfi->object_table = g_hash_table_new_full(NULL, NULL, NULL, g_free); rfi->display = gdk_display_get_default(); rfi->bpp = gdk_visual_get_best_depth(); }
/* Plugin implementation */ int janus_sampleevh_init(const char *config_path) { if(g_atomic_int_get(&stopping)) { /* Still stopping from before */ return -1; } if(config_path == NULL) { /* Invalid arguments */ return -1; } /* Read configuration */ gboolean enabled = FALSE; char filename[255]; g_snprintf(filename, 255, "%s/%s.cfg", config_path, JANUS_SAMPLEEVH_PACKAGE); JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename); janus_config *config = janus_config_parse(filename); if(config != NULL) { /* Handle configuration */ janus_config_print(config); /* Setup the sample event handler, if required */ janus_config_item *item = janus_config_get_item_drilldown(config, "general", "enabled"); if(!item || !item->value || !janus_is_true(item->value)) { JANUS_LOG(LOG_WARN, "Sample event handler disabled (Janus API)\n"); } else { /* Backend to send events to */ item = janus_config_get_item_drilldown(config, "general", "backend"); if(!item || !item->value || strstr(item->value, "http") != item->value) { JANUS_LOG(LOG_WARN, "Missing or invalid backend\n"); } else { backend = g_strdup(item->value); /* Any credentials needed? */ item = janus_config_get_item_drilldown(config, "general", "backend_user"); backend_user = (item && item->value) ? g_strdup(item->value) : NULL; item = janus_config_get_item_drilldown(config, "general", "backend_pwd"); backend_pwd = (item && item->value) ? g_strdup(item->value) : NULL; /* Any specific setting for retransmissions? */ item = janus_config_get_item_drilldown(config, "general", "max_retransmissions"); if(item && item->value) { int mr = atoi(item->value); if(mr < 0) { JANUS_LOG(LOG_WARN, "Invalid negative value for 'max_retransmissions', using default (%d)\n", max_retransmissions); } else if(mr == 0) { JANUS_LOG(LOG_WARN, "Retransmissions disabled (max_retransmissions=0)\n"); max_retransmissions = 0; } else { max_retransmissions = mr; } } item = janus_config_get_item_drilldown(config, "general", "retransmissions_backoff"); if(item && item->value) { int rb = atoi(item->value); if(rb <= 0) { JANUS_LOG(LOG_WARN, "Invalid negative or null value for 'retransmissions_backoff', using default (%d)\n", retransmissions_backoff); } else { retransmissions_backoff = rb; } } /* Which events should we subscribe to? */ item = janus_config_get_item_drilldown(config, "general", "events"); if(item && item->value) { if(!strcasecmp(item->value, "none")) { /* Don't subscribe to anything at all */ janus_flags_reset(&janus_sampleevh.events_mask); } else if(!strcasecmp(item->value, "all")) { /* Subscribe to everything */ janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_ALL); } else { /* Check what we need to subscribe to */ gchar **subscribe = g_strsplit(item->value, ",", -1); if(subscribe != NULL) { gchar *index = subscribe[0]; if(index != NULL) { int i=0; while(index != NULL) { while(isspace(*index)) index++; if(strlen(index)) { if(!strcasecmp(index, "sessions")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_SESSION); } else if(!strcasecmp(index, "handles")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_HANDLE); } else if(!strcasecmp(index, "jsep")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_JSEP); } else if(!strcasecmp(index, "webrtc")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_WEBRTC); } else if(!strcasecmp(index, "media")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_MEDIA); } else if(!strcasecmp(index, "plugins")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_PLUGIN); } else if(!strcasecmp(index, "transports")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_TRANSPORT); } else if(!strcasecmp(index, "core")) { janus_flags_set(&janus_sampleevh.events_mask, JANUS_EVENT_TYPE_CORE); } else { JANUS_LOG(LOG_WARN, "Unknown event type '%s'\n", index); } } i++; index = subscribe[i]; } } g_strfreev(subscribe); } } } /* Is grouping of events ok? */ item = janus_config_get_item_drilldown(config, "general", "grouping"); group_events = item && item->value && janus_is_true(item->value); /* Done */ enabled = TRUE; } } } janus_config_destroy(config); config = NULL; if(!enabled) { JANUS_LOG(LOG_FATAL, "Sample event handler not enabled/needed, giving up...\n"); return -1; /* No point in keeping the plugin loaded */ } JANUS_LOG(LOG_VERB, "Sample event handler configured: %s\n", backend); /* Initialize libcurl, needed for forwarding events via HTTP POST */ curl_global_init(CURL_GLOBAL_ALL); /* Initialize the events queue */ events = g_async_queue_new_full((GDestroyNotify) janus_sampleevh_event_free); g_atomic_int_set(&initialized, 1); /* Launch the thread that will handle incoming events */ GError *error = NULL; handler_thread = g_thread_try_new("janus sampleevh handler", janus_sampleevh_handler, NULL, &error); if(error != NULL) { g_atomic_int_set(&initialized, 0); JANUS_LOG(LOG_ERR, "Got error %d (%s) trying to launch the SampleEventHandler handler thread...\n", error->code, error->message ? error->message : "??"); return -1; } JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_SAMPLEEVH_NAME); return 0; }
/** * g_async_queue_new: * * Creates a new asynchronous queue. * * Returns: a new #GAsyncQueue. Free with g_async_queue_unref() */ GAsyncQueue * g_async_queue_new (void) { return g_async_queue_new_full (NULL); }
static void facq_pipeline_monitor_constructed(GObject *self) { FacqPipelineMonitor *mon = FACQ_PIPELINE_MONITOR(self); mon->priv->q = g_async_queue_new_full((GDestroyNotify)facq_pipeline_message_free); }
/* * Construct new bufferpool and allocate buffers from driver * * @elem the parent element that owns this buffer * @fd the file descriptor of the device file * @count the requested number of buffers in the pool * @caps the requested buffer caps * @return the bufferpool or <code>NULL</code> if error */ GstBufferClassBufferPool * gst_buffer_manager_new (GstElement * elem, int fd, int count, GstCaps * caps) { GstBufferClassBufferPool *pool = NULL; GstVideoFormat format; gint width, height ; void *vidStreamBufVa; unsigned long vidStreamBufPa; int n, i; gst_initpacket pack_info; if (gst_video_format_parse_caps(caps, &format, &width, &height)) { bc_buf_params_t param; /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ CMEM_init(); vidStreamBufVa = CMEM_alloc((width*height*2*MAX_FCOUNT), &cmem_params); if (!vidStreamBufVa) { printf ("CMEM_alloc for Video Stream buffer returned NULL \n"); return NULL; } vidStreamBufPa = CMEM_getPhys(vidStreamBufVa); for (i = 0; i < count; i++) { TextureBufsPa[i] = vidStreamBufPa + (width*height*2*i); } /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ param.count = count; param.width = width; /* width should be multiple of 32 */ param.height = height; switch(format) { case 3 : param.fourcc = BC_PIX_FMT_YUYV; break; case 22: param.fourcc = BC_PIX_FMT_NV12; break; case 4 : param.fourcc = BC_PIX_FMT_UYVY; break; default: /* Uknown Format */ return -1; } param.type = BC_MEMORY_USERPTR; pack_info.params = param; pack_info.phyaddr = vidStreamBufPa; n = write(fd_bcinit_fifo, &pack_info, sizeof(gst_initpacket)); if(n != sizeof(gst_initpacket)) { printf("Error in writing to queue\n"); } /* We no longer need this pipe */ close(fd_bcinit_fifo); /* construct bufferpool */ pool = (GstBufferClassBufferPool *) gst_mini_object_new (GST_TYPE_BCBUFFERPOOL); //TODO: Remove fd from pool -not required any more. pool->fd = -1; pool->elem = elem; pool->num_buffers = param.count; GST_DEBUG_OBJECT (pool->elem, "orig caps: %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (pool->elem, "requested %d buffers, got %d buffers", count, param.count); pool->caps = caps; /* and allocate buffers: */ pool->num_buffers = param.count; pool->buffers = g_new0 (GstBufferClassBuffer *, param.count); pool->avail_buffers = g_async_queue_new_full ( (GDestroyNotify) gst_mini_object_unref); for (i = 0; i < param.count; i++) { // TODO: Find correct size here GstBufferClassBuffer *buf = gst_bcbuffer_new (pool, i, param.width*param.height*2, TextureBufsPa[i]); GST_BUFFER_DATA (buf) = (vidStreamBufVa + param.width*param.height*2*i); GST_BUFFER_SIZE (buf) = param.width*param.height*2; if (G_UNLIKELY (!buf)) { GST_WARNING_OBJECT (pool->elem, "Buffer %d allocation failed", i); goto fail; } gst_buffer_set_caps (GST_BUFFER (buf), caps); pool->buffers[i] = buf; g_async_queue_push (pool->avail_buffers, buf); } return pool; } else {