NTP------网络时间协议

PTP------精确时间协议

PTS,DTS的关系:

http://www.cnblogs.com/qingquan/archive/2011/07/27/2118967.html

都知道RTSP协议中,真正的数据传输是RTP协议来传输的,每个RTP包都有一个timestamp,(相对时间戳 relative timestamp)这个时间戳是需要经过换算的,我需要把它换算成相应的时间打印到播放器显示的每一帧上。

不过据http://stackoverflow.com/questions/20094998/retrieving-timestamp-in-rtp-rtsp

介绍,AftergettingFrame回调函数中处理的帧时间的,这个时间是PTS(presentationTime timestamp)

以下是代码片断:

 void DummySink::afterGettingFrame(void* clientData, unsigned frameSize, unsigned numTruncatedBytes,
struct timeval presentationTime, unsigned durationInMicroseconds) {
DummySink* sink = (DummySink*)clientData;
sink->afterGettingFrame(frameSize, numTruncatedBytes, presentationTime, durationInMicroseconds);
} // If you don't want to see debugging output for each received frame, then comment out the following line:
#define DEBUG_PRINT_EACH_RECEIVED_FRAME 1 void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes,
struct timeval presentationTime, unsigned /*durationInMicroseconds*/) {
// We've just received a frame of data. (Optionally) print out information about it:
#ifdef DEBUG_PRINT_EACH_RECEIVED_FRAME
if (fStreamId != NULL) envir() << "Stream \"" << fStreamId << "\"; ";
envir() << fSubsession.mediumName() << "/" << fSubsession.codecName() << ":\tReceived " << frameSize << " bytes";
if (numTruncatedBytes > ) envir() << " (with " << numTruncatedBytes << " bytes truncated)";
char uSecsStr[ + ]; // used to output the 'microseconds' part of the presentation time
sprintf_s(uSecsStr, "%06u", (unsigned)presentationTime.tv_usec);
envir() << ".\tPresentation time: " << (int)presentationTime.tv_sec << "." << uSecsStr;
if (fSubsession.rtpSource() != NULL && !fSubsession.rtpSource()->hasBeenSynchronizedUsingRTCP()) {
envir() << "!"; // mark the debugging output to indicate that this presentation time is not RTCP-synchronized
}
//#ifdef DEBUG_PRINT_NPT
envir() << "\tNPT: " << fSubsession.getNormalPlayTime(presentationTime);
//#endif
envir() << "\n";
#endif // Then continue, to request the next frame of data:
continuePlaying();
} Boolean DummySink::continuePlaying() {
if (fSource == NULL) return False; // sanity check (should not happen) // Request the next frame of data from our input source. "afterGettingFrame()" will get called later, when it arrives:
fSource->getNextFrame(fReceiveBuffer, DUMMY_SINK_RECEIVE_BUFFER_SIZE,
afterGettingFrame, this,
onSourceClosure, this);
return True;
}

以下是openRTSP Demo的timestamp片断:

  if (notifyTheUser) {
struct timeval timeNow;
gettimeofday(&timeNow, NULL);
char timestampStr[];
sprintf_s(timestampStr, "%ld%03ld", timeNow.tv_sec, (long)(timeNow.tv_usec/));
*env << (syncStreams ? "Synchronized d" : "D")
<< "ata packets have begun arriving [" << timestampStr << "]\007\n";
return;
}

当然LIVE555自身就在服务端把PTS转换成RTP timestamp了然后进行传输,然后到客户端又自动将RTP timestamp转换成PTS。如果要把PTS转换成世界协调时间(UTS),就需要用gettimeofday()这个函数来转换。

references:

http://comments.gmane.org/gmane.comp.multimedia.live555.devel/12552

http://bbs.csdn.net/topics/390676557?page=1

http://live-devel.live.narkive.com/LfuvIyZj/rtp-timestamp-to-utc-time

