MirrorLink(五 RTP client--整合RTP库到项目中)

2024-02-11 13:32

本文主要是介绍MirrorLink(五 RTP client--整合RTP库到项目中),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、整合RTP库(example1.cpp)到项目中进行编译

提示错误:

/mnt/hgfs/ubuntu/MAKE/example1/src/anw_rtp.cpp:40: undefined reference to `jrtplib::RTPGetErrorString[abi:cxx11](int)'

修改方法 :

增加:-D_GLIBCXX_USE_CXX11_ABI=0 
修改前:C++FLAGS = $(CFLAGS_DEBUG) -c -g

修改后:C++FLAGS = $(CFLAGS_DEBUG) -c -g -D_GLIBCXX_USE_CXX11_ABI=0 

二、文档说明:

1、启动手机端的RTP Server:

通过UPNP发送LaunchApplication() action(UPnP Application Server Service文档中有描述)启动RTP Server application,

(1)MirrorLink UPnP Control Point(MirrorLink Client端)调用GetApplicationList()获取applist

(2)MirrorLink UPnP Server(MirrorLink Server端)返回A_ARG_TYPE_AppList

(3)MirrorLink Client通过protocolID and direction elements来确定具体启动那个RTP app

例如:

<app><appID>0x5</appID><name>RTP Server 99</name><description>RTP Audio Server</description><allowedProfileIDs>0</allowedProfileIDs><remotingInfo><protocolID>RTP</protocolID><format>99</format><direction>out</direction><audioIPL>4800</audioIPL><audioMPL>9600</audioMPL></remotingInfo><appInfo><appCategory>0xf0000001</appCategory><trustLevel>0x80</trustLevel></appInfo><audioInfo><audioType>application</audioType><contentCategory>0x2</contentCategory><contentRules>0x0</contentRules><trustLevel>0x80</trustLevel></audioInfo><resourceStatus>free</resourceStatus>
</app>

上面是获取到的applist中其中一个RTP Server app的配置,我们根据

remotingInfo.protocolID:RTP

audioInfo.contentCategory:0x2(如果是voice command,应该判断这个值是0x10)

注意:audioInfo.contentCategory在audio文档中说是0x1

但是按照upnp application server文档应该是bit 1即0x2

确定这就是我们要选择的app

(4)MirrorLink UPnP Control Point(MirrorLink Client端)调用LaunchApplication() action启动对应的RTP server app

(5)MirrorLink Server会启动对应的RTP Server

(6)MirrorLink UPnP Server返回一个 A_ARG_TYPE_URI

<?xml version="1.0"?>
<u:LaunchApplicationResponse xmlns:u="urn:schemas-upnp-org:service:TmApplicationServer:1">
<AppURI>RTP://192.168.42.129:10600</AppURI>
</u:LaunchApplicationResponse>

(7)MirrorLink Client根据URL启动RTP Client

2、RTP AUDIO STREAMING
MirrorLink server必须能够发送单向RTP audio streaming给MirrorLink client
MirrorLink Client必须能够接收来自MirrorLink Server的单向RTP audio streaming
MirrorLink server可能支持发送双向RTP audio streaming,注意:如果MirrorLink server不支持双向RTP streaming,那么电话通话只能使用BT HFP。

RTP packet包含:RTP header和payload

(1)RTP header的结构:

第一部分:

上面的12个字符是每个RTP包都包含的。

Version (V   2 bits) : The RTP version defined by this specification is two (2).这个不用关注,jrtplib中默认就是2

Padding (P   1bit) :  If the padding bit is set, the packet contains one or more additional padding octets at the end which are not part of the payload. 这个不用关注,jrtplib中默认是0

Extension (X   1 bit) : If the extension bit is set, the fixed header MUST be followed by exactly one header extension. If the RTP header carries information about the audio category and application id, then this bit MUST be one (1). 
CSRC count (CC   4bits) : The CSRC count contains the number of CSRC identifiers that follow the fixed header.这个不用关注,暂时没有用到
Marker (M     1bit) : The interpretation of the marker is defined ;
      0: More packets will follow. 
      1: Current package carries the end of stream

Payload type (PT     7 bits) :This field identifies the format of the RTP payload and determines its interpretation by the  application.
Sequence number (16 bits): The sequence number increments by one for each RTP data packet sent, and MAY be used by the receiver to detect packet loss and to restore packet sequence.这个不用关注,jrtplib中自己维护

Timestamp(32 bits) :The timestamp reflects the sampling instant of the first octet in the RTP data packet. The  initial value of the timestamp is random.这个不用关注,jrtplib中自己维护
SSRC Synchronization source(32 bits) : This field identifies the synchronization source. 这个不用关注,暂时没有用到
CSRC Contributing Source (32 bits): An array of 0 to 15 CSRC elements identifying the contributing sources for the payload contained in this packet. The number of identifiers is given by the CC field.这个不用关注,暂时没有用到

第二部分:如果第一部分RTP Header中的Extension (X   1 bit) 为1,则RTP包中需要添加第二部分

Profile Identifier(16bits): Profile identifier for the extension header; MUST be 0x388C
Length(16bits): Number of 32-bit words for the extension, excluding the extension header (therefore 0 is a valid length).Length MUST be an even number. 
Header Extension(Array of 64 bits,所以上面的Length必须是偶数):
     The first 32 bits give the unique application id. For an application being advertised via  UPnP, the unique application id MUST match the advertised appID. This field MAY be  left empty (i.e. zero value).
     The second 32 bits give the application category

(2)RTP Audio Payload Definition

RTP payload type是MirrorLink Server和MirrorLink Client通过UPNP进行提前协商的。

(MirrorLink Client先调用SetClientProfile通知自己支持的payload type,然后通过GetApplicationList获取到某个app支持的payload type)

MirrorLink主要关注3个payload type:0,98,99

其中RTP Server应该支持payload type 0,必须支持payload type 99;RTP Client必须支持payload type 99

type 0:8bit,8khz,单声道

type 98:signed 16bit(大端),48khz,单声道

type 99:signed 32bit(大端,每个声道16bit),48khz,双声道

3、Establishing the RTP Connection

RTP streaming是基于UDP传输的。

(1)RTP Server within MirrorLink Server

MirrorLink Client此时需要建立一个RTP Client,ip和port根据LaunchApplication() action(启动MirrorLink Server端的RTP server)获取的URL确定

具体流程如下:

1). RTP server: 等待UDP包(1byte的udp包,注意:不是RTP payload长度是1byte,是整个udp包只有1byte,这个byte是任意值)
2). RTP client: 向RTP server发送1 byte UDP packet
3). RTP client: 然后等待接收数据
4). RTP server: 确定client的IP和port
5). RTP server: 开始发送 RTP streaming; 如果没有数据,应该发送一个没有payload的空的RTP packet
6). RTP client:开始接收RTP packets.
7). RTP client: 如果RTP client没有接收到任何的RTP packets,那么RTP client必须每隔一段时间发送1 byte的 UDP packets

(2)RTP Server within MirrorLink Client

MirrorLink Client此时需要建立一个RTP Server,目标ip和port根据LaunchApplication() action(启动MirrorLink Server端的RTP client)获取的URL确定

1). UPnP Control Point: Invoke UPnP LaunchApplication action for the respective RTP Client on the MirrorLink Server. 
2). UPnP Server: Return IP address and port number for the RTP client as a reply for the LaunchApplicationRequest action. 
3). RTP Client: Get ready for getting RTP streaming
4). RTP Server: Starts RTP streaming; if no audio data available, RTP Server SHOULD send a single RTP packet, without data payload.

4、VOICE COMMAND HANDLING

Voice Command中用到了VNC Device Status message中的Voice Command and Microphone flags

注意:Device Status Voice Command flag 用来表示VC session的开始和结束,Device Status Microphone flag表示一条Voice Commands的开始和结束,如果一个vc session只包含一条voice command,则可以用下图来表示:

1)MirrorLink Client发送VNC Device Status Request (测试发现Voice Command和Microphone都要设置成enable,如果只设置Voice Command华为手机异常)请求建立vc session

2)MirrorLink Server 决定是否建立vc session,并且发送VNC Device Status(Voice Command enabled or disabled),建立vc session则Voice Command为enabled,否则是disabled

3)MirrorLink Server 发送VNC Device Status(Microphone enabled )请求MirrorLink Client打开microphone

4)MirrorLink Client 打开microphone,然后立即发送RTP streaming(注意:rtp包的RTP header extension等于0xF0000010 或者0xF0000020)

5)如果mic被占用,则MirrorLink Client接收到VNC Device Status Microphone enabled message以后必须回复VNC Device Status Request Microphone disabled message
6)MirrorLink Server 停止microphone输入时必须 发送VNC Device Status Voice Mic disabled message. MirrorLink Server or Client 停止VC session时 必须VNC Device Status Request message (Voice Command flag disabled) 
7)the MirrorLink Server 如果请求继续VC回话, 需要发送一个新的VNC  Device Status message(Microphone flag enabled), 具体流程如下(但是测试发现,手机根本不按照这个流程来,开启和关闭语音识别的时候,我们收不到任何消息):

 

The MirrorLink Server SHOULD send VNC Device Status with the Voice Command flag enabled together with or before Microphone flag enabled (Δt_vr-mic ≥ 0) 
The MirrorLink Server SHOULD send VNC Device Status with the Voice Command flag disabled together with or after Microphone disabled (Δt_mic-vr ≥ 0)

 

VC session发生在Phone Call过程中,流程图如下(目前测试发现三星和华为手机都不支持双向(bi)的RTP,所以这个不用管):

 

 

 

 

 

 

 

 

这篇关于MirrorLink(五 RTP client--整合RTP库到项目中)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/699915

相关文章

SpringBoot通过main方法启动web项目实践

《SpringBoot通过main方法启动web项目实践》SpringBoot通过SpringApplication.run()启动Web项目,自动推断应用类型,加载初始化器与监听器,配置Spring... 目录1. 启动入口:SpringApplication.run()2. SpringApplicat

Springboot项目构建时各种依赖详细介绍与依赖关系说明详解

《Springboot项目构建时各种依赖详细介绍与依赖关系说明详解》SpringBoot通过spring-boot-dependencies统一依赖版本管理,spring-boot-starter-w... 目录一、spring-boot-dependencies1.简介2. 内容概览3.核心内容结构4.

Spring Boot 整合 SSE(Server-Sent Events)实战案例(全网最全)

《SpringBoot整合SSE(Server-SentEvents)实战案例(全网最全)》本文通过实战案例讲解SpringBoot整合SSE技术,涵盖实现原理、代码配置、异常处理及前端交互,... 目录Spring Boot 整合 SSE(Server-Sent Events)1、简述SSE与其他技术的对

Java整合Protocol Buffers实现高效数据序列化实践

《Java整合ProtocolBuffers实现高效数据序列化实践》ProtocolBuffers是Google开发的一种语言中立、平台中立、可扩展的结构化数据序列化机制,类似于XML但更小、更快... 目录一、Protocol Buffers简介1.1 什么是Protocol Buffers1.2 Pro

springboot整合mqtt的步骤示例详解

《springboot整合mqtt的步骤示例详解》MQTT(MessageQueuingTelemetryTransport)是一种轻量级的消息传输协议,适用于物联网设备之间的通信,本文介绍Sprin... 目录1、引入依赖包2、yml配置3、创建配置4、自定义注解6、使用示例使用场景:mqtt可用于消息发

在ASP.NET项目中如何使用C#生成二维码

《在ASP.NET项目中如何使用C#生成二维码》二维码(QRCode)已广泛应用于网址分享,支付链接等场景,本文将以ASP.NET为示例,演示如何实现输入文本/URL,生成二维码,在线显示与下载的完整... 目录创建前端页面(Index.cshtml)后端二维码生成逻辑(Index.cshtml.cs)总结

Spring Boot项目如何使用外部application.yml配置文件启动JAR包

《SpringBoot项目如何使用外部application.yml配置文件启动JAR包》文章介绍了SpringBoot项目通过指定外部application.yml配置文件启动JAR包的方法,包括... 目录Spring Boot项目中使用外部application.yml配置文件启动JAR包一、基本原理

Springboot项目登录校验功能实现

《Springboot项目登录校验功能实现》本文介绍了Web登录校验的重要性,对比了Cookie、Session和JWT三种会话技术,分析其优缺点,并讲解了过滤器与拦截器的统一拦截方案,推荐使用JWT... 目录引言一、登录校验的基本概念二、HTTP协议的无状态性三、会话跟android踪技术1. Cook

springboot项目中集成shiro+jwt完整实例代码

《springboot项目中集成shiro+jwt完整实例代码》本文详细介绍如何在项目中集成Shiro和JWT,实现用户登录校验、token携带及接口权限管理,涉及自定义Realm、ModularRe... 目录简介目的需要的jar集成过程1.配置shiro2.创建自定义Realm2.1 LoginReal

idea Maven Springboot多模块项目打包时90%的问题及解决方案

《ideaMavenSpringboot多模块项目打包时90%的问题及解决方案》:本文主要介绍ideaMavenSpringboot多模块项目打包时90%的问题及解决方案,具有很好的参考价值,... 目录1. 前言2. 问题3. 解决办法4. jar 包冲突总结1. 前言之所以写这篇文章是因为在使用Mav