void obs_output_force_stop(obs_output_t *output) { if (!obs_output_valid(output, "obs_output_force_stop")) return; if (!stopping(output)) { output->stop_code = 0; do_output_signal(output, "stopping"); obs_output_actual_stop(output, true, 0); } }
bool obs_output_begin_data_capture(obs_output_t *output, uint32_t flags) { bool encoded, has_video, has_audio, has_service; if (!obs_output_valid(output, "obs_output_begin_data_capture")) return false; if (delay_active(output)) return begin_delayed_capture(output); if (active(output)) return false; output->total_frames = 0; convert_flags(output, flags, &encoded, &has_video, &has_audio, &has_service); if (!can_begin_data_capture(output, encoded, has_video, has_audio, has_service)) return false; os_atomic_set_bool(&output->data_active, true); hook_data_capture(output, encoded, has_video, has_audio); if (has_service) obs_service_activate(output->service); do_output_signal(output, "activate"); os_atomic_set_bool(&output->active, true); if (reconnecting(output)) { signal_reconnect_success(output); os_atomic_set_bool(&output->reconnecting, false); } else if (delay_active(output)) { do_output_signal(output, "starting"); } else { signal_start(output); } return true; }
void obs_output_end_data_capture(obs_output_t *output) { bool encoded, has_video, has_audio, has_service; encoded_callback_t encoded_callback; if (!obs_output_valid(output, "obs_output_end_data_capture")) return; if (output->delay_active) { output->delay_capturing = false; return; } if (!output->active) return; convert_flags(output, 0, &encoded, &has_video, &has_audio, &has_service); if (encoded) { if (output->active_delay_ns) encoded_callback = process_delay; else encoded_callback = (has_video && has_audio) ? interleave_packets : default_encoded_callback; if (has_video) obs_encoder_stop(output->video_encoder, encoded_callback, output); if (has_audio) stop_audio_encoders(output, encoded_callback); } else { if (has_video) video_output_disconnect(output->video, default_raw_video_callback, output); if (has_audio) audio_output_disconnect(output->audio, output->mixer_idx, default_raw_audio_callback, output); } if (has_service) obs_service_deactivate(output->service, false); if (output->active_delay_ns) obs_output_cleanup_delay(output); do_output_signal(output, "deactivate"); output->active = false; }
void obs_output_stop(obs_output_t *output) { bool encoded; if (!obs_output_valid(output, "obs_output_stop")) return; if (!output->context.data) return; encoded = (output->info.flags & OBS_OUTPUT_ENCODED) != 0; if (encoded && output->active_delay_ns) { obs_output_delay_stop(output); } else { obs_output_actual_stop(output, false); do_output_signal(output, "stopping"); } }
static void *end_data_capture_thread(void *data) { bool encoded, has_video, has_audio, has_service; encoded_callback_t encoded_callback; obs_output_t *output = data; convert_flags(output, 0, &encoded, &has_video, &has_audio, &has_service); if (encoded) { if (output->active_delay_ns) encoded_callback = process_delay; else encoded_callback = (has_video && has_audio) ? interleave_packets : default_encoded_callback; if (has_video) obs_encoder_stop(output->video_encoder, encoded_callback, output); if (has_audio) stop_audio_encoders(output, encoded_callback); } else { if (has_video) video_output_disconnect(output->video, default_raw_video_callback, output); if (has_audio) audio_output_disconnect(output->audio, output->mixer_idx, default_raw_audio_callback, output); } if (has_service) obs_service_deactivate(output->service, false); if (output->active_delay_ns) obs_output_cleanup_delay(output); do_output_signal(output, "deactivate"); os_atomic_set_bool(&output->active, false); os_event_signal(output->stopping_event); os_atomic_set_bool(&output->end_data_capture_thread_active, false); return NULL; }
bool obs_output_start(obs_output_t *output) { bool encoded; if (!obs_output_valid(output, "obs_output_start")) return false; if (!output->context.data) return false; encoded = (output->info.flags & OBS_OUTPUT_ENCODED) != 0; if (encoded && output->delay_sec) { return obs_output_delay_start(output); } else { if (obs_output_actual_start(output)) { do_output_signal(output, "starting"); return true; } return false; } }
void obs_output_stop(obs_output_t *output) { bool encoded; if (!obs_output_valid(output, "obs_output_stop")) return; if (!output->context.data) return; if (!active(output) && !reconnecting(output)) return; if (reconnecting(output)) { obs_output_force_stop(output); return; } encoded = (output->info.flags & OBS_OUTPUT_ENCODED) != 0; if (encoded && output->active_delay_ns) { obs_output_delay_stop(output); } else if (!stopping(output)) { do_output_signal(output, "stopping"); obs_output_actual_stop(output, false, os_gettime_ns()); } }
static inline void signal_reconnect_success(struct obs_output *output) { do_output_signal(output, "reconnect_success"); }
static inline void signal_start(struct obs_output *output) { do_output_signal(output, "start"); }