得到RTP包中的timestamp的更多相关文章

  1. RTP包中timestamp的间隔问题

    概述 近期在和同事调试G729的编解码库时碰到一个语音质量的问题,问题产生的原因和RTP包中的时间戳设置有关,特此记录下来. 问题现象,1001和1002账号注册在fs,媒体设置为G729并通过fs中 ...

  2. Live555中RTP包的打包与发送过程分析

    这里主要分析一下,live555中关于RTP打包发送的部分.在处理完PLAY命令之后,就开始发送RTP数据包了(其实在发送PLAY命令的response包之前,就会发送一个RTP包,这里传输就已经开始 ...

  3. RTP 包格式 详细解析

    H.264 视频 RTP 负载格式 1. 网络抽象层单元类型 (NALU) NALU 头由一个字节组成, 它的语法如下: +---------------+      |0|1|2|3|4|5|6|7 ...

  4. H264 RTP包解析

    1.  预备 视频: 由一副副连续的图像构成,由于数据量比较大,因此为了节省带宽以及存储,就需要进行必要的压缩与解压缩,也就是编解码. h264裸码流: 对一个图像或者一个视频序列进行压缩,即产生码流 ...

  5. NALU数据打RTP包流程详解

    最近在看RTP发送H264数据的文章,感觉很乱,没有比较清晰易懂的教程,自己整理了一下各种资料,备忘! --------Part A  ---- 先说说H264数据,H264在网络传输的是NALU(N ...

  6. RTP包的结构

    live555中数据的发送最后是要使用RTP协议发送的,下面介绍一下RTP包格式. RTP packet RTP是基于UDP协议的,RTP服务器会通过UDP协议,通常每次会发送一个RTP packet ...

  7. FU-A分包方式,以及从RTP包里面得到H.264数据和AAC数据的方法。。

    [原创] RFC3984是H.264的baseline码流在RTP方式下传输的规范,这里只讨论FU-A分包方式,以及从RTP包里面得到H.264数据和AAC数据的方法. 1.单个NAL包单元 12字节 ...

  8. (转)谈谈RTP传输中的负载类型和时间戳

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://ticktick.blog.51cto.com/823160/350142 最近被 ...

  9. rtp包格式

    转载一篇帮助我了解h264 rtp的文档,地址http://www.cppblog.com/czanyou/archive/2009/12/25/67940.html 当packetization-m ...

随机推荐

  1. python 2017.1.9

    python对缩进和空格要求非常严格,要求非常对齐 print时不同字符串之间会自动加上空格 while 和 if 等没有结束标记,全部通过对齐的方式表示的

  2. Spring Remoting by HTTP Invoker Example--reference

    Spring provides its own implementation of remoting service known as HttpInvoker. It can be used for ...

  3. yii CGridView colum 链接

    默认显示的内容是没有链接的,现在想加链接,效果图如下 代码位置就在columns数组里,直接上代码说明 $this->widget('zii.widgets.grid.CGridView', a ...

  4. LSI MegaCli 命令使用4

    Dell服务器常用管理命令总结准备新版本的 MegaCli-1.01.24-0.i386.rpm 会把程序安装在/opt下,可以自定义安装目录,例如:rpm --relocate /opt/=/usr ...

  5. #ifndef #define #endif 的用法

    1.文件中的#ifndef 头件的中的#ifndef,这是一个很关键的东西.比如你有两个C文件,这两个C文件都include了同一个头文件.而编译时,这两个C文件要一同编译成一个可运行文件,于是问题来 ...

  6. ASP.NET-FineUI开发实践-9(三)

    1. TextChanged事件前台触发回发后台,接上文,先给TextBox1加上事件,看看是怎么生成出来的, 注意AutoPostBack="true",找源代码,f4多出了个 ...

  7. ASP.NET-FineUI开发实践-9(四)

    现在是这么个问题,在开发中表格是动态出来的,就是标准板是全部字段列出,客户要根据情况列出自己想要的,在增加操作页面的同时要是能用前台自带的功能直接保存到后台就好了,现在的列显示和隐藏是不回发的. 1. ...

  8. 安装Microsoft oneDrive(原skyDrive)

    oneDrive下载地址:https://onedrive.live.com/about/zh-cn/download/ 安装时报错:Error 0x80040ca0 解决方案:关闭安装程序,按下面的 ...

  9. Cannot modify header information - headers already sent by

    有时候你在使用 header("Location: http://localhost/myblog/index.php/manager/listview");的时候会出现这个问题, ...

  10. (转)XML CDATA是什么?

    解析数据 XML 解析器通常情况下会处理XML文档中的所有文本. 当XML元素被解析的时候,XML元素内部的文本也会被解析: <message>This text is also pars ...