想对设备互联有深入了解,最简单直接的还是拿业内最好的精品进行分析。

     如下是Pad跟手机的p2p组网的日志,平板作为GO,手机是GC,频率是5G频段,因为5G信号频宽较宽,无线环境比较干净,干扰少,网速稳定,做短距离传输极好。为什么是平板作为GO而不是手机,另外也可以关注下手机投PC侧是否也是PC侧作为GO, 这里可以去了解下PC侧的p2p连接,会有答案。

wpa_supplicant: p2p0: P2P: Use primary interface for group operations
wpa_supplicant: p2p0: P2P: Starting GO
wpa_supplicant: p2p0: P2P: Request scan (that will be skipped) to start GO)
wpa_supplicant: p2p0: Setting scan request: 0.000000 sec
wpa_supplicant: Start a pre-selected network without scan step
wpa_supplicant: SAE-PK: Not a valid password (length)
wpa_supplicant: Setting up AP (SSID='DIRECT-jo-HONOR Pad View7 Pro')
wpa_supplicant: nl80211: Set mode ifindex 17 iftype 9 (P2P_GO)
wpa_supplicant: nl80211: Interface p2p0 mode change to P2P - disable 11b rates
wpa_supplicant: nl80211: Setup AP(p2p0) - device_ap_sme=1 use_monitor=0
wpa_supplicant: nl80211: Set freq 5180 (ht_enabled=0, vht_enabled=0, he_enabled=0, bandwidth=0 MHz, cf1=0 MHz, cf2=0 MHz)
wpa_supplicant:   * freq=5180
wpa_supplicant:   * channel_type=0
wpa_supplicant: Determining HT/VHT options based on driver capabilities (freq=5180 chan=36)
wpa_supplicant: Enable HT support (p2p_group=1 11a=1 ht40_hw_capab=1 ssid->ht40=0)
wpa_supplicant: P2P: * Device Info
wpa_supplicant: P2P: * Device ID: 1a:**:**:**:9b:a2
wpa_supplicant: P2P: GO - group idle
wpa_supplicant: P2P: * Device Info
wpa_supplicant: P2P: * Device ID: 1a:**:**:**:9b:a2
wpa_supplicant: BSS count 1, BSSID mask 00:**:**:**:00:00 (0 bits)
wpa_supplicant: nl80211: Added 802.11b mode based on 802.11g information
wpa_supplicant: nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED]
wpa_supplicant: nl80211: Mode IEEE 802.11a: 5180 5200 5220 5240 5260[RADAR] 5280[RADAR] 5300[RADAR] 5320[RADAR] 5500[DISABLED][RADAR] 5520[DISABLED][RADAR] 5540[DISABLED][RADAR] 5560[DISABLED][RADAR] 5580[DISABLED][RADAR]
wpa_supplicant: nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED]
wpa_supplicant: Completing interface initialization
wpa_supplicant: Mode: IEEE 802.11a  Channel: 36  Frequency: 5180 MHz
wpa_supplicant: hostapd_handle_dfs_offload: iface->cac_started: 0
wpa_supplicant: hostapd_handle_dfs_offload: freq 5180 MHz does not require DFS. Continue channel/AP setup
wpa_supplicant: Proceed with AP/channel setup
wpa_supplicant: 40/80 MHz channel width is not supported in 5/6 GHz
wpa_supplicant: nl80211: Set freq 5180 (ht_enabled=1, vht_enabled=0, he_enabled=1, bandwidth=20 MHz, cf1=5180 MHz, cf2=0 MHz)
wpa_supplicant:   * freq=5180
wpa_supplicant:   * bandwidth=20
wpa_supplicant: p2p-p2p0-3: P2P: WLAN AP allows cross connection
wpa_supplicant: p2p-p2p0-3: State: SCANNING -> ASSOCIATING
wpa_supplicant: WPS: AP vendor specific ies from wpa_bss
wpa_supplicant: Notifying state change event to hidl control: 5
wpa_supplicant: bss->freq (5805)
wpa_supplicant: Limit connection to BSSID 1a:**:**:**:9b:a2 freq=5805 MHz based on scan results (bssid_set=1 wps=0)
wpa_supplicant: p2p-p2p0-3: [PMF]ssid-ieee80211w=3,wpa_s-conf-pmf=0
wpa_supplicant: nl80211: Set mode ifindex 56 iftype 8 (P2P_CLIENT)
wpa_supplicant: nl80211: Connect (ifindex=56)
wpa_supplicant:   * bssid=1a:**:**:**:9b:a2
wpa_supplicant:   * freq=5805
wpa_supplicant:   * SSID=DI***************************
wpa_supplicant:   * pairwise=0xfac04
wpa_supplicant:   * group=0xfac04
wpa_supplicant:   * Auth Type 0
wpa_supplicant:   * WPS:0, privacy:1
wpa_supplicant: nl80211: Connect request send successfully
wpa_supplicant: Not configuring frame filtering - BSS 00:**:**:**:00:00 is not a Hotspot 2.0 network
wpa_supplicant: P2P: * Device Info: addr 1a:**:**:**:9b:a2 primary device type 10-0050F204-5 device name 'HONOR Pad View7 Pro' config methods 0x188
wpa_supplicant: nl80211: Drv Event 46 (NL80211_CMD_CONNECT) received for p2p-p2p0-3
wpa_supplicant: nl80211: Set drv->ssid based on scan res info to 'DI***************************'
wpa_supplicant: p2p-p2p0-3: freq=5805 MHz
wpa_supplicant: p2p-p2p0-3: State: ASSOCIATING -> ASSOCIATED
wpa_supplicant: Notifying state change event to hidl control: 6
wpa_supplicant: p2p-p2p0-3: Associated to a new BSS: BSSID=1a:**:**:**:9b:a2

  p2p连接后就是开始能力集协商,从日志看其实这协商就是正常的rtsp能力交互,包括音视频编解码格式协商,uibc能力协商。手机端的多屏协同是一个服务,过滤进程号可以跟踪连接过程的日志,不过很有意思的是连接过程中先初始化DLNA,但是我试了图片拖曳、视频播放,都没有走DLNA,更像是DMC,但是看不出控制的是什么,以后多连些设备再看看了。 

