首页 文章 精选 留言 我的

精选列表

搜索[云真机],共10000篇文章
优秀的个人博客,低调大师

在SIP对讲机中RTP/RTCP的实现

RTP/RTCP的定义及用途,还是请大家自己google。对于wifi手机来说呢,RTP协议用来传送编码后的语音,RTCP协议用来传送控制信息,公司的RTCP附带了一些语音统计信息和jitter buffer的统计信息用来防止语音抖动。由于是公司的东西,我就不细说了。下面是这两个协议的具体实现代码:RTP和RTCP的头部信息如下,一会给出详细的字节图和编码过程。RTP的头部信息: 复制代码 typedef struct _RTP_HEAD { unsigned charVersion: 2; unsigned charPadding: 1; unsigned charExtension: 1; unsigned charCcount: 4; unsigned charMarker: 1; unsigned charPtype: 7; WORDSnumber;//16bits DWORDTimestamp;//32 DWORDSsrc;//32 DWORDCsrc;//32 }RTP_HEAD,*pRTP_HEAD; RTCP的头部信息: 复制代码 typedef struct _RTCP_HEAD { unsigned charVersion: 2; unsigned charPadding: 1; unsigned charPCount: 5; unsigned charPtype;//8bits WORDLength;//16bits }RTCP_HEAD,*pRTCP_HEAD; 里面各个bit位表示的意思老规矩,不懂google之。具体实现呢,不能给出公司的代码,只能给出尽量通用一些的代码,程序员对比bit图和程序源代码应该很容易就能理解:RTP的bit图和代码实现: 复制代码 // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //0 |V=2|P|X|CC |M| PT| sequence number | //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //4 | timestamp | //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //8 | synchronization source (SSRC) identifier| //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // 12 |payload header | //| ....| //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ //| payload | //| ....| //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ void RTPCompose( string& buffer, int payloadType, int sequenceNum, int timestamp, int ssrc, const char* payloadHeader, int payloadHeaderLength, const char* payload, int payloadLength ) { ASSERT( payload && payloadLength >= 0 ); buffer.resize( 12 + payloadHeaderLength + payloadLength ); buffer[0]= (char)(2<<6);//v=2, p=x=cc=0 buffer[1]= (char)(payloadType & 0x127); // 7-bits for payload type *((unsigned short*)&buffer[2]) = (unsigned short)sequenceNum; *((unsigned int*)&buffer[4]) = (unsigned int)timestamp; *((unsigned int*)&buffer[8]) = (unsigned int)ssrc; memcpy( &buffer[12], payloadHeader, payloadHeaderLength ); memcpy( &buffer[12+payloadHeaderLength], payload, payloadLength ); } 解码是编码的逆过程俺就不罗嗦了。RTCP的bit图和代码实现: 复制代码 //0 1 2 3 //0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //byte=0 |V=2|P|RC | PT=SR=200 | length| // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // 4 | SSRC of sender| // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // 8 |NTP timestamp, most significant word | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //12 | NTP timestamp, least significant word | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //16 | RTP timestamp | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //20 | sender's packet count | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //24 |sender's octet count | // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ //28 |V=2|P|SC |PT=SDES=202| length| // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ //32 |SSRC/CSRC_1| // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //36 |CNAME=1| length| user and domain name... // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ void RTCPSRCompose( string& buffer, int receptionCount, int ssrc, int64 ntpTimestamp, int rtpTimestamp, int sentPackets, int sentBytes, const wstring& cname ) { const string& cnameUTF8 = ConvertToUTF8( cname ); int length = 8 + 20 + 4 + 6 + cnameUTF8.size( ); // 注意此处可能存在bug。 buffer.resize( length ); buffer[0]= (char)(2<<6);//V=2,P=RC=0 buffer[1]= (char)200; // PT=SR=200 *(unsigned short*)&buffer[2]= 6; // length (7 32-bit words, minus one) *(unsigned int*)&buffer[4]= (unsigned int)ssrc; *(unsigned int*)&buffer[8]= (unsigned int)(ntpTimestamp >> 32);// High 32-bits *(unsigned int*)&buffer[12] = (unsigned int)(ntpTimestamp & 0xFFFFFFFF); // Low 32-bits *(unsigned int*)&buffer[16] = (unsigned int)rtpTimestamp; *(unsigned int*)&buffer[20] = (unsigned int)sentPackets; *(unsigned int*)&buffer[24] = (unsigned int)sentBytes; buffer[28] = (char)(2<<6 & 1);//V=2, P=0, SC=1 *(unsigned short*)&buffer[30] = 0xFFFF;// 注意这里应该填写长度,由于我们并没有数据因此无法填写。请程序员按自己的 包长自己填写。 *(unsigned int*)&buffer[32] = (unsigned int)ssrc; buffer[36] = 1; // CNAME=1 buffer[37] = (char)cnameUTF8.size( ); memcpy( &buffer[38], cnameUTF8.c_str( ), cnameUTF8.size( ) );// 同理此处请程序员自己填写 } 以上是较为简单的实现。实际应用中必然需要填写自己附加的信息。实际上这个项目的代码均为在linux下用纯c写的代码,而我上传得代码为windows 下的c++代码。由于c++中Cstring类的存在,使RTP/RTCP的代码简化了不少。如果是在linux下编程的朋友稍加修改后,即可使用。此处仅仅只是给出RTP/RTCP的一个最简单和相对比较通用的实现而已。最后当然要唠叨一下TBCP突发通话消息如何通过RTCP包传送,很简单,将上面RTCP包中的RC项由subtype代替。其它按上一篇讲解的携带 TBCP消息的RTCP包的标准编写就可以了。注意,这个标准是别人定的,如果觉得不好,自己定一个也是可以的。这样就要编写自己的服务器端了。下次再讨论一下关于PTT的在线服务,创建群组列表等对PTT来说至关重要的问题的实现。 本文转自einyboy博客园博客,原文链接:http://www.cnblogs.com/einyboy/archive/2012/10/18/2729687.html,如需转载请自行联系原作者。

优秀的个人博客,低调大师

docker容器与物理机之间拷贝文件的方法

一般情况下,我们在启动容器的时候可以使用-v参数映射宿主机的文件或者目录到容器里,这样的话,在宿主机相关目录下的文件修改会自动在容器里生效。 但是,如果我们已经启动了一个容器的话,就只能使用下面的这种方式在容器和宿主机之间拷贝文件了。 docker ps 获取目标容器的ID或者容器的名称 # 我这里的是容器ID为52261df2fab6 docker inspect -f'``.`Id`' 容器的ID # 获取容器的ID全名称 得到一串类似52261df2fab612b24b3502c4ad98c22aff70ce9fa641c5c9f735ac2415e92da3 cp /root/test.log /var/lib/docker/devicemapper/mnt/52261d...xxx/rootfs/root/ # 这样就把宿主机的test.log拷贝到容器的/root/目录下了。 # 说明:上面的这个方法在CentOS6.7通过yum安装的docker-io测试通过。我另一台测试机安装的是docker-engine,则根本没有/rootfs/这个目录。 最后,还有1个方法,就是在容器里面安装openssh-server和openssh-clients,然后通过scp的方式进行文件拷贝操作。但是docker官方不建议给docker使用ssh连接的方式去管理。 本文转自 lirulei90 51CTO博客,原文链接:http://blog.51cto.com/lee90/1877218,如需转载请自行联系原作者

优秀的个人博客,低调大师

OpenStack —— 虚拟机的启动过程简述(八)

DashboardorCLIgets the user credential and does the REST call toKeystonefor authentication. Keystoneauthenticate the credentials and generate & send back auth-token which will be used for sending request to other Components through REST-call. DashboardorCLIconvert the new instance request specified in ‘launch instance’ or ‘nova-boot’ form to REST API request and send it tonova-api. nova-apireceive the request and sends the request for validation auth-token and access permission tokeystone. Keystonevalidates the token and sends updated auth headers with roles and permissions. nova-apiinteracts withnova-database. Creates initial db entry for new instance. nova-apisends therpc.callrequest tonova-schedulerexcepting to get updated instance entry with host ID specified. nova-schedulerpicks the request from thequeue. nova-schedulerinteracts withnova-databaseto find an appropriate host via filtering and weighing. Returns the updated instance entry with appropriate host ID after filtering and weighing. nova-schedulersends therpc.castrequest tonova-computefor ‘launching instance’ on appropriate host . nova-computepicks the request from thequeue. nova-computesend therpc.callrequest tonova-conductorto fetch the instance information such ashost ID and flavor( Ram , CPU ,Disk). nova-conductorpicks the request from thequeue. nova-conductorinteracts withnova-database. Return the instance information. nova-computepicks the instance information from thequeue. nova-computedoes the REST call by passing auth-token toglance-apito get the Image URI by Image ID from glance and upload image from image storage. glance-apivalidates the auth-token withkeystone. nova-computeget the image metadata. nova-computedoes the REST-call by passing auth-token toNetwork APIto allocate and configure the network such that instance gets the IP address. quantum-servervalidates theauth-token withkeystone. nova-computeget the network info. nova-computedoes the REST call by passingauth-token toVolume APIto attach volumes to instance. cinder-apivalidates the auth-token withkeystone. nova-computegets the block storage info. nova-computegenerates data for hypervisor driver and executes request on Hypervisor( vialibvirtorapi). 本文转自 wzlinux 51CTO博客,原文链接:http://blog.51cto.com/wzlinux/1964195,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册