1. 程式人生 > >LIVE555學習2:live555程式碼目錄結構

LIVE555學習2:live555程式碼目錄結構

文章目錄

1 原始碼下載

原始碼下載地址:http://www.live555.com/liveMedia/public/
開啟後,選擇live555-latest.tar.gz

2 文件說明

文件說明:http://www.live555.com/liveMedia/#description
資料結構,裡面講解了每一個類以及類之間的各種的關係:

http://www.live555.com/liveMedia/doxygen/html/annotated.html
檔案列表,用圖示方式講解了各個檔案之間的關係,以及每個模組與其他模組之間的關係:
http://www.live555.com/liveMedia/doxygen/html/files.html

3 簡單介紹

live555 是一個 C++ 開發的流媒體專案,它主要由幾個用於多媒體流的庫組成。live555 使用開放的標準協議 (RTP/RTCP,RTSP,SIP),方便與其它標準的流媒體元件互操作。這些庫可以為 Unix-like(包括 Linux 和 Mac OS X),Windows,和 QNX (及其它 POSIX 相容系統)等系統進行編譯,它們可以被用於構建流媒體應用。除了庫之外,live555 還包含了兩個流媒體應用程式 “LIVE555 Media Server” 和 “LIVE555 Proxy Server”,它們都是 RTSP 伺服器應用程式。
live555 的庫可以被用於處理 MPEG,H.265,H.264,H.263+,DV 或 JPEG 視訊,及多種音訊格式。它們還可以非常簡單地進行擴充套件,以支援其它的音訊或視訊編解碼格式,並可以被用於構建基本的 RTSP 或 SIP 客戶端和伺服器。

4 目錄結構

開啟原始碼,主要有以下幾個目錄:
在這裡插入圖片描述

其中,有四個重要的類庫,當我們自己編寫程式的時候,這四個類庫可以以靜態庫的方式進行連結,如下:

4.1 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.
理解如下:
這個類庫主要包含兩個抽象基類“UsageEnvironment”和“TaskScheduler”,
“UsageEnvironment”主要用於訊息的輸入輸出,例如輸出錯誤/警告資訊等。
“TaskScheduler”主要用於非同步讀取事件分配處理程式
此外,“HashTable”類定義了通用雜湊表的介面,由其餘程式碼使用。

4.2 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.
理解如下:
此庫中的類封裝了網路介面和套接字,即與網路相關的類的定義和實現都是在這個類庫中。 “Groupsock”類封裝了一個用於傳送(和/或接收)多播資料報的套接字。

4.3 liveMedia

官網描述如下:
This library defines a class hierarchy - rooted in the “Medium” class - for a variety of streaming media types and codecs.
理解如下:
該類庫是live555中最常用的,定義了抽象類“Medium”,適用於各種流媒體型別和編解碼器。

4.4 BasicUsageEnvironment

官網描述如下:
This library defines one 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.
理解如下:
該類庫是“UsageEnvironment”類的一個具體實現(即子類),用於簡單的控制檯輸入輸出等。

如下,為測試相關程式碼:

4.5 testProgs

該目錄實現了一些使用“BasicUsageEnvironment”的簡單程式來演示如何使用這些庫開發應用程式。

4.5.1 RTSP client端相關測試用例

4.5.1.1 openRTSP

命令列的 RTSP 全功能客戶端

4.5.1.2 testRTSPClient

命令列程式,主要用於顯示如何開啟和接收由RTSP URL指定的媒體流,即以rtsp://開頭的URL,但是此程式沒有對接收到的音視訊流資料進行其他操作。

4.5.2 RTSP server端相關測試用例

4.5.2.1 testOnDemandRTSPServer

該測試程式建立一個RTSP伺服器,並且根據客戶端的需要建立RTP單播進行流傳輸。

4.5.3 SIP client

命令列的 SIP 會話記錄器

4.5.4 其它

其它的測試用例,這裡不再介紹,官網上有詳細的說明。

4.6 mediaServer

此中包含了Live555流媒體伺服器的標準示例程式,目錄下的“live555MediaServer.cpp”便是一個完整的伺服器端測試程式,可將本地不同格式的視訊檔案轉化為流,傳遞給客戶端。上篇部落格中測試程式就是使用的這個程式,可以在VLC進行拉流測試。

4.7 proxyServer

是live555實現的代理伺服器,這個程式可以從其他的流媒體伺服器(如支援RTSP的攝像機)取實時的視訊流然後轉發給多個RTSP客戶端,這個程式很有用,可以轉發攝像機的實時視訊流。