2013-09-30 19:37:13 -07:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.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
|
2013-12-02 21:24:38 -08:00
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
2013-09-30 19:37:13 -07:00
|
|
|
(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/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-12-30 09:09:20 -08:00
|
|
|
#include "callback/calldata.h"
|
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
#include "obs.h"
|
2014-01-26 17:48:14 -08:00
|
|
|
#include "obs-internal.h"
|
2013-09-30 19:37:13 -07:00
|
|
|
#include "obs-module.h"
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
struct obs_subsystem *obs = NULL;
|
2013-10-14 12:37:52 -07:00
|
|
|
|
2013-11-01 14:33:00 -07:00
|
|
|
extern char *find_libobs_data_file(const char *file);
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
static inline void make_gs_init_data(struct gs_init_data *gid,
|
|
|
|
struct obs_video_info *ovi)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-11-20 14:00:16 -08:00
|
|
|
memcpy(&gid->window, &ovi->window, sizeof(struct gs_window));
|
2013-11-26 21:20:11 -08:00
|
|
|
gid->cx = ovi->window_width;
|
|
|
|
gid->cy = ovi->window_height;
|
2013-11-20 14:00:16 -08:00
|
|
|
gid->num_backbuffers = 2;
|
|
|
|
gid->format = GS_RGBA;
|
|
|
|
gid->zsformat = GS_ZS_NONE;
|
|
|
|
gid->adapter = ovi->adapter;
|
|
|
|
}
|
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
static inline void make_video_info(struct video_output_info *vi,
|
2013-11-20 14:00:16 -08:00
|
|
|
struct obs_video_info *ovi)
|
|
|
|
{
|
|
|
|
vi->name = "video";
|
2014-01-19 02:16:41 -08:00
|
|
|
vi->format = ovi->output_format;
|
2013-11-20 14:00:16 -08:00
|
|
|
vi->fps_num = ovi->fps_num;
|
|
|
|
vi->fps_den = ovi->fps_den;
|
|
|
|
vi->width = ovi->output_width;
|
|
|
|
vi->height = ovi->output_height;
|
|
|
|
}
|
|
|
|
|
2013-11-26 21:20:11 -08:00
|
|
|
static bool obs_init_textures(struct obs_video_info *ovi)
|
|
|
|
{
|
|
|
|
struct obs_video *video = &obs->video;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_TEXTURES; i++) {
|
|
|
|
video->copy_surfaces[i] = gs_create_stagesurface(
|
|
|
|
ovi->output_width, ovi->output_height,
|
|
|
|
GS_RGBA);
|
|
|
|
|
|
|
|
if (!video->copy_surfaces[i])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
video->render_textures[i] = gs_create_texture(
|
|
|
|
ovi->base_width, ovi->base_height,
|
|
|
|
GS_RGBA, 1, NULL, GS_RENDERTARGET);
|
|
|
|
|
|
|
|
if (!video->render_textures[i])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
video->output_textures[i] = gs_create_texture(
|
|
|
|
ovi->output_width, ovi->output_height,
|
|
|
|
GS_RGBA, 1, NULL, GS_RENDERTARGET);
|
|
|
|
|
|
|
|
if (!video->output_textures[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
static bool obs_init_graphics(struct obs_video_info *ovi)
|
|
|
|
{
|
|
|
|
struct obs_video *video = &obs->video;
|
|
|
|
struct gs_init_data graphics_data;
|
2013-10-25 10:25:28 -07:00
|
|
|
bool success = true;
|
2013-11-20 14:00:16 -08:00
|
|
|
int errorcode;
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
make_gs_init_data(&graphics_data, ovi);
|
2013-12-06 05:38:19 -08:00
|
|
|
video->base_width = ovi->base_width;
|
|
|
|
video->base_height = ovi->base_height;
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
errorcode = gs_create(&video->graphics, ovi->graphics_module,
|
|
|
|
&graphics_data);
|
2013-09-30 19:37:13 -07:00
|
|
|
if (errorcode != GS_SUCCESS) {
|
|
|
|
if (errorcode == GS_ERROR_MODULENOTFOUND)
|
|
|
|
blog(LOG_ERROR, "Could not find graphics module '%s'",
|
2013-11-20 14:00:16 -08:00
|
|
|
ovi->graphics_module);
|
2013-09-30 19:37:13 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
gs_entercontext(video->graphics);
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-11-26 21:20:11 -08:00
|
|
|
if (!obs_init_textures(ovi))
|
|
|
|
success = false;
|
2013-10-25 10:25:28 -07:00
|
|
|
|
|
|
|
if (success) {
|
2013-11-01 14:33:00 -07:00
|
|
|
char *filename = find_libobs_data_file("default.effect");
|
2013-11-20 14:00:16 -08:00
|
|
|
video->default_effect = gs_create_effect_from_file(filename,
|
2013-11-01 14:33:00 -07:00
|
|
|
NULL);
|
|
|
|
bfree(filename);
|
2013-11-20 14:00:16 -08:00
|
|
|
if (!video->default_effect)
|
2013-10-25 10:25:28 -07:00
|
|
|
success = false;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-10-14 12:37:52 -07:00
|
|
|
gs_leavecontext();
|
2013-10-25 10:25:28 -07:00
|
|
|
return success;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
static bool obs_init_video(struct obs_video_info *ovi)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-11-20 14:00:16 -08:00
|
|
|
struct obs_video *video = &obs->video;
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
struct video_output_info vi;
|
2013-11-20 14:00:16 -08:00
|
|
|
int errorcode;
|
|
|
|
|
|
|
|
make_video_info(&vi, ovi);
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
errorcode = video_output_open(&video->video, &vi);
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
if (errorcode != VIDEO_OUTPUT_SUCCESS) {
|
|
|
|
if (errorcode == VIDEO_OUTPUT_INVALIDPARAM)
|
|
|
|
blog(LOG_ERROR, "Invalid video parameters specified");
|
|
|
|
else
|
|
|
|
blog(LOG_ERROR, "Could not open video output");
|
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
return false;
|
2013-11-20 14:00:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
errorcode = pthread_create(&video->video_thread, NULL,
|
|
|
|
obs_video_thread, obs);
|
|
|
|
if (errorcode != 0)
|
2013-09-30 19:37:13 -07:00
|
|
|
return false;
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
video->thread_initialized = true;
|
2013-09-30 19:37:13 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-26 21:20:11 -08:00
|
|
|
static void obs_free_video()
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-11-20 14:00:16 -08:00
|
|
|
struct obs_video *video = &obs->video;
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
if (video->video) {
|
|
|
|
void *thread_retval;
|
|
|
|
|
|
|
|
video_output_stop(video->video);
|
2013-11-26 21:20:11 -08:00
|
|
|
if (video->thread_initialized) {
|
2013-11-20 14:00:16 -08:00
|
|
|
pthread_join(video->video_thread, &thread_retval);
|
2013-11-26 21:20:11 -08:00
|
|
|
video->thread_initialized = false;
|
|
|
|
}
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
video_output_close(video->video);
|
2013-11-26 21:20:11 -08:00
|
|
|
video->video = NULL;
|
2013-11-20 14:00:16 -08:00
|
|
|
}
|
2013-11-26 21:20:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void obs_free_graphics()
|
|
|
|
{
|
|
|
|
struct obs_video *video = &obs->video;
|
|
|
|
size_t i;
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
if (video->graphics) {
|
|
|
|
int cur_texture = video->cur_texture;
|
|
|
|
gs_entercontext(video->graphics);
|
|
|
|
|
|
|
|
if (video->copy_mapped)
|
|
|
|
stagesurface_unmap(video->copy_surfaces[cur_texture]);
|
|
|
|
|
2013-11-26 21:20:11 -08:00
|
|
|
for (i = 0; i < NUM_TEXTURES; i++) {
|
2013-11-20 14:00:16 -08:00
|
|
|
stagesurface_destroy(video->copy_surfaces[i]);
|
2013-11-26 21:20:11 -08:00
|
|
|
texture_destroy(video->render_textures[i]);
|
|
|
|
texture_destroy(video->output_textures[i]);
|
|
|
|
|
|
|
|
video->copy_surfaces[i] = NULL;
|
|
|
|
video->render_textures[i] = NULL;
|
|
|
|
video->output_textures[i] = NULL;
|
|
|
|
}
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
effect_destroy(video->default_effect);
|
2013-11-26 21:20:11 -08:00
|
|
|
video->default_effect = NULL;
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
gs_leavecontext();
|
|
|
|
|
|
|
|
gs_destroy(video->graphics);
|
2013-11-26 21:20:11 -08:00
|
|
|
video->graphics = NULL;
|
|
|
|
video->cur_texture = 0;
|
2013-11-20 14:00:16 -08:00
|
|
|
}
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
static bool obs_init_audio(struct audio_output_info *ai)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-11-20 14:00:16 -08:00
|
|
|
struct obs_audio *audio = &obs->audio;
|
|
|
|
int errorcode;
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
/* TODO: sound subsystem */
|
2013-09-30 19:37:13 -07:00
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
errorcode = audio_output_open(&audio->audio, ai);
|
2013-11-20 14:00:16 -08:00
|
|
|
if (errorcode == AUDIO_OUTPUT_SUCCESS)
|
|
|
|
return true;
|
2013-11-20 14:11:31 -08:00
|
|
|
else if (errorcode == AUDIO_OUTPUT_INVALIDPARAM)
|
2013-11-20 14:00:16 -08:00
|
|
|
blog(LOG_ERROR, "Invalid audio parameters specified");
|
|
|
|
else
|
|
|
|
blog(LOG_ERROR, "Could not open audio output");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void obs_free_audio(void)
|
|
|
|
{
|
|
|
|
struct obs_audio *audio = &obs->audio;
|
|
|
|
if (audio->audio)
|
|
|
|
audio_output_close(audio->audio);
|
|
|
|
|
|
|
|
memset(audio, 0, sizeof(struct obs_audio));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool obs_init_data(void)
|
|
|
|
{
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data *data = &obs->data;
|
2014-01-08 17:07:04 -08:00
|
|
|
pthread_mutexattr_t attr;
|
|
|
|
bool success = false;
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
pthread_mutex_init_value(&obs->data.displays_mutex);
|
|
|
|
|
2014-01-08 17:07:04 -08:00
|
|
|
if (pthread_mutexattr_init(&attr) != 0)
|
2013-10-14 12:37:52 -07:00
|
|
|
return false;
|
2014-01-08 17:07:04 -08:00
|
|
|
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0)
|
|
|
|
goto fail;
|
|
|
|
if (pthread_mutex_init(&data->sources_mutex, &attr) != 0)
|
|
|
|
goto fail;
|
|
|
|
if (pthread_mutex_init(&data->displays_mutex, &attr) != 0)
|
|
|
|
goto fail;
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
if (pthread_mutex_init(&data->outputs_mutex, &attr) != 0)
|
|
|
|
goto fail;
|
|
|
|
if (pthread_mutex_init(&data->encoders_mutex, &attr) != 0)
|
|
|
|
goto fail;
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2014-01-23 16:00:42 -08:00
|
|
|
data->valid = true;
|
2014-01-08 17:07:04 -08:00
|
|
|
|
|
|
|
fail:
|
|
|
|
pthread_mutexattr_destroy(&attr);
|
2014-01-23 16:00:42 -08:00
|
|
|
return data->valid;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
static void obs_free_data(void)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data *data = &obs->data;
|
2013-11-22 09:02:57 -08:00
|
|
|
uint32_t i;
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2014-01-23 16:00:42 -08:00
|
|
|
data->valid = false;
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
for (i = 0; i < MAX_CHANNELS; i++)
|
|
|
|
obs_set_output_source(i, NULL);
|
|
|
|
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
while (data->outputs.num)
|
|
|
|
obs_output_destroy(data->outputs.array[0]);
|
|
|
|
while (data->encoders.num)
|
|
|
|
obs_encoder_destroy(data->encoders.array[0]);
|
2013-11-20 14:00:16 -08:00
|
|
|
while (data->displays.num)
|
|
|
|
obs_display_destroy(data->displays.array[0]);
|
2013-10-14 12:37:52 -07:00
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
pthread_mutex_lock(&obs->data.sources_mutex);
|
|
|
|
for (i = 0; i < data->sources.num; i++)
|
|
|
|
obs_source_release(data->sources.array[i]);
|
|
|
|
da_free(data->sources);
|
|
|
|
pthread_mutex_unlock(&obs->data.sources_mutex);
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
|
|
|
|
pthread_mutex_destroy(&data->sources_mutex);
|
|
|
|
pthread_mutex_destroy(&data->displays_mutex);
|
|
|
|
pthread_mutex_destroy(&data->outputs_mutex);
|
|
|
|
pthread_mutex_destroy(&data->encoders_mutex);
|
2013-11-20 14:00:16 -08:00
|
|
|
}
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-12-26 22:10:15 -08:00
|
|
|
static inline bool obs_init_handlers(void)
|
|
|
|
{
|
|
|
|
obs->signals = signal_handler_create();
|
|
|
|
if (!obs->signals)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
obs->procs = proc_handler_create();
|
|
|
|
return (obs->procs != NULL);
|
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
static bool obs_init(void)
|
|
|
|
{
|
|
|
|
obs = bmalloc(sizeof(struct obs_subsystem));
|
|
|
|
memset(obs, 0, sizeof(struct obs_subsystem));
|
2013-10-14 12:37:52 -07:00
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
obs_init_data();
|
|
|
|
return obs_init_handlers();
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
bool obs_startup()
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-11-20 14:00:16 -08:00
|
|
|
bool success;
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
if (obs) {
|
|
|
|
blog(LOG_ERROR, "Tried to call obs_startup more than once");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = obs_init();
|
|
|
|
if (!success)
|
|
|
|
obs_shutdown();
|
|
|
|
|
|
|
|
return success;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
void obs_shutdown(void)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!obs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
da_free(obs->input_types);
|
|
|
|
da_free(obs->filter_types);
|
|
|
|
da_free(obs->transition_types);
|
|
|
|
da_free(obs->output_types);
|
2013-11-20 14:00:16 -08:00
|
|
|
da_free(obs->service_types);
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
obs_free_data();
|
|
|
|
obs_free_video();
|
2013-11-26 21:20:11 -08:00
|
|
|
obs_free_graphics();
|
2013-11-20 14:00:16 -08:00
|
|
|
obs_free_audio();
|
2013-12-26 22:10:15 -08:00
|
|
|
proc_handler_destroy(obs->procs);
|
|
|
|
signal_handler_destroy(obs->signals);
|
2013-09-30 19:37:13 -07:00
|
|
|
|
|
|
|
for (i = 0; i < obs->modules.num; i++)
|
|
|
|
free_module(obs->modules.array+i);
|
|
|
|
da_free(obs->modules);
|
|
|
|
|
|
|
|
bfree(obs);
|
2013-10-14 12:37:52 -07:00
|
|
|
obs = NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
bool obs_reset_video(struct obs_video_info *ovi)
|
2013-10-14 12:37:52 -07:00
|
|
|
{
|
2013-11-26 21:20:11 -08:00
|
|
|
struct obs_video *video = &obs->video;
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
obs_free_video();
|
2013-10-14 12:37:52 -07:00
|
|
|
|
2013-11-26 21:20:11 -08:00
|
|
|
if (!ovi) {
|
|
|
|
obs_free_graphics();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!video->graphics && !obs_init_graphics(ovi))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return obs_init_video(ovi);
|
2013-10-14 12:37:52 -07:00
|
|
|
}
|
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
bool obs_reset_audio(struct audio_output_info *ai)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2014-01-09 18:08:20 -08:00
|
|
|
obs_free_audio();
|
2013-11-26 21:20:11 -08:00
|
|
|
if(!ai)
|
|
|
|
return true;
|
|
|
|
|
2014-01-09 18:08:20 -08:00
|
|
|
return obs_init_audio(ai);
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-12-06 05:38:19 -08:00
|
|
|
bool obs_get_video_info(struct obs_video_info *ovi)
|
|
|
|
{
|
|
|
|
struct obs_video *video = &obs->video;
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
const struct video_output_info *info;
|
2013-12-06 05:38:19 -08:00
|
|
|
|
2013-12-22 22:40:07 -08:00
|
|
|
if (!obs || !video->graphics)
|
2013-12-06 05:38:19 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
info = video_output_getinfo(video->video);
|
|
|
|
|
|
|
|
memset(ovi, 0, sizeof(struct obs_video_info));
|
|
|
|
ovi->base_width = video->base_width;
|
|
|
|
ovi->base_height = video->base_height;
|
|
|
|
ovi->output_width = info->width;
|
|
|
|
ovi->output_height = info->height;
|
2014-01-19 02:16:41 -08:00
|
|
|
ovi->output_format = info->format;
|
2013-12-06 05:38:19 -08:00
|
|
|
ovi->fps_num = info->fps_num;
|
|
|
|
ovi->fps_den = info->fps_den;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
bool obs_get_audio_info(struct audio_output_info *aoi)
|
2013-12-06 05:38:19 -08:00
|
|
|
{
|
|
|
|
struct obs_audio *audio = &obs->audio;
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
const struct audio_output_info *info;
|
2013-12-06 05:38:19 -08:00
|
|
|
|
2013-12-22 22:40:07 -08:00
|
|
|
if (!obs || !audio->audio)
|
2013-12-06 05:38:19 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
info = audio_output_getinfo(audio->audio);
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
memcpy(aoi, info, sizeof(struct audio_output_info));
|
2013-12-06 05:38:19 -08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-20 16:23:19 -08:00
|
|
|
bool obs_enum_input_types(size_t idx, const char **id)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
|
|
|
if (idx >= obs->input_types.num)
|
|
|
|
return false;
|
2013-12-20 16:23:19 -08:00
|
|
|
*id = obs->input_types.array[idx].id;
|
2013-09-30 19:37:13 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-20 16:23:19 -08:00
|
|
|
bool obs_enum_filter_types(size_t idx, const char **id)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
|
|
|
if (idx >= obs->filter_types.num)
|
|
|
|
return false;
|
2013-12-20 16:23:19 -08:00
|
|
|
*id = obs->filter_types.array[idx].id;
|
2013-09-30 19:37:13 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-20 16:23:19 -08:00
|
|
|
bool obs_enum_transition_types(size_t idx, const char **id)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
|
|
|
if (idx >= obs->transition_types.num)
|
|
|
|
return false;
|
2013-12-20 16:23:19 -08:00
|
|
|
*id = obs->transition_types.array[idx].id;
|
2013-09-30 19:37:13 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-20 16:23:19 -08:00
|
|
|
bool obs_enum_output_types(size_t idx, const char **id)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
|
|
|
if (idx >= obs->output_types.num)
|
|
|
|
return false;
|
2013-12-20 16:23:19 -08:00
|
|
|
*id = obs->output_types.array[idx].id;
|
2013-09-30 19:37:13 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-14 12:37:52 -07:00
|
|
|
graphics_t obs_graphics(void)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-12-31 06:10:47 -08:00
|
|
|
return (obs != NULL) ? obs->video.graphics : NULL;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
audio_t obs_audio(void)
|
|
|
|
{
|
|
|
|
return (obs != NULL) ? obs->audio.audio : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
video_t obs_video(void)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers. The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do. (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)
Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them. Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.
My true goal for this is to make output and encoder plugins as simple to
create as possible. I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc. A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.
Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 00:58:47 -08:00
|
|
|
return (obs != NULL) ? obs->video.video : NULL;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
bool obs_add_source(obs_source_t source)
|
|
|
|
{
|
2013-12-28 04:33:16 -08:00
|
|
|
struct calldata params = {0};
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
pthread_mutex_lock(&obs->data.sources_mutex);
|
|
|
|
da_push_back(obs->data.sources, &source);
|
|
|
|
obs_source_addref(source);
|
|
|
|
pthread_mutex_unlock(&obs->data.sources_mutex);
|
|
|
|
|
2013-12-28 04:33:16 -08:00
|
|
|
calldata_setptr(¶ms, "source", source);
|
|
|
|
signal_handler_signal(obs->signals, "source-add", ¶ms);
|
|
|
|
calldata_free(¶ms);
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_source_t obs_get_output_source(uint32_t channel)
|
|
|
|
{
|
2013-11-22 15:18:31 -08:00
|
|
|
struct obs_source *source;
|
2013-11-20 14:00:16 -08:00
|
|
|
assert(channel < MAX_CHANNELS);
|
2013-11-22 15:18:31 -08:00
|
|
|
source = obs->data.channels[channel];
|
|
|
|
|
|
|
|
obs_source_addref(source);
|
|
|
|
return source;
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
void obs_set_output_source(uint32_t channel, obs_source_t source)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
2013-11-20 14:00:16 -08:00
|
|
|
struct obs_source *prev_source;
|
2014-01-04 12:38:56 -08:00
|
|
|
struct calldata params = {0};
|
2013-11-20 14:00:16 -08:00
|
|
|
assert(channel < MAX_CHANNELS);
|
|
|
|
|
|
|
|
prev_source = obs->data.channels[channel];
|
2014-01-04 12:38:56 -08:00
|
|
|
|
|
|
|
calldata_setuint32(¶ms, "channel", channel);
|
|
|
|
calldata_setptr(¶ms, "prev_source", prev_source);
|
|
|
|
calldata_setptr(¶ms, "source", source);
|
|
|
|
signal_handler_signal(obs->signals, "channel-change", ¶ms);
|
|
|
|
calldata_getptr(¶ms, "source", &source);
|
|
|
|
calldata_free(¶ms);
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
obs->data.channels[channel] = source;
|
|
|
|
|
2014-01-04 12:38:56 -08:00
|
|
|
if (source != prev_source) {
|
|
|
|
if (source)
|
|
|
|
obs_source_addref(source);
|
|
|
|
if (prev_source)
|
|
|
|
obs_source_release(prev_source);
|
|
|
|
}
|
2013-09-30 19:37:13 -07:00
|
|
|
}
|
2013-11-22 15:18:31 -08:00
|
|
|
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
void obs_enum_outputs(bool (*enum_proc)(void*, obs_output_t), void *param)
|
|
|
|
{
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data *data = &obs->data;
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
|
|
|
|
pthread_mutex_lock(&data->outputs_mutex);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < data->outputs.num; i++)
|
|
|
|
if (!enum_proc(param, data->outputs.array[i]))
|
|
|
|
break;
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&data->outputs_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_enum_encoders(bool (*enum_proc)(void*, obs_encoder_t), void *param)
|
|
|
|
{
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data *data = &obs->data;
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
|
|
|
|
pthread_mutex_lock(&data->encoders_mutex);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < data->encoders.num; i++)
|
|
|
|
if (!enum_proc(param, data->encoders.array[i]))
|
|
|
|
break;
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&data->encoders_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_enum_sources(bool (*enum_proc)(void*, obs_source_t), void *param)
|
2013-11-22 15:18:31 -08:00
|
|
|
{
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data *data = &obs->data;
|
2013-11-22 15:18:31 -08:00
|
|
|
|
|
|
|
pthread_mutex_lock(&data->sources_mutex);
|
|
|
|
|
Add preliminary output/encoder interface
- First, I redid the output interface for libobs. I feel like it's
going in a pretty good direction in terms of design.
Right now, the design is so that outputs and encoders are separate.
One or more outputs can connect to a specific encoder to receive its
data, or the output can connect directly to raw data from libobs
output itself, if the output doesn't want to use a designated encoder.
Data is received via callbacks set when you connect to the encoder or
raw output. Multiple outputs can receive the data from a single
encoder context if need be (such as for streaming to multiple channels
at once, and/or recording with the same data).
When an encoder is first connected to, it will connect to raw output,
and start encoding. Additional connections will receive that same
data being encoded as well after that. When the last encoder has
disconnected, it will stop encoding. If for some reason the encoder
needs to stop, it will use the callback with NULL to signal that
encoding has stopped. Some of these things may be subject to change
in the future, though it feels pretty good with this design so far.
Will have to see how well it works out in practice versus theory.
- Second, Started adding preliminary RTMP/x264 output plugin code.
To speed things up, I might just make a direct raw->FFmpeg output to
create a quick output plugin that we can start using for testing all
the subsystems.
2014-01-16 21:34:51 -08:00
|
|
|
for (size_t i = 0; i < data->sources.num; i++)
|
|
|
|
if (!enum_proc(param, data->sources.array[i]))
|
2013-12-20 18:35:12 -08:00
|
|
|
break;
|
2013-11-22 15:18:31 -08:00
|
|
|
|
|
|
|
pthread_mutex_unlock(&data->sources_mutex);
|
|
|
|
}
|
2013-12-20 18:35:12 -08:00
|
|
|
|
|
|
|
obs_source_t obs_get_source_by_name(const char *name)
|
|
|
|
{
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data *data = &obs->data;
|
2013-12-20 18:35:12 -08:00
|
|
|
struct obs_source *source = NULL;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
pthread_mutex_lock(&data->sources_mutex);
|
|
|
|
|
|
|
|
for (i = 0; i < data->sources.num; i++) {
|
|
|
|
struct obs_source *cur_source = data->sources.array[i];
|
|
|
|
if (strcmp(cur_source->name, name) == 0) {
|
|
|
|
source = cur_source;
|
2013-12-29 08:17:00 -08:00
|
|
|
obs_source_addref(source);
|
2013-12-20 18:35:12 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&data->sources_mutex);
|
|
|
|
return source;
|
|
|
|
}
|
2013-12-22 00:30:18 -08:00
|
|
|
|
|
|
|
effect_t obs_get_default_effect(void)
|
|
|
|
{
|
|
|
|
return obs->video.default_effect;
|
|
|
|
}
|
2013-12-26 22:10:15 -08:00
|
|
|
|
|
|
|
signal_handler_t obs_signalhandler(void)
|
|
|
|
{
|
|
|
|
return obs->signals;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc_handler_t obs_prochandler(void)
|
|
|
|
{
|
|
|
|
return obs->procs;
|
|
|
|
}
|