KitUtil : In getMetaDataAppId, Failed to read meta data for the AppID.
PlayerService: onBind in
PlayerManager: unregisterListener pid not found pid = 31954
CallBackMgr: removeListenerAndUsingCapability pid =31954
CallBackMgr: addListenerAndUsingCapability pid = 31954, listener = com.huawei.android.airsharing.service.b@af857b4
NetworkMgr: init in.
MiraCastEngine: before setWifiDisplayEnable().
MiraCastEngine: netState is other
MiraCastEngine: NetworkStateRecv mWifiFreq: 5805, mP2pFreq: -1
MiraCastEngine: NetworkStateRecv mWifiFreq: 5805, mP2pFreq: -1
MiraCastEngine: netState is other
MiraCastEngine: NetworkStateRecv mWifiFreq: 5805, mP2pFreq: -1
CallBackMgr: setIsUserAgreeDisclaimer true
CallBackMgr: updateUsingCapability pid = 31954, capability = 13
PlayerSourceManager: setUsingCapability pid = 31954, usingCapability = 13
DlnaControllerManager: startDlna(String mode) with mode[DMC].
DLNA_JNI: Enter Java_com_huawei_android_multiscreen_dlna_sdk_jni_DlnaUniswitch_dlnaApiSetDmcAutoBrowseDisable
DLNA_JNI: Enter CheckPermissoin uid_t 1000
DLNA_JNI: Leave Java_com_huawei_android_multiscreen_dlna_sdk_jni_DlnaUniswitch_dlnaApiSetDmcAutoBrowseDisable
DLNA_JNI: Enter CheckPermissoin uid_t 1000
DLNA_JNI: Enter Java_com_huawei_android_multiscreen_dlna_sdk_jni_DlnaUniswitch_dlnaApiStackInit
DLNA_JNI: Enter FindCallback
DLNA_JNI: Leave FindCallback
DLNA_JNI: before DlnaApiRegisterSysCallback
VPPUPNP : [VPPDLNA][DlnaApiStackInit][:508]-:DlnaApiStackInit Enter, initMode = 9, DLNA_STACK_VERSION = MediaOS V100R001C00B706 2.0 20140430
DLNA_JNI: Enter DlnaGetIPAndMAC
DLNA_JNI: Leave DlnaGetIPAndMAC
HiSight-HiSightManager: [32a4d110d55eb87, 918d87, 2ffbf4a] the session of pid is null, the session of airSharing pid is null: true
UtilTools: [32a4d110d55eb87, e70371, 2ffbf4a] getRealProjectionDevice, belong to trusted list.
PlayerSourceManager: [32a4d110d55eb87, e70371, 2ffbf4a] AirSharing 11.1.0.325 connectDevice, callerPackage :com.huawei.dmsdp, currentTimeMillis :1667895509584
PlayerSourceManager: [32a4d110d55eb87, e70371, 2ffbf4a] scheduleConnectDevice in
PlayerSourceManager: [32a4d110d55eb87, 3eebb58, e70371] handle connect device
PlayerSourceManager: [70e58710d58f3e7, 0, 0] connectDevice in, callingPid is 31954; mode is = MIRROR; mCallerPackage = com.huawei.dmsdp
HiSight-HiSightManager: [70e58710d58f3e7, 0, 0] the session of pid is null, the session of airSharing pid is null: true
WifiInfoEvent: [70e58710d58f3e7, 0, 0] get info is invalid
UPNP-1.6.25: MAX-AGE     =  1800
UPNP-1.6.25: MX     =  0
UPNP-1.6.25: DeviceType   =  urn:schemas-upnp-org:device:MediaServer:1
UPNP-1.6.25: ServiceType =

