Skip to content

Commit 990949e

Browse files
committed
增加设备直连入口、更新xp2p snapshot版本
1 parent bbac993 commit 990949e

File tree

12 files changed

+45
-76
lines changed

12 files changed

+45
-76
lines changed

sdk/video-link-android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies {
4949
// api('com.tencent.iot.thirdparty.android:xp2p-sdk:latest.integration') {
5050
// changing = true
5151
// }
52-
api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.53'
52+
api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.54-SNAPSHOT'
5353
api 'com.tencent.iot.thirdparty.android:media-server:1.0.7'
5454
api 'io.github.sundoggynew:iot-soundtouch:1.0.0'
5555
api 'io.github.sundoggynew:iot-voice-changer:1.0.0'
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.tencent.iot.explorer.link.demo.video
22

33
import com.tencent.iot.explorer.link.demo.R
4-
import com.tencent.iot.explorer.link.demo.BaseActivity
54
import com.tencent.iot.explorer.link.demo.VideoBaseActivity
6-
import com.tencent.iot.explorer.link.demo.video.preview.VideoTestActivity
7-
import kotlinx.android.synthetic.main.activity_video_options.*
5+
import kotlinx.android.synthetic.main.activity_video_options.btn_video
6+
import kotlinx.android.synthetic.main.activity_video_options.btn_video_link
7+
import kotlinx.android.synthetic.main.activity_video_options.btn_video_wlan
88

99
class VideoOptionsActivity : VideoBaseActivity() {
1010
override fun getContentView(): Int {
@@ -15,8 +15,8 @@ class VideoOptionsActivity : VideoBaseActivity() {
1515

1616
override fun setListener() {
1717
btn_video.setOnClickListener { jumpActivity(VideoInputAuthorizeActivity::class.java) }
18-
// btn_video_wlan.setOnClickListener { jumpActivity(VideoWlanDetectActivity::class.java) }
19-
btn_video_test.setOnClickListener { jumpActivity(VideoTestInputActivity::class.java) }
18+
btn_video_wlan.setOnClickListener { jumpActivity(VideoWlanDetectActivity::class.java) }
19+
btn_video_link.setOnClickListener { jumpActivity(VideoTestInputActivity::class.java) }
2020
}
2121

2222
}

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/VideoWlanDetectActivity.kt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package com.tencent.iot.explorer.link.demo.video
22

33
import android.text.InputType
44
import android.text.TextUtils
5-
import android.util.Log
65
import android.view.View
76
import android.widget.Toast
8-
import androidx.recyclerview.widget.LinearLayoutManager
97
import com.alibaba.fastjson.JSONArray
108
import com.tencent.iot.explorer.link.core.utils.SharePreferenceUtil
119
import com.tencent.iot.explorer.link.demo.App
@@ -25,7 +23,6 @@ import kotlinx.android.synthetic.main.fragment_video_device.*
2523
import kotlinx.android.synthetic.main.input_item_layout.view.*
2624
import kotlinx.coroutines.*
2725
import java.util.*
28-
import kotlin.collections.ArrayList
2926

3027
class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScope() {
3128

@@ -50,23 +47,21 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
5047
client_token_layout.iv_more.visibility = View.GONE
5148

5249
launch (Dispatchers.Main) {
53-
var jsonArrStr = SharePreferenceUtil.getString(this@VideoWlanDetectActivity, VideoConst.VIDEO_WLAN_CONFIG, VideoConst.VIDEO_ACCESS_INFOS)
50+
val jsonArrStr = SharePreferenceUtil.getString(this@VideoWlanDetectActivity, VideoConst.VIDEO_WLAN_CONFIG, VideoConst.VIDEO_ACCESS_INFOS)
5451
jsonArrStr?.let {
55-
var accessInfos = JSONArray.parseArray(jsonArrStr, AccessInfo::class.java)
52+
val accessInfos = JSONArray.parseArray(jsonArrStr, AccessInfo::class.java)
5653
accessInfos?.let {
5754
if (accessInfos.size > 0) {
58-
var accessInfo = accessInfos.get(accessInfos.size - 1)
55+
val accessInfo = accessInfos.get(accessInfos.size - 1)
5956
client_token_layout.ev_content.setText(accessInfo.accessToken)
6057
product_id_layout.ev_content.setText(accessInfo.productId)
6158
}
6259
}
6360
}
6461
}
6562

66-
var layoutManager = LinearLayoutManager(this@VideoWlanDetectActivity)
6763
adapter = WlanDevsAdapter(this@VideoWlanDetectActivity, datas)
68-
devs_lv.setLayoutManager(layoutManager)
69-
devs_lv.setAdapter(adapter)
64+
devs_lv.adapter = adapter
7065
adapter?.setOnItemClicked(onItemClicked)
7166
}
7267

@@ -97,7 +92,7 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
9792
super.onPause()
9893
}
9994

100-
var searchClickedListener = object : View.OnClickListener {
95+
private var searchClickedListener = object : View.OnClickListener {
10196
override fun onClick(v: View?) {
10297
if (TextUtils.isEmpty(product_id_layout.ev_content.text)) {
10398
Toast.makeText(this@VideoWlanDetectActivity, R.string.hint_product_id, Toast.LENGTH_SHORT).show()
@@ -109,7 +104,7 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
109104
return
110105
}
111106

112-
var accessInfo = AccessInfo()
107+
val accessInfo = AccessInfo()
113108
accessInfo.accessToken = client_token_layout.ev_content.text.toString()
114109
accessInfo.productId = product_id_layout.ev_content.text.toString()
115110

@@ -118,7 +113,7 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
118113
}
119114

120115
datas.clear()
121-
var detectBody = WlanDetectBody()
116+
val detectBody = WlanDetectBody()
122117
detectBody.productId = accessInfo.productId
123118
detectBody.clientToken = accessInfo.accessToken
124119
}
@@ -137,7 +132,7 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
137132
}
138133

139134
private fun checkAccessInfo(accessInfo: AccessInfo) {
140-
var accessInfos: MutableList<AccessInfo> = ArrayList()
135+
val accessInfos: MutableList<AccessInfo> = ArrayList()
141136
accessInfos.add(accessInfo)
142137
SharePreferenceUtil.saveString(this@VideoWlanDetectActivity, VideoConst.VIDEO_WLAN_CONFIG, VideoConst.VIDEO_ACCESS_INFOS, JSONArray.toJSONString(accessInfos))
143138
}

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ class VideoPreviewActivity : VideoPreviewBaseActivity(), EventView,
133133
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
134134
appConfig.appSecret =
135135
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
136-
appConfig.userId =
137-
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;查找日志是需提供此userid字段
138136
appConfig.autoConfigFromDevice = false //是否启动跟随配置,需要控制台配置
139137
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
140138
}

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPreviewMJPEGActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ class VideoPreviewMJPEGActivity : VideoPreviewBaseActivity(), EventView,
105105
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
106106
appConfig.appSecret =
107107
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
108-
appConfig.userId =
109-
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
110108
appConfig.autoConfigFromDevice = true
111109
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
112110
appConfig.crossStunTurn = false

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoPushStreamActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ class VideoPushStreamActivity : VideoPreviewBaseActivity(), EventView,
104104
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
105105
appConfig.appSecret =
106106
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
107-
appConfig.userId =
108-
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
109107
appConfig.autoConfigFromDevice = true
110108
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
111109
appConfig.crossStunTurn = false

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoTestActivity.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,18 @@ import tv.danmaku.ijk.media.player.IjkMediaPlayer
6868
import java.lang.ref.WeakReference
6969
import java.util.Locale
7070

71-
open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope by MainScope(),
72-
TextureView.SurfaceTextureListener,
73-
IMediaPlayer.OnInfoListener {
71+
class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope by MainScope(),
72+
TextureView.SurfaceTextureListener, IMediaPlayer.OnInfoListener {
73+
7474
private val player = IjkMediaPlayer()
7575
lateinit var surface: Surface
7676
private var productId: String = ""
7777
private var deviceName: String = ""
7878
private var xp2pInfo: String = ""
7979
private val channel: Int = 0
8080
private var urlPrefix = ""
81+
private var audioRecordUtil: AudioRecordUtil? = null
82+
8183
private var screenWidth = 0
8284
private var screenHeight = 0
8385
private var startShowVideoTime = 0L
@@ -88,9 +90,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
8890
private val MSG_UPDATE_HUD = 1
8991
private var permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
9092
private var filePath: String? = null
91-
private var audioRecordUtil: AudioRecordUtil? = null
9293

93-
@Volatile
9494
private var speakAble = false
9595
private var audioAble = true
9696
private var orientationV = true
@@ -100,8 +100,6 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
100100
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
101101
appConfig.appSecret =
102102
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
103-
appConfig.userId =
104-
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
105103
appConfig.autoConfigFromDevice = false
106104
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
107105
appConfig.crossStunTurn = false
@@ -220,7 +218,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
220218
radio_record.setOnCheckedChangeListener { buttonView, isChecked ->
221219
if (isChecked) {
222220
filePath = CommonUtils.generateFileDefaultPath()
223-
var ret = player.startRecord(filePath)
221+
val ret = player.startRecord(filePath)
224222
if (ret != 0) {
225223
ToastDialog(
226224
this,

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/WlanVideoPreviewActivity.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//import java.util.*
4242
//
4343
//
44-
//class WlanVideoPreviewActivity : VideoPreviewBaseActivity(), TextureView.SurfaceTextureListener,
44+
//class WlanVideoPreviewActivity : VideoBaseActivity(), TextureView.SurfaceTextureListener,
4545
// XP2PCallback, CoroutineScope by MainScope() {
4646
//
4747
// var tag = WlanVideoPreviewActivity::class.simpleName
@@ -71,9 +71,6 @@
7171
// var port = 0
7272
// var address = ""
7373
// var channel = 0
74-
// override fun updateXp2pInfo(xp2pInfo: String) {
75-
// TODO("Not yet implemented")
76-
// }
7774
//
7875
// override fun getContentView(): Int {
7976
// return R.layout.activity_video_preview
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
android:layout_width="match_parent"
45
android:layout_height="match_parent"
5-
android:background="@color/white"
6-
xmlns:app="http://schemas.android.com/apk/res-auto">
6+
android:background="@color/white">
77

88
<include
99
android:id="@+id/v_title"
@@ -12,50 +12,46 @@
1212
<View
1313
android:layout_width="match_parent"
1414
android:layout_height="1dp"
15-
app:layout_constraintTop_toBottomOf="@id/v_title"
1615
android:background="@color/black_1A000000"
17-
/>
16+
app:layout_constraintTop_toBottomOf="@id/v_title" />
1817

1918
<include
2019
android:id="@+id/product_id_layout"
2120
layout="@layout/input_item_layout"
2221
android:layout_width="match_parent"
2322
android:layout_height="56dp"
24-
app:layout_constraintTop_toBottomOf="@id/v_title"
25-
/>
23+
app:layout_constraintTop_toBottomOf="@id/v_title" />
2624

2725
<include
2826
android:id="@+id/client_token_layout"
2927
layout="@layout/input_item_layout"
3028
android:layout_width="match_parent"
3129
android:layout_height="56dp"
32-
app:layout_constraintTop_toBottomOf="@id/product_id_layout"
33-
/>
30+
app:layout_constraintTop_toBottomOf="@id/product_id_layout" />
3431

3532
<Button
3633
android:id="@+id/btn_detect"
3734
android:layout_width="match_parent"
3835
android:layout_height="45dp"
39-
app:layout_constraintStart_toStartOf="parent"
40-
app:layout_constraintEnd_toEndOf="parent"
41-
app:layout_constraintTop_toBottomOf="@id/client_token_layout"
4236
android:layout_marginStart="16dp"
43-
android:layout_marginEnd="16dp"
4437
android:layout_marginTop="30dp"
38+
android:layout_marginEnd="16dp"
39+
android:background="@drawable/background_blue_btn"
4540
android:text="@string/search_devs"
4641
android:textColor="@color/white"
4742
android:textSize="@dimen/ts_17"
48-
android:background="@drawable/background_blue_btn"
49-
/>
43+
app:layout_constraintEnd_toEndOf="parent"
44+
app:layout_constraintStart_toStartOf="parent"
45+
app:layout_constraintTop_toBottomOf="@id/client_token_layout" />
5046

5147
<androidx.recyclerview.widget.RecyclerView
5248
android:id="@+id/devs_lv"
5349
android:layout_width="match_parent"
5450
android:layout_height="0dp"
5551
android:layout_marginTop="30dp"
5652
android:layout_marginBottom="30dp"
57-
app:layout_constraintTop_toBottomOf="@id/btn_detect"
53+
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
5854
app:layout_constraintBottom_toBottomOf="parent"
59-
/>
55+
app:layout_constraintTop_toBottomOf="@id/btn_detect" />
6056

6157
</androidx.constraintlayout.widget.ConstraintLayout>

sdkdemo/src/main/res/layout/activity_video_options.xml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,6 @@
7474
app:layout_constraintBottom_toBottomOf="parent"
7575
app:layout_constraintTop_toTopOf="parent" />
7676

77-
<Button
78-
android:id="@+id/btn_video_pro"
79-
android:layout_width="match_parent"
80-
android:layout_height="45dp"
81-
android:layout_marginStart="30dp"
82-
android:layout_marginTop="20dp"
83-
android:layout_marginEnd="30dp"
84-
android:background="@drawable/background_blue_cell_btn"
85-
android:text="@string/video_pro"
86-
android:textAllCaps="false"
87-
android:textColor="@color/blue_0052D9"
88-
android:textSize="@dimen/ts_17"
89-
app:layout_constraintTop_toBottomOf="@id/btn_video" />
90-
9177
<Button
9278
android:id="@+id/btn_video_wlan"
9379
android:layout_width="match_parent"
@@ -100,17 +86,17 @@
10086
android:textAllCaps="false"
10187
android:textColor="@color/blue_0052D9"
10288
android:textSize="@dimen/ts_17"
103-
app:layout_constraintTop_toBottomOf="@id/btn_video_pro" />
89+
app:layout_constraintTop_toBottomOf="@id/btn_video" />
10490

10591
<Button
106-
android:id="@+id/btn_video_test"
92+
android:id="@+id/btn_video_link"
10793
android:layout_width="match_parent"
10894
android:layout_height="45dp"
10995
android:layout_marginStart="30dp"
11096
android:layout_marginTop="20dp"
11197
android:layout_marginEnd="30dp"
11298
android:background="@drawable/background_blue_cell_btn"
113-
android:text="@string/video_test"
99+
android:text="@string/video_link"
114100
android:textAllCaps="false"
115101
android:textColor="@color/blue_0052D9"
116102
android:textSize="@dimen/ts_17"

0 commit comments

Comments
 (0)