예제 #1
0
static void interleave_packets(void *data, struct encoder_packet *packet)
{
	struct obs_output     *output = data;
	struct encoder_packet out;
	size_t                idx;

	pthread_mutex_lock(&output->interleaved_mutex);

	if (prepare_interleaved_packet(output, &out, packet)) {
		for (idx = 0; idx < output->interleaved_packets.num; idx++) {
			struct encoder_packet *cur_packet;
			cur_packet = output->interleaved_packets.array + idx;

			if (out.dts_usec < cur_packet->dts_usec)
				break;
		}

		da_insert(output->interleaved_packets, idx, &out);
		set_higher_ts(output, &out);

		/* when both video and audio have been received, we're ready
		 * to start sending out packets (one at a time) */
		if (output->received_audio && output->received_video)
			send_interleaved(output);
	}

	pthread_mutex_unlock(&output->interleaved_mutex);
}
예제 #2
0
static inline void insert_interleaved_packet(struct obs_output *output,
		struct encoder_packet *out)
{
	size_t idx;
	for (idx = 0; idx < output->interleaved_packets.num; idx++) {
		struct encoder_packet *cur_packet;
		cur_packet = output->interleaved_packets.array + idx;

		if (out->dts_usec < cur_packet->dts_usec)
			break;
	}

	da_insert(output->interleaved_packets, idx, out);
}
예제 #3
0
static void da_insert_test(void) {
    printsln((String)__func__);
    Array ac, ex;

    ac = da_of_string("1, 2, 3, 4, 5, 6");
    da_insert(ac, 0, 9);
    ex = da_of_string("9, 1, 2, 3, 4, 5");
    da_check_within(ac, ex);
    a_free(ac);
    a_free(ex);

    ac = da_of_string("1, 2, 3, 4, 5, 6");
    da_insert(ac, 5, 9);
    ex = da_of_string("1, 2, 3, 4, 5, 9");
    da_check_within(ac, ex);
    a_free(ac);
    a_free(ex);

    ac = da_of_string("1, 2, 3, 4, 5, 6");
    da_insert(ac, 3, 9);
    ex = da_of_string("1, 2, 3, 9, 4, 5");
    da_check_within(ac, ex);
    a_free(ac);
    a_free(ex);

    ac = da_of_string("1");
    da_insert(ac, -1, 9);
    ex = da_of_string("1");
    da_check_within(ac, ex);
    a_free(ac);
    a_free(ex);

    ac = da_of_string("1");
    da_insert(ac, 1, 9);
    ex = da_of_string("1");
    da_check_within(ac, ex);
    a_free(ac);
    a_free(ex);

    ac = da_of_string("");
    da_insert(ac, 0, 9);
    ex = da_of_string("");
    da_check_within(ac, ex);
    a_free(ac);
    a_free(ex);
}