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-10-14 04:21:15 -07:00
|
|
|
#pragma once
|
2013-09-30 19:37:13 -07:00
|
|
|
|
|
|
|
#include "util/darray.h"
|
|
|
|
#include "util/threading.h"
|
|
|
|
|
|
|
|
#include "graphics/graphics.h"
|
|
|
|
|
|
|
|
#include "media-io/video-io.h"
|
|
|
|
#include "media-io/audio-io.h"
|
|
|
|
|
|
|
|
#include "obs.h"
|
|
|
|
#include "obs-module.h"
|
|
|
|
#include "obs-source.h"
|
|
|
|
#include "obs-output.h"
|
2013-11-26 21:26:14 -08:00
|
|
|
#include "obs-service.h"
|
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
|
|
|
#include "obs-encoder.h"
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2014-01-17 05:24:34 -08:00
|
|
|
#define LOAD_MODULE_SUBFUNC(name, required) \
|
|
|
|
do { \
|
|
|
|
info->name = load_module_subfunc(module, module_name, \
|
|
|
|
id, #name, required); \
|
|
|
|
if (required && !info->name) \
|
|
|
|
return false; \
|
|
|
|
} while (false)
|
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
#define NUM_TEXTURES 2
|
|
|
|
|
|
|
|
struct obs_display {
|
2013-11-20 14:00:16 -08:00
|
|
|
swapchain_t swap; /* can be NULL if just sound */
|
|
|
|
obs_source_t channels[MAX_CHANNELS];
|
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
/* TODO: sound output target */
|
|
|
|
};
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
struct obs_video {
|
|
|
|
graphics_t graphics;
|
|
|
|
stagesurf_t copy_surfaces[NUM_TEXTURES];
|
2013-11-26 21:26:14 -08:00
|
|
|
texture_t render_textures[NUM_TEXTURES];
|
|
|
|
texture_t output_textures[NUM_TEXTURES];
|
2014-02-05 19:36:21 -08:00
|
|
|
bool textures_rendered[NUM_TEXTURES];
|
|
|
|
bool textures_output[NUM_TEXTURES];
|
2013-11-20 14:00:16 -08:00
|
|
|
bool textures_copied[NUM_TEXTURES];
|
2014-02-05 19:36:21 -08:00
|
|
|
effect_t default_effect;
|
|
|
|
stagesurf_t mapped_surface;
|
2013-11-20 14:00:16 -08:00
|
|
|
int cur_texture;
|
|
|
|
|
|
|
|
video_t video;
|
|
|
|
pthread_t video_thread;
|
|
|
|
bool thread_initialized;
|
|
|
|
|
2013-12-06 05:38:19 -08:00
|
|
|
uint32_t base_width;
|
|
|
|
uint32_t base_height;
|
2013-11-20 14:00:16 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct obs_audio {
|
2014-01-31 23:49:50 -08:00
|
|
|
/* TODO: sound output subsystem */
|
2013-11-20 14:00:16 -08:00
|
|
|
audio_t audio;
|
|
|
|
};
|
|
|
|
|
2013-11-20 17:36:46 -08:00
|
|
|
/* user sources, output channels, and displays */
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data {
|
2013-12-20 18:35:12 -08:00
|
|
|
/* arrays of pointers jim? you should really stop being lazy and use
|
|
|
|
* linked lists. */
|
2013-11-20 14:00:16 -08:00
|
|
|
DARRAY(struct obs_display*) displays;
|
|
|
|
DARRAY(struct obs_source*) sources;
|
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
|
|
|
DARRAY(struct obs_output*) outputs;
|
|
|
|
DARRAY(struct obs_encoder*) encoders;
|
2013-11-20 14:00:16 -08:00
|
|
|
|
|
|
|
obs_source_t channels[MAX_CHANNELS];
|
|
|
|
pthread_mutex_t sources_mutex;
|
|
|
|
pthread_mutex_t displays_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_t outputs_mutex;
|
|
|
|
pthread_mutex_t encoders_mutex;
|
2014-01-23 16:00:42 -08:00
|
|
|
|
|
|
|
volatile bool valid;
|
2013-11-20 14:00:16 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct obs_subsystem {
|
|
|
|
DARRAY(struct obs_module) modules;
|
|
|
|
DARRAY(struct source_info) input_types;
|
|
|
|
DARRAY(struct source_info) filter_types;
|
|
|
|
DARRAY(struct source_info) transition_types;
|
|
|
|
DARRAY(struct output_info) output_types;
|
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
|
|
|
DARRAY(struct encoder_info) encoder_types;
|
2013-11-20 14:00:16 -08:00
|
|
|
DARRAY(struct service_info) service_types;
|
2014-02-01 16:43:32 -08:00
|
|
|
DARRAY(struct obs_modal_ui) ui_modal_callbacks;
|
|
|
|
DARRAY(struct obs_modeless_ui) ui_modeless_callbacks;
|
2013-11-20 14:00:16 -08:00
|
|
|
|
2013-12-26 22:10:15 -08:00
|
|
|
signal_handler_t signals;
|
|
|
|
proc_handler_t procs;
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
/* segmented into multiple sub-structures to keep things a bit more
|
|
|
|
* clean and organized */
|
|
|
|
struct obs_video video;
|
|
|
|
struct obs_audio audio;
|
2014-01-27 08:07:13 -08:00
|
|
|
struct obs_program_data data;
|
2013-09-30 19:37:13 -07:00
|
|
|
};
|
|
|
|
|
2013-11-20 14:00:16 -08:00
|
|
|
extern struct obs_subsystem *obs;
|
2013-10-14 12:37:52 -07:00
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
extern void *obs_video_thread(void *param);
|