zoukankan      html  css  js  c++  java
  • Apache 流媒体 拖动模块编译

    Windows使用apxs独立编译 Apache 模块
    http://blog.sina.com.cn/s/blog_43b83d340100mdhl.html
    安装 apxs
    1.解压apxs.zip,如C:apxs
    2.打开命令提示符,切换当前目录到解压的路径C:apxs
    3.输入
    perl Configure.pl --with-apache2=Path oApache2 --with-apache-prog=httpd.exe
    其中Path oApache2需要替换为Apache的安装路径
    如果提示perl为不可执行程序的话,需要安装Perl,如Strawberry Perl
    4.切换到Apache安装目录下的bin文件夹中,输入apxs,如有解释apxs用法的文本出现,则表明安装完成。
     
    使用apxs在windows下编译模块
    1.修改在apache下的build目录中config_vars.mk文件
    将CC = gcc 的gcc改为cl.exe ,LD = g++的g++改为link.exe,CPP = gcc-E的gcc-E删掉
    2.打开VS2005命令提示符(或者进入命令提示符,输入 %comspec% /k ""编译器变量初始化脚本路径"" x86
    编译器变量初始化脚本路径:在vc6下是"C:Program FilesMicrosoft Visual StudioVC98BinVCVARS32.BAT",vs2005下是"C:Program FilesMicrosoft Visual Studio 8VCvcvarsall.bat")
    3.将apxs 所在路径设置为系统环境变量的系统路径。
    4.运行apxs -n helloworld -g(其中helloworld为模块名)
    5.将路径切换到helloworld文件夹,输入
    apxs -c -i -a mod_helloworld.c libapr-1.lib libaprutil-1.lib libapriconv-1.lib libhttpd.lib
    (将helloworld文件夹替换为你的模块所在路径,mod_helloworld.c替换为你的模块文件名)
     

    http://www.server110.com/apache/201403/6943.html

    apache下配置flv拖动

    环境:debian apache2 ckplayer

    1、安装apxs工具。

    apxs 是Apache的扩展工具,用于编译一个或多个源程序或目标代码文件为动态共享对象,使之可以用LoadModule指令在运行时加载到Apache 服器中。

    作为apache模块的编译工具,用它来编译mod_flvx.c文件。

    debian和ubuntu下,apxs被放在apache2-threaded-dev和apache2-prefork-dev里,安装任一个即可。

    apt-get install  apache2-prefork-dev

    whereis apxs2 查看安装路径

    man apxs 如果你想看看这东西怎么用的话

    2、下载mod_flvx.c并进行编译

    wget https://github.com/osantana/mod_flvx/blob/master/mod_flvx.c 或者

    wget http://people.apache.org/~pquerna/modules/mod_flvx.c

    使用apxs进行编译,编译前,请检查apxs的版本,如果新安装的基本没啥问题吧

    apxs -c -i -a ./mod_flvx.c

    3、在apache的配置文件中增加mod_flvx.so模块,并添加对.flv的处理

    在apache的conf.d目录下创建mod_flvx.conf文件,并写入以下内容

    LoadModule flvx_module /usr/lib/apache2/modules/mod_flvx.so

    AddHandler flv-stream .flv

    4、重启apache

    5、如果还不能拖动,则

    1)FLV没有metadata关键帧数据

    可以使用yamdi或flvtool2为你的flv视频添加关键帧

    yamdi -i source.flv -o dest.flv或

    flvtool2 -U source.flv

    如果没有yamdi或者flvtool2可apt-get先安装。

    这里我用flvtool2报错,于是用了yamdi,没报错。据说yamdi效率更高。

    2)如果还不能拖动,则尝试配置播放器。

    我这里用的是ckplayer。

    搜了一下ckplayer的配置:http://www.ckplayer.com/view.php?id=82

    ckplayer.js里

      (1)ck.setup = '1,1,1,1,1,1,0,0,1,2,5';的第6个参数,是否使用http流式控制1是/0不是

      (2)h的值,h:'1',//播放http视频流时采用何种拖动方法,0是按关键帧,1是按关键时间点

      (3)q:'',//视频流拖动时参考函数,默认是start。

    关于选择关键帧还是关键时间点的区别,默认的是flv是按关键时间点,而mp4是按关键帧来随意拖动的,但很多网站是把这二个设置成统一的,要么都按关键帧,要么都按关键时间点。

    这里我执行了(1)。

    然后,就好了。。。可以拖动了。。。

    转载请注明原文地址:http://www.server110.com/apache/201403/6943.html

    mp4-----------

    http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Apache-Version2

    Dependencies ¶

    We will be using ​apxs2, the APache eXtenSion tool, to build and install the module for the Apache server.

    Make sure you have apxs2 installed:

    sudo apt-get install apache2-threaded-dev
    

    Download

    Download the source of the H264 Streaming Module for Apache.

    cd ~
    wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
    tar -zxvf apache_mod_h264_streaming-2.2.7.tar.gz
    

    Build

    cd ~/mod_h264_streaming-2.2.7
    ./configure --with-apxs=`which apxs2`
    make
    sudo make install
    

    Configuration

    Edit the configuration file (in /etc/apache/httpd.conf) so that file requests ending in ".mp4" are handled by the h264_streaming_module.

    LoadModule h264_streaming_module /usr/lib/apache2/modules/mod_h264_streaming.so
    AddHandler h264-streaming.extensions .mp4
    

    Start Apache.

    sudo /etc/init.d/apache start
    

    Build & Configuration (CentOS 5.2)

    CentOS users can follow these intructions for building the module instead. It uses apxs (instead of apxs2) and httpd (instead of apache).

    sudo yum install httpd-devel 
    sudo yum install httpd mod_ssl
    
    cd ~/mod_h264_streaming-2.2.5
    ./configure
    make
    sudo make install
    
    sudo vi /etc/httpd/conf/httpd.conf 
    Add the line 
    'AddHandler h264-streaming.extensions .mp4' 
    after the line 
    'LoadModule h264_streaming_module /usr/lib/httpd/modules/mod_h264_streaming.so' 
    sudo /etc/init.d/httpd start 
    

    License

    This version is free if you agree to the ​noncommercial license. Please mention its use on your website, in the lines of 'This website uses H264 pseudo video streaming technology by​CodeShop'.

    Our commercial license is very inexpensive, see the following page to check if you need a commercial license.

    Testing

    Continue to the testing page to verify your setup.

    Demo

    See ​http://h264-demo.code-shop.com/demo/apache/testlist.html for a demo running Apache.

    Apache Module 开发后记

    上一篇文章

    开发出 apache 2.0 的模块以后,又面对着要将其移植到 apache 其他版本的需求,经过这段时间一点点的修补,现在我的模块已经可以同时在 1.3/2.0/2.2 下编译。甚至在 2.0/Win32 环境下也编译出了 dll,供在个人PC上做开发的同事使用。

    我感觉如果项目不复杂的话,可以学习我这样把所有的内容放在一个文件里面的做法。

    最重要的就是利用 MODULE_MAGIC_COOKIE 的定义,把 1.3 和 2.0/2.2 的不同之处融合在一起。例子:

    #if MODULE_MAGIC_COOKIE == 0x41503230UL || MODULE_MAGIC_COOKIE == 0x41503232UL
     
    #include "util_filter.h"
    #include "apr_strings.h"
    module AP_MODULE_DECLARE_DATA foobar_module;
    #define APLOG_FOOBAR APLOG_ERR,0
     
    #else
     
    module MODULE_VAR_EXPORT foobar_module;
    #define apr_pool_t          pool
    #define apr_table_t         table
    #define apr_pcalloc         ap_pcalloc
    #define apr_table_unset     ap_table_unset
    #define apr_table_set       ap_table_set
    #define apr_table_get       ap_table_get
    #define apr_table_make      ap_make_table
    #define apr_pstrdup         ap_pstrdup
    #define apr_snprintf        ap_snprintf
    #define apr_pstrndup        ap_pstrndup
    #define APLOG_FOOBAR APLOG_ERR
     
    #endif /* MODULE_MAGIC_COOKIE == 0x41503230UL */

    同样,模块初始化的部分也这样针对不同版本定义一下。

    这样主要的功能函数就可以使用同样的代码模块,并使用 apr_* 系列函数族了。

    之所以要对 APLOG_ERR 做定义,是因为在 1.3 和 2.x 版本中,ap_log_error 和 ap_log_rerror 所使用的参数数目不一致,2.x 的参数要多一个,因此针对 2.x自动增加一个参数——",0"

    2.0 和 2.2 有些地方也有小差别,我的代码里面就碰到了 apr_socket_create 的参数不一样。同样简单 #if 就可以处理了。

    在 1.3 里面 module initializer 如果 2.x 里面的 post_config 会运行两次,而且2.x 上的这个小技巧无法直接使用了。本来是不影响程序运行的,但还是想出了一个变态的办法来解决它。module initializer 两次执行之间的一个重要事件就是 apache 的 daemonize。那样怎么来判断当前进程是否在 daemon 状态下呢?我的方案是:

    /* 小技巧,用于帮助 init_module 只执行一次检查 */
    #define MAX_FDS 1024
    int daemon_flag(int fds[MAX_FDS])
    {
        int fd;
        int newfd;
        int i;
        int opt;
        socklen_t optlen = sizeof(int);
        int ret = 0;
     
        memset(fds, 0, sizeof(int) * MAX_FDS);
        newfd = fd = socket(AF_INET,SOCK_STREAM,0);
        while (newfd < MAX_FDS && newfd > 0) {
            fds[newfd] = 1;
            newfd = dup(fd);
        }
        for (i = 0; i < MAX_FDS; i++) {
            if (fds[i] == 1) {
                close(i);
            } else {
                if (0 == getsockopt(i, SOL_SOCKET, SO_REUSEADDR, &opt, &optlen)) {
                    fds[i] = -1; //这样返回以后也知道哪些 fd 被监听
                    ret = 1;
                }
            }
        }
        return ret;
    }

    因为我知道 apache 必然会对监听套接字设置 SO_REUSEADDR,所以可如此判断。

    由于 apache2 有了 apr 的支持,几乎不用修改任何代码模块就可以在 win32 下编译。而且只需要 MS 的免费工具就可以了,包括 MSVC C++ Toolkit 2003 和 Platform SDK。设置好 INCLUDE/LIB 路径后,只需要执行
    cl /MD /D "WIN32" /c mod_foobar.c
    link /DLL mod_foobar.obj libhttpd.lib libapr.lib

    这样就得到了可被 LoadModule 的 mod_foobar.dll

    win32 下我碰到的问题稍微麻烦一些。启动 apache 无法成功,报告什么 OPENSSL_Applink 错误。看了 openssl 的 FAQ,说什么要 include 一个 applink.c,但仍然无济于事。不过查看 applink.c 后发现,它似乎和 IO 库相关;最后我把以前使用的 stdio 替换成了 openssl 自己的 bio 函数族,该问题就消失了。

    openssl 的 win32 库从这里下载并安装

     
    http://httpd.apache.org/docs/current/platform/windows.html#down
  • 相关阅读:
    理解Linq和lambda
    (转)Fidder教程
    (转)Fiddler Composer创建和发送HTTP Request
    (转)http协议详解
    C# sealed & internal
    javascript中的封装,多态,继承
    Fiddler Script 用法
    强烈推荐:240多个jQuery插件
    用C#编写ActiveX控件(1)
    用C#编写ActiveX控件(二)
  • 原文地址:https://www.cnblogs.com/jukan/p/5921060.html
Copyright © 2011-2022 走看看