利用nginx搭建httprtmp协议的流媒体服务器

实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtmp协议;同时打开rtmp的hls功能
资料:
HTTPLive Streaming(缩写是HLS)是一个由苹果公司提出的基于HTTP的流媒体网络传输协议。
HLS只请求基本的HTTP报文,与实时传输协议(RTP)不同,HLS可以穿过任何允许HTTP数据通过的防火墙或者代理服务器。它也很容易使用内容分发网络来传输媒体流。
使用ffmpeg来完成对flv、mp4、mp3等格式的转化(点播实验暂时不测试)

一、准备工作
模块:nginx_mod_h264_streaming(支持h264编码的视频)
模块:http_flv_module支持flv
模块:http_mp4_module支持mp4
下载地址:
http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
http://nginx.org
https://github.com/arut/nginx-rtmp-module

1、安装依赖包:
#yum-y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-develexpat-devel gettext-devel libtool mhash.x86_64perl-Digest-SHA1.x86_64

2、安装git工具:
#mkdirsoft-source
#cdsoft-source
#wgethttp://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
#tarxzvf git-latest.tar.gz
#cdgit-2013-02-04
#autoconf
#./configure
#make&& make install
# git--version
gitversion 1.8.1.GIT
#cd ..

3、安装ffmpeg及其依赖包:
++++++++Yasm+++++++++++
#wgethttp://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
#tarxzvf yasm-1.2.0.tar.gz
#cdyasm-1.2.0
#./configure
#make
#makeinstall
#cd ..
++++++++x264+++++++++++
#gitclone git://git.videolan.org/x264
#cdx264
#./configure--enable-shared
#make
#makeinstall
#cd ..
++++++++LAME+++++++++++
#wgethttp://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
#tarxzvf lame-3.99.5.tar.gz
#cdlame-3.99.5
#./configure--enable-nasm
#make
#makeinstall
#cd ..
++++++++libogg+++++++++++
#wgethttp://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
#tarxzvf libogg-1.3.0.tar.gz
#cdlibogg-1.3.0
#./configure
#make
#makeinstall
#cd ..
++++++++libvorbis+++++++++++
#wgethttp://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
#tarxzvf libvorbis-1.3.3.tar.gz
#cdlibvorbis-1.3.3
#./configure
#make
#makeinstall
#cd ..
++++++++libvpx+++++++++++
#gitclone http://git.chromium.org/webm/libvpx.git
#cdlibvpx
#./configure --enable-shared
#make
#makeinstall
#cd ..
++++++++FAAD2+++++++++++
#wgethttp://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
#tarzxvf faad2-2.7.tar.gz
#cdfaad2-2.7
#./configure
#make
#makeinstall
#cd ..
++++++++FAAC+++++++++++
#wgethttp://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
#tarzxvf faac-1.28.tar.gz
#cdfaac-1.28
#./configure
#make
#makeinstall
#cd ..

编译FAAC-1.28时遇到错误:

mpeg4ip.h:126:error:new declaration ‘char*strcasestr(const char*, const char*)’

解决方法:

