rtsp開源服務器之live555

Live555是一個實現了RTSP協議的開源流媒體框架,Live555包含RTSP服務器端的實現以及RTSP客戶端的實現。Live555可以將若干種格式的視頻文件或者音頻文件轉換成視頻流或者音頻流在網絡中通過RTSP協議分發傳播,這便是流媒體服務器最核心的功能。Live555支持以下幾種文件格式的流化:  

A MPEG Transport Stream file (with file name suffix ".ts")A Matroska or WebM file (with filename suffix ".mkv" or ".webm")An Ogg file (with filename suffix ".ogg", "ogv", or ".opus")A MPEG-1 or 2 Program Stream file (with file name suffix ".mpg")A MPEG-4 Video Elementary Stream file (with file name suffix ".m4e")A H.264 Video Elementary Stream file (with file name suffix ".264")A H.265 Video Elementary Stream file (with file name suffix ".265")A VOB video+audio file (with file name suffix ".vob")A DV video file (with file name suffix ".dv")A MPEG-1 or 2 (including layer III - i.e., 'MP3') audio file (with file name suffix ".mp3")A WAV (PCM) audio file (with file name suffix ".wav")An AMR audio file (with file name suffix ".amr")An AC-3 audio file (with file name suffix ".ac3")An AAC (ADTS format) audio file (with file name suffix ".aac")

  經過Live555流化後的視頻流或者音頻流可以通過實現了標準RTSP協議的播放器(如VLC)來播放。

  Live555的官網:http://www.live555.com/,下載Live555的源代碼:
http://www.live555.com/liveMedia/public/

下載源碼後解壓得到live目錄,目錄結構如下,lib目錄是編譯後產生的目錄:


主要使用其中的四個目錄,分別對應Live555的四個庫:

    UsageEnvironment目錄,生成的靜態庫為libUsageEnvironment.lib,這個庫主要包含一些基本數據結構以及工具類的定義

    groupsock目錄,生成的靜態庫為libgroupsock.lib,這個庫主要包含網絡相關類的定義和實現

    liveMedia目錄,生成的靜態庫為libliveMedia.lib,這個庫包含了Live555核心功能的實現

    BasicUsageEnvironment目錄,生成的靜態庫為
libBasicUsageEnvironment.lib,這個庫主要包含對UsageEnvironment庫中一些類的實現

  mediaServer目錄中包含Live555流媒體服務器的標準示例程序,運行live555MediaServer.exe後出現如下界面:

   

  在mediaServer目錄中放入你的媒體文件,如test.mp3,在VLC播放器中選擇“媒體”-“打開網絡串流”,然後輸入
rtsp://127.0.0.1:8554/test.mp3 就可以播放剛才的mp3文件了。

  proxyServer目錄中是live555實現的代理服務器的例子程序,這個程序可以從其他的流媒體服務器(如支持RTSP的攝像機)取實時的視頻流然後轉發給多個RTSP客戶端,這個程序很有用,可以轉發攝像機的實時視頻流。

  testProgs目錄中包含很多的測試例子程序,我經常用的是
testOnDemandRTSPServer.cpp,我是從這個例子程序開始學習Live555的。