没有合适的资源?快使用搜索试试~ 我知道了~
首页Live555源码分析RTSP客户端
Live555源代码分析之RTSP客户端testRTSPClient Author: 灯下野狐 E-mail: dengxiayehu@yeah.net Date : 2012-02 PS : 欢迎交流,转载请务必注明出处。 以 testRTSPClient.cpp 为例,介绍 Live555 中 RTSP 客户端的处理。
资源详情
资源评论
资源推荐
Live555 —— 源代码分析之 RTSP 客户端(一)
Author: 灯下野狐
E-mail: dengxiayehu@yeah.net
Date : 2012-02
PS : 欢迎交流,转载请务必注明出处。
以 testRTSPClient.cpp 为例,介绍 Live555 中 RTSP 客户端的处理。
=================================================================
==> 相关全局变量
char eventLoopWatchVariable = 0;
=================================================================
int main(int argc, char** argv) {
// Begin by setting up our usage environment: // 下面两个基础类的使用参见 RTSP 服务器部分的介绍文档
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
// 支持播放多个 Live555 的媒体源,我们这里以 1 个为例,h264 相关
// We need at least one "rtsp://" URL argument:
if (argc < 2) {
usage(*env, argv[0]);
return 1;
}
// There are argc-1 URLs: argv[1] through argv[argc-1]. Open and start streaming each one:
for (int i = 1; i <= argc-1; ++i) {
openURL(*env, argv[0], argv[i]);
}
// All subsequent activity takes place within the event loop:
env->taskScheduler().doEventLoop(&eventLoopWatchVariable);
// This function call does not return, unless, at some point in time,
"eventLoopWatchVariable" gets set to something non-zero.
return 0;
// 一般下面的语句很少使用到,因为当退出了上面的循环后,一般就是程序的终止
// If you choose to continue the application past this point (i.e., if you comment out the
// "return 0;" statement above), and if you don't intend to do anything more with the
// "TaskScheduler" and "UsageEnvironment" objects, then you can also reclaim the (small)
// memory used by these objects by uncommenting the following code:
/*
env->reclaim(); env = NULL;
delete scheduler; scheduler = NULL;
*/
}
看下 openURL()函数做了什么:
=================================================================
==> 相关宏定义及全局变量
// by default, print verbose output from each "RTSPClient"
#define RTSP_CLIENT_VERBOSITY_LEVEL 1
// Counts how many streams (i.e., "RTSPClient"s) are currently in use.
static unsigned rtspClientCount = 0;
==> 相关类定义
// Define a class to hold per-stream state that we maintain throughout each stream's
// lifetime:
class StreamClientState {
public:
StreamClientState();
virtual ~StreamClientState();
public:
MediaSubsessionIterator* iter;
MediaSession* session;
MediaSubsession* subsession;
TaskToken streamTimerTask;
double duration;
};
// 注意看下面注释
// If you're streaming just a single stream (i.e., just from a single URL, once), then you
// can define and use just a single "StreamClientState" structure, as a global variable in
// your application. However, because - in this demo application - we're showing how to
// play multiple streams, concurrently, we can't do that. Instead, we have to have a
// separate "StreamClientState" structure for each "RTSPClient". To do this, we subclass
// "RTSPClient", and add a "StreamClientState" field to the subclass:
class ourRTSPClient: public RTSPClient {
public:
static ourRTSPClient* createNew(UsageEnvironment& env, char const* rtspURL,
int verbosityLevel = 0,
char const* applicationName = NULL,
成都刘德华2012
- 粉丝: 36
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
- MW全能培训汽轮机调节保安系统PPT教学课件.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论6