Example #1
0
/**
 * Update the input settings
 */
static void pulse_update(void *vptr, obs_data_t settings)
{
	PULSE_DATA(vptr);
	bool restart = false;
	const char *new_device;

	new_device = obs_data_getstring(settings, "device_id");
	if (!data->device || strcmp(data->device, new_device) != 0) {
		if (data->device)
			bfree(data->device);
		data->device = bstrdup(new_device);
		restart = true;
	}

	if (!restart)
		return;

	if (data->stream)
		pulse_stop_recording(data);
	pulse_start_recording(data);
}
Example #2
0
//     ssize_t size = 0;
//     char *buffer = as_char_array(env, array, &size);
//     decrypted = ss_decrypt(BUFF_SIZE, buffer, &size, temp_d_ctx);
//     if(decrypted == NULL) {
//         return NULL;
//     }
//     return as_byte_array(env, decrypted, size);
// }
JNIEXPORT jint JNICALL Java_me_smartproxy_crypto_CryptoUtils_encrypt(JNIEnv *env, jclass thiz, jobject array,
                                                                    jint jsize, jlong id) {

    ssize_t size = (ssize_t) jsize;
    jbyte *bytes = (jbyte *) env->GetDirectBufferAddress(array);

    buffer_t *buffer = (buffer_t *) ss_malloc(sizeof(buffer_t));
    balloc(buffer, BUFF_SIZE);

    memcpy(buffer->array, bytes, size);
    buffer->len = size;

    enc_connection *connection = enc_ctx_map[id];
    ss_encrypt(buffer, connection->text_e_ctx, BUFF_SIZE);
    size = buffer->len;
    memcpy(bytes, buffer->array, buffer->len);

    bfree(buffer);

    return size;
}
Example #3
0
/**
 * Update the settings for the v4l2 source
 *
 * Since there are very few settings that can be changed without restarting the
 * stream we don't bother to even try. Whenever this is called the currently
 * active stream (if exists) is stopped, the settings are updated and finally
 * the new stream is started.
 */
static void v4l2_update(void *vptr, obs_data_t *settings)
{
	V4L2_DATA(vptr);

	v4l2_terminate(data);

	if (data->device_id)
		bfree(data->device_id);

	data->device_id  = bstrdup(obs_data_get_string(settings, "device_id"));
	data->input      = obs_data_get_int(settings, "input");
	data->pixfmt     = obs_data_get_int(settings, "pixelformat");
	data->standard   = obs_data_get_int(settings, "standard");
	data->dv_timing  = obs_data_get_int(settings, "dv_timing");
	data->resolution = obs_data_get_int(settings, "resolution");
	data->framerate  = obs_data_get_int(settings, "framerate");

	v4l2_update_source_flags(data, settings);

	v4l2_init(data);
}
static void start_from_buffer(struct obs_encoder *encoder, uint64_t v_start_ts)
{
	size_t size = encoder->audio_input_buffer[0].size;
	struct audio_data audio = {0};
	size_t offset_size = 0;

	for (size_t i = 0; i < MAX_AV_PLANES; i++) {
		audio.data[i] = encoder->audio_input_buffer[i].data;
		memset(&encoder->audio_input_buffer[i], 0,
				sizeof(struct circlebuf));
	}

	if (encoder->first_raw_ts < v_start_ts)
		offset_size = calc_offset_size(encoder, v_start_ts,
				encoder->first_raw_ts);

	push_back_audio(encoder, &audio, size, offset_size);

	for (size_t i = 0; i < MAX_AV_PLANES; i++)
		bfree(audio.data[i]);
}
Example #5
0
int rlfs_removeFile(char *filename) {
    int fd;
    int id;
    int sect;
    int size;
    struct Block *b;
    fd = rlfs_open(filename, 'w');
    if (fd < 0) {
        return -1;
    }
    id = openFiles[fd].id;
    sect = openFiles[fd].baseSector;
    size = openFiles[fd].size;
    rlfs_close(fd);
    b = bread(0, 0);
    b->data[id << 4] = 0xffff;
    b->flags = BLOCK_MODIFIED;
    bfree(b);
    removeMarkersForFile(sect, size);
    return 0;
}
Example #6
0
int rlfs_create(char *name) {
    int freeSect;
    int i;
    struct Block *b;
    printf("create file %s\n", name);
    freeSect = rlfs_findFreeSector();
    rlfs_markSector(freeSect, 1);

    b = bread(0, 0);
    for (i = 0; i < 256; i += 16) {
        if (b->data[i] == 0 || b->data[i] == 0xffff)
            break;
    }
    b->data[i] = 1;
    b->data[i + 1] = 0;
    b->data[i + 2] = freeSect;
    strcpy((char *)(b->data) + 3 + i, (char *)(name));
    bfree(b);
    printf("created file at %d\n", freeSect);
    return i;
}
Example #7
0
File: btree.c Project: Zkin/tux3
static int try_bnode_merge(struct sb *sb, struct buffer_head *intobuf,
			   struct buffer_head *frombuf)
{
	struct bnode *into = bufdata(intobuf);
	struct bnode *from = bufdata(frombuf);

