Moudle 数据结构,在plugins目录下load
struct obs_module {
char *mod_name;
const char *file;
char *bin_path;
char *data_path;
void *module;
bool loaded;
bool (*load)(void); /**< 初始化module,并注册组件obs_register_*** */
void (*unload)(void);
void (*post_load)(void);
void (*set_locale)(const char *locale);
void (*free_locale)(void);
uint32_t (*ver)(void);
void (*set_pointer)(obs_module_t *module);
const char *(*name)(void);
const char *(*description)(void);
const char *(*author)(void);
struct obs_module *next;
};
View 数据结构
struct obs_view {
pthread_mutex_t channels_mutex;
obs_source_t *channels[MAX_CHANNELS];
};
Display 数据结构
struct obs_display {
bool size_changed;
bool enabled;
uint32_t cx, cy;
uint32_t background_color;
gs_swapchain_t *swap; //一个display对应一个swpchain
pthread_mutex_t draw_callbacks_mutex;
pthread_mutex_t draw_info_mutex;
DARRAY(struct draw_callback) draw_callbacks;
struct obs_display *next;
struct obs_display **prev_next;
};
Core-video 核心视频数据结构
struct obs_vframe_info {
uint64_t timestamp;
int count;
};
struct obs_core_video {
graphics_t *graphics; //Subsystem d3d、opengl
gs_stagesurf_t *copy_surfaces[NUM_TEXTURES];
gs_texture_t *render_textures[NUM_TEXTURES];
gs_texture_t *output_textures[NUM_TEXTURES];
gs_texture_t *convert_textures[NUM_TEXTURES];
bool textures_rendered[NUM_TEXTURES];
bool textures_output[NUM_TEXTURES];
bool textures_copied[NUM_TEXTURES];
bool textures_converted[NUM_TEXTURES];
struct circlebuf vframe_info_buffer;
gs_effect_t *default_effect;
gs_effect_t *default_rect_effect;
gs_effect_t *opaque_effect;
gs_effect_t *solid_effect;
gs_effect_t *conversion_effect;
gs_effect_t *bicubic_effect;
gs_effect_t *lanczos_effect;
gs_effect_t *bilinear_lowres_effect;
gs_effect_t *premultiplied_alpha_effect;
gs_samplerstate_t *point_sampler;
gs_stagesurf_t *mapped_surface;
int cur_texture;
long raw_active;
uint64_t video_time;
uint64_t video_avg_frame_time_ns;
double video_fps;
video_t *video; //VideoOutput
pthread_t video_thread;
uint32_t total_frames;
uint32_t lagged_frames;
bool thread_initialized;
bool gpu_conversion;
const char *conversion_tech;
uint32_t conversion_height;
uint32_t plane_offsets[3];
uint32_t plane_sizes[3];
uint32_t plane_linewidth[3];
uint32_t output_width;
uint32_t output_height;
uint32_t base_width;
uint32_t base_height;
float color_matrix[16];
enum obs_scale_type scale_type;
gs_texture_t *transparent_texture;
gs_effect_t *deinterlace_discard_effect;
gs_effect_t *deinterlace_discard_2x_effect;
gs_effect_t *deinterlace_linear_effect;
gs_effect_t *deinterlace_linear_2x_effect;
gs_effect_t *deinterlace_blend_effect;
gs_effect_t *deinterlace_blend_2x_effect;
gs_effect_t *deinterlace_yadif_effect;
gs_effect_t *deinterlace_yadif_2x_effect;
struct obs_video_info ovi;
};
Core-data 核心数据结构
struct obs_core_data {
struct obs_source *first_source;
struct obs_source *first_audio_source;
struct obs_display *first_display;
struct obs_output *first_output;
struct obs_encoder *first_encoder;
struct obs_service *first_service;
pthread_mutex_t sources_mutex;
pthread_mutex_t displays_mutex;
pthread_mutex_t outputs_mutex;
pthread_mutex_t encoders_mutex;
pthread_mutex_t services_mutex;
pthread_mutex_t audio_sources_mutex;
pthread_mutex_t draw_callbacks_mutex;
DARRAY(struct draw_callback) draw_callbacks;
DARRAY(struct tick_callback) tick_callbacks;
struct obs_view main_view;
long long unnamed_index;
volatile bool valid;
};
Core 内核
全局唯一
包含以上核心数据,video、audio、data、hotkeys
struct obs_core {
struct obs_module *first_module;
DARRAY(struct obs_module_path) module_paths;
/*--------------------------------------source info--------------------------------------------*/
/**
按照source类型,分类存储每一个被注册的source的source_info
enum obs_source_type {
OBS_SOURCE_TYPE_INPUT,
OBS_SOURCE_TYPE_FILTER,
OBS_SOURCE_TYPE_TRANSITION,
OBS_SOURCE_TYPE_SCENE,
};
*/
DARRAY(struct obs_source_info) source_types;
DARRAY(struct obs_source_info) input_types;
DARRAY(struct obs_source_info) filter_types;
DARRAY(struct obs_source_info) transition_types;
DARRAY(struct obs_output_info) output_types;
/*--------------------------------------encoder info--------------------------------------------*/
/*
enum obs_encoder_type {
OBS_ENCODER_AUDIO,
OBS_ENCODER_VIDEO
};
*/
DARRAY(struct obs_encoder_info) encoder_types;
DARRAY(struct obs_service_info) service_types;
DARRAY(struct obs_modal_ui) modal_ui_callbacks;
DARRAY(struct obs_modeless_ui) modeless_ui_callbacks;
signal_handler_t *signals;
proc_handler_t *procs;
char *locale;
char *module_config_path;
bool name_store_owned;
profiler_name_store_t *name_store;
/* segmented into multiple sub-structures to keep things a bit more
* clean and organized */
struct obs_core_video video;
struct obs_core_audio audio;
struct obs_core_data data;
struct obs_core_hotkeys hotkeys;
};
Context 共享的上下文环境数据
struct obs_context_data {
char *name; /**< source 名称eg."Window Capture" *** */
void *data; /**< source.create,source 相关联的源对象 *** */
obs_data_t *settings; /**< 对souces的json配置文件里 settings属性的引用 *** */
signal_handler_t *signals; /** < singnal句柄,绑定source_signals回调函数 *** */
proc_handler_t *procs;
enum obs_obj_type type; /**< obj类型source、output、encoder
、service *** */
DARRAY(obs_hotkey_id) hotkeys;
DARRAY(obs_hotkey_pair_id) hotkey_pairs;
obs_data_t *hotkey_data;
DARRAY(char*) rename_cache;
pthread_mutex_t rename_cache_mutex;
pthread_mutex_t *mutex;
struct obs_context_data *next;
struct obs_context_data **prev_next;
bool private; /**< 是否私有化,source为filter时是true *** */
};
Soucre 源数据结构
struct obs_source {
struct obs_context_data context;
struct obs_source_info info;
struct obs_weak_source *control;
/* general exposed flags that can be set for the source */
uint32_t flags;
uint32_t default_flags;
/* indicates ownership of the info.id buffer */
bool owns_info_id;
/* signals to call the source update in the video thread */
bool defer_update;
/* ensures show/hide are only called once */
volatile long show_refs;
/* ensures activate/deactivate are only called once */
volatile long activate_refs;
/* used to indicate that the source has been removed and all
* references to it should be released (not exactly how I would prefer
* to handle things but it's the best option) */
bool removed;
bool active;
bool showing;
/* used to temporarily disable sources if needed */
bool enabled;
/* timing (if video is present, is based upon video) */
volatile bool timing_set;
volatile uint64_t timing_adjust;
uint64_t resample_offset;
uint64_t last_audio_ts;
uint64_t next_audio_ts_min;
uint64_t next_audio_sys_ts_min;
uint64_t last_frame_ts;
uint64_t last_sys_timestamp;
bool async_rendered;
/* audio */
bool audio_failed;
bool audio_pending;
bool pending_stop;
bool user_muted;
bool muted;
struct obs_source *next_audio_source;
struct obs_source **prev_next_audio_source;
uint64_t audio_ts;
struct circlebuf audio_input_buf[MAX_AUDIO_CHANNELS];
size_t last_audio_input_buf_size;
DARRAY(struct audio_action) audio_actions;
float *audio_output_buf[MAX_AUDIO_MIXES][MAX_AUDIO_CHANNELS];
struct resample_info sample_info;
audio_resampler_t *resampler;
pthread_mutex_t audio_actions_mutex;
pthread_mutex_t audio_buf_mutex;
pthread_mutex_t audio_mutex;
pthread_mutex_t audio_cb_mutex;
DARRAY(struct audio_cb_info) audio_cb_list;
struct obs_audio_data audio_data;
size_t audio_storage_size;
uint32_t audio_mixers;
float user_volume;
float volume;
int64_t sync_offset;
int64_t last_sync_offset;
/* async video data */
gs_texture_t *async_texture;
gs_texrender_t *async_texrender;
struct obs_source_frame *cur_async_frame;
bool async_gpu_conversion;
enum video_format async_format;
enum video_format async_cache_format;
enum gs_color_format async_texture_format;
float async_color_matrix[16];
bool async_full_range;
float async_color_range_min[3];
float async_color_range_max[3];
int async_plane_offset[2];
bool async_flip;
bool async_active;
bool async_update_texture;
bool async_unbuffered;
bool async_decoupled;
struct obs_source_frame *async_preload_frame;
DARRAY(struct async_frame) async_cache;
DARRAY(struct obs_source_frame*)async_frames;
pthread_mutex_t async_mutex;
uint32_t async_width;
uint32_t async_height;
uint32_t async_cache_width;
uint32_t async_cache_height;
uint32_t async_convert_width;
uint32_t async_convert_height;
/* async video deinterlacing */
uint64_t deinterlace_offset;
uint64_t deinterlace_frame_ts;
gs_effect_t *deinterlace_effect;
struct obs_source_frame *prev_async_frame;
gs_texture_t *async_prev_texture;
gs_texrender_t *async_prev_texrender;
uint32_t deinterlace_half_duration;
enum obs_deinterlace_mode deinterlace_mode;
bool deinterlace_top_first;
bool deinterlace_rendered;
/* filters */
struct obs_source *filter_parent;
struct obs_source *filter_target;
DARRAY(struct obs_source*) filters;
pthread_mutex_t filter_mutex;
gs_texrender_t *filter_texrender;
enum obs_allow_direct_render allow_direct;
bool rendering_filter;
/* sources specific hotkeys */
obs_hotkey_pair_id mute_unmute_key;
obs_hotkey_id push_to_mute_key;
obs_hotkey_id push_to_talk_key;
bool push_to_mute_enabled;
bool push_to_mute_pressed;
bool user_push_to_mute_pressed;
bool push_to_talk_enabled;
bool push_to_talk_pressed;
bool user_push_to_talk_pressed;
uint64_t push_to_mute_delay;
uint64_t push_to_mute_stop_time;
uint64_t push_to_talk_delay;
uint64_t push_to_talk_stop_time;
/* transitions */
uint64_t transition_start_time;
uint64_t transition_duration;
pthread_mutex_t transition_tex_mutex;
gs_texrender_t *transition_texrender[2];
pthread_mutex_t transition_mutex;
obs_source_t *transition_sources[2];
bool transitioning_video;
bool transitioning_audio;
bool transition_source_active[2];
uint32_t transition_alignment;
uint32_t transition_actual_cx;
uint32_t transition_actual_cy;
uint32_t transition_cx;
uint32_t transition_cy;
uint32_t transition_fixed_duration;
bool transition_use_fixed_duration;
enum obs_transition_mode transition_mode;
enum obs_transition_scale_type transition_scale_type;
struct matrix4 transition_matrices[2];
struct audio_monitor *monitor;
enum obs_monitoring_type monitoring_type;
obs_data_t *private_settings;
};
VideoInof 视频配置信息 首次从配置文件中获取
struct obs_video_info {
#ifndef SWIG
/**
* Graphics module to use (usually "libobs-opengl" or "libobs-d3d11")
*/
const char *graphics_module;
#endif
uint32_t fps_num; /**< Output FPS numerator */
uint32_t fps_den; /**< Output FPS denominator */
uint32_t base_width; /**< Base compositing width */
uint32_t base_height; /**< Base compositing height */
uint32_t output_width; /**< Output width */
uint32_t output_height; /**< Output height */
enum video_format output_format; /**< Output format */
/** Video adapter index to use (NOTE: avoid for optimus laptops) */
uint32_t adapter;
/** Use shaders to convert to different color formats */
bool gpu_conversion;
enum video_colorspace colorspace; /**< YUV type (if YUV) */
enum video_range_type range; /**< YUV range (if YUV) */
enum obs_scale_type scale_type; /**< How to scale if scaling */
};
VideoOutPut 数据结构
struct video_output {
struct video_output_info info;
pthread_t thread;
pthread_mutex_t data_mutex;
bool stop;
os_sem_t *update_semaphore;
uint64_t frame_time; //每一帧的时间,纳秒级别,例如fps=30则为33333333
uint32_t skipped_frames;
uint32_t total_frames;
bool initialized;
pthread_mutex_t input_mutex;
DARRAY(struct video_input) inputs;
size_t available_frames;
size_t first_added;
size_t last_added;
struct cached_frame_info cache[MAX_CACHE_SIZE];
};