ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:722.76KB ,
资源ID:1310987      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-1310987.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(librtmp使用扩展时间戳时服务器会将连接断开解释资料.docx)为本站会员(b****2)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

librtmp使用扩展时间戳时服务器会将连接断开解释资料.docx

1、librtmp使用扩展时间戳时服务器会将连接断开解释资料rtmpdump的librtmp时间戳有问题,服务器会断开连接分类: ffmpeg c+ linux open-source 2013-10-28 21:49 700人阅读 评论(7) 收藏 举报# header0x44 0xff 0xff 0xff 0x00 0x01 0x19 0x08# extended timestamp0x7f 0xff 0xf8 0x00 # body 0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0x2d 0x2d 0x2d 0x2d 0x2d0x2d 0x2d 0x2d 0x2d 0x2d 0x2d 0x2d 0x2d0x2d 0x2d 0x2d 0x2d 0x2d 0x2d 0x2d 0x2d对于0xC这种后续的chunk包的extended timestamp该不该发,rtmp协议中说是不发,但是FMLE是发的,推流超过4.5小时就需要用extended timestamp了。rtmpdump里面的librtmp,不会发这个包,(ffm

6、peg里面用-enable-librtmp就会使用这个rtmp的库),而且是在开始就会发这个包。6.1.3. Extended Timestampplain view plaincopyprint?1 This field is transmitted only when the normal time stamp in the 2 chunk message header is set to 0x00ffffff. If normal time stamp is 3 set to any value less than 0x00ffffff, this field MUST NOT be 4

7、 present. This field MUST NOT be present if the timestamp field is not 5 present. Type 3 chunks MUST NOT have this field. This field is transmitted only when the normal time stamp in thechunk message header is set to 0x00ffffff. If normal time stamp isset to any value less than 0x00ffffff, this fiel

8、d MUST NOT bepresent. This field MUST NOT be present if the timestamp field is notpresent. Type 3 chunks MUST NOT have this field.有可能是adobe变更了这个协议,也就是说,FMLE给FMS,FMS给flash-player,都是带这个时间戳的。收包时,服务器端则需要检测下,若接下来的4字节不是extended timestamp,那么就忽略就好了。发包时,只能采取配置,要么发,要么不发。默认发就好了。看nginx-rtmp代码:cpp view plaincopy

9、print?6 ngx_rtmp_recv(ngx_event_t *rev) 7 8 for( ; ) 9 /* parse headers */ 10 if (b-pos = b-start) 11 /* chunk basic header */ 12 fmt = (*p 6) & 0x03; 13 csid = *p+ & 0x3f; 14 if (fmt little-endian 4b */ 16 pp = (u_char*)timestamp; 17 ext = (timestamp = 0x00ffffff); 18 if (fmt little-endian 4b type*

10、/ 20 pp = (u_char*)&h-mlen; 21 h-type = *(uint8_t*)p+; 22 if (fmt = 0) 23 /* stream: little-endian 4b - little-endian 4b */ 24 pp = (u_char*)&h-msid; 25 26 27 28 /* extended header */ 29 if (ext) 30 pp = (u_char*)timestamp; 31 pp3 = *p+; 32 pp2 = *p+; 33 pp1 = *p+; 34 pp0 = *p+; 35 ngx_rtmp_recv(ngx

11、_event_t *rev) for( ; ) /* parse headers */ if (b-pos = b-start) /* chunk basic header */ fmt = (*p 6) & 0x03; csid = *p+ & 0x3f; if (fmt little-endian 4b */ pp = (u_char*)timestamp; ext = (timestamp = 0x00ffffff); if (fmt little-endian 4b type*/ pp = (u_char*)&h-mlen; h-type = *(uint8_t*)p+; if (fm

12、t = 0) /* stream: little-endian 4b - little-endian 4b */ pp = (u_char*)&h-msid; /* extended header */ if (ext) pp = (u_char*)timestamp; pp3 = *p+; pp2 = *p+; pp1 = *p+; pp0 = *p+; 可见,不管是什么chunk,只要有extended-timestamp,nginx-rtmp都会读这个。所以nginx-rtmp对接FMLE是没有问题的,对接librtmp有问题。更好的做法是判断下读出来的extended timestam

13、p是否是和之前的一样,如果不是一样说明没有发,就忽略。nginx-rtmp发包的逻辑:cpp view plaincopyprint?36 ngx_rtmp_prepare_message 37 38 /* create fmt3 header for successive fragments */ 39 thsize = p - out-buf-pos; 40 ngx_memcpy(th, out-buf-pos, thsize); 41 th0 |= 0xc0; 42 /* message header */ 43 if (fmt play_time_fix) 59 ngx_memcpy(

14、&ththsize, p - 4, 4); 60 thsize += 4; 61 62 ngx_rtmp_prepare_message /* create fmt3 header for successive fragments */ thsize = p - out-buf-pos; ngx_memcpy(th, out-buf-pos, thsize); th0 |= 0xc0; /* message header */ if (fmt play_time_fix) ngx_memcpy(&ththsize, p - 4, 4); thsize += 4; nginx-rtmp还特意说明

15、了flash客户端就是和rtmp规范不一样。out-buf-pos就是指向包的第一个chunk,若有extended-timestamp,那么肯定会在第一个包加上extended timestamp;后面还有个th和thsize,就是给后续的type=3的chunk包的,会加上这4字节的extended timestamp:cpp view plaincopyprint?63 /* This CONTRADICTS the standard 64 * but thats the way flash client 65 * wants data to be encoded; 66 * ffmpe

16、g complains */ 67 if (cscf-play_time_fix) 68 ngx_memcpy(&ththsize, p - 4, 4); 69 thsize += 4; 70 71 72 /* append headers to successive fragments */ 73 for(out = out-next; out; out = out-next) 74 out-buf-pos -= thsize; 75 ngx_memcpy(out-buf-pos, th, thsize); 76 /* This CONTRADICTS the standard * but

17、thats the way flash client * wants data to be encoded; * ffmpeg complains */ if (cscf-play_time_fix) ngx_memcpy(&ththsize, p - 4, 4); thsize += 4; /* append headers to successive fragments */ for(out = out-next; out; out = out-next) out-buf-pos -= thsize; ngx_memcpy(out-buf-pos, th, thsize); 所以nginx

18、-rtmp收发包都是需要这个extended-timestamp,对于chunk type为3的包。另外,把chunksize设置大一点,最大是65536,避免发type=3的chunk包,也是一个很好的方法。不过视频的I帧一般较大,超过64KB也有可能。The maximum chunk size can be 65536 bytes and minimum 128 bytes.按照这种规则,即type=3的chunk也发extended-timestamp,是没有问题:FMLE一直没有断开,客户端也没有断开。服务器端是srs(simple rtmp server),也没有断开:时间已经超过了24位,使用extended-timestamp:plain view plaincopyprint?77 (gdb) p /x 21039918 78 $1 = 0x1410b2e (gdb) p /x 21039918$1 = 0x1410b2e而nginx呢,是采用第一个包发完全的extended-timestamp,但是后续都是发type=1的chunk,即时间戳差值。完毕。

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2