SDP Profile-level-id解析

SIP SDP Profile-level-id解析

基于SIP协议的VOIP通信,该字段通常位于视频协商sdp报文中,如:
video 23456 RTP/AVP 121
rtpmap:121 H264/90000
fmtp: 121 profile-level-id=42801E; packetization-mode=1


42801E分三部分
0x42 66
0x80 1000 0000 (二进制)
0x1E 30

对应profile_idc(8 bits)、profile_iop(8 bits)、level_idc(8 bits),含义如下:
profile_idc:(16进制)
   66 Baseline profile (VOIP中常用这个)
   77 Main profile
   88 Extended profile
profile_iop:(8位分别意义)
   constraint_set0_flag    1代表编码的视频序列完全遵从A.2.1所有条款,0不一定。
constraint_set1 _flag 1代表编码的视频序列完全遵从A.2.2所有条款,0不一定。
   constraint_set2_flag    1代表编码的视频序列完全遵从A.2.3所有条款,0不一定。
       注意:当上面3位有任意一位设置为1时,意味着视频序列完全遵从A.2所有条款,当proifle_idc为44、100、110、122或244时,此三位必须为0。
   constraint_set3_flag    (1)当profile_idc为66、77或88且level_idc为11时,1代表遵从Annex A for level 1b,0代表遵从Annex for level 1.1。
                                           (2)当profile_idc为100或110,1代表遵从Annex A for the High 10 Intra profile,0不一定。
                                           (3)当profile_idc为122,1代表遵从Annex A for the High 4:2:2 Intra profile,0不一定。
                                           (4)当profile_idc为44,此数据位应设置为1,0是错误的。
                                           (5)当profile_idc为244,1代表遵从Annex A for the High 4:4:4 Intra profile,0不一定。
                                           (6)当profile_idc为66、77或88且level_idc不为11时,1保留给未来使用,应设置为0,同时解码器应该忽略此数据位的值。
   constraint_set4_flag    (1)当profile_idc为77、88或100,1代表frame_mbs_only_flag等于1,0则表示frame_mbs_only_flag可能1可能0。
                                           (2)当profile_idc为118或128,,1代表编码的视频序列遵从H.10.1.1的所有条款,0不一定。
                                           (3)当profile_idc不为以上两条时,1保留给未来使用,应设置为0,同时解码器应该忽略此数据位的值。
   constraint_set5_flag    (1)当profile_idc为77、88或100,1代表Bslice类型不存在于编码的视频序列中,0不一定。
                                           (2)当profile_idc为118,1代表遵从H.10.1.2的所有条款,0不一定。
                                           (3)当profile_idc不为以上两条时,1保留给未来使用,应设置为0,同时解码器应该忽略此数据位的值。
   constraint_set6_flag 保留,设置为0。
   constraint_set7_flag 保留,设置为0。
levle_idc
等级 最大比特率(BP、MP、EP)kbit/s 高分辨率示例@最高帧率(最大存储帧)
1 64 128*96@30.9(8)   176*144@15.0(4)
1b 128 128*96@30.9(8)   176*144@15.0(4)
1.1 192 176*144@30.3(9)   320*240@10.0(3)   352*288@7.5(2)
1.2 384 320*240@20.0(7)   352*288@15.2(6)
1.3 768 320*240@36.0(7)   352*288@30.0(6)
2 2000 320*240@36.0(7)   352*288@30.0(6)
2.1 4000 352*480@30.0(7)   352*576@25.0(6)
2.2 4000 352*480@30.7(12)   352*576@25.6(10)   720*480@15.0(6)   720*576@12.5(5)
3 10000 352*480@61.4(12)   352*576@51.1(10)   720*480@30.0(6)   720*576@25.0(5)
3.1 14000 720*480@80.0(13)   720*576@66.7(11)   1280*720@30.0(5)
3.2 20000 1280*720@60.0(5)   1280*1024@42.2(4)
4 20000 1280*720@68.3(9)   1920*1080@30.1(4)   2048*1024@30.0(4)
4.1 50000 1280*720@68.3(9)   1920*1080@30.1(4)   2048*1024@30.0(4)
4.2 50000 1280*720@145.1(9)   1920*1080@64.0(4)   2048*1080@60.0(4)
5 135000 1920*1080@72.3(13)   2048*1024@72.0(13)   2048*1080@67.8(12)   2560*1920@30.7(5)   3672*1536@26.7(5)
5.1 240000 1920*1080@120.5(16)   2560*1920@51.2(9)   3840*2160@31.7(5)   4096*2048@30.0(5)   4096*2160@28.5(5)   4096*2304@26.7(5)
5.2 240000 1920*1080@172.0(16)   2560*1920@108.0(9)   3840*2160@66.8(5)   4096*2048@63.3(5)   4096*2160@60.0(5)   4096*2304@56.3(5)