从123行开始修改此文件mpeg4ip.h,到129行结束。
修改前:
#ifdef __cplusplus
extern "C" {
#endif
char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif

修改后:
#ifdef __cplusplus
extern "C++" {
#endif
constchar *strcasestr(const char*haystack, const char *needle);
#ifdef __cplusplus
}
#endif

++++++++Xvid+++++++++++
#wgethttp://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
#tarzxvf xvidcore-1.3.2.tar.gz
#cdxvidcore/build/generic
#./configure
#make
#makeinstall
cd ..
#gitclone git://source.ffmpeg.org/ffmpeg
#cdffmpeg
#./configure --prefix=/opt/ffmpeg/ --enable-version3  --enable-libvpx --enable-libfaac--enable-libmp3lame  --enable-libvorbis --enable-libx264 --enable-libxvid--enable-shared --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads
#make&& make install
#cd ..

修改/etc/ld.so.conf如下:
includeld.so.conf.d/*.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/ffmpeg/lib
#ldconfig

由于暂时没有找到合适版本rtmpmodel ,所以,这里只是做了flv和MP4的,红色部分暂时不用添加
二、安装Nginx相关模块
#tarzxvf nginx_mod_h264_streaming-2.2.7.tar.gz
#gitclone git://github.com/arut/nginx-rtmp-module.git
#tarzxvf pcre-8.12.tar.gz
#cdpcre-8.12
#./configure
#make&& make install
#tarzxvf nginx-1.2.6.tar.gz
#cdnginx-1.2.6
#./configure--prefix=/usr/local/nginx  --add-module=../nginx_mod_h264_streaming-2.2.7--with-http_flv_module --with-http_gzip_static_module--with-http_stub_status_module --with-http_mp4_module --add-module=../nginx-rtmp-module--add-module=../nginx-rtmp-module/hls --with-cc-opt=-I/opt/ffmpeg/include--with-ld-opt='-L/opt/ffmpeg/lib -Wl,-rpath=/opt/ffmpeg/lib'
#make&& make install
三、修改nginx主配置文件,配置虚拟主机(这里我们暂时只配置和测试点播,直播请看借鉴地址):
user nobody nobody;
worker_processes4;
error_log logs/nginx_error.log  info;
pid       logs/nginx.pid;
worker_rlimit_nofile51200;
events
  {
      use epoll;
      worker_connections 51200;
  }

http
  {
      include       mime.types;
      default_type  application/octet-stream;
      server_names_hash_bucket_size 128;
      client_header_buffer_size 32k;
      large_client_header_buffers 4 32k;
      client_max_body_size 50m ;
      limit_conn_zone $binary_remote_addr zone=perip:256k;
      limit_conn_log_level notice;
      sendfile on;
      tcp_nopush     on;
      keepalive_timeout 6000;#测试并发临时调大
      tcp_nodelay on;
      gzip on;
      gzip_min_length  1k;
      gzip_buffers     4 16k;
      gzip_http_version 1.0;
      gzip_comp_level 2;
      gzip_types       text/plainapplication/x-javascript text/css application/xml;
      gzip_vary on;
      #log format
      log_format  main  '$remote_addr - $remote_user[$time_local] "$request" '
           '$status $body_bytes_sent "$http_referer" '
           '"$http_user_agent" $http_x_forwarded_for';

#支持flv
server
      {
          listen       80 ;
          server_name 192.168.0.33;

root index.html

limit_rate_after5m;  

limit_rate512k;

location ~ \.flv$ {

root  /media/nginx;   -视频存放地点
                  flv;

}
          location ~ \.mp4$ {

root /media/nginx;
                  flv;
                              }
          access_log logs/nginxflv_access.log  main;
}

下载并安装yamdi

[root@flv ~]# wgethttp://cdnetworks-kr-2.dl.sourceforge.net/ \

>project/yamdi/yamdi/1.8/yamdi-1.8.tar.gz

[root@flv ~]# tar -zxvf yamdi-1.8.tar.gz

yamdi-1.8

yamdi-1.8/CHANGES

yamdi-1.8/LICENSE

yamdi-1.8/Makefile

yamdi-1.8/Makefile.mingw32

yamdi-1.8/README

yamdi-1.8/man1

yamdi-1.8/yamdi.c

yamdi-1.8/man1/yamdi.1

[root@ flv ~]# cd yamdi-1.8

[root@ flv yamdi-1.8]# make

gcc -O2 -Wall yamdi.c -o yamdi

[root@ flv yamdi-1.8]# make install

install -m 0755 -o root yamdi/usr/local/bin

使用yamdi

这里我们准备个文件,以便后面使用:

[root@flv  html]# yamdi -i 62664.flv -o 7345.flv

简单的说一下,-i表示输入文件,在这里输入文件为62664.flv,即它是没有添加过关键帧的文件;-o表示输出文件,在这里是7345.flv,它是添加过关键帧的,在对这两文件的访问中会发现,播放62664.flv是不能实现拖动操作的,而7345.flv则可以。

下载并设置JW player

JW player是一个开源的FLV播放器,它现在也支持MP4。

[root@flv ~]# wget  http://www.longtailvideo.com/jw/upload/mediaplayer-viral.zip

[root@flv ~]# unzip mediaplayer-viral.zip

Archive:  mediaplayer-viral.zip

creating: mediaplayer-5.7-viral/

inflating: mediaplayer-5.7-viral/JW  Player Quick Start Guide.pdf

inflating: mediaplayer-5.7-viral/jwplayer.js

inflating:  mediaplayer-5.7-viral/license.txt

inflating: mediaplayer-5.7-viral/player.swf

inflating:  mediaplayer-5.7-viral/preview.jpg

inflating:  mediaplayer-5.7-viral/readme.html

inflating:  mediaplayer-5.7-viral/swfobject.js

inflating: mediaplayer-5.7-viral/video.mp4

注意点

注意在解压包中,player.swfjwplayer.js是我们需要的文件,将其拷贝到Nginx的web目录下:

[root@flv ~]#cd mediaplayer-5.7-viral/

[root@mail mediaplayer-5.7-viral]# cp jwplayer.js  player.swf  /usr/local/nginx-1.0.2-flv/html/

到现在为止,FLV服务器已经架设完毕。

我们访问测试一下看:

访问方法:

http://flv.xx.com/player.swf?type=http&file=7345.flv

↑访问协议 ↑FLV服务器地址 ↑播放器名称↑http分发方式↑访问的文件名

---------------------------------------------------------

实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtmp协议;同时打开rtmp的hls功能
资料:
HTTP Live Streaming(缩写是 HLS)是一个由苹果公司提出的基于HTTP的流媒体 网络传输协议。
HLS只请求基本的HTTP报文,与实时传输协议(RTP)不同,HLS可以穿过任何允许HTTP数据通过的防火墙或者代理服务器。它也很容易使用内容分发网络来传输媒体流。
使用ffmpeg来完成对flv、mp4、mp3等格式的转化(点播实验暂时不测试)

一、准备工作
模块:nginx_mod_h264_streaming(支持h264编码的视频)
模块:http_flv_module 支持flv
模块:http_mp4_module 支持mp4
下载地址:
http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
http://nginx.org
https://github.com/arut/nginx-rtmp-module

1、安装依赖包:
#yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64

2、安装git工具:
#mkdir soft-source
#cd soft-source
#wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
#tar xzvf git-latest.tar.gz 
#cd git-2013-02-04
#autoconf
#./configure
#make && make install
# git --version
git version 1.8.1.GIT
#cd ..

3、安装ffmpeg及其依赖包:
++++++++Yasm+++++++++++
#wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
#tar xzvf yasm-1.2.0.tar.gz
#cd yasm-1.2.0
#./configure
#make
#make install
#cd ..
++++++++x264+++++++++++
#git clone git://git.videolan.org/x264
#cd x264
#./configure --enable-shared 
#make
#make install
#cd ..
++++++++LAME+++++++++++
#wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
#tar xzvf lame-3.99.5.tar.gz
#cd lame-3.99.5
#./configure --enable-nasm
#make
#make install
#cd ..
++++++++libogg+++++++++++
#wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
#tar xzvf libogg-1.3.0.tar.gz
#cd libogg-1.3.0
#./configure
#make
#make install
#cd ..
++++++++libvorbis+++++++++++
#wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
#tar xzvf libvorbis-1.3.3.tar.gz
#cd libvorbis-1.3.3
#./configure
#make
#make install
#cd ..
++++++++libvpx+++++++++++
#git clone http://git.chromium.org/webm/libvpx.git
#cd libvpx
#./configure  --enable-shared
#make
#make install
#cd ..
++++++++FAAD2+++++++++++
#wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
#tar zxvf faad2-2.7.tar.gz
#cd faad2-2.7
#./configure
#make
#make install
#cd ..
++++++++FAAC+++++++++++
#wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
#tar zxvf faac-1.28.tar.gz
#cd faac-1.28
#./configure
#make
#make install
#cd ..
++++++++Xvid+++++++++++
#wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
#tar zxvf xvidcore-1.3.2.tar.gz
#cd xvidcore/build/generic
#./configure
#make
#make install
cd ..
#git clone git://source.ffmpeg.org/ffmpeg
#cd ffmpeg
#./configure  --prefix=/opt/ffmpeg/ --enable-version3  --enable-libvpx --enable-libfaac --enable-libmp3lame  --enable-libvorbis --enable-libx264 --enable-libxvid --enable-shared --enable-gpl --enable-postproc --enable-nonfree  --enable-avfilter --enable-pthreads
#make && make install
#cd ..

修改/etc/ld.so.conf如下:
include ld.so.conf.d/*.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/ffmpeg/lib
#ldconfig
二、安装Nginx相关模块
#tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
#git clone git://github.com/arut/nginx-rtmp-module.git
#tar zxvf pcre-8.12.tar.gz
#cd pcre-8.12
#./configure
#make && make install
#tar zxvf nginx-1.2.6.tar.gz
#cd nginx-1.2.6
#./configure --prefix=/usr/local/nginx  --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_mp4_module --add-module=../nginx-rtmp-module --add-module=../nginx-rtmp-module/hls --with-cc-opt=-I/opt/ffmpeg/include --with-ld-opt='-L/opt/ffmpeg/lib -Wl,-rpath=/opt/ffmpeg/lib'
#make && make install
三、修改nginx主配置文件,配置虚拟主机(这里我们暂时只配置和测试点播,直播请看借鉴地址):
user  nobody nobody;
worker_processes 4;
error_log  logs/nginx_error.log  info;
pid        logs/nginx.pid;
worker_rlimit_nofile 51200;
events
    {
        use epoll;
        worker_connections 51200;
    }
#rtmp_auto_push on;
rtmp {
    server {
    listen 1935;
    application vod {
            play /opt/media/nginxrtmp/flv;
    }
    }
}
http
    {
        include       mime.types;
        default_type  application/octet-stream;
        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m ;
        limit_conn_zone $binary_remote_addr zone=perip:256k;
        limit_conn_log_level notice;
        sendfile on;
        tcp_nopush     on;
        keepalive_timeout 6000;#测试并发临时调大
        tcp_nodelay on;
        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.0;
        gzip_comp_level 2;
        gzip_types       text/plain application/x-javascript text/css application/xml;
        gzip_vary on;
        #log format
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';

#支持flv
server
        {
            listen       8081;
            server_name 192.168.0.33;
            root /opt/pub/media/nginx; #http协议时候,flv视频位置
            location ~ .*.(flv|swf|mp4|wma|wmv)$ {
                    valid_referers none blocked *.xxxx.com http://localhost;
                    if ($invalid_referer) {
                    return 403;
                    }
            }
            location ~ \.flv$ {
                    flv;
                    limit_conn one 20;#限制客户端并发连接数
                    limit_rate 200k;#限制每客户端最大带宽
            }
            location ~ \.mp4$ {
                    flv;
                    limit_conn one 20;
                    limit_rate 200k;
            }
            access_log  logs/nginxflv_access.log  main;
}

server
        {
            listen       8082;
            server_name 192.168.0.33;
            index index.html;
            location / {
                root /opt/pub/media/nginx-rtmp;
            }
            access_log  logs/nginxrtmpflv_access.log  main;
        }

server {
        listen      8080;
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            root /opt/pub/soft/nginx-rtmp-module;
        }
        location / {
            root /opt/pub/soft/nginx-rtmp-module/test/rtmp-publisher;
        }
    }

http://192.168.0.33:8080/stats 查看rtmp客户请求信息
http://192.168.0.33:8081/index.html 查看nginx http协议时候的flv视频
http://192.168.0.33:8082/index.html  查看nginx rtmp协议时候的flv视频

四、基本功能测试:
播放器采用开源播放器jwplayer,将播放器放到index.html同级目录下
NGINX-Http测试页面index.html(切记http的时候需要给视频添加关键帧)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test of nginx-http</title>
</head>
<body>
<div id="myElement"></div>
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="480" height="360">
  <param name="movie" value="player.swf" />
  <param name="quality" value="high" />
  <param name="wmode" value="opaque" />
  <param name="swfversion" value="6.0.65.0" />
  <param name="flashvars" value="type=http&file=http://192.168.0.33:8081/2.flv&autostart=true">
  <EMBED SRC=\'#\'" WIDTH="480" HEIGHT="360" QUALITY="high" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/i
ndex.cgi?P1_Prod_Version=ShockwaveFlash" flashvars="type=http&file=http://192.168.0.33:8081/2.flv&autostart=true" wmode="opaq
ue" /> 
</object>
</body>
</html>
NGINX-RTMP测试页面index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nginx-rtmp</title>
</head>

<body>
<div id="myElement"></div>
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="480" height="360">
  <param name="movie" value="player.swf" />
  <param name="quality" value="high" />
  <param name="wmode" value="opaque" />
  <param name="swfversion" value="6.0.65.0" />
  <param name="flashvars" value="streamer=rtmp://192.168.0.33:1935/vod&file=2.flv&autostart=true">
  <EMBED SRC=\'#\'" WIDTH="480" HEIGHT="360" QUALITY="high" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/i
ndex.cgi?P1_Prod_Version=ShockwaveFlash" flashvars="streamer=rtmp://192.168.0.33:1935/vod&file=2.flv&autostart=true" wmode="o
paque" /> 
</object>
</body>
</html>

页面能打开正常播放就说明配置是正确的。

五、并发测试
NGINX-HTTP采用loadrunner测试(略)
NGINX-RTMP采用开源软件flazr测试:
前提需要安装jdk软件
client.bat rtmp://192.168.0.33:1935/vod/2.flv -load 500
这里的500是并发数

由于局域网的限制,带宽测试到一定大小的时候就上不去了,故此步截图不忽略。

借鉴地址:
https://github.com/arut/nginx-rtmp-module/wiki/Examples
http://blog.sina.com.cn/s/blog_438308750100ez27.html
http://space.itpub.net/27043155/viewspace-735288
http://riches.blog.51cto.com/1167414/649598
https://github.com/arut/nginx-rtmp-module
http://www.yeeach.com

利用Nginx搭建http和rtmp协议的流媒体服务器[转]的更多相关文章

  1. 利用Nginx搭建http和rtmp协议的流媒体服务器

    http://www.linuxidc.com/Linux/2013-02/79118.htm

  2. nginx搭建http和rtmp协议的流媒体服务器

    nginx搭建http和rtmp协议的流媒体服务器 时间:2013-09-23 23:52来源:佚名 作者:本站 举报 点击:232次 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtm ...

  3. 利用 Nginx 搭建小型的文件服务器

    利用 Nginx 搭建小型的文件服务器 1.查看 Nginx 配置 android@localhost:/etc/nginx/conf.d$ nginx -hnginx version: nginx/ ...

  4. 利用nginx搭建RTMP视频点播、直播、HLS服务器(转)

    开发环境 Ubuntu 14.04 server nginx-1.8.1 nginx-rtmp-module nginx的服务器的搭建 安装nginx的依赖库 sudo apt-get update ...

  5. 利用nginx搭建RTMP视频点播、直播、HLS服务器

    开发环境 Ubuntu 14.04 server nginx-1.8.1 nginx-rtmp-module nginx的服务器的搭建 安装nginx的依赖库 sudo apt-get update ...

  6. 利用Nginx搭建RTMP视频直播,点播服务器,ffmpeg推流,回看

        一.环境和工具 ubuntu 14.04 desktop 不用server的原因是一部分的演示用到了linux视频播放和直播软件,自己还要装桌面,麻烦. 不建议使用 最新的16TLS,我一开始 ...

  7. nginx搭建支持http和rtmp协议的流媒体server之中的一个

    实验目的:让Nginx支持flv和mp4格式文件,支持RTMP协议的直播和点播:同一时候打开RTMP的HLS功能 ​资料:HTTP Live Streaming(缩写是 HLS)是一个由苹果公司提出的 ...

  8. 基于Nginx+nginx-rtmp-module+ffmpeg搭建rtmp、hls流媒体服务器(二)

    前言 Nginx-rtmp-module插件针对RTMP协议中一些命令,实现了事件通知和exec外部脚本处理.这里我通过一个简单的SpringBoot项目和Python代码,快速搭建一个HTTP服务来 ...

  9. rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加

    关键词:Nignx(http服务器):rtmp,hls(流媒体服务) 前言:感谢开源,感谢战斗民族.现在在做流媒体服务的一些工作,流媒体服务器搭建的网上教程多入牛毛,但是细细查看,发现很多同志贴上来的 ...

随机推荐

  1. 【51Nod 1190】最小公倍数之和 V2

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1190 \[ \begin{aligned} &\sum_{i=a ...

  2. USACO 2017 FEB Platinum nocross DP

    题目大意 上下有两个长度为n.位置对应的序列A.B,其中数的范围均为1~n.若abs(A[i]-B[j]) <= 4,则A[i]与B[j]间可以连一条边.现要求在边与边不相交的情况下的最大的连边 ...

  3. [转]用 Jsp 的 Session 机制编写的购物车程序

    一.构建的商品类 //写一个Goods类,并定义商品的各个属性,返回商品属性的方法,以及商品对象进行比较的方法//Goods.java package com.viita.Shop; public c ...

  4. (转)H264通过RTMP发布 V2.0 (Red5 Wowza 测试通过)

    直接上代码 // demo.cpp : 定义控制台应用程序的入口点.//#include "stdafx.h"#includeextern "C"{#inclu ...

  5. 企业应用:浅谈 “数据权限” 和 查询 API 设计

    背景 多数企业应用都需要对数据权限进行控制,如:某个用户只能看到某个范围的数据(数据行).某个用户只能看到某几列数据(数据列).本文以数据行级别的权限控制为范例,谈谈如何设计权限模型和查询 API. ...

  6. Go:如何组织代码

    备注 此文主要是对官方教程的学习总结,官方教程:http://golang.org/doc/code.html. 工作空间(Workspaces) Go代码必须保持在一个workspace,works ...

  7. ARC中的@autoreleasepool还有作用吗?

    ARC中的@autoreleasepool还有作用吗? QUESTION For the most part with ARC (Automatic Reference Counting), we d ...

  8. [转] 上级向的十个iOS面试问题

    上级向的十个iOS面试问题 转自 http://onevcat.com/2013/04/ios-interview/ 不管对于招聘和应聘来说,面试都是很重要的一个环节,特别对于开发者来说,面试中的技术 ...

  9. 用 Nokitjs 解决前端开发中的跨域问题

    问题 在开发一些「单页应用」时,通常会使用 Ajax 和服务器通讯,比如 RESTful API,通常「前端」和「服务端 API」可能是有不同人员在负责,也不在同一个工程下,那么开发过程中就可能会遇到 ...

  10. poi 技术动态更新 Excel模板内容,动态更新内容

    1.控制器方法 private URL base = this.getClass().getResource(""); /** * 流拍之后,可以下载询价单 * * @param ...