然后开始是RTSP协商,协商多媒体参数,视频格式是H265,协商了上限、下限的码率,这个上限、下限应该是根据RTCP反馈网络进行动态调整视频码率,视频宽高,另外就是UIBC的行为定义。

HiSight-RTSP-Encap: [70e58810d59716a, 26234c2, 0] Encapsulate common response RTSP/1.0 200 OK
HiSight-RTSP-Encap: Date: 2022-11-08 16:18:29 PM Tue
HiSight-RTSP-Encap: Server: localhost
HiSight-RTSP-Encap: Cseq: 1
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: [70e58810d59716a, 26234c2, 0] Send announce option request.
HiSight-RTSP-Encap: [70e58810d59716a, 32156e4, 0] Send M1 option request OPTIONS * RTSP/1.0
HiSight-RTSP-Encap: Date: 2022-11-08 16:18:29 PM Tue
HiSight-RTSP-Encap: CSeq: 2
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: [70e58810d59716a, 8eb963, 0] Encapsulate sink option response sequence id: 2
HiSight-RTSP-Encap: [70e58810d59716a, 8eb963, 0] Sending defaultResponse: RTSP/1.0 200 OK
HiSight-RTSP-Encap: Server: localhost
HiSight-RTSP-Encap: Cseq: 2
HiSight-RTSP-Encap: Public: hisight1.1, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: --------------
HiSight-RTSP-Encap: [70e58810d59716a, 8eb963, 0] Send M3 GET_PARAMETER request GET_PARAMETER rtsp://localhost/hisight1.1 RTSP/1.0
HiSight-RTSP-Encap: Date: 2022-11-08 16:18:29 PM Tue
HiSight-RTSP-Encap: CSeq: 3
HiSight-RTSP-Encap: Content-Type: text/parameters
HiSight-RTSP-Encap: Content-Length: 186
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: his_version
HiSight-RTSP-Encap: his_video_formats
HiSight-RTSP-Encap: his_audio_codecs
HiSight-RTSP-Encap: his_uibc_capability
HiSight-RTSP-Encap: his_feature
HiSight-RTSP-Encap: his_vtp
HiSight-RTSP-Encap: his_device_type
HiSight-RTSP-Encap: his_network_config
HiSight-RTSP-Encap: his_player_controller_capability
HiSight-RTSP-Encap: his_media_capability
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Send set parampter M4.
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Set video format, width 1080, height 2400
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Set audio format 1
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encapsulate feature set 101
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encapsulate feature set 103
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Support Uibc true, support Vtp true
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_point_down
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_point_up
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_move
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_key_down
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_key_up
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is mouse_down
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is mouse_up
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is mouse_move
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is vertical_wheel
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is horizontal_wheel
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_point_down
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_point_up
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_move
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_key_down
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is left_key_up
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is mouse_down
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is mouse_up
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is mouse_move
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is vertical_wheel
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Encap generic str is horizontal_wheel
HiSight-RTSP-Encap: [70e58810d59716a, 2ad31c7, 0] Send M4 request projection mode MIRROR
HiSight-RTSP-Encap: [70e58810d59716a, 3316272, 0] Encapsulate action method in.
HiSight-RTSP-Encap: [70e58810d59716a, 3316272, 0] Sending M5 SET_PARAMETER rtsp://localhost/hisight1.1 RTSP/1.0
HiSight-RTSP-Encap: Date: 2022-11-08 16:18:29 PM Tue
HiSight-RTSP-Encap: CSeq: 5
HiSight-RTSP-Encap: Content-Type: text/parameters
HiSight-RTSP-Encap: Content-Length: 27
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: his_trigger_method: SETUP
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: [70e58810d59716a, 2097119, 167b514] Sending setup response.
HiSight-RTSP-Encap: [70e58810d59716a, 159983f, 0] Encapsulate common response RTSP/1.0 200 OK
HiSight-RTSP-Encap: Date: 2022-11-08 16:18:29 PM Tue
HiSight-RTSP-Encap: Server: localhost
HiSight-RTSP-Encap: Cseq: 4
HiSight-RTSP-Encap: 
HiSight-RTSP-Encap: [70e58810d59716a, c659ab, 0] Encapsulate common response RTSP/1.0 200 OK
HiSight-RTSP-Encap: Date: 2022-11-08 16:19:04 PM Tue
HiSight-RTSP-Encap: Server: localhost
HiSight-RTSP-Encap: Cseq: 5
HiSight-RTSP-Encap:
HiSight-RTSP-Ctl: [70e58710d58f3e7, 3fd39c8, 0] Start device type 5, subtype 51,local 192.168.49***,remote 192.168.49***
HiSight-RTSP-Ctl: [70e58810d59716a, 2765261, 0] On peer ready
HiSight-RTSP-Ctl: [70e58810d59716a, 26234c2, 0] On request ANNOUNCE * RTSP/1.0
HiSight-RTSP-Ctl: [70e58810d59716a, 26234c2, 0] AuthNeg: We rcv encrypt data aes128ctr, send data=aes128ctr, get version 1, get ControlAlgId = 1, get MediaAlgId = 1
HiSight-RTSP-Ctl: [70e58810d59716a, 32156e4, 0] On response, State:11
HiSight-RTSP-Ctl: [70e58810d59716a, 22a199e, 0] On response, State:1
HiSight-RTSP-Ctl: [70e58810d59716a, 8eb963, 0] On request OPTIONS * RTSP/1.0
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] On response, State:3
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink HiSight version is 1.1
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] device_type 5;subtype 51;
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink device type 5 subtype 51
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] His_video_formats: codecs 2;fps 60;gop 300;bitrate 3145728;vbr-min 1048576;vbr-max 5242880;dpi 0;scr-w 0;scr-h 0;width 1080;height 2400
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] processSinkVideoCodecs, sourcecodecs: 2 sinkcodecs: 2 negcodecs: 2
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink vbr-min 1048576 vbr-max 5242880
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink bitrate 3145728
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] neg video formats: codecs 2,fps 60,gop 300,bitrate 3145728,min-bitrate 1048576,max-bitrate 5242880,dpi 0,scr-width 0,scr-height 0,width 1080,height 2400
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink feature: 101
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink feature: 103
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Sink audioCodecs 1 negotiated value 1
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is left_point_down, localList index 0
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is left_point_up, localList index 1
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is left_move, localList index 2
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is left_key_down, localList index 3
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is left_key_up, localList index 4
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is mouse_down, localList index 5
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is mouse_up, localList index 6
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is mouse_move, localList index 7
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is vertical_wheel, localList index 8
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is horizontal_wheel, localList index 9
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 1, determine str is stylus, localList index -1
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is input_content, localList index 0
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is input_focus, localList index 1
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is virtualkey_back, localList index 2
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is virtualkey_home, localList index 3
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is virtualkey_recent_app, localList index 4
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is virtualkey_quick_setting, localList index 5
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is message_extend, localList index 6
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Determine Uibc listType 3, determine str is message_reserved, localList index 7
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Negotiated UIBC result is true
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Process network config, not carry his_network_config.
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Peer support vtp for video, result is 1
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] processModuleCustomParams in, controllerParams: null,mediaParams {"h265_supported":false,"slice_num_splice":false,"slice_num_advance":false,"max_inputbuffer_size_slice_num":1,"slice_size_splice":false,"slice_size_advance":false,"max_inputbuffer_size_slice_size":1,"none_slice":true,"pad_fps_optimization":true};
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Module custom params negotiation done,send M4 request: 0
HiSight-RTSP-Ctl: [70e58810d59716a, 2ad31c7, 0] Send M4 request,result: true
HiSight-RTSP-Ctl: [70e58810d59716a, 3316272, 0] On response, State:4
HiSight-RTSP-Ctl: [70e58810d59716a, 3316272, 0] Send action method is SETUP
HiSight-RTSP-Ctl: [70e58810d59716a, 3a1caa8, 0] On response, State:5
HiSight-RTSP-Ctl: [70e58810d59716a, 167b514, 0] On request SETUP * RTSP/1.0
HiSight-RTSP-Ctl: [70e58810d59716a, 159983f, 0] On request PLAY * RTSP/1.0
HiSight-RTSP-Ctl: [70e58810d59716a, 159983f, 0] Get vtp port is invalid.
HiSight-RTSP-Ctl: [70e58810d59716a, c659ab, 0] On request PAUSE  RTSP/1.0

