live555 源代码简单分析1 主程序

本文介绍了开源流媒体服务器live555的源代码特点,如.hh头文件和面向对象设计。主要关注点在于live555MediaServer主程序,分析了包含DynamicRTSPServer.cpp和live555MediaServer.cpp的两个关键CPP文件,以及main()函数中DynamicRTSPServer类的使用。提供了一份live555源代码的下载链接,并推荐了一位教师的人工智能教程。
摘要由CSDN通过智能技术生成
               

live555是使用十分广泛的开源流媒体服务器,之前也看过其他人写的live555的学习笔记,在这里自己简单总结下。

live555源代码有以下几个明显的特点:

1.头文件是.hh后缀的,但没觉得和.h后缀的有什么不同

2.采用了面向对象的程序设计思路,里面各种对象

 

好了,不罗嗦,使用vc2010打开live555的vc工程,看到live555源代码结构如下:



源代码由5个工程构成(4个库和一个主程序):

libUsageEnvironment.lib;libliveMedia.lib;libgroupsock.lib;libBasicUsageEnvironment.lib;以及live555MediaServer

这里我们只分析live555MediaServer这个主程序,其实代码量并不大,主要有两个CPP:DynamicRTSPServer.cpp和live555MediaServer.cpp

程序的main()在live555MediaServer.cpp中,在main()中调用了DynamicRTSPServer中的类

 

不废话,直接贴上有注释的源码

live555MediaServer.cpp:

#include <BasicUsageEnvironment.hh>#include "DynamicRTSPServer.hh"#include "version.hh"int main(int argc, char** argv) // Begin by setting up our usage environment:  // TaskScheduler用于任务计划  TaskScheduler* scheduler = BasicTaskScheduler::createNew();  // UsageEnvironment用于输出  UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);  UserAuthenticationDatabase* authDB = NULL;#ifdef ACCESS_CONTROL  // To implement client access control to the RTSP server, do the following:  authDB = new UserAuthenticationDatabase;  authDB->addUserRecord("username1", "password1"); // replace these with real strings  // Repeat the above with each <username>, <password> that you wish to allow  // access to the server.#endif  //建立 RTSP server.  使用默认端口 (554),  // and then with the alternative port number (8554):  RTSPServer* rtspServer;  portNumBits rtspServerPortNum = 554//创建 RTSPServer实例  rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);  if (rtspServer == NULL) {    rtspServerPortNum = 8554;    rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);  }  if (rtspServer == NULL) {    *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";    exit(1);  }  //用到了运算符重载  *env << "LIVE555 Media Server\n";  *env &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值