2018-09-14

Moudle 數(shù)據(jù)結(jié)構(gòu)循捺,在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 數(shù)據(jù)結(jié)構(gòu)

struct obs_view {
    pthread_mutex_t                 channels_mutex;
    obs_source_t                    *channels[MAX_CHANNELS];
};

Display 數(shù)據(jù)結(jié)構(gòu)

struct obs_display {
    bool                            size_changed;
    bool                            enabled;
    uint32_t                        cx, cy;
    uint32_t                        background_color;
    gs_swapchain_t                  *swap;                      //一個(gè)display對(duì)應(yīng)一個(gè)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 核心視頻數(shù)據(jù)結(jié)構(gòu)

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 核心數(shù)據(jù)結(jié)構(gòu)

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 內(nèi)核

全局唯一

包含以上核心數(shù)據(jù)从橘,video、audio础钠、data恰力、hotkeys

struct obs_core {
    struct obs_module               *first_module;
    DARRAY(struct obs_module_path)  module_paths;
/*--------------------------------------source info--------------------------------------------*/
 /**
按照source類型,分類存儲(chǔ)每一個(gè)被注冊的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 共享的上下文環(huán)境數(shù)據(jù)

struct obs_context_data {
    char                            *name;                                             /**< source 名稱eg."Window Capture" *** */
    void                            *data;                                               /**< source.create旗吁,source 相關(guān)聯(lián)的源對(duì)象 *** */
    obs_data_t                      *settings;                                    /**< 對(duì)souces的json配置文件里 settings屬性的引用 *** */  
    signal_handler_t                *signals;                                  /** < singnal句柄踩萎,綁定source_signals回調(diào)函數(shù) *** */
    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時(shí)是true *** */                                
};

Soucre 源數(shù)據(jù)結(jié)構(gòu)

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 數(shù)據(jù)結(jié)構(gòu)

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;              //每一幀的時(shí)間,納秒級(jí)別企孩,例如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];
};
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末锭碳,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子柠硕,更是在濱河造成了極大的恐慌工禾,老刑警劉巖运提,帶你破解...
    沈念sama閱讀 216,651評(píng)論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蝗柔,死亡現(xiàn)場離奇詭異,居然都是意外死亡民泵,警方通過查閱死者的電腦和手機(jī)癣丧,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,468評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來栈妆,“玉大人胁编,你說我怎么就攤上這事×鄱” “怎么了嬉橙?”我有些...
    開封第一講書人閱讀 162,931評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長寥假。 經(jīng)常有香客問我市框,道長,這世上最難降的妖魔是什么糕韧? 我笑而不...
    開封第一講書人閱讀 58,218評(píng)論 1 292
  • 正文 為了忘掉前任枫振,我火速辦了婚禮,結(jié)果婚禮上萤彩,老公的妹妹穿的比我還像新娘粪滤。我一直安慰自己,他們只是感情好雀扶,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,234評(píng)論 6 388
  • 文/花漫 我一把揭開白布杖小。 她就那樣靜靜地躺著,像睡著了一般愚墓。 火紅的嫁衣襯著肌膚如雪予权。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,198評(píng)論 1 299
  • 那天转绷,我揣著相機(jī)與錄音伟件,去河邊找鬼。 笑死议经,一個(gè)胖子當(dāng)著我的面吹牛斧账,可吹牛的內(nèi)容都是我干的谴返。 我是一名探鬼主播,決...
    沈念sama閱讀 40,084評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼咧织,長吁一口氣:“原來是場噩夢啊……” “哼嗓袱!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起习绢,我...
    開封第一講書人閱讀 38,926評(píng)論 0 274
  • 序言:老撾萬榮一對(duì)情侶失蹤渠抹,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后闪萄,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體梧却,經(jīng)...
    沈念sama閱讀 45,341評(píng)論 1 311
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,563評(píng)論 2 333
  • 正文 我和宋清朗相戀三年败去,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了放航。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,731評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡圆裕,死狀恐怖广鳍,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情吓妆,我是刑警寧澤赊时,帶...
    沈念sama閱讀 35,430評(píng)論 5 343
  • 正文 年R本政府宣布,位于F島的核電站行拢,受9級(jí)特大地震影響祖秒,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜剂陡,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,036評(píng)論 3 326
  • 文/蒙蒙 一狈涮、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧鸭栖,春花似錦歌馍、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,676評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至溅话,卻和暖如春晓锻,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背飞几。 一陣腳步聲響...
    開封第一講書人閱讀 32,829評(píng)論 1 269
  • 我被黑心中介騙來泰國打工砚哆, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人屑墨。 一個(gè)月前我還...
    沈念sama閱讀 47,743評(píng)論 2 368
  • 正文 我出身青樓躁锁,卻偏偏與公主長得像纷铣,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子战转,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,629評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • Data Visualization with D3 D3: SVG中的jQurey 1. Add Documen...
    王策北閱讀 760評(píng)論 0 2
  • 1搜立、通過CocoaPods安裝項(xiàng)目名稱項(xiàng)目信息 AFNetworking網(wǎng)絡(luò)請(qǐng)求組件 FMDB本地?cái)?shù)據(jù)庫組件 SD...
    陽明先生_X自主閱讀 15,979評(píng)論 3 119
  • 在世界歷史上括荡,或許說起塞萬提斯傻昙,是很陌生的崔泵,或許一點(diǎn)印象都沒有蚓庭,但是,我提起一部名著命雀,你就會(huì)豁然開朗蒜哀,奧,原來是他...
    王老師聊圍棋閱讀 1,207評(píng)論 1 6
  • 在沒有搞清楚問題的真正根源時(shí)吏砂,就冒然行動(dòng),不就成“好心辦壞事”嗎乘客?真正的主動(dòng)掌控應(yīng)該是系統(tǒng)思考的結(jié)果狐血,而不...
    彭紅霞_a827閱讀 113評(píng)論 0 0
  • 投射兒子遇到貴人引領(lǐng),脫胎換骨易核,發(fā)奮圖強(qiáng)匈织,做一個(gè)有理想有夢想的人; 投射兒子開學(xué)開心上學(xué)牡直。目標(biāo)計(jì)劃穩(wěn)定堅(jiān)強(qiáng)缀匕。 投射...
    樂天派女神閱讀 105評(píng)論 0 0