协商的日志中没有看到audio协商相关的信息,但是通过codec部分还是能看到音频的格式应该是aac,但是有意思的是创建了4个audio的子继承,这个还是可以深入了解的。

CCodec  : Created component [c2.android.aac.encoder]
CCodec  : Created component [c2.android.aac.encoder]
CCodec  : Created component [c2.android.aac.encoder]
CCodec  : Created component [c2.android.aac.encoder]

互联设备中支持所有音频的扭转,所以这里音频采集的就不再是通过remotedevice了,因为remotedevice有部分声音是采集不到的,例如闹钟、电话声音等。从日志上看应该是从代理节点采集数据,这样子的话应该是所有的音频数据的采集都是走代理节点,audio 数据回写应该也是写到此节点,这部分的实现需要在系统中实现了。

APM_AudioPolicyManager: setDeviceConnectionStateInt() device: 0x2000000, state 1, name DMSDP format 0x0
APM_AudioPolicyManager: setDeviceConnectionStateInt() device: 0x2000000, state 1, name DMSDP format 0x0
APM_AudioPolicyManager: setDeviceConnectionStateInt() device: 0x81000000, state 1, name DMSDP format 0x0
APM_AudioPolicyManager: setDeviceConnectionStateInt() device: 0x81000000, state 1, name DMSDP format 0x0

    视频采集编码部分可以看看如下部分,还是通过virtualdisplay获取当前屏幕数据,设置宽高、dpi,根据协商设置比特率,编码部分走的ACODEC没什么日志,画面静止后转为动画瞬间并没有呼吸效应画面很流畅,这里的qp参数应该有部分的调整,应该走的是VBR。而且画面静止转动画后会对网络有比较大的冲击,容易出现音频的卡顿,而这里都是很顺畅,应该在网络发包做了调优。然后统计每秒的视频帧率,从统计的帧率看并没有稳定60fps,并不需要将输出帧率固定再60fps。