	/* Try to merge nodes */
	if (bnode_merge_nodes(sb, into, from)) {
		/*
		 * We know frombuf is redirected and dirty. So, in
		 * here, we can just cancel bnode_redirect by bfree(),
		 * instead of defered_bfree()
		 * FIXME: we can optimize freeing bnode without
		 * bnode_redirect, and if we did, this is not true.
		 */
		bfree(sb, bufindex(frombuf), 1);
		log_bnode_merge(sb, bufindex(frombuf), bufindex(intobuf));
		return 1;
	}
	return 0;
}
Example #8
0
/**@brief Sending an event
 * @param[in]  id  Message identifier
 * @param[in] battery_service_evt_content_rsp_msg Content of battery event
 */
static void bs_send_evt_msg(
	uint16_t id,
	battery_service_evt_content_rsp_msg_t *
	battery_service_evt_content_rsp_msg)
{
	battery_service_listen_evt_rsp_msg_t *evt = NULL;

	evt = (battery_service_listen_evt_rsp_msg_t *)cfw_alloc_evt_msg(
		&battery_service, id,
		sizeof(
			battery_service_listen_evt_rsp_msg_t));

	if ((NULL != evt) &&
	    (NULL != battery_service_evt_content_rsp_msg)) {
		memcpy(&evt->battery_service_evt_content_rsp_msg,
		       battery_service_evt_content_rsp_msg,
		       sizeof(battery_service_evt_content_rsp_msg_t));
	}
	cfw_send_event(&evt->header);
	bfree(evt); /* message has been cloned by cfw_send_event */
}
Example #9
0
obs_output_t obs_output_create(const char *id, const char *settings)
{
	const struct output_info *info = find_output(id);
	struct obs_output *output;

	if (!info) {
		blog(LOG_WARNING, "Output '%s' not found", id);
		return NULL;
	}

	output = bmalloc(sizeof(struct obs_output));
	output->data = info->create(settings, output);
	if (!output->data) {
		bfree(output);
		return NULL;
	}

	dstr_init_copy(&output->settings, settings);
	memcpy(&output->callbacks, info, sizeof(struct output_info));
	return output;
}
Example #10
0
/*
 * Destroy the plugin object and free all memory
 */
