obs-internal.h 3.6 KB
Newer Older
J
jp9000 已提交
1 2 3 4 5
/******************************************************************************
    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
6
    the Free Software Foundation, either version 2 of the License, or
J
jp9000 已提交
7 8 9 10 11 12 13 14 15 16 17
    (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/>.
******************************************************************************/

18
#pragma once
J
jp9000 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31

#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"
32
#include "obs-service.h"
33
#include "obs-encoder.h"
J
jp9000 已提交
34

35 36 37 38 39 40 41 42
#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)

J
jp9000 已提交
43 44 45
#define NUM_TEXTURES 2

struct obs_display {
46 47 48
	swapchain_t                 swap; /* can be NULL if just sound */
	obs_source_t                channels[MAX_CHANNELS];

J
jp9000 已提交
49 50 51
	/* TODO: sound output target */
};

52 53 54 55 56
/* ------------------------------------------------------------------------- */

struct obs_video {
	graphics_t                  graphics;
	stagesurf_t                 copy_surfaces[NUM_TEXTURES];
57 58
	texture_t                   render_textures[NUM_TEXTURES];
	texture_t                   output_textures[NUM_TEXTURES];
59 60 61 62 63 64 65 66 67
	effect_t                    default_effect;
	bool                        textures_copied[NUM_TEXTURES];
	bool                        copy_mapped;
	int                         cur_texture;

	video_t                     video;
	pthread_t                   video_thread;
	bool                        thread_initialized;

68 69
	uint32_t                    base_width;
	uint32_t                    base_height;
70 71 72 73 74 75 76
};

struct obs_audio {
	/* TODO: audio subsystem */
	audio_t                     audio;
};

77
/* user sources, output channels, and displays */
J
jp9000 已提交
78
struct obs_data {
79 80
	/* arrays of pointers jim?  you should really stop being lazy and use
	 * linked lists. */
81 82
	DARRAY(struct obs_display*) displays;
	DARRAY(struct obs_source*)  sources;
83 84
	DARRAY(struct obs_output*)  outputs;
	DARRAY(struct obs_encoder*) encoders;
85 86 87 88

	obs_source_t                channels[MAX_CHANNELS];
	pthread_mutex_t             sources_mutex;
	pthread_mutex_t             displays_mutex;
89 90
	pthread_mutex_t             outputs_mutex;
	pthread_mutex_t             encoders_mutex;
91 92

	volatile bool               valid;
93 94 95 96 97 98 99 100
};

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;
101
	DARRAY(struct encoder_info) encoder_types;
102 103
	DARRAY(struct service_info) service_types;

104 105 106
	signal_handler_t            signals;
	proc_handler_t              procs;

107 108 109 110 111
	/* segmented into multiple sub-structures to keep things a bit more
	 * clean and organized */
	struct obs_video            video;
	struct obs_audio            audio;
	struct obs_data             data;
J
jp9000 已提交
112 113
};

114
extern struct obs_subsystem *obs;
115

J
jp9000 已提交
116
extern void *obs_video_thread(void *param);