16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] VideoEncoder Constructor in, deviceType is 5, deviceSubType is 51
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] DefaultVideoBitrate is : 8.0Mbps, minVideoBitrate is 3.0Mbps, maxVideoBitrate is 10.0Mbps
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] VideoEncoder Constructor out
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setVideoEncoderWidthHeight in, width is 1080, height is 2400, multiWindowMode is 0
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setVirtualDisplayDpi : 480
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] updateVideoFps in, currentFps : 30, newFps : 60
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setVideoIframeInterval : 5.0
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] set invalid screen width : 0, height : 0
16:18:29.759 10298 32091 E HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] ERROR : set invalid screen size
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setVirtualDisplayName new name : HiSightPCDisplay
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setVirtualDisplayType : 3
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setMinMaxVideoBitrate in, minVideoBitrate is : 1.0Mbps, maxVideoBitrate is : 5.2Mbps
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setDefaultVideoBitrate in, currBitrate is : 3.1Mbps
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] setVideoEncoderType type : video/hevc
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] prepareVideoEncoder in
16:18:29.759 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] initCallbackHandlerThread in.
16:18:29.763 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] prepareVideoEncoderForMatebookOrPad in.
16:18:29.767 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] prepareVideoEncoderForMatebookOrPad out.
16:18:29.825 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] getSecondaryScreenWidth in.
16:18:29.825 10298 32091 E HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] not hw fold display.
16:18:29.825 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] getCurrentRotation in
16:18:29.825 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] getCurrentRotation invoke success, mCurrRotation is 0
16:18:29.825 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] updateDisplayAndVideoResolution in
16:18:29.826 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] updateResolutionInStandardScreen in
16:18:29.826 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] updateResolutionInStandardScreen out
16:18:29.826 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] updateDisplayAndVideoResolution out, currRotation: 0, currDisplayMode: 0, mCurrentVideoWidth: 1080, mCurrentVideoHeight: 2400, mVideoWith: 1080, mVideoHeight: 2400
16:18:29.826 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] judgeDeviceRotated out, currRotation: 0, currVideoWidth: 1080, currVideoHeight: 2400, mVideoWith: 1080, mVideoHeight: 2400, mInitialVideoWidth: 1080, mInitialVideoHeight: 2400
16:18:29.904 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] create VirtualDisplay VirtualDisplay{display=Display id 47: DisplayInfo{"HiSightPCDisplay, displayId 47", uniqueId "****", app 1080 x 2400, real 1080 x 2400, largest app 1080 x 2400, smallest app 1080 x 2400, mode 48, defaultMode 48, modes [{id=48, width=1080, height=2400, fps=60.0}], colorMode 0, supportedColorModes [0], hdrCapabilities null, rotation 0, density 480 (480.0 x 480.0) dpi, layerStack 47, appVsyncOff 0, presDeadline 16666666, type VIRTUAL, state ON, owner com.huawei.android.airsharing (uid 1000), FLAG_PRESENTATION, removeMode 0}, DisplayMetrics{density=3.0, width=1080, height=2400, scaledDensity=3.0, xdpi=480.0, ydpi=480.0, densityDpi=480, noncompatWidthPixels=1080, noncompatHeightPixels=2400, noncompatDensity=3.0, noncompatDensityDpi=480, noncompatXdpi=480.0, noncompatYdpi=480.0}, isValid=true, token=android.hardware.display.DisplayManagerGlobal$VirtualDisplayCallback@e7fb9c8, surface=Surface(name=null)/@0xfad3a61}
16:18:29.911 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] checkDeviceHasNavigationBar in
16:18:29.912 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] checkDeviceHasNavigationBar out, noNavigationBar
16:18:29.914 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, e9beb4, cd8fa8] suspendVideoEncoder in
16:18:29.914 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 1a5a32a, e9beb4] handle message: 5, displayMode is 0, mMultiWindowMode is 0
16:18:29.914 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 1a5a32a, e9beb4] suspendVideoEncodeInner in
16:18:29.917 10298 32091 I HiSight-M-EncoderVideo: [70e58810d59716a, 2a42af1, 159983f] resumeVideoEncoder in
16:18:29.917 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 70f5f8, 2a42af1] handle message: 4, displayMode is 0, mMultiWindowMode is 0
16:18:29.917 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 70f5f8, 2a42af1] resumeVideoEncoderInner in
16:18:29.917 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 70f5f8, 2a42af1] Is First Resume, no need IDRRequest
16:18:29.918 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 70f5f8, 2a42af1] Screen is not Locked.
16:18:29.918 10298 32136 I HiSight-M-EncoderVideo: [70e58810d59716a, 70f5f8, 2a42af1] resumeVideoEncoderInner out
16:18:29.923 10298 32153 I HiSight-M-EncoderVideo: We have got 0 frames from Encoder.
16:18:30.058 10298 32145 I HiSight-M-EncoderVideo: MediaCodec Callback onOutputFormatChanged
16:18:30.058 10298 32145 I HiSight-M-EncoderVideo: onOutputFormatChanged, new MediaFormat : {max-bitrate=3145728, vendor.hisi.SupportHvc=0, vendor.hisi.hisi-ext-codec-perceptual-coding-supported=2, mime=video/hevc, vendor.hisi.LowBitrate=2, vendor.hisi.hisi-ext-codec-scale-supported=1, bitrate=3145728, vendor.hisi.SupportMoreLTRF=0, vendor.hisi.hisi-ext-codec-crop-supported=1, vendor.hisi.hisi-ext-codec-qp-regulation-supported=1, color-standard=1, vendor.hisi.hisi-ext-codec-ltr-supported=1, color-transfer=3, width=1080, vendor.hisi.hisi-ext-codec-roi-supported=1, vendor.hisi.hisi-ext-codec-non-ref-p-frames-supported=1, vendor.hisi.hisi-ext-codec-more-ltr-supported=0, color-range=2, frame-rate=60, height=2400, csd-0=java.nio.HeapByteBuffer[pos=0 lim=87 cap=87]}
16:18:30.924 10298 32153 I HiSight-M-EncoderVideo: We have got 34 frames from Encoder.
16:18:31.924 10298 32153 I HiSight-M-EncoderVideo: We have got 39 frames from Encoder.

