LIVE555 Streaming Media

来源:互联网 发布:斯蒂芬库里数据 编辑:程序博客网 时间:2024/04/28 07:30

This code forms a set of C++ libraries for multimedia streaming, using open standard protocols (RTP/RTCP, RTSP, SIP). These libraries - which can be compiled for Unix (including Linux and Mac OS X), Windows, and QNX (and other POSIX-compliant systems) - can be used to build streaming applications. The libraries are already being used to implement applications such as the "LIVE555 Media Server" and "LIVE555 Proxy Server" (RTSP server applications), "liveCaster" and "playRTPMPEG" (for streaming MP3 audio using RTP/RTCP), and "vobStreamer" (for streaming DVD content using RTP/RTCP/RTSP). The libraries can also be used to stream, receive, and process MPEG, H.264, H.263+, DV or JPEG video, and several audio codecs. They can easily be extended to support additional (audio and/or video) codecs, and can also be used to build basicRTSPorSIPclients and servers, and have been used to add streaming support to existing media player applications, such as "VLC" and "MPlayer".  (For some specific examples of how these libraries can be used, see thetest programs below.)

Description

  The code includes the following libraries, each with its own subdirectory:


 

UsageEnvironment

The "UsageEnvironment" and "TaskScheduler" classes are used for scheduling deferred events, for assigning handlers for asynchronous read events, and for outputting error/warning messages. Also, the "HashTable" class defines the interface to a generic hash table, used by the rest of the code.

These are all abstract base classes; they must be subclassed for use in an implementation. These subclasses can exploit the particular properties of the environment in which the program will run - e.g., its GUI and/or scripting environment.


 

groupsock

The classes in this library encapsulate network interfaces and sockets. In particular, the "Groupsock" class encapsulates a socket for sending (and/or receiving) multicast datagrams.

 


 

liveMedia

This library defines a class hierarchy - rooted in the "Medium" class - for a variety of streaming media types and codecs.

 


 

BasicUsageEnvironment

This library definesone concrete implementation(i.e., subclasses) of the "UsageEnvironment" classes, for use in simple, console applications. Read events and delayed operations are handled using a select() loop.

 

live555简介

  Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP、RTSP、SIP等的支持。Live555实现了对多种音视频编码格式的音视频数据的流化、接收和处理等支持,包括MPEG、H.263+、DV、JPEG视频和多种音频编码。同时由于良好的设计,Live555非常容易扩展对其他格式的支持。目前,Live555已经被用于多款播放器的流媒体播放功能的实现,如VLC(VideoLan)、MPlayer。

Live555 Streaming Media整体框架

  UsageEnvironment模块是对系统环境的抽象,包括抽象类UsageEnvironment和TaskScheduler。UsageEnvironment主要用于消息的输入输出和用户交互功能;TaskScheduler实现事件的异步处理、事件处理函数的注册等,它通过维护一个异步读取源实现对诸如通信消息到达等事件的处理,通过使用DelayQueue实现对其他注册函数的延时调度。该模块还包含一个HashTable类,在整个项目中都可以用到它。程序设计者通过自定义该抽象了类UsageEnvironment和TaskScheduler类的子类,就可以在特定环境(如GUI环境)中运行,不需要进行过多的修改。

  BasicUsageEnvironment模块是UsageEnvironment的一个控制台应用的实现。它针对控制台的输入输出和信号响应进行具体实现。

  GroupSock模块用于实现数据包的发送和接收。GroupSock主要被设计用以支持多播,但它也完全支持单播通信。

  LiveMedia模块是Live555最重要的模块。该模块声明了一个抽象类Medium,其他所有类都派生自该类,下面简要介绍这些类:

  Ø RTSPClient:该类实现RTSP请求的发送和响应的解析,同时根据解析的结果创建对应的RTP会话。

  Ø MediaSession:用于表示一个RTP会话,一个MediaSession可能包含多个子会话(MediaSubSession),子会话可以是音频子会话、视频子会话等。

  Ø RTCPInstance:该类实现RTCP协议的通信。

  Ø Source和Sink:这两个概念类似DirectShow中的Filter。Source抽象了数据源,比如通过RTP读取数据。Sink是数据消费者的抽象,比如把接收到数据存储到文件,该文件就是一个Sink。数据的流动可能经过多个Source和Sink。MediaSink是各种类型的Sink的基类,MediaSource是各种类型Source的基类,各种类型的流媒体格式和编码的支持即是通过对这两个类的派生实现的。Source和Sink通过RTP子会话(MediaSubSession)联系在一起。

openRTSP客户端流程

  1、创建TaskScheduler和BasicUsageEnvironment类;

  2、命令行解析,获取流媒体地址和其他选项;

  3、创建RTSPClient对象;

  4、如果需要,RTSPClient对象发送OPTIONS命令并解析服务端响应,获取可以使用命令集。

  5、RTSPClient对象发送DESCRIBE命令,并从获服务端反馈中获取流媒体相关描述SDP字串。

  6、创建MediaSession对象,解析SDP字串,创建了相应的子会话对象。在这个过程中还完成了RTP和RTCP通信使用的GroupSock对象的创建,包括协议和端口的选择。

  7、根据流媒体不同类型,实例化具体的RTP会话的Source和Sink对象。

  8、RTSPClient对象发送SETUP和PLAY命令,服务端开始传输流媒体数据。

  9、TaskScheduler开始事件处理循环,通过select监听数据包到达并调用注册函数进行处理。

 

原创粉丝点击