live555 source

news/2025/3/17 21:08:03/

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>

http://www.ppmy.cn/news/488379.html

相关文章

WPF使用Live Chart之动态更新数据

WPF使用Live Chart之动态更新数据 效果如下&#xff1a; 前台代码&#xff1a; <Window x:Class"Chapter3.MainWindow"xmlns"http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x"http://schemas.microsoft.com/winfx/2006/xam…

live555源码分析(五)DESCRIBE请求的处理

live555源码分析系列 live555源码分析&#xff08;一&#xff09;live555初体验 live555源码分析&#xff08;二&#xff09;基本组件上 live555源码分析&#xff08;三&#xff09;基本组件下 live555源码分析&#xff08;四&#xff09;RTSPServer分析 live555源码分析&…

Live555实时视频流应用总结

1&#xff0c;linux 环境&#xff1a; 官网上下载&#xff0c;下载地址&#xff1a;http://www.live555.com/liveMedia/public/ live555 版本&#xff1a;“2018.12.14” 参考&#xff1a;http://www.live555.com/liveMedia/faq.html 这个FAQ要仔细阅读。 2,编译 根据不同的平台…

RedisLive安装指南

引言&#xff1a;Redis是目前最为流行的缓存服务&#xff0c;本文将详细介绍如何搭建RedisLive的监控环境。本文安装之后的功能仍不完整&#xff0c;无实时的数据显示。 1. 环境介绍 Centos 4.7.4, Python 2.6.6, 检查环境信息&#xff0c; 打开命令行&#xff1a; [abcdZC_VM_…

live2d内嵌html,为你的博客博客/网页添加Live2d二次元老婆的插件/手动方法

前言 好久没搞WP的教程了,想不想为你的博客加一个看板娘呢,反正我想2333,所以我便汇总了一下网上这些教程模型和机器人api。 插件版 Wordpress 1、Wikimoe大佬制作的插件(伊斯特瓦尔) 2、小白-白大佬制作的插件(22&33娘单服装版本) Github 3、小白-白大佬制作的插件(…

LIVE555学习5:testOnDemandRTSPServer例程解析

文章目录 1 主函数2 ServerMediaSession3 Source 和 Sink 关于testOnDemandRTSPServer例程分析&#xff0c;网上有很多文章&#xff0c;有些写的非常详细&#xff0c;将涉及到的每个函数以及类进行了详细讲解&#xff0c;看了之后很有收获&#xff0c;可是让自己写是如何也写不…

live555源码分析(八)多播

live555源码分析系列 live555源码分析&#xff08;一&#xff09;live555初体验 live555源码分析&#xff08;二&#xff09;基本组件上 live555源码分析&#xff08;三&#xff09;基本组件下 live555源码分析&#xff08;四&#xff09;RTSPServer分析 live555源码分析&…

LIVE555学习1:Linux下live555的编译及测试

以下为在linux下编译和测试live555的全部过程。 文章目录 1 源码下载2 编译3 测试 1 源码下载 官网地址&#xff1a;http://www.live555.com/liveMedia/public/ 打开后&#xff0c;选择live555-latest.tar.gz 2 编译 在主目录下创建文件config.3516c&#xff0c;内容如下&am…