其实互联实现还是比较佩服拖拽的体验效果的,因为在平板端拖拽,无延迟的体验确实挺牛的,之前在wfd实现UIBC时有时候都会顿一下,体验很不爽。文件拖拽需要配合文件管理器进行修改了,数据传输、控制部分还是在互联的进程中由UIBC进行控制。

JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.723695 fillp_conn.c:393,FillpConnReqAckInput <F-LOGBUTT>FillpConnReqAckInput IN
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.723733 fillp_conn.c:1545,FillpSendConnConfirm <F-LOGBUTT>FillpSendConnConfirm IN
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.723865 fillp_conn.c:1672,FillpSendConnConfirm <F-LOGBUTT>FillpSendConnConfirm OUT
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.723880 fillp_conn.c:476,FillpConnReqAckInput <F-LOGBUTT>FillpConnReqAckInput OUT
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.746591 fillp_conn.c:947,FillpConnConfirmAckInput <F-LOGBUTT>FillpConnConfirmAckInput IN
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.750140 fillp_flow_control.c:464,FillpFcInit <F-LOGERR>fillp_sock_id:0, fc alg:4h, characters:1h, peer_alg:7h, peerCharacters:1h
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.751809 fillp_conn.c:787,FillpHandleConnConfirmAckInput <F-LOGBUTT>FillpHandleConnConfirmAckInput IN
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.752039 fillp_conn.c:811,FillpHandleConnConfirmAckInput <F-LOGBUTT>FillpHandleConnConfirmAckInput OUT
JNI_FT_SOCKET: FillpAdpDebugSend : 91   1108 16:18:29.752070 fillp_conn.c:1076,FillpConnConfirmAckInput <F-LOGBUTT>FillpConnConfirmAckInput OUT

