Skip to content

Commit

Permalink
修改xp2p版本2.4.40, startService添加超时tcp切换时间参数。
Browse files Browse the repository at this point in the history
Change-Id: I6c39d4943f93718f818a9379f8482c89061a85ef
  • Loading branch information
SundoggyNew committed Oct 24, 2023
1 parent 9f7f38b commit 5635f0f
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion sdk/video-link-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 8 additions & 7 deletions sdk/video-link-android/doc/VideoSDK接入说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

| 参数 | 类型 | 描述 | 输入/输出 |
Expand All @@ -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通道传输音视频裸流
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
```

| 参数 | 类型 | 描述 | 输入/输出 |
Expand All @@ -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切换时间 | 输入 |

| 返回值 | 描述 |
|:-|:-|
Expand All @@ -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通道传输音视频裸流
Expand Down Expand Up @@ -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)
```
5 changes: 3 additions & 2 deletions sdk/video-link-android/doc/VideoSDK接口说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -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切换时间 |

| 返回值 | 描述 |
|:-|:-|
Expand Down Expand Up @@ -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)
```
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -658,7 +658,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
id,
App.data.accessInfo!!.productId,
devInfo?.DeviceName,
""
"", 5
) != 0
) {
XP2P.stopService(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

//实例化对象并设置监听器
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

//实例化对象并设置监听器
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5635f0f

Please sign in to comment.