Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2691743
  • 博文数量: 505
  • 博客积分: 1552
  • 博客等级: 上尉
  • 技术积分: 2514
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-23 18:24
文章分类

全部博文(505)

文章存档

2019年(12)

2018年(15)

2017年(1)

2016年(17)

2015年(14)

2014年(93)

2013年(233)

2012年(108)

2011年(1)

2009年(11)

分类: LINUX

2012-12-01 15:14:07

Live555 是一个为跨平台的C++开源项目,它实现了RTP/RTCP、RTSP、SIP等的支持。并且相对于其他的流媒体服务器是完全开源并且免费的。

废话不多说,下面开始。

 

1、首先到它的主页下载一个源码包:

我下载的是latest的,具体什么版本还真不清楚闭嘴

 

2、放到linux目录下解压:

  1. root@kubuntu:/home/frank tar zxvf live555-latest.tar.gz  
  2. root@kubuntu:/home/frank# cd live  
  3. root@kubuntu:/home/frank/live#  

 

3、首先尝试在PC的Linux上编译:
区别于传统的源码包,不是传统的配置方式,而是通过genMakefiles配对目录下的config.*文件生成Makefile

  1. root@kubuntu:/home/frank/live# ./genMakefiles linux  
  2. root@kubuntu:/home/frank/live# make  


编译很顺利,然后上网找一个*.264文件(常见的就是那个test.264在新闻报道奋斗)放在当前目录下

执行mediaServer目录下的live555MediaServer服务器原型

  1. root@kubuntu:/home/frank/live# ./mediaServer/live555MediaServer  
  2. LIVE555 Media Server  
  3.         version 0.75 (LIVE555 Streaming Media library version 2012.11.08).  
  4. Play streams from this server using the URL  
  5.         rtsp://192.168.1.41:8554/<filename>  
  6. where <filename> is a file present in the current directory.  
  7. Each file's type is inferred from its name suffix:  
  8.         ".264" => a H.264 Video Elementary Stream file  
  9.         ".aac" => an AAC Audio (ADTS format) file  
  10.         ".ac3" => an AC-3 Audio file  
  11.         ".amr" => an AMR Audio file  
  12.         ".dv" => a DV Video file  
  13.         ".m4e" => a MPEG-4 Video Elementary Stream file  
  14.         ".mkv" => a Matroska audio+video+(optional)subtitles file  
  15.         ".mp3" => a MPEG-1 or 2 Audio file  
  16.         ".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file  
  17.         ".ts" => a MPEG Transport Stream file  
  18.                 (a ".tsx" index file - if present - provides server 'trick play' support)  
  19.         ".wav" => a WAV Audio file  
  20.         ".webm" => a WebM audio(Vorbis)+video(VP8) file  
  21. See http://www.live555.com/mediaServer/ for additional documentation.  
  22. (We use port 8080 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)  

通过VLC可以点播rtsp://192.168.1.41:8554/test.264视频,

(注意:test.264所在的目录要和live555MediaServer执行目录相一致,若test.264放在live目录下,则需要在live目录下执行./mediaServer/live555MediaServer)

 

4、交叉编译

编译器arm-hismall-linux-gcc/arm-hismall-linux-g++

同理如果通过genMakefiles生成交叉编译的Makefile,我们需要一个对应的config.*

因此我们创建一个config.hi3507,内容可以参考config.armlinux

  1. root@kubuntu:/home/frank/live# cat config.hi3507  
  2. CROSS_COMPILE?=         arm-hismall-linux-  
  3. COMPILE_OPTS =          $(INCLUDES) -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64  
  4. C =                     c  
  5. C_COMPILER =            $(CROSS_COMPILE)gcc  
  6. C_FLAGS =               $(COMPILE_OPTS)  
  7. CPP =                   cpp  
  8. CPLUSPLUS_COMPILER =    $(CROSS_COMPILE)g++  
  9. CPLUSPLUS_FLAGS =       $(COMPILE_OPTS) -Wall -DBSD=1  
  10. OBJ =                   o  
  11. LINK =                  $(CROSS_COMPILE)g++ -o  
  12. LINK_OPTS =  
  13. CONSOLE_LINK_OPTS =     $(LINK_OPTS)  
  14. LIBRARY_LINK =          $(CROSS_COMPILE)ar cr  
  15. LIBRARY_LINK_OPTS =     $(LINK_OPTS)  
  16. LIB_SUFFIX =                    a  
  17. LIBS_FOR_CONSOLE_APPLICATION =  
  18. LIBS_FOR_GUI_APPLICATION =  
  19. EXE =  

 

然后与在PC上编译一样,进行编译。

  1. root@kubuntu:/home/frank/live# ./genMakefiles hi3507  
  2. root@kubuntu:/home/frank/live# make clean;make  

这里要记得先make clean,否则因为之前在PC上编译的目标文件没清楚会导致链接失败。

编译时会产生一个错误

  1. In file included from MPEG4GenericRTPSink.cpp:22:  
  2. include/Locale.hh:47:123: xlocale.h: No such file or directory  
  3. In file included from MPEG4GenericRTPSink.cpp:22:  
  4. include/Locale.hh:62: error: `locale_t' does not name a type  
  5. make[1]: *** [MPEG4GenericRTPSink.o] Error 1  
  6. make[1]: Leaving directory `/home/frank/live/liveMedia'  
  7. make: *** [all] Error 2  


这个是由于海思使用的是uClinux,并没有xlocale.h这个头文件,

而live555内部的一个locale模块调用了(见liveMeida/locale.hh),因此通过编译选项把他去掉。

修改config.hi3507,在编译选项上加入-DXLOCALE_NOT_USED=1把此模块去掉。

 

  1. CROSS_COMPILE?=         arm-hismall-linux-  
  2. COMPILE_OPTS =          $(INCLUDES) -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64  
  3. C =                     c  
  4. C_COMPILER =            $(CROSS_COMPILE)gcc  
  5. C_FLAGS =               $(COMPILE_OPTS)  
  6. CPP =                   cpp  
  7. CPLUSPLUS_COMPILER =    $(CROSS_COMPILE)g++  
  8. CPLUSPLUS_FLAGS =       $(COMPILE_OPTS) -Wall -DBSD=1 -DLOCALE_NOT_USED  
  9. OBJ =                   o  
  10. LINK =                  $(CROSS_COMPILE)g++ -o  
  11. LINK_OPTS =  
  12. CONSOLE_LINK_OPTS =     $(LINK_OPTS)  
  13. LIBRARY_LINK =          $(CROSS_COMPILE)ar cr  
  14. LIBRARY_LINK_OPTS =     $(LINK_OPTS)  
  15. LIB_SUFFIX =                    a  
  16. LIBS_FOR_CONSOLE_APPLICATION =  
  17. LIBS_FOR_GUI_APPLICATION =  
  18. EXE =  


再次生成Makefile并编译

  1. root@kubuntu:/home/frank/live# ./genMakefiles hi3507  
  2. root@kubuntu:/home/frank/live# make  


编译成功!

再按照上述方法把程序放到hi3507上运行测试


 

阅读(2505) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~