再看看平板端的日志,上来先是DMSDP的初始化(第一眼看还是以为是DMS,后面网上查了下是HarmonyOS设备虚拟化),其实更关注的是camera 数据采集后,数据如何填充到手机端。

DMSDP   : DMSDPService:DMSDPService onCreate
DMSDP   : SinkProfile:SinkProfile util construct
DMLog   : DeviceManager:set flags:3, countryCode: 
AwareBitmapCacher: init processName:com.hihonor.dmsdp pid=28270 uid=1000
DMSDP   : SinkProfile:execute to connect sink profile service
DMLog   : RemoteServiceConnection:begin to bind service:ComponentInfo{com.hihonor.iconnect/com.hihonor.devicemanager.service.CloudDeviceManagerService}
ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:2026 android.content.ContextWrapper.bindService:812 com.hihonor.devicemanager.client.a.a:147 com.hihonor.dmsdpdevice.a.c:1277 com.hihonor.dmsdpdevice.a.lambda$gmGC7SawuKKi_8Jc3ls7Xp-b3ZE:0 
CamSDK_CameraJniInit: JNI_OnLoad: begin load Camera JNI
CamSDK_CameraJniInit: JNI_OnLoad: load jni so success
RasterMill: RegisterAndroidCameraJniUtil: Start Register Android Camera Jni Util
RasterMill: RegisterNativeCameraJniUtil: Start Register Native Camera Jni Util
DMSDP   : CamSDK_CameraModuleUtils:register camera jni util
DMSDP   : CamSDK_CameraModuleUtils:register camera status handler
DMSDP   : DMSDPService:registerReceiver
DMSDP   : DMSDPService:created from userUnlocked 
DMSDP   : DMSDPService:init
DMSDP   : DMSDPController:init
DMSDP   : DiscoverManager:init
DMSDP   : DMSDPDeviceManager:init
DMSDP   : SoftBusChannel sink:SoftBusChannel init
NearbyInterface: getServiceFromManager: DdmpDataBusService
NearbyInterface: put entryMap, name=com.hihonor.dmsdp+dmsdpsession+server
NearbyInterface: addEntry: succ=true name=com.hihonor.dmsdp+dmsdpsession+server
DMSDP   : softBusManager:createSessionServer:com.hihonor.dmsdp com.hihonor.dmsdp+dmsdpsession+server ret:0 isServer: true

