static void interleave_packets(void *data, struct encoder_packet *packet) { struct obs_output *output = data; struct encoder_packet out; bool was_started; if (!active(output)) return; if (packet->type == OBS_ENCODER_AUDIO) packet->track_idx = get_track_index(output, packet); pthread_mutex_lock(&output->interleaved_mutex); /* if first video frame is not a keyframe, discard until received */ if (!output->received_video && packet->type == OBS_ENCODER_VIDEO && !packet->keyframe) { discard_unused_audio_packets(output, packet->dts_usec); pthread_mutex_unlock(&output->interleaved_mutex); if (output->active_delay_ns) obs_free_encoder_packet(packet); return; } was_started = output->received_audio && output->received_video; if (output->active_delay_ns) out = *packet; else obs_duplicate_encoder_packet(&out, packet); if (was_started) apply_interleaved_packet_offset(output, &out); else check_received(output, packet); insert_interleaved_packet(output, &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) { if (!was_started) { if (prune_interleaved_packets(output)) { if (initialize_interleaved_packets(output)) { resort_interleaved_packets(output); send_interleaved(output); } } } else { send_interleaved(output); } } pthread_mutex_unlock(&output->interleaved_mutex); }
static void default_encoded_callback(void *param, struct encoder_packet *packet) { struct obs_output *output = param; if (packet->type == OBS_ENCODER_AUDIO) packet->track_idx = get_track_index(output, packet); if (!output->stopped) output->info.encoded_packet(output->context.data, packet); if (packet->type == OBS_ENCODER_VIDEO) output->total_frames++; }
static void default_encoded_callback(void *param, struct encoder_packet *packet) { struct obs_output *output = param; if (data_active(output)) { if (packet->type == OBS_ENCODER_AUDIO) packet->track_idx = get_track_index(output, packet); output->info.encoded_packet(output->context.data, packet); if (packet->type == OBS_ENCODER_VIDEO) output->total_frames++; } if (output->active_delay_ns) obs_free_encoder_packet(packet); }
static void interleave_packets(void *data, struct encoder_packet *packet) { struct obs_output *output = data; struct encoder_packet out; bool was_started; if (packet->type == OBS_ENCODER_AUDIO) packet->track_idx = get_track_index(output, packet); pthread_mutex_lock(&output->interleaved_mutex); was_started = output->received_audio && output->received_video; if (output->active_delay_ns) out = *packet; else obs_duplicate_encoder_packet(&out, packet); if (was_started) apply_interleaved_packet_offset(output, &out); else check_received(output, packet); insert_interleaved_packet(output, &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) { if (!was_started) { prune_interleaved_packets(output); if (initialize_interleaved_packets(output)) { resort_interleaved_packets(output); send_interleaved(output); } } else { send_interleaved(output); } } pthread_mutex_unlock(&output->interleaved_mutex); }