其在协商中的值=level_idc*10的16进制数,如上面的1E=30,就是等级3,另外packetization-mode表示载荷类型,范围0-2(0:NAL  1:非交错  2:交错,隔行扫描)。


参考文档:ITU-T H264 04/2013

对接国标摄像头需要使用 SIP 协议进行通信,以下是整合 springboot 和 SIP 协议的代码示例: 1. 添加依赖 在 pom.xml 文件中添加以下依赖: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-sip</artifactId> <version>2.4.5</version> </dependency> ``` 2. 配置 SIP 在 application.properties 文件中添加以下配置: ```properties # SIP server configuration spring.sip.server.address=192.168.0.1 spring.sip.server.port=5060 spring.sip.server.transport=udp # SIP client configuration spring.sip.client.address=192.168.0.2 spring.sip.client.port=5060 spring.sip.client.transport=udp spring.sip.client.username=username spring.sip.client.password=password ``` 3. 编写代码 创建一个 SIP 消息监听器,用于处理 SIP 消息: ```java @Component public class SipListener implements MessageListener { @Autowired private SipSessionRegistry sipSessionRegistry; @Override public void onMessage(SipMessage sipMessage) { // 处理 SIP 消息 } } ``` 创建一个 SIP 客户端,用于向 SIP 服务器发送请求: ```java @Service public class SipClient { @Autowired private SipSessionRegistry sipSessionRegistry; @Autowired private SipMessageFactory sipMessageFactory; @Autowired private SipClientTransactionFactory sipClientTransactionFactory; @Autowired private SipServerLocator sipServerLocator; public void sendInvite(String address) throws Exception { Request request = sipMessageFactory.createRequest( "INVITE", "sip:" + address + ":5060", "SIP/2.0"); // 添加必要的头部信息 request.addHeader("From", "<sip:username@192.168.0.2>;tag=123456"); request.addHeader("To", "<sip:" + address + ":5060>"); request.addHeader("Call-ID", UUID.randomUUID().toString()); request.addHeader("CSeq", "1 INVITE"); request.addHeader("Contact", "<sip:username@192.168.0.2>"); request.addHeader("Content-Type", "application/sdp"); // 设置 SDP String sdp = "v=0\r\n" + "o=- 0 0 IN IP4 192.168.0.2\r\n" + "s=Java SIP Client\r\n" + "c=IN IP4 192.168.0.2\r\n" + "t=0 0\r\n" + "m=video 5004 RTP/AVP 96\r\n" + "a=rtpmap:96 H264/90000\r\n" + "a=fmtp:96 packetization-mode=1; profile-level-id=42001E; sprop-parameter-sets=Z00AH5pmDoAtyA==,aOvssiw=\r\n" + "a=sendonly"; request.setContent(sdp, "application/sdp"); // 发送 INVITE 请求 SipClientTransaction transaction = sipClientTransactionFactory.createClientTransaction(request); transaction.sendRequest(); // 将会话保存到会话注册表中 SipSession session = new SipSession(); session.setTransaction(transaction); session.setRemoteAddress(address); session.setRemotePort(5060); sipSessionRegistry.addSession(session); } } ``` 4. 调用 SIP 客户端 在需要发送 INVITE 请求的地方调用 SIP 客户端的 sendInvite 方法即可: ```java @Autowired private SipClient sipClient; public void sendInviteRequest(String address) throws Exception { sipClient.sendInvite(address); } ``` 5. 配置国标摄像头 配置国标摄像头需要使用国标协议,以下是配置国标摄像头的代码示例: ```java public void configureCamera(String address) throws Exception { // 创建 SIP 客户端 SipClient sipClient = new SipClient(); // 发送 INVITE 请求 sipClient.sendInvite(address); // 等待响应 Thread.sleep(5000); // 获取 SDP SipSession session = sipSessionRegistry.getSession(address); String sdp = session.getResponse().getContent().toString(); // 解析 SDP 获取视频流地址 String videoUrl = parseVideoUrlFromSdp(sdp); // 配置国标摄像头 configureGbCamera(videoUrl); } ``` 以上就是整合 springboot 和 SIP 协议进行国标摄像头对接的流程和代码示例。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值