@@ -88,7 +88,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
8888 BuildConfig .TencentIotLinkSDKDemoAppSecret // 为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
8989 appConfig.userId =
9090 " " // 用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
91- appConfig.autoConfigFromDevice = true
91+ appConfig.autoConfigFromDevice = false
9292 appConfig.type = XP2PProtocolType .XP2P_PROTOCOL_AUTO
9393 appConfig.crossStunTurn = false
9494 }
@@ -110,7 +110,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
110110 )
111111 XP2P .setCallback(this )
112112
113- tv_video_quality.text = " 高清 "
113+ tv_video_quality.text = " 标清 "
114114 v_preview.surfaceTextureListener = this
115115 val wm = this .getSystemService(WINDOW_SERVICE ) as WindowManager
116116 val dm = DisplayMetrics ()
@@ -120,6 +120,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
120120 val density = dm.density // 屏幕密度(0.75 / 1.0 / 1.5)
121121 screenWidth = (width / density).toInt() // 屏幕宽度(dp)
122122 screenHeight = (height / density).toInt() // 屏幕高度(dp)
123+ startService()
123124 }
124125
125126 private fun startService () {
@@ -137,6 +138,28 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
137138 XP2P .stopService(id)
138139 }
139140
141+ private fun checkDeviceState () {
142+ Log .d(" VideoTestActivity" , " ====检测设备状态===" )
143+ launch(Dispatchers .IO ) {
144+ val command = " action=user_define&channel=0&cmd=device_state"
145+ val retContent = XP2P .postCommandRequestSync(
146+ " ${productId} /${deviceName} " ,
147+ command.toByteArray(), command.toByteArray().size.toLong(), 1 * 1000 * 1000
148+ ) ? : " "
149+ Log .d(" VideoTestActivity" , " device_state back content:$retContent " )
150+
151+ // if (retContent.isEmpty()) {
152+ // launch(Dispatchers.Main) {
153+ // restartService()
154+ // }
155+ // } else {
156+ launch(Dispatchers .Main ) {
157+ delegateHttpFlv()
158+ }
159+ // }
160+ }
161+ }
162+
140163 private fun delegateHttpFlv () {
141164 val id = " ${productId} /${deviceName} "
142165// XP2P.recordstreamPath("/storage/emulated/0/data_video.flv") //自定义采集裸流路径
@@ -307,7 +330,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
307330 it.setOption(
308331 IjkMediaPlayer .OPT_CATEGORY_PLAYER , " mediacodec-handle-resolution-change" , 1
309332 )
310-
333+ // it.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 50*1024)
311334 it.setFrameSpeed(1.5f )
312335 while (! ::surface.isInitialized) {
313336 delay(50 )
@@ -344,6 +367,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
344367 } else if (event == 1004 || event == 1005 ) {
345368 if (event == 1004 ) {
346369 Log .e(" VideoTestActivity" , " ====event === 1004" )
370+ // checkDeviceState()
347371 delegateHttpFlv()
348372 }
349373 }
0 commit comments