live555库
来源:互联网 发布:mac上用的无线鼠标 编辑:程序博客网 时间:2024/04/28 13:45
Real Time Streaming Protocol或者RTSP(实时流媒体协议),是由Real network 和Netscape共同提出的如何有效地在IP网络上传输流媒体数据的应用层协议。RTSP提供一种可扩展的框架,使能够提供能控制的,按需传输实时数 据,比如音频和视频文件。源数据可以包括现场数据的反馈和存贮的文件。rtsp对流媒体提供了诸如暂停,快进等控制,而它本身并不传输数据,rtsp作用 相当于流媒体服务器的远程控制。传输数据可以通过传输层的tcp,udp协议,rtsp也提供了基于rtp传输机制的一些有效的方法。
RTSP协议是一个非常类似HTTP协议的流控制协议。它们都使用纯文本来发送信息,而且rtsp协议的语法 也和HTTP类似。Rtsp一开始这样设计,也是为了能够兼容使用以前写的HTTP协议分析代 码 。这是个好消息。它们主要的区别是HTTP协议是没有状态的, http协议在发送一个命令后,连接会断 开,而且命令之间没有依赖性。不同的是RTSP的命令需要知道现在正处于一个什么状态,也就是说rtsp的命令总是按照顺序来发送,某个命令总在另外一个命令之前要发送。Rtsp不管处于什么状态都不会去断掉连接。HTTP 协议默 认使用80端口,而RTSP 默认使用554端口。如果一些服务器因为某些安全的原因而封掉了这个端口,那代理和防火墙可能不让RTSP消息通 过,需要管理员去放开554端口,而使得rtsp协议能通过。
基本类
在Mplayer中如果使用live选项进行编译,则需要安装live555库。live555实现RTP/RTSP功能。
使用环境(usageEnvironment):UsageEnvironment和TaskScheduler类用在调度不同事件。还有 HashTable类定义,这些都是抽象基类。在使用过程中可以利用环境的特定功能。
groupsock:封装网络接口和socket。特别是还封装了multicast应用,这个multicast并不是Mbone意义的 multicast,而是将多个写而不读socket组合处理,用来模拟multicast。
liveMedia:定义一个类栈,根类是Medium类-不同的流类型和编解码器。
BasicUsageEnvironment:定义一个usageEnvironment的实现, 这个里面除了有一个TaskScheduler以外,都是一些说明性的东西。TaskSheduler里面是一些调度相关的函数,其中 doEventLoop是主控函数,定义为纯虚函数。
BasicTaskScheduler0:主要成员变量有fdelayQueue, fReadHandlers, fLastHandledSocketNum;这里主要的处理函数是scheduleDelayedTask, 通过定时器触发一个时间,比如RTCP包的发送等。
BasicTaskScheduler:中又添加了fMaxNumSockets和fReadSet。其中freadHandlers类中定义一个链表,将所有的句柄,对应的处理函数 和处理函数参数作链接成一个链表,通过成员函数assignHandler管理。这里面主要的函数是turnOnBackgroundReadHandling, 这个函数把句柄和处理函数注册到 select中,这样可以完成数据包的等待及其处理操作。MediaSession类中定义了一个mediaSubSession链表;MediaSubSession中又SessionId,服务端口 号,rtp/rtcp ChannelId和MediaSink指针,等等一些参数信息。
H.264
1. 基类
Medium:定义媒体名字和环境信息,处理任务名,静态函数close和lookupByName和一些虚函数来指明该medium类型,是媒体帧的基 类。
MediaSource类:实现基类中medium类型的虚函数,
FramedSoruce:定义了getNextFrame和doGetNextFrame纯虚函数是使用到的一些变量。
2. 相关类
H264VideoStreamFramer;H264VideoFileSink;H264VideoRTPSource;H264VideoRTPSinik H.264利用NAL封装数据,通过RTP传输数据包。相关的处理在RTPSource/Sink中。
Mplayer
从RTSP或者SIP中渠道SDP描述,然后调用Live555中的mediaSession类创建Session。通过成员函数 initializeWithSDP分析SDP描述。
OpenRTSP
1. Client
1. 创建TaskScheduler和UsageEnvironment实例;
2. 调用createClient创建media实例;
在openRTSP.c中,main完成配置以后,开始如下循环:
startPlayingStreams();
env->taskScheduler().doEventLoop(); // does not return
在BasicTaskScheduler0类中,定义为while(1) SingleStep();
SingleStep的处理是通过select监听一组句柄,这组句柄通过iter组成的链表串接起来,对每个句柄有处理函数,如果有句柄上有数据,那么 调用对应的处理函数。
2. liev555mediaserver
创建过程:
1. 创建TaskScheduler:这里仅仅初始化一个fdset并且socket数目初始化为0。
2. 以TaskScheduler为参数创建UsageEnvironment对象。
3. 以前述environment和服务端口号(554/8554)以及用户认证对象为参数创建 RTSPServer对象,这里是用子类 DynamicRTSPServer 的创建函数创建。在createNew成员函数中建立socket,分配发送缓冲区,和创建RTSPServer对象。这里通过 turnOnBackgroundReadHandling函数将要处理的句柄和处理函数关联起来。
4. 执行env->taskScheduler().doEventLoop();
URL分析:
sdp格式说明 >time> r= time> z=time>
time> .... k= k= : a= a=: m= v = (协议版本) o = (所有者/创建者和会话标识符) s = (会话名称) i = * (会话信息) u = * (URI 描述) e = * (Email 地址) p = * (电话号码) c = * (连接信息) b = * (带宽信息) z = * (时间区域调整) k = * (加密密钥) a = * (0 个或多个会话属性行) 时间描述: t = (会话活动时间) r = * (0或多次重复次数) 媒体描述: m = (媒体名称和传输地址) i = * (媒体标题) c = * (连接信息 — 如果包含在会话层则该字段可选) b = * (带宽信息) k = * (加密密钥) a = * (0 个或多个媒体属性行) 参考文章:rfc2326(rtsp);rfc2327(sdp)
[0x8b93138] live555 demux debug: RTP subsession 'video/H264'Sending request: SETUP rtsp://192.168.1.38:8554/5.264/track1 RTSP/1.0CSeq: 3Transport: RTP/AVP;unicast;client_port=43862-43863User-Agent: VLC media player (LIVE555 Streaming Media v2010.02.10) Received SETUP response: RTSP/1.0 200 OKCSeq: 3Date: Wed, Feb 23 2011 02:32:46 GMTTransport: RTP/AVP;unicast;destination=192.168.1.38;source=192.168.1.38;client_port=43862-43863;server_port=6970-6971Session: 4C618051 [0x8b74088] main input debug: selecting program id=0[0x8b93138] live555 demux debug: setup start: 0.000000 stop:0.000000Sending request: PLAY rtsp://192.168.1.38:8554/5.264/ RTSP/1.0CSeq: 4Session: 4C618051Range: npt=0.000-User-Agent: VLC media player (LIVE555 Streaming Media v2010.02.10) Received PLAY response: RTSP/1.0 200 OKCSeq: 4Date: Wed, Feb 23 2011 02:32:46 GMTRange: npt=0.000-Session: 4C618051RTP-Info: url=rtsp://192.168.1.38:8554/5.264/track1;seq=10298;rtptime=1299638508 [0x8b93138] live555 demux debug: We have a timeout of 60 seconds[0x8b93138] live555 demux debug: spawned timeout thread[0x8b93138] live555 demux debug: play start: 0.000000 stop:0.000000[0x8b93138] main demux debug: using access_demux module "live555"[0x8b93138] main demux debug: TIMER module_need() : 5.161 ms - Total 5.161 ms / 1 intvls (Avg 5.161 ms)[0x8b93e78] main decoder debug: looking for decoder module: 31 candidates[0x8b93e78] avcodec decoder debug: libavcodec initialized (interface 0x341401)[0x8b93e78] avcodec decoder debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) started[0x8b93e78] main decoder debug: using decoder module "avcodec"[0x8b93e78] main decoder debug: TIMER module_need() : 11.674 ms - Total 11.674 ms / 1 intvls (Avg 11.674 ms)[0x8bace08] main packetizer debug: looking for packetizer module: 21 candidates[0x8bace08] packetizer_h264 packetizer debug: found NAL_SPS (sps_id=0)[0x8bace08] packetizer_h264 packetizer debug: found NAL_PPS (pps_id=0 sps_id=0)[0x8bace08] main packetizer debug: using packetizer module "packetizer_h264"[0x8bace08] main packetizer debug: TIMER module_need() : 1.079 ms - Total 1.079 ms / 1 intvls (Avg 1.079 ms)[0x8b93e78] main decoder debug: thread (decoder) created at priority 0 (input/decoder.c:315)[0x8b93e78] main decoder debug: thread started[0x8b74088] main input debug: `rtsp://192.168.1.38:8554/5.264' successfully openedSending request: GET_PARAMETER rtsp://192.168.1.38:8554/5.264/ RTSP/1.0CSeq: 5Session: 4C618051User-Agent: VLC media player (LIVE555 Streaming Media v2010.02.10) Received GET_PARAMETER response: RTSP/1.0 200 OKCSeq: 5Date: Wed, Feb 23 2011 02:32:46 GMTSession: 4C618051 [0x8b74088] main input debug: Buffering 0%[0x8b74088] main input debug: Buffering 0%[0x8b74088] main input debug: Buffering 0%[0x8b74088] main input debug: Buffering 3%[0x8b74088] main input debug: Buffering 6%[0x8b74088] main input debug: Buffering 6%[0x8b74088] main input debug: no usable vout present, spawning one[0x8c51b38] main spu text debug: looking for text renderer module: 2 candidates[0x8c5dd98] main generic debug: thread (fontlist builder) created at priority 0 (freetype.c:480)[0x8c51b38] freetype spu text debug: using fontsize: 2[0x8c51b38] main spu text debug: using text renderer module "freetype"[0x8c51b38] main spu text debug: TIMER module_need() : 0.812 ms - Total 0.812 ms / 1 intvls (Avg 0.812 ms)[0x8c52b38] main scale debug: looking for video filter2 module: 17 candidates[0x8c52b38] swscale scale debug: 32x32 chroma: YUVA -> 16x16 chroma: YUVA with scaling using Bicubic (good quality)[0x8c52b38] main scale debug: using video filter2 module "swscale"[0x8c52b38] main scale debug: TIMER module_need() : 1.111 ms - Total 1.111 ms / 1 intvls (Avg 1.111 ms)[0x8c5eb58] main scale debug: looking for video filter2 module: 17 candidates[0x8c5eb58] yuvp scale debug: YUVP to YUVA converter[0x8c5eb58] main scale debug: using video filter2 module "yuvp"[0x8c5eb58] main scale debug: TIMER module_need() : 1.085 ms - Total 1.085 ms / 1 intvls (Avg 1.085 ms)[0x8c5dd98] main generic debug: thread started[0x8c4e188] main video output debug: window size: 1280x720[0x8c4e188] main video output debug: looking for video output module: 7 candidates[0x8c4e188] xvideo video output error: cannot open display[0x8c4e188] x11 video output error: cannot open display[0x8c4e188] fb video output warning: disabling tty handling, use with caution because there is no way to return to the tty.[0x8c4e188] fb video output error: cannot get terminal mode (Invalid argument)[0x8c4e188] opengl video output debug: Texture size: 2048x1024[0x8cff420] main generic debug: looking for opengl provider module: 1 candidate[0x8cff420] glx generic error: cannot open display[0x8cff420] main generic debug: TIMER module_need() : 0.379 ms - Total 0.379 ms / 1 intvls (Avg 0.379 ms)[0x8c4e188] opengl video output warning: No OpenGL provider found[0x8c5dd98] freetype generic debug: Building font database...[0x8c5dd98] freetype generic debug: Finished building font database.[0x8c5dd98] freetype generic debug: Took 1256 microseconds[0x8c5dd98] main generic debug: thread ended[0x8c4e188] main video output debug: removing module "caca"[0x8c51b38] main spu text debug: removing module "freetype"[0x8c5eb58] main scale debug: removing module "yuvp"[0x8c52b38] main scale debug: removing module "swscale"
- Live555库
- live555库
- Live555库
- live555库
- live555库(zz)RTSP
- live555库的认识
- live555生成库文件
- 编译live555共享库
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- 女性英文名大全
- JAVA反射机制定义
- Javascript在jsp页面的使用(一)
- POJ 3207 2-sat
- SAP ABAP 学习路线图
- live555库
- 2 Texture && PRVShell
- 安装Android SDK时出错解决
- 男生英文名大全
- java的addShutdownHook
- 互加好友 有积分送 兄弟帮忙啊
- 泛型入门
- FAQ of the ucos_ii&ucgui
- jquery方式提交中文乱码问题