diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/nvr/VideoNvrActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/nvr/VideoNvrActivity.kt index e50b8b818..d47714b9e 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/nvr/VideoNvrActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/nvr/VideoNvrActivity.kt @@ -87,8 +87,8 @@ class VideoNvrActivity : VideoBaseActivity(), DevsAdapter.OnItemClicked, XP2PCal App.data.accessInfo?.let { countDownLatch = CountDownLatch(1) - var started = XP2P.startServiceWithXp2pInfo("${it.productId}/${devName}", - it.productId, devName, "", 5) + var started = XP2P.startServiceWithXp2pInfo(this@VideoNvrActivity, "${it.productId}/${devName}", + it.productId, devName, "") if (started != 0) return@launch countDownLatch.await(5, TimeUnit.SECONDS) diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/playback/localPlayback/VideoLocalPlaybackFragment.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/playback/localPlayback/VideoLocalPlaybackFragment.kt index 8b29d19d0..5011fb2e5 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/playback/localPlayback/VideoLocalPlaybackFragment.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/playback/localPlayback/VideoLocalPlaybackFragment.kt @@ -619,9 +619,9 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf Thread(Runnable { var id = "${App.data.accessInfo?.productId}/${devInfo?.DeviceName}" - var started = XP2P.startServiceWithXp2pInfo( + var started = XP2P.startServiceWithXp2pInfo(context, id, - App.data.accessInfo?.productId, devInfo?.DeviceName, "",5 + App.data.accessInfo?.productId, devInfo?.DeviceName, "" ) if (started != 0) { launch(Dispatchers.Main) { @@ -663,11 +663,11 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf // 发现断开尝试恢复视频,每隔一秒尝试一次 XP2P.stopService(id) - while (XP2P.startServiceWithXp2pInfo( + while (XP2P.startServiceWithXp2pInfo(context, id, App.data.accessInfo!!.productId, devInfo?.DeviceName, - "", 5 + "" ) != 0 ) { XP2P.stopService(id) diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoMultiPreviewActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoMultiPreviewActivity.kt index bd382be2b..48fd5e60d 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoMultiPreviewActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoMultiPreviewActivity.kt @@ -112,8 +112,8 @@ class VideoMultiPreviewActivity : VideoBaseActivity(), XP2PCallback, CoroutineSc private fun setPlayerSource(player: IjkMediaPlayer, devName: String, channel: Int) { Thread(Runnable { var id = "${App.data.accessInfo!!.productId}/${devName}" - var started = XP2P.startServiceWithXp2pInfo(id, - App.data.accessInfo!!.productId, devName, "", 5) + var started = XP2P.startServiceWithXp2pInfo(this@VideoMultiPreviewActivity, id, + App.data.accessInfo!!.productId, devName, "") // 已经启动过,或者第一次启动,继续进行 if (started != 0 && started != -1011) { launch(Dispatchers.Main) { @@ -281,13 +281,13 @@ class VideoMultiPreviewActivity : VideoBaseActivity(), XP2PCallback, CoroutineSc if (!playerHolder.keepAliveThreadRuning) break //锁被释放后,检查守护线程是否继续运行 // 发现断开尝试恢复视频,每隔一秒尝试一次 - var flag = XP2P.startServiceWithXp2pInfo(id, App.data.accessInfo!!.productId, playerHolder.devName, "", 5) + var flag = XP2P.startServiceWithXp2pInfo(this@VideoMultiPreviewActivity, id, App.data.accessInfo!!.productId, playerHolder.devName, "") while (flag != 0 && flag != -1011) { // XP2P.stopService(id) synchronized(objectLock) { objectLock.wait(1000) } - flag = XP2P.startServiceWithXp2pInfo(id, App.data.accessInfo!!.productId, playerHolder.devName, "", 5) + flag = XP2P.startServiceWithXp2pInfo(this@VideoMultiPreviewActivity, id, App.data.accessInfo!!.productId, playerHolder.devName, "") } Log.d(tag, "index=${id!!}/${channel} keepPlayerplay countDownLatch wait ") diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewActivity.kt index 29d157d12..509e74135 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewActivity.kt @@ -146,8 +146,8 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface } XP2P.setCallback(this) - XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 + XP2P.startService(this@VideoPreviewActivity, "${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", + App.data.accessInfo!!.productId, presenter.getDeviceName() ) //实例化对象并设置监听器 @@ -217,7 +217,7 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface // 发现断开尝试恢复视频,每隔一秒尝试一次 Log.d(tag, "====开始尝试重连...") XP2P.stopService(id) - while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=0 + while (XP2P.startService(this@VideoPreviewActivity, id, App.data.accessInfo!!.productId, presenter.getDeviceName())!=0 || XP2P.setParamsForXp2pInfo(id, accessId, accessToken, "") != 0 || getDeviceStatus(id) != 0) { XP2P.stopService(id) diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewMJPEGActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewMJPEGActivity.kt index 545bab191..0ee0e2afb 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewMJPEGActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewMJPEGActivity.kt @@ -142,8 +142,8 @@ class VideoPreviewMJPEGActivity : VideoBaseActivity(), EventView, TextureView.Su } XP2P.setCallback(this) - XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 + XP2P.startService(this@VideoPreviewMJPEGActivity, "${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", + App.data.accessInfo!!.productId, presenter.getDeviceName() ) //实例化对象并设置监听器 @@ -213,7 +213,7 @@ class VideoPreviewMJPEGActivity : VideoBaseActivity(), EventView, TextureView.Su // 发现断开尝试恢复视频,每隔一秒尝试一次 Log.d(tag, "====开始尝试重连...") XP2P.stopService(id) - while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=0 + while (XP2P.startService(this@VideoPreviewMJPEGActivity, id, App.data.accessInfo!!.productId, presenter.getDeviceName())!=0 || XP2P.setParamsForXp2pInfo(id, accessId, accessToken, "") != 0 || getDeviceStatus(id) != 0) { XP2P.stopService(id) diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPushStreamActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPushStreamActivity.kt index 4daff3da5..c19e03d58 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPushStreamActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPushStreamActivity.kt @@ -127,8 +127,8 @@ class VideoPushStreamActivity : VideoBaseActivity(), EventView, TextureView.Surf } XP2P.setCallback(this) - XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 + XP2P.startService(this@VideoPushStreamActivity, "${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", + App.data.accessInfo!!.productId, presenter.getDeviceName() ) holder = sv_camera_view.holder @@ -220,7 +220,7 @@ class VideoPushStreamActivity : VideoBaseActivity(), EventView, TextureView.Surf // 发现断开尝试恢复视频,每隔一秒尝试一次 Log.d(tag, "====开始尝试重连...") XP2P.stopService(id) - while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=0 + while (XP2P.startService(this@VideoPushStreamActivity, id, App.data.accessInfo!!.productId, presenter.getDeviceName())!=0 || XP2P.setParamsForXp2pInfo(id, accessId, accessToken, "") != 0 || getDeviceStatus(id) != 0) { XP2P.stopService(id) diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoWithoutPropertyActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoWithoutPropertyActivity.kt index c7bc99a36..a3d7a6ee2 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoWithoutPropertyActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoWithoutPropertyActivity.kt @@ -151,8 +151,8 @@ class VideoWithoutPropertyActivity : VideoBaseActivity(), EventView, TextureView } XP2P.setCallback(this) - XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 + XP2P.startService(this@VideoWithoutPropertyActivity, "${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", + App.data.accessInfo!!.productId, presenter.getDeviceName() ) val wm = this.getSystemService(WINDOW_SERVICE) as WindowManager @@ -257,7 +257,7 @@ class VideoWithoutPropertyActivity : VideoBaseActivity(), EventView, TextureView // 发现断开尝试恢复视频,每隔一秒尝试一次 Log.d(tag, "====开始尝试重连...") XP2P.stopService(id) - while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=0 + while (XP2P.startService(this@VideoWithoutPropertyActivity, id, App.data.accessInfo!!.productId, presenter.getDeviceName())!=0 || XP2P.setParamsForXp2pInfo(id, accessId, accessToken, "") != 0 || getDeviceStatus(id) != 0) { XP2P.stopService(id)