static void kr_mkv_rebuild_header_for_streaming (kr_mkv_t *mkv) { size_t len; uint8_t *segment; uint8_t *segment_info; kr_mkv_t *shdr; char *title; len = mkv->e->pos; mkv->stream_hdr = malloc (len); shdr = kr_mkv_create_bufsize (len); kr_ebml2_set_buffer (shdr->e, shdr->io->buf, shdr->io->space); kr_ebml2_pack_header (shdr->e, "webm", 2, 2); kr_ebml2_start_element (shdr->e, MKV_SEGMENT, &segment); title = "A Krad Restream"; kr_ebml2_start_element (shdr->e, MKV_SEGMENT_INFO, &segment_info); kr_ebml2_pack_string (shdr->e, MKV_SEGMENT_TITLE, title); kr_ebml2_pack_int32 (shdr->e, MKV_SEGMENT_TIMECODESCALE, mkv->timecode_scale); kr_ebml2_pack_string (shdr->e, MKV_SEGMENT_MUXINGAPP, KRAD_MKV_VERSION); kr_ebml2_pack_string (shdr->e, MKV_SEGMENT_WRITINGAPP, KRAD_VERSION_STRING); kr_ebml2_finish_element (shdr->e, segment_info); kr_ebml2_pack_data (shdr->e, MKV_TRACKS, mkv->tracks_info_data, mkv->tracks_info_data_size); mkv->stream_hdr_len = shdr->e->pos; memcpy (mkv->stream_hdr, shdr->e->bufstart, mkv->stream_hdr_len); kr_mkv_destroy (&shdr); }
void kr_compositor_snapshot_jpeg (kr_client_t *client) { unsigned char *command; unsigned char *snap_command; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_SNAPSHOT_JPEG, &snap_command); kr_ebml2_finish_element (client->ebml2, snap_command); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_info (kr_client_t *client) { unsigned char *mixer_command; unsigned char *get_info; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &mixer_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_GET_INFO, &get_info); kr_ebml2_finish_element (client->ebml2, get_info); kr_ebml2_finish_element (client->ebml2, mixer_command); kr_client_push (client); }
void kr_compositor_open_display (kr_client_t *client, int width, int height) { unsigned char *compositor_command; unsigned char *display; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_OPEN_DISPLAY, &display); kr_ebml2_finish_element (client->ebml2, display); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
void kr_compositor_subunit_list (kr_client_t *client) { unsigned char *command; unsigned char *list; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_LIST_SUBUNITS, &list); kr_ebml2_finish_element (client->ebml2, list); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_compositor_close_display (kr_client_t *client) { unsigned char *command; unsigned char *display; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_CLOSE_DISPLAY, &display); kr_ebml2_finish_element (client->ebml2, display); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_compositor_info (kr_client_t *client) { unsigned char *command; unsigned char *info_command; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_INFO, &info_command); kr_ebml2_finish_element (client->ebml2, info_command); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_unbind_portgroup_xmms2 (kr_client_t *client, char *portgroupname) { unsigned char *mixer_command; unsigned char *unbind; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &mixer_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_UNBIND_PORTGROUP_XMMS2, &unbind); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, portgroupname); kr_ebml2_finish_element (client->ebml2, unbind); kr_ebml2_finish_element (client->ebml2, mixer_command); kr_client_push (client); }
void kr_mixer_portgroup_list (kr_client_t *client) { unsigned char *mixer_command; unsigned char *get_portgroups; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &mixer_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_LIST_PORTGROUPS, &get_portgroups); kr_ebml2_finish_element (client->ebml2, get_portgroups); kr_ebml2_finish_element (client->ebml2, mixer_command); kr_client_push (client); }
void kr_audioport_destroy_cmd (kr_client_t *client) { unsigned char *compositor_command; unsigned char *destroy_audioport; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_LOCAL_AUDIOPORT_DESTROY, &destroy_audioport); kr_ebml2_finish_element (client->ebml2, destroy_audioport); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
void kr_mixer_bind_portgroup_xmms2 (kr_client_t *client, char *portgroupname, char *ipc_path) { unsigned char *mixer_command; unsigned char *bind; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &mixer_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_BIND_PORTGROUP_XMMS2, &bind); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, portgroupname); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_XMMS2_IPC_PATH, ipc_path); kr_ebml2_finish_element (client->ebml2, bind); kr_ebml2_finish_element (client->ebml2, mixer_command); kr_client_push (client); }
void kr_videoport_create_cmd (kr_client_t *client) { unsigned char *compositor_command; unsigned char *create_videoport; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_LOCAL_VIDEOPORT_CREATE, &create_videoport); kr_ebml2_finish_element (client->ebml2, create_videoport); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
void kr_videoport_destroy_cmd (kr_client_t *client) { unsigned char *compositor_command; unsigned char *destroy_videoport; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_LOCAL_VIDEOPORT_DESTROY, &destroy_videoport); kr_ebml2_finish_element (client->ebml2, destroy_videoport); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
void kr_compositor_subunit_destroy (kr_client_t *client, kr_address_t *address) { unsigned char *command; unsigned char *destroy; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_REMOVE_SUBUNIT, &destroy); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_RADIO_SUBUNIT, address->path.subunit.compositor_subunit); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_RADIO_SUBUNIT, address->id.number); kr_ebml2_finish_element (client->ebml2, destroy); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_set_sample_rate (kr_client_t *client, int sample_rate) { unsigned char *mixer_command; unsigned char *set_sample_rate; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &mixer_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_SET_SAMPLE_RATE, &set_sample_rate); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_MIXER_SAMPLE_RATE, sample_rate); kr_ebml2_finish_element (client->ebml2, set_sample_rate); kr_ebml2_finish_element (client->ebml2, mixer_command); kr_client_push (client); }
void kr_mixer_portgroup_info (kr_client_t *client, char *portgroupname) { unsigned char *command; unsigned char *info; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_PORTGROUP_INFO, &info); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, portgroupname); kr_ebml2_finish_element (client->ebml2, info); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_remove_portgroup (kr_client_t *client, char *name) { unsigned char *command; unsigned char *destroy; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_DESTROY_PORTGROUP, &destroy); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, name); kr_ebml2_finish_element (client->ebml2, destroy); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_push_tone (kr_client_t *client, char *tone) { unsigned char *command; unsigned char *push; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_PUSH_TONE, &push); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_TONE_NAME, tone); kr_ebml2_finish_element (client->ebml2, push); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_unplug_portgroup (kr_client_t *client, char *name, char *remote_name) { unsigned char *command; unsigned char *unplug; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_UNPLUG_PORTGROUP, &unplug); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, name); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, remote_name); kr_ebml2_finish_element (client->ebml2, unplug); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_compositor_set_resolution (kr_client_t *client, int width, int height) { unsigned char *compositor_command; unsigned char *set_resolution; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_SET_RESOLUTION, &set_resolution); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_COMPOSITOR_WIDTH, width); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_COMPOSITOR_HEIGHT, height); kr_ebml2_finish_element (client->ebml2, set_resolution); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
void kr_mixer_set_portgroup_crossfade_group (kr_client_t *client, char *portgroupname, char *crossfade_group) { unsigned char *command; unsigned char *update; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_UPDATE_PORTGROUP, &update); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, portgroupname); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_CROSSFADE_NAME, crossfade_group); kr_ebml2_finish_element (client->ebml2, update); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_mixer_create_portgroup (kr_client_t *client, char *name, char *direction, int channels) { unsigned char *command; unsigned char *create; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_CREATE_PORTGROUP, &create); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, name); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_DIRECTION, direction); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_CHANNELS, channels); kr_ebml2_finish_element (client->ebml2, create); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
void kr_compositor_set_frame_rate (kr_client_t *client, int numerator, int denominator) { unsigned char *compositor_command; unsigned char *set_frame_rate; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_SET_FRAME_RATE, &set_frame_rate); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_COMPOSITOR_FPS_NUMERATOR, numerator); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_COMPOSITOR_FPS_DENOMINATOR, denominator); kr_ebml2_finish_element (client->ebml2, set_frame_rate); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
void kr_mixer_set_control (kr_client_t *client, char *portgroup_name, char *control_name, float control_value, int duration) { unsigned char *mixer_command; unsigned char *set_control; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &mixer_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_SET_CONTROL, &set_control); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, portgroup_name); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_CONTROL_NAME, control_name); kr_ebml2_pack_float (client->ebml2, EBML_ID_KRAD_MIXER_CONTROL_VALUE, control_value); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_MIXER_CONTROL_DURATION, duration); kr_ebml2_finish_element (client->ebml2, set_control); kr_ebml2_finish_element (client->ebml2, mixer_command); kr_client_push (client); }
void kr_audioport_create_cmd (kr_client_t *client, krad_mixer_portgroup_direction_t direction) { unsigned char *compositor_command; unsigned char *create_audioport; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &compositor_command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_LOCAL_AUDIOPORT_CREATE, &create_audioport); if (direction == OUTPUT) { kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_DIRECTION, "output"); } else { kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_DIRECTION, "input"); } kr_ebml2_finish_element (client->ebml2, create_audioport); kr_ebml2_finish_element (client->ebml2, compositor_command); kr_client_push (client); }
int kr_compositor_background (kr_client_t *client, char *filename) { unsigned char *command; unsigned char *background; if ((filename == NULL) || (!(strlen(filename)))) { return 0; } kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_SET_BACKGROUND, &background); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_COMPOSITOR_FILENAME, filename); kr_ebml2_finish_element (client->ebml2, background); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); return 1; }
void kr_mixer_update_portgroup_mixmap_channel (kr_client_t *client, char *portgroupname, int in_channel, int out_channel) { unsigned char *command; unsigned char *update; unsigned char *map; kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_CMD_UPDATE_PORTGROUP, &update); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_NAME, portgroupname); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_MIXER_MIXMAP_CHANNEL, &map); kr_ebml2_finish_element (client->ebml2, map); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_CHANNEL, in_channel); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_MIXER_PORTGROUP_CHANNEL, out_channel); kr_ebml2_finish_element (client->ebml2, update); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); }
int kr_compositor_subunit_create (kr_client_t *client, kr_compositor_subunit_t type, char *option, char *option2) { unsigned char *command; unsigned char *subunit; command = 0; subunit = 0; switch ( type ) { case KR_SPRITE: case KR_TEXT: case KR_VECTOR: case KR_VIDEOPORT: if ((option != NULL) && (strlen(option))) { break; } default: return 0; } if (option2 == NULL) { option2 = ""; } kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD, &command); kr_ebml2_start_element (client->ebml2, EBML_ID_KRAD_COMPOSITOR_CMD_ADD_SUBUNIT, &subunit); kr_ebml2_pack_int32 (client->ebml2, EBML_ID_KRAD_RADIO_SUBUNIT, type); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_RADIO_SUBUNIT, option); kr_ebml2_pack_string (client->ebml2, EBML_ID_KRAD_RADIO_SUBUNIT, option2); kr_ebml2_finish_element (client->ebml2, subunit); kr_ebml2_finish_element (client->ebml2, command); kr_client_push (client); return 1; }