【原创】动态图像监测开源代码 motion 学习 ----- Motion源码分析(1)

本文详细解析动态图像监测工具Motion的源码,从main函数开始,重点探讨motion_loop()和motion_web_control()两个关键线程,阐述它们在Motion中的作用,包括配置文件读取、图像采集和运动检测等功能。
摘要由CSDN通过智能技术生成


【原创】动态图像监测开源代码 motion 学习 ----- Motion源码分析(1)


经过这两天对motion源码的分析,发现关于motion代码分析的资料很少,现在终于看出来点儿意思了。因为motion源码文件不是太多,所以直接从main函数入手。


分析工具:Source Insight。


main函数位于源码文件motion.c中。下面是main函数的源代码。

/**
 * main
 *
 *   Main entry point of Motion. Launches all the motion threads and contains
 *   the logic for starting up, restarting and cleaning up everything.
 *
 * Parameters:
 *
 *   argc - size of argv
 *   argv - command-line options
 *
 * Returns: Motion exit status = 0 always
 */
int main (int argc, char **argv)
{
    int i;
    /*    pthread_attr_t为线程属性结构体。   */
    pthread_attr_t thread_attr;
    /*    pthread_t为线程id类型,打印时要用%u。    */
    pthread_t thread_id;

    /* Setup signals and do some initialization. 1 in the call to
     * 'motion_startup' means that Motion will become a daemon if so has been
     * requested, and argc and argc are necessary for reading the command
     * line options.

        设置信号并做一些初始化。motion_startup中的1表示Motion将以守护进程的方式
        运行,前提是用户有这样的需要。另外,命令行选项需要argc。
     */

    /*  
        sigaction为结构体,详细规定了信号处理函数和信号标志等信息。
        sigaction()为信号处理函数。        
    */
    struct sigaction sig_handler_action;
    struct sigaction sigchild_action;
    setup_signals(&sig_handler_action, &sigchild_action);

    motion_startup(1, argc, argv);

#ifdef HAVE_FFMPEG
    /* FFMpeg initialization is only performed if FFMpeg support was found
     * and not disabled during the configure phase.
     */
    ffmpeg_init();
#endif /* HAVE_FFMPEG */

    /* In setup mode, Motion is very communicative towards the user, which
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值