mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 09:39:15 +00:00
This deprecates the following functions, replacing them with new versions: - `obs_output_can_begin_data_capture()` - now `*capture2()` - `obs_output_initialize_encoders()` - now `*encoders2()` - `obs_output_begin_data_capture()` - now `*capture2()` The flags parameter was initially designed to support audio-only or video-only operation of an output which had the `OBS_OUTPUT_AV` flag, however, full support for that was never implemented, and there are likely fundamental issues with an implementation, mainly that most outputs are programmed assuming that there will always be at least one audio and one video track. This requires new flags specifying support for optional audio/video, among other things. An implementation to allow audio/video to be optional is best done using the flag technique above, with audio/video enablement specified by whether media (raw, `video_t/audio_t`) or encoder (`obs_encoder_t`) objects are specified. Since every implementation I could find always specifies `flags` as 0, I was able to safely conclude that immediately removing the parameter's functionality is safe to do.
100 lines
2.7 KiB
C
100 lines
2.7 KiB
C
/******************************************************************************
|
|
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
******************************************************************************/
|
|
|
|
#include <util/threading.h>
|
|
#include <obs-module.h>
|
|
|
|
struct null_output {
|
|
obs_output_t *output;
|
|
|
|
pthread_t stop_thread;
|
|
bool stop_thread_active;
|
|
};
|
|
|
|
static const char *null_output_getname(void *unused)
|
|
{
|
|
UNUSED_PARAMETER(unused);
|
|
return "Null Encoding Output";
|
|
}
|
|
|
|
static void *null_output_create(obs_data_t *settings, obs_output_t *output)
|
|
{
|
|
struct null_output *context = bzalloc(sizeof(*context));
|
|
context->output = output;
|
|
UNUSED_PARAMETER(settings);
|
|
return context;
|
|
}
|
|
|
|
static void null_output_destroy(void *data)
|
|
{
|
|
struct null_output *context = data;
|
|
if (context->stop_thread_active)
|
|
pthread_join(context->stop_thread, NULL);
|
|
bfree(context);
|
|
}
|
|
|
|
static bool null_output_start(void *data)
|
|
{
|
|
struct null_output *context = data;
|
|
|
|
if (!obs_output_can_begin_data_capture2(context->output))
|
|
return false;
|
|
if (!obs_output_initialize_encoders2(context->output))
|
|
return false;
|
|
|
|
if (context->stop_thread_active)
|
|
pthread_join(context->stop_thread, NULL);
|
|
|
|
obs_output_begin_data_capture2(context->output);
|
|
return true;
|
|
}
|
|
|
|
static void *stop_thread(void *data)
|
|
{
|
|
struct null_output *context = data;
|
|
obs_output_end_data_capture(context->output);
|
|
context->stop_thread_active = false;
|
|
return NULL;
|
|
}
|
|
|
|
static void null_output_stop(void *data, uint64_t ts)
|
|
{
|
|
struct null_output *context = data;
|
|
UNUSED_PARAMETER(ts);
|
|
|
|
context->stop_thread_active = pthread_create(&context->stop_thread,
|
|
NULL, stop_thread,
|
|
data) == 0;
|
|
}
|
|
|
|
static void null_output_data(void *data, struct encoder_packet *packet)
|
|
{
|
|
UNUSED_PARAMETER(data);
|
|
UNUSED_PARAMETER(packet);
|
|
}
|
|
|
|
struct obs_output_info null_output_info = {
|
|
.id = "null_output",
|
|
.flags = OBS_OUTPUT_AV | OBS_OUTPUT_ENCODED,
|
|
.get_name = null_output_getname,
|
|
.create = null_output_create,
|
|
.destroy = null_output_destroy,
|
|
.start = null_output_start,
|
|
.stop = null_output_stop,
|
|
.encoded_packet = null_output_data,
|
|
};
|