static void pulse_destroy(void *vptr)
{
	PULSE_DATA(vptr);

	if (!data)
		return;

	if (data->thread) {
		void *ret;
		os_event_signal(data->event);
		pthread_join(data->thread, &ret);
	}

	os_event_destroy(data->event);

	pa_proplist_free(data->props);

	blog(LOG_DEBUG, "pulse-input: Input destroyed");

	bfree(data);
}
Example #11
0
static void scene_destroy(void *data)
{
	struct obs_scene *scene = data;
	struct obs_scene_item *item;

	pthread_mutex_lock(&scene->mutex);

	item = scene->first_item;

	while (item) {
		struct obs_scene_item *del_item = item;
		item = item->next;

		obs_sceneitem_remove(del_item);
	}

	pthread_mutex_unlock(&scene->mutex);

	pthread_mutex_destroy(&scene->mutex);
	bfree(scene);
}
Example #12
0
int umRestore(char_t *filename)
{
	if (filename && *filename) {
		if (saveFilename != NULL) {
			bfree(B_L, saveFilename);
		}

		saveFilename = bstrdup(B_L, filename);
	}

	a_assert(saveFilename && *saveFilename);

	trace(3, T("UM: Loading User Configuration from file <%s>\n"), 
		saveFilename);

/*
 *	First empty the database, otherwise we wind up with duplicates!
 */
	dbZero(didUM);
	return dbLoad(didUM, saveFilename, 0);
}
Example #13
0
void
aead_ctx_release(cipher_ctx_t *cipher_ctx)
{
    if (cipher_ctx->chunk != NULL) {
        bfree(cipher_ctx->chunk);
        ss_free(cipher_ctx->chunk);
        cipher_ctx->chunk = NULL;
    }

    if (cipher_ctx->cipher->method >= CHACHA20POLY1305IETF) {
        return;
    }

    if (cipher_ctx->aes256gcm_ctx != NULL) {
        ss_aligned_free(cipher_ctx->aes256gcm_ctx);
        return;
    }

    mbedtls_cipher_free(cipher_ctx->evp);
    ss_free(cipher_ctx->evp);
}
static void *color_key_create(obs_data_t *settings, obs_source_t *context)
{
	struct color_key_filter_data *filter =
		bzalloc(sizeof(struct color_key_filter_data));
	char *effect_path = obs_module_file("color_key_filter.effect");

	filter->context = context;

	obs_enter_graphics();

	filter->effect = gs_effect_create_from_file(effect_path, NULL);
	if (filter->effect) {
		filter->color_param = gs_effect_get_param_by_name(
				filter->effect, "color");
		filter->contrast_param = gs_effect_get_param_by_name(
				filter->effect, "contrast");
		filter->brightness_param = gs_effect_get_param_by_name(
				filter->effect, "brightness");
		filter->gamma_param = gs_effect_get_param_by_name(
				filter->effect, "gamma");
		filter->key_color_param = gs_effect_get_param_by_name(
				filter->effect, "key_color");
		filter->similarity_param = gs_effect_get_param_by_name(
				filter->effect, "similarity");
		filter->smoothness_param = gs_effect_get_param_by_name(
				filter->effect, "smoothness");
	}

	obs_leave_graphics();

	bfree(effect_path);

	if (!filter->effect) {
		color_key_destroy(filter);
		return NULL;
	}

	color_key_update(filter, settings);
	return filter;
}
Example #15
0
void gs_device::InitDevice(gs_init_data *data, IDXGIAdapter *adapter)
{
	wstring adapterName;
	DXGI_SWAP_CHAIN_DESC swapDesc;
	DXGI_ADAPTER_DESC desc;
	D3D_FEATURE_LEVEL levelUsed;
	HRESULT hr;

	make_swap_desc(swapDesc, data);

	uint32_t createFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef _DEBUG
	createFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	adapterName = (adapter->GetDesc(&desc) == S_OK) ? desc.Description :
		L"<unknown>";

	char *adapterNameUTF8;
	os_wcs_to_utf8(adapterName.c_str(), 0, &adapterNameUTF8);
	blog(LOG_INFO, "Loading up D3D11 on adapter %s", adapterNameUTF8);
	bfree(adapterNameUTF8);

	hr = D3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN,
			NULL, createFlags, featureLevels,
			sizeof(featureLevels) / sizeof(D3D_FEATURE_LEVEL),
			D3D11_SDK_VERSION, &swapDesc,
			defaultSwap.swap.Assign(), device.Assign(),
			&levelUsed, context.Assign());
	if (FAILED(hr))
		throw HRError("Failed to create device and swap chain", hr);

	blog(LOG_INFO, "D3D11 loaded sucessfully, feature level used: %u",
			(uint32_t)levelUsed);

	defaultSwap.device     = this;
	defaultSwap.hwnd       = (HWND)data->hwnd;
	defaultSwap.numBuffers = data->num_backbuffers;
	defaultSwap.Init(data);
}
Example #16
0
void
bfree(Device dev, long addr, int d)
{
	Iobuf *p;
	long a;
	int i;

	if(!addr)
		return;
	if(d > 0) {
		d--;
		p = getbuf(dev, addr, Bread);
		if(p) {
			for(i=INDPERBUF-1; i>=0; i--) {
				a = ((long*)p->iobuf)[i];
				bfree(dev, a, d);
			}
			putbuf(p);
		}
	}
	/*
	 * stop outstanding i/o
	 */
	p = getbuf(dev, addr, Bprobe);
	if(p) {
		p->flags &= ~(Bmod|Bimm);
		putbuf(p);
	}
	/*
	 * dont put written worm
	 * blocks into free list
	 */
	if(nofree(dev, addr))
		return;
	p = getbuf(dev, superaddr(dev), Bread|Bmod);
	if(!p || checktag(p, Tsuper, QPSUPER))
		panic("bfree: super block");
	addfree(dev, addr, (Superb*)p->iobuf);
	putbuf(p);
}
Example #17
0
accessMeth_t umGetAccessMethodForURL(char_t *url)
{
	accessMeth_t	amRet;
	char_t			*urlHavingLimit, *group;
	
	urlHavingLimit = umGetAccessLimit(url);
	if (urlHavingLimit) {
		group = umGetAccessLimitGroup(urlHavingLimit);

		if (group && *group) {
			amRet = umGetGroupAccessMethod(group);
		} else {
			amRet = umGetAccessLimitMethod(urlHavingLimit);
		}

		bfree(B_L, urlHavingLimit);
	} else {
		amRet = AM_FULL;
	}

	return amRet;
}
Example #18
0
void dstr_to_lower(struct dstr *str)
{
	wchar_t *wstr;
	wchar_t *temp;

	if (dstr_is_empty(str))
		return;

	wstr = dstr_to_wcs(str);
	temp = wstr;

	if (!wstr)
		return;

	while (*temp) {
		*temp = (wchar_t)towlower(*temp);
		temp++;
	}

	dstr_from_wcs(str, wstr);
	bfree(wstr);
}
Example #19
0
static void *filter_create(obs_data_t settings, obs_source_t source)
{
	struct test_filter *tf = bzalloc(sizeof(struct test_filter));
	char *effect_file;

	obs_enter_graphics();

	effect_file = obs_module_file("test.effect");

	tf->source = source;
	tf->whatever = gs_effect_create_from_file(effect_file, NULL);
	bfree(effect_file);
	if (!tf->whatever) {
		filter_destroy(tf);
		return NULL;
	}

	obs_leave_graphics();

	UNUSED_PARAMETER(settings);
	return tf;
}
Example #20
0
void audio_output_close(audio_t audio)
{
	void *thread_ret;
	size_t i;

	if (!audio)
		return;

	if (audio->initialized) {
		event_signal(&audio->stop_event);
		pthread_join(audio->thread, &thread_ret);
	}

	for (i = 0; i < audio->lines.num; i++)
		audio_line_destroy_data(audio->lines.array[i]);

	da_free(audio->lines);
	media_remove_output(audio->media, audio->output);
	event_destroy(&audio->stop_event);
	pthread_mutex_destroy(&audio->line_mutex);
	bfree(audio);
}
Example #21
0
static void gl_get_program_info(GLuint program, const char *file,
		char **error_string)
{
	char    *errors;
	GLint   info_len = 0;
	GLsizei chars_written = 0;

	glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_len);
	if (!gl_success("glGetProgramiv") || !info_len)
		return;

	errors = bzalloc(info_len+1);
	glGetProgramInfoLog(program, info_len, &chars_written, errors);
	gl_success("glGetProgramInfoLog");

	blog(LOG_DEBUG, "Compiler warnings/errors for %s:\n%s", file, errors);

	if (error_string)
		*error_string = errors;
	else
		bfree(errors);
}
Example #22
0
File: btree.c Project: Zkin/tux3
static int try_leaf_merge(struct btree *btree, struct buffer_head *intobuf,
			  struct buffer_head *frombuf)
{
	struct vleaf *from = bufdata(frombuf);
	struct vleaf *into = bufdata(intobuf);

