From 5635f0fcb29a64c753bb7c4e78234e57fedd7ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?whalensun=28=E5=AD=99=E4=BC=9F=29?= <532125505@qq.com> Date: Tue, 24 Oct 2023 16:53:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9xp2p=E7=89=88=E6=9C=AC2.4.40,?= =?UTF-8?q?=20startService=E6=B7=BB=E5=8A=A0=E8=B6=85=E6=97=B6tcp=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=97=B6=E9=97=B4=E5=8F=82=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6c39d4943f93718f818a9379f8482c89061a85ef --- sdk/video-link-android/build.gradle | 2 +- ...16\245\345\205\245\350\257\264\346\230\216.md" | 15 ++++++++------- ...16\245\345\217\243\350\257\264\346\230\216.md" | 5 +++-- .../link/demo/video/nvr/VideoNvrActivity.kt | 2 +- .../localPlayback/VideoLocalPlaybackFragment.kt | 4 ++-- .../video/preview/VideoMultiPreviewActivity.kt | 6 +++--- .../demo/video/preview/VideoPreviewActivity.kt | 4 ++-- .../video/preview/VideoPreviewMJPEGActivity.kt | 4 ++-- .../demo/video/preview/VideoPushStreamActivity.kt | 4 ++-- .../video/preview/VideoWithoutPropertyActivity.kt | 4 ++-- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/sdk/video-link-android/build.gradle b/sdk/video-link-android/build.gradle index 28f6cfaf4..82586d6f4 100644 --- a/sdk/video-link-android/build.gradle +++ b/sdk/video-link-android/build.gradle @@ -48,7 +48,7 @@ dependencies { // changing = true // } // api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.23' - api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.38' + api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.40' api 'com.tencent.iot.thirdparty.android:media-server:1.0.5' api 'io.github.sundoggynew:iot-soundtouch:1.0.0' api 'io.github.sundoggynew:iot-voice-changer:1.0.0' diff --git "a/sdk/video-link-android/doc/VideoSDK\346\216\245\345\205\245\350\257\264\346\230\216.md" "b/sdk/video-link-android/doc/VideoSDK\346\216\245\345\205\245\350\257\264\346\230\216.md" index bd909b2fa..3e2d69378 100644 --- "a/sdk/video-link-android/doc/VideoSDK\346\216\245\345\205\245\350\257\264\346\230\216.md" +++ "b/sdk/video-link-android/doc/VideoSDK\346\216\245\345\205\245\350\257\264\346\230\216.md" @@ -211,7 +211,7 @@ setUserCallbackToXp2p(_av_data_recv, _msg_notify); * 接口描述: 初始化xp2p服务。 ``` -int startServiceWithXp2pInfo(const char* id, const char *product_id, const char *device_name, const char* xp2p_info); +int startServiceWithXp2pInfo(const char* id, const char *product_id, const char *device_name, const char* xp2p_info, int sensor_timeout); ``` | 参数 | 类型 | 描述 | 输入/输出 | @@ -233,7 +233,7 @@ const char* xp2p_info = getXP2PInfo(...); /* 设置回调函数 */ setUserCallbackToXp2p(_av_data_recv, _msg_notify); /* 初始化p2p */ -startServiceWithXp2pInfo($id, $product_id, $device_name, xp2p_info); +startServiceWithXp2pInfo($id, $product_id, $device_name, xp2p_info, sensor_timeout); ``` ##### 2.1.3 P2P通道传输音视频裸流 @@ -562,7 +562,7 @@ void sample() { int ret = 0; START: - ret = startServiceWithXp2pInfo($id, $product_id, $device_name, $xp2p_info); + ret = startServiceWithXp2pInfo($id, $product_id, $device_name, $xp2p_info $sensor_timeout); if (ret < 0>) { printf("p2p start error\n"); return; @@ -617,7 +617,7 @@ void sample() { int ret = 0; START: - ret = startServiceWithXp2pInfo($id, $product_id, $device_name, $xp2p_info); + ret = startServiceWithXp2pInfo($id, $product_id, $device_name, $xp2p_info, $sensor_timeout); if (ret < 0>) { printf("p2p start error\n"); return; @@ -774,7 +774,7 @@ class VideoActivity : XP2PCallback { * 接口描述: 初始化xp2p服务。 ``` -public static void startServiceWithXp2pInfo(String id, String product_id, String device_name, String xp2p_info) +public static void startServiceWithXp2pInfo(String id, String product_id, String device_name, String xp2p_info, int sensor_timeout) ``` | 参数 | 类型 | 描述 | 输入/输出 | @@ -783,6 +783,7 @@ public static void startServiceWithXp2pInfo(String id, String product_id, String | product_id | String | 目标camera产品信息 | 输入 | | device_name | String | 目标camera设备名称 | 输入 | | xp2p_info | String | xp2p信息 | 输入 | +| sensor_timeout | int | 超时tcp切换时间 | 输入 | | 返回值 | 描述 | |:-|:-| @@ -795,7 +796,7 @@ String xp2p_info = getXP2PInfo(...) /* 设置回调 */ XP2P.setCallback(this) /* 初始化p2p */ -XP2P.startServiceWithXp2pInfo($id, $product_id, $device_name, xp2p_info) +XP2P.startServiceWithXp2pInfo($id, $product_id, $device_name, xp2p_info, sensor_timeout) ``` ##### 2.2.3 P2P通道传输音视频裸流 @@ -1032,5 +1033,5 @@ override fun onDestroy() { String xp2p_info = getXP2PInfo(...) // 从自建后台获取xp2p info XP2P.setCallback(this) -XP2P.startServiceWithXp2pInfo(id, product_id, device_name, xp2p_info) +XP2P.startServiceWithXp2pInfo(id, product_id, device_name, xp2p_info, sensor_timeout) ``` diff --git "a/sdk/video-link-android/doc/VideoSDK\346\216\245\345\217\243\350\257\264\346\230\216.md" "b/sdk/video-link-android/doc/VideoSDK\346\216\245\345\217\243\350\257\264\346\230\216.md" index 31416d2f3..0a50b61f6 100644 --- "a/sdk/video-link-android/doc/VideoSDK\346\216\245\345\217\243\350\257\264\346\230\216.md" +++ "b/sdk/video-link-android/doc/VideoSDK\346\216\245\345\217\243\350\257\264\346\230\216.md" @@ -4,13 +4,14 @@ ### 接口说明 1. 初始化xp2p服务接口 -> int startService(String id, String product_id, String device_name) +> int startService(String id, String product_id, String device_name, int sensor_timeout) | 参数 | 类型 | 描述 | |:-|:-|:-| | id | String | 目标camera在app端的唯一标识符,可以使用产品信息和设备名称组合,如:"$product/$device_name" | | product_id | String | 产品ID | | device_name | String | 设备名称 | +| sensor_timeout | int | 超时tcp切换时间 | | 返回值 | 描述 | |:-|:-| @@ -342,6 +343,6 @@ DeviceServerInfo 定义如下 ... String xp2p_info = getXP2PInfo(...) // 从自建后台获取xp2p info XP2P.setCallback(this) -XP2P.startService(id, product_id, device_name) +XP2P.startService(id, product_id, device_name, sensor_timeout) XP2P.setParamsForXp2pInfo(deviceId, "", "", xp2pInfo) ``` \ No newline at end of file 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 ff711ac21..e50b8b818 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 @@ -88,7 +88,7 @@ class VideoNvrActivity : VideoBaseActivity(), DevsAdapter.OnItemClicked, XP2PCal App.data.accessInfo?.let { countDownLatch = CountDownLatch(1) var started = XP2P.startServiceWithXp2pInfo("${it.productId}/${devName}", - it.productId, devName, "") + it.productId, devName, "", 5) 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 2033bca1d..052e858b5 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 @@ -612,7 +612,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf var id = "${App.data.accessInfo?.productId}/${devInfo?.DeviceName}" var started = XP2P.startServiceWithXp2pInfo( id, - App.data.accessInfo?.productId, devInfo?.DeviceName, "" + App.data.accessInfo?.productId, devInfo?.DeviceName, "",5 ) if (started != 0) { launch(Dispatchers.Main) { @@ -658,7 +658,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf 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 e00db22a8..bd382be2b 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 @@ -113,7 +113,7 @@ class VideoMultiPreviewActivity : VideoBaseActivity(), XP2PCallback, CoroutineSc Thread(Runnable { var id = "${App.data.accessInfo!!.productId}/${devName}" var started = XP2P.startServiceWithXp2pInfo(id, - App.data.accessInfo!!.productId, devName, "") + App.data.accessInfo!!.productId, devName, "", 5) // 已经启动过,或者第一次启动,继续进行 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, "") + var flag = XP2P.startServiceWithXp2pInfo(id, App.data.accessInfo!!.productId, playerHolder.devName, "", 5) while (flag != 0 && flag != -1011) { // XP2P.stopService(id) synchronized(objectLock) { objectLock.wait(1000) } - flag = XP2P.startServiceWithXp2pInfo(id, App.data.accessInfo!!.productId, playerHolder.devName, "") + flag = XP2P.startServiceWithXp2pInfo(id, App.data.accessInfo!!.productId, playerHolder.devName, "", 5) } 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 bef1ee344..24b830e64 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 @@ -145,7 +145,7 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface XP2P.setCallback(this) XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName() + App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 ) //实例化对象并设置监听器 @@ -215,7 +215,7 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface // 发现断开尝试恢复视频,每隔一秒尝试一次 Log.d(tag, "====开始尝试重连...") XP2P.stopService(id) - while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName())!=0 + while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=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 91b1ee1c3..545bab191 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 @@ -143,7 +143,7 @@ class VideoPreviewMJPEGActivity : VideoBaseActivity(), EventView, TextureView.Su XP2P.setCallback(this) XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName() + App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 ) //实例化对象并设置监听器 @@ -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())!=0 + while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=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 12b30ec9b..4daff3da5 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 @@ -128,7 +128,7 @@ class VideoPushStreamActivity : VideoBaseActivity(), EventView, TextureView.Surf XP2P.setCallback(this) XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName() + App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 ) 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())!=0 + while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=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 ca1e2176c..c7bc99a36 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 @@ -152,7 +152,7 @@ class VideoWithoutPropertyActivity : VideoBaseActivity(), EventView, TextureView XP2P.setCallback(this) XP2P.startService("${App.data.accessInfo!!.productId}/${presenter.getDeviceName()}", - App.data.accessInfo!!.productId, presenter.getDeviceName() + App.data.accessInfo!!.productId, presenter.getDeviceName(), 5 ) 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())!=0 + while (XP2P.startService(id, App.data.accessInfo!!.productId, presenter.getDeviceName(), 5)!=0 || XP2P.setParamsForXp2pInfo(id, accessId, accessToken, "") != 0 || getDeviceStatus(id) != 0) { XP2P.stopService(id)