协商过程的跟手机端类似没什么好看的,但是到解码这边的我就有那么点点看不懂了,前面大家握手商量的是是60帧,这咋说变就变变成30帧了,总觉得哪里不对,但是不知道哪里出错了。

I CCodec  : setup formats input: AMessage(what = 0x00000000) = {
I CCodec  :   int32_t max-input-size = 5242880
I CCodec  :   int32_t width = 1080
I CCodec  :   int32_t priority = 0
I CCodec  :   string mime = "video/hevc"
I CCodec  :   int32_t frame-rate = 30
I CCodec  :   int32_t height = 2400
I CCodec  :   int32_t level = 131072
I CCodec  :   Rect crop(0, 0, 318, 238)
I CCodec  : }
I CCodec  : setup formats output: AMessage(what = 0x00000000) = {
I CCodec  :   int32_t android._color-format = 2130708361
I CCodec  :   int32_t android._video-scaling = 1
I CCodec  :   int32_t sar-width = 1
I CCodec  :   int32_t color-standard = 4
I CCodec  :   int32_t color-range = 2
I CCodec  :   int32_t color-transfer = 3
I CCodec  :   int32_t android._dataspace = 259
I CCodec  :   int32_t width = 1080
I CCodec  :   int32_t rotation-degrees = 0
I CCodec  :   int32_t sar-height = 1
I CCodec  :   int32_t max-width = 320
I CCodec  :   int32_t max-height = 240
I CCodec  :   int32_t priority = 0
I CCodec  :   string mime = "video/raw"
I CCodec  :   Rect crop(0, 0, 318, 238)
I CCodec  :   Buffer hdr-static-info = {
I CCodec  :     00000000:  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
I CCodec  :     00000010:  00 00 00 00 00 00 00 00  00                       .........
I CCodec  :   }
I CCodec  :   int32_t frame-rate = 30
I CCodec  :   int32_t height = 2400
I CCodec  :   int3

另外通过日志可以发如果画面是静止的,就会出现如下打印,那应该也是说明静止画面下其实源端是没有数据传输过来的,所以源端没有保证输出帧率是60fps。

HiSight-M-DecoderFast: Notice : unable to dequeueOutputBuffer

抓空中包可以看到音频数据跟视频数据是两个socket在传输。如果是自己写demo玩,可以传裸流,如果是产品话还是应该进行加密。

多屏协同的延时在50ms左右,这个延时体验国内已经是业内标杆了。关于优化部分,从日志上看不出什么有用信息了,只能自己根据延时去拆了。有优化空间的模块:视频编码优化、策略发包、数据接收、rtcp策略、音视频渲染,都会有调优的空间,不过UIBC反控无感延迟,个人还是觉得比50ms延迟难的多。有空了自己写demo,在相同的手机平板上试试投屏延时能到多少。

这里很多逻辑都是根据日志推测的可能有很多是不准确的哈,有兴趣的自己拿设备深入分析哈。反正性能调优还是只能靠自己。