	/* Try to merge leaves */
	if (btree->ops->leaf_merge(btree, into, from)) {
		struct sb *sb = btree->sb;
		/*
		 * We know frombuf is redirected and dirty. So, in
		 * here, we can just cancel leaf_redirect by bfree(),
		 * instead of defered_bfree()
		 * FIXME: we can optimize freeing leaf without
		 * leaf_redirect, and if we did, this is not true.
		 */
		bfree(sb, bufindex(frombuf), 1);
		log_leaf_free(sb, bufindex(frombuf));
		return 1;
	}
	return 0;
}
Example #23
0
void gs_destroy(graphics_t graphics)
{
	if (!graphics)
		return;

	while (thread_graphics)
		gs_leavecontext();

	if (graphics->device) {
		graphics->exports.device_entercontext(graphics->device);
		graphics->exports.vertexbuffer_destroy(graphics->sprite_buffer);
		graphics->exports.vertexbuffer_destroy(
				graphics->immediate_vertbuffer);
		graphics->exports.device_destroy(graphics->device);
	}

	pthread_mutex_destroy(&graphics->mutex);
	da_free(graphics->matrix_stack);
	da_free(graphics->viewport_stack);
	os_dlclose(graphics->module);
	bfree(graphics);
}
Example #24
0
static void obs_encoder_actually_destroy(obs_encoder_t encoder)
{
	if (encoder) {
		pthread_mutex_lock(&encoder->outputs_mutex);
		for (size_t i = 0; i < encoder->outputs.num; i++) {
			struct obs_output *output = encoder->outputs.array[i];
			obs_output_remove_encoder(output, encoder);
		}
		da_free(encoder->outputs);
		pthread_mutex_unlock(&encoder->outputs_mutex);

		free_audio_buffers(encoder);

		if (encoder->context.data)
			encoder->info.destroy(encoder->context.data);
		da_free(encoder->callbacks);
		pthread_mutex_destroy(&encoder->callbacks_mutex);
		pthread_mutex_destroy(&encoder->outputs_mutex);
		obs_context_data_free(&encoder->context);
		bfree(encoder);
	}
}
Example #25
0
static void ble_set_bda_cb(int status, void *user_data)
{
	struct ble_enable_req *req = user_data;

	if (!req)
		return;

	struct ble_enable_rsp *resp = (void *)cfw_alloc_rsp_msg(&req->header,
			    MSG_ID_BLE_ENABLE_RSP, sizeof(*resp));
	resp->status = status;

	if (status == 0) {
		resp->enable = 1;

		nble_gap_read_bda_req(resp);
	} else {
		/* error case */
		resp->enable = 0;
		cfw_send_message(resp);
	}
	bfree(req);
}
Example #26
0
static void
free_server(server_t *server)
{
    if (server->remote != NULL) {
        server->remote->server = NULL;
    }
    if (server->e_ctx != NULL) {
        crypto->ctx_release(server->e_ctx);
        ss_free(server->e_ctx);
    }
    if (server->d_ctx != NULL) {
        crypto->ctx_release(server->d_ctx);
        ss_free(server->d_ctx);
    }
    if (server->buf != NULL) {
        bfree(server->buf);
        ss_free(server->buf);
    }
    ss_free(server->recv_ctx);
    ss_free(server->send_ctx);
    ss_free(server);
}
Example #27
0
int	umSetUserPassword(char_t *user, char_t *pass)
{
	int		row, nRet;
	char_t	*password;

	a_assert(user && *user);
	a_assert(pass && *pass);
	trace(3, T("UM: Attempting to change the password for user <%s>\n"), user);
/*
 *	Find the row of the user
 */
	if ((row = dbSearchStr(didUM, UM_USER_TABLENAME, UM_NAME, user, 0)) < 0) {
		return UM_ERR_NOT_FOUND;
	}

	password = bstrdup(B_L, pass);
	umEncryptString(password);
	nRet = dbWriteStr(didUM, UM_USER_TABLENAME, UM_PASS, row, password);
	bfree(B_L, password);

	return nRet;
}
Example #28
0
static void rtmp_stream_destroy(void *data)
{
	struct rtmp_stream *stream = data;

	if (stopping(stream) && !connecting(stream)) {
		pthread_join(stream->send_thread, NULL);

	} else if (connecting(stream) || active(stream)) {
		if (stream->connecting)
			pthread_join(stream->connect_thread, NULL);

		stream->stop_ts = 0;
		os_event_signal(stream->stop_event);

		if (active(stream)) {
			os_sem_post(stream->send_sem);
			obs_output_end_data_capture(stream->output);
			pthread_join(stream->send_thread, NULL);
		}
	}

	if (stream) {
		free_packets(stream);
		dstr_free(&stream->path);
		dstr_free(&stream->key);
		dstr_free(&stream->username);
		dstr_free(&stream->password);
		dstr_free(&stream->encoder_name);
		dstr_free(&stream->bind_ip);
		os_event_destroy(stream->stop_event);
		os_sem_destroy(stream->send_sem);
		pthread_mutex_destroy(&stream->packets_mutex);
		circlebuf_free(&stream->packets);
#ifdef TEST_FRAMEDROPS
		circlebuf_free(&stream->droptest_info);
#endif
		bfree(stream);
	}
}
Example #29
0
/*
 * Create the cursor texture, either by updating if the new cursor has the same
 * size or by creating a new texture if the size is different
 */
static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) {
	uint32_t *pixels = xcursor_pixels(xc);

	if (data->tex
	&& data->last_height == xc->width
	&& data->last_width == xc->height) {
		gs_texture_set_image(data->tex, (const uint8_t *) pixels,
			xc->width * sizeof(uint32_t), False);
	} else {
		if (data->tex)
			gs_texture_destroy(data->tex);

		data->tex = gs_texture_create(xc->width, xc->height,
			GS_BGRA, 1, (const uint8_t **) &pixels, GS_DYNAMIC);
	}

	bfree(pixels);

	data->last_serial = xc->cursor_serial;
	data->last_width = xc->width;
	data->last_height = xc->height;
}
Example #30
0
bool obs_module_load()
{
	char *config_dir = obs_module_config_path(NULL);
	if (config_dir) {
		os_mkdirs(config_dir);
		bfree(config_dir);
	}

	FT_Init_FreeType(&ft2_lib);

	if (ft2_lib == NULL) {
		blog(LOG_WARNING, "FT2-text: Failed to initialize FT2.");
		return false;
	}

	if (!load_cached_os_font_list())
		load_os_font_list();

	obs_register_source(&freetype2_source_info);

	return true;
}