live555 source
来源:互联网 发布:知乎目标用户 编辑:程序博客网 时间:2024/06/02 00:41
Source和Sink:可以把source理解为发送端的流,sink理解为接受端。MediaSink是各种类型的Sink的基类,MediaSource是各种类型Source的基类,各种类型的流媒体格式和编码的支持即是通过对这两个类的派生实现的。Source和Sink通过RTP子会话(MediaSubSession)联系在一起。
FramedSource 派生自MediaSource, 一帧码流的实现。私有unsigned char* fTo; // in 是指向发送的码流的指针。
重要的函数有 getNextFrame
void
FramedSource::getNextFrame(unsigned
char
* to, unsigned maxSize,
afterGettingFunc* afterGettingFunc,
void
* afterGettingClientData,
onCloseFunc* onCloseFunc,
void
* onCloseClientData) {
// Make sure we're not already being read:
if
(fIsCurrentlyAwaitingData) {
envir() <<
"FramedSource["
<<
this
<<
"]::getNextFrame(): attempting to read more than once at the same time!\n"
;
envir().internalError();
}
fTo = to;
fMaxSize = maxSize;
fNumTruncatedBytes = 0;
// by default; could be changed by doGetNextFrame()
fDurationInMicroseconds = 0;
// by default; could be changed by doGetNextFrame()
fAfterGettingFunc = afterGettingFunc;
fAfterGettingClientData = afterGettingClientData;
fOnCloseFunc = onCloseFunc;
fOnCloseClientData = onCloseClientData;
fIsCurrentlyAwaitingData = True;
doGetNextFrame();
}
doGetNextFrame(); 是一个虚函数,具体各种编码模式,我们可以根据自己的码流类型定义一个派生自FramedSource的类, 重新再定义doGetNextFrame如何获得下一帧的码流。在自己重定义的doGetNextFrame() 中将fTo指向要发送的缓存。
<br><br>我们可以通过doGetNextFrame() 是fTo重定向我们要发送的流,而不是从文件中读取。(搞定了source)之后就是要如何让fTo与发送会话连接起来,OnDemandServerMediaSubsession由 ServerMediaSubsession 派生而来,其有一个新的私有函数
virtual
FramedSource* createNewStreamSource,我们又可以重新定义一个派生自OnDemandServerMediaSubsession 的类,重新定义createNewStreamSource 将fTo 与 ServerMedia联系起来。<br>如下live555中的例子<br><br>
FramedSource* H264VideoFileServerMediaSubsession::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) { estBitrate = 500; // kbps, estimate // Create the video source: ByteStreamFileSource* fileSource = ByteStreamFileSource::createNew(envir(), fFileName); if (fileSource == NULL) return NULL; fFileSize = fileSource->fileSize(); // Create a framer for the Video Elementary Stream: return H264VideoStreamFramer::createNew(envir(), fileSource);}
ByteStreamFileSource说到底还是继承自FramedSource,定义了从文件获取source的方法,而这个函数又将ServerMedia 与source联系了起来,
ServerMedia 就知道该发送什么东东了。 return H264VideoStreamFramer::createNew(envir(), fileSource); 给 ServerMedia 返回了一个 FramedSource 。
不过,如果自己定义的ServerMedia直接从 OnDemandServerMediaSubsession 继承的话,有很多纯虚函数需要自己去实现,比较麻烦,所以可以直接从
H264VideoFileServerMediaSubsession 继承,它实现了这些纯虚函数,我们只需重定义createNewStreamSource 就ok了。
<br><br><br>
0 0
- live555 source
- 流媒体学习笔记3(live555的source-sink)
- live555杂谈系列(一)---source,sink简介
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- live555
- LIVE555
- live555
- live555
- LIVE555
- Live555
- 约瑟夫环
- Android 设置 横屏 竖屏
- 实现一个简单的Servlet容器
- 在mac下面获取IP地址的方法
- 迷你播放器--第一阶段(2)--退出时自动最小化(不是关闭),增加当前播放曲目的跑马灯效果
- live555 source
- [POJ 4001-4010][2011 Asia Fuzhou Regional Contest]2011 ACM 福州赛区现场赛题解(不断更新)
- 哈夫曼编码
- 贪心算法 解决 活动选择问题
- Java多线程总结之由synchronized说开去
- Mybatis_review之配置文件中的properties节点内容说明
- Make Photo Magic 使用Aviary SDK 进行图片编辑开发,功能非常强大!!!!(Aviary SDK安装说明)
- javafx tableview 绑定字段的两种方法
- Python开发问题 还要凑齐1打问题,陆续ING。。。