Skip to content

Commit 2ac6cbe

Browse files
author
archurtan
committed
使用iot-video平台接口拉取设备列表.
Change-Id: If1aafee7f25e71cf53970df96eca643ce72cb8c9
1 parent c80c1f4 commit 2ac6cbe

File tree

10 files changed

+48
-55
lines changed

10 files changed

+48
-55
lines changed

sdk/video-link-android/src/main/java/com/tencent/iot/video/link/service/VideoBaseService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,13 @@ open class VideoBaseService(secretId: String, secretKey: String) {
163163
* video获取设备信息列表 DescribeDevices
164164
*/
165165
fun describeDevices(
166-
productId: String, returnModel: Boolean, limit: Int, offset: Int, callback: VideoCallback
166+
productId: String, limit: Int, offset: Int, callback: VideoCallback
167167
) {
168168
var headerParams = videoCommonHeaderParams("DescribeDevices")
169169
val param = TreeMap<String, Any>()
170170
param["Limit"] = limit
171171
param["Offset"] = offset
172172
param["ProductId"] = productId
173-
param["ReturnModel"] = returnModel
174173
val authorization = sign(VideoHttpUtil.VIDEO_SERVICE, headerParams, param)
175174
if (authorization != null) {
176175
headerParams["Authorization"] = authorization
@@ -208,7 +207,7 @@ open class VideoBaseService(secretId: String, secretKey: String) {
208207
// param["X-TC-Version"] = "2019-11-26"
209208
// param["X-TC-Timestamp"] = (System.currentTimeMillis() / 1000).toString()
210209
// return param
211-
return videoCommonHeaderParams(action, "2019-11-26")
210+
return videoCommonHeaderParams(action, "2021-11-25")
212211
}
213212

214213
open fun sign(

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package com.tencent.iot.explorer.link.demo.video
22

33
class DevInfo {
4-
var deviceName = ""
4+
var DeviceName = ""
55
var Status = 0
66
var DevicePsk = ""
7-
var CreateTime = 0L
8-
var FirstOnlineTime = 0L
97
var LoginTime = 0L
8+
var ExpireTime = 0L
109
var LogLevel = 0
11-
var Version = ""
12-
var channel = 0
13-
var online = 0
14-
var address = ""
15-
var port = 0
10+
var Online = 0
11+
var EnableState =0
12+
var Channel = 0
13+
1614
set(value) {
1715
field = value
1816
Status = field

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class DevsAdapter(context: Context, list: MutableList<DevInfo>) : RecyclerView.A
6262
}
6363

6464
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
65-
holder.devName.setText(list.get(position)?.deviceName)
65+
holder.devName.setText(list.get(position)?.DeviceName)
6666

6767
videoProductInfo?.let {
6868
when(it.DeviceType ) {
@@ -83,7 +83,7 @@ class DevsAdapter(context: Context, list: MutableList<DevInfo>) : RecyclerView.A
8383
tipText?.setText(context?.getString(R.string.devs_checked, checkedIds?.size))
8484
}
8585

86-
if (list.get(position)?.Status == 1) {
86+
if (list.get(position)?.Online == 1) {
8787
holder.backgroundLayout.visibility = View.GONE
8888
holder.statusTv.setText(R.string.online)
8989
context?.let {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class VideoDeviceFragment : BaseFragment(), VideoCallback, DevsAdapter.OnItemCli
106106
for (i in 0 until it.list.size) {
107107
if (it.checkedIds.contains(i)) {
108108
var dev = DevUrl2Preview()
109-
dev.devName = it.list.get(i).deviceName
109+
dev.devName = it.list.get(i).DeviceName
110110
dev.Status = it.list.get(i).Status
111111
allUrl.add(dev)
112112
}
@@ -204,7 +204,7 @@ class VideoDeviceFragment : BaseFragment(), VideoCallback, DevsAdapter.OnItemCli
204204
videoProductInfo?.let {
205205
App.data.accessInfo?.let {
206206
devs.clear()
207-
VideoBaseService(it.accessId, it.accessToken).getDeviceList(it.productId, 0, 99, this)
207+
VideoBaseService(it.accessId, it.accessToken).describeDevices(it.productId, 99, 0, this)
208208
}
209209
}
210210
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
7777
App.data.accessInfo?.productId = product_id_layout.ev_content.text.toString()
7878

7979
var dev = DevInfo()
80-
dev.deviceName = datas.get(pos).deviceName
81-
dev.channel = 0
80+
dev.DeviceName = datas.get(pos).deviceName
81+
dev.Channel = 0
8282
dev.Status = 1
83-
dev.address = datas.get(pos).address
84-
dev.port = datas.get(pos).port
8583
WlanVideoPreviewActivity.startPreviewActivity(this@VideoWlanDetectActivity, dev)
8684
}
8785
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class VideoNvrActivity : VideoBaseActivity(), DevsAdapter.OnItemClicked, XP2PCal
7171

7272
var devInfo = JSON.parseObject(devInfoStr, DevInfo::class.java)
7373
devInfo?.let {
74-
tv_title.setText(it.deviceName)
75-
showDev(it.deviceName)
74+
tv_title.setText(it.DeviceName)
75+
showDev(it.DeviceName)
7676
}
7777
}
7878
}
@@ -106,8 +106,8 @@ class VideoNvrActivity : VideoBaseActivity(), DevsAdapter.OnItemClicked, XP2PCal
106106
var dev = DevUrl2Preview()
107107
dev.devName = tv_title.text.toString()
108108
dev.Status = it.list.get(i).Status
109-
dev.channel = it.list.get(i).channel
110-
dev.channel2DevName = it.list.get(i).deviceName
109+
dev.channel = it.list.get(i).Channel
110+
dev.channel2DevName = it.list.get(i).DeviceName
111111
allUrl.add(dev)
112112
}
113113
}
@@ -193,9 +193,9 @@ class VideoNvrActivity : VideoBaseActivity(), DevsAdapter.OnItemClicked, XP2PCal
193193

194194
override fun onItemClicked(pos: Int, dev: DevInfo) {
195195
var devInfo = DevInfo()
196-
devInfo.deviceName = tv_title.text.toString()
197-
devInfo.online = dev.online
198-
devInfo.channel = dev.channel
196+
devInfo.DeviceName = tv_title.text.toString()
197+
devInfo.Online = dev.Online
198+
devInfo.Channel = dev.Channel
199199
var options = arrayListOf(getString(R.string.preview))
200200
var dlg =
201201
ListOptionsDialog(

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/playback/cloudPlayback/VideoCloudPlaybackFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class VideoCloudPlaybackFragment: VideoPlaybackBaseFragment(), TextureView.Surfa
100100
presenter.setAccessId(it.accessId)
101101
presenter.setAccessToken(it.accessToken)
102102
presenter.setProductId(it.productId)
103-
presenter.setDeviceName(devInfo!!.deviceName)
103+
presenter.setDeviceName(devInfo!!.DeviceName)
104104
try2GetRecord(Date())
105105
}
106106
palayback_video.surfaceTextureListener = this
@@ -118,7 +118,7 @@ class VideoCloudPlaybackFragment: VideoPlaybackBaseFragment(), TextureView.Surfa
118118
private fun try2GetVideoDateData() {
119119
App.data.accessInfo?.let { accessInfo ->
120120
devInfo?.let {
121-
VideoBaseService(accessInfo.accessId, accessInfo.accessToken).getIPCDateData(accessInfo.productId, it.deviceName, this)
121+
VideoBaseService(accessInfo.accessId, accessInfo.accessToken).getIPCDateData(accessInfo.productId, it.DeviceName, this)
122122
}
123123
}
124124
}
@@ -129,7 +129,7 @@ class VideoCloudPlaybackFragment: VideoPlaybackBaseFragment(), TextureView.Surfa
129129

130130
App.data.accessInfo?.let {
131131
if (devInfo == null) return@let
132-
VideoBaseService(it.accessId, it.accessToken).getIPCTimeData(it.productId, devInfo!!.deviceName, timeStr!!, this)
132+
VideoBaseService(it.accessId, it.accessToken).getIPCTimeData(it.productId, devInfo!!.DeviceName, timeStr!!, this)
133133
}
134134
}
135135

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/playback/localPlayback/VideoLocalPlaybackFragment.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
162162
devInfo ?: let { return@setOnClickListener }
163163
if (TextUtils.isEmpty(tv_all_time.text.toString())) return@setOnClickListener
164164

165-
var id = "${App.data.accessInfo?.productId}/${devInfo?.deviceName}"
165+
var id = "${App.data.accessInfo?.productId}/${devInfo?.DeviceName}"
166166
Log.d(TAG, "setOnClickListener currentPlayerState $currentPlayerState")
167167

168168
if (currentPlayerState) {
169169
launch(Dispatchers.IO) {
170-
var stopCommand = Command.pauseLocalVideoUrl(devInfo!!.channel)
170+
var stopCommand = Command.pauseLocalVideoUrl(devInfo!!.Channel)
171171
var resp = sendCmd(id, stopCommand)
172172
var commandResp = JSONObject.parseObject(resp, CommandResp::class.java)
173173
if (commandResp != null && commandResp.status == 0) {
@@ -183,7 +183,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
183183

184184
} else {
185185
launch(Dispatchers.IO) {
186-
var startCommand = Command.resumeLocalVideoUrl(devInfo!!.channel)
186+
var startCommand = Command.resumeLocalVideoUrl(devInfo!!.Channel)
187187
var resp = sendCmd(id, startCommand)
188188
var commandResp = JSONObject.parseObject(resp, CommandResp::class.java)
189189
if (commandResp != null && commandResp.status == 0) {
@@ -392,7 +392,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
392392
val offset = initDownload(playbacks[pos])
393393
if (offset >= 0) {
394394
XP2P.startAvRecvService(
395-
"${App.data.accessInfo!!.productId}/${devInfo?.deviceName}",
395+
"${App.data.accessInfo!!.productId}/${devInfo?.DeviceName}",
396396
"action=download&channel=0&file_name=${playbacks[pos].file_name}&offset=${offset}",
397397
false
398398
)
@@ -473,24 +473,24 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
473473

474474
private fun requestTagDateInfo(dateStr: String): String {
475475
if (App.data.accessInfo == null || devInfo == null ||
476-
TextUtils.isEmpty(devInfo?.deviceName)
476+
TextUtils.isEmpty(devInfo?.DeviceName)
477477
) return ""
478478

479-
var id = "${App.data.accessInfo?.productId}/${devInfo?.deviceName}"
479+
var id = "${App.data.accessInfo?.productId}/${devInfo?.DeviceName}"
480480
var timeStr = formateDateParam(dateStr)
481481
Log.d(TAG, "request timeStr $timeStr")
482-
var command = Command.getMonthDates(devInfo!!.channel, timeStr)
482+
var command = Command.getMonthDates(devInfo!!.Channel, timeStr)
483483
if (TextUtils.isEmpty(command)) return ""
484484
return sendCmd(id, command)
485485
}
486486

487487
private fun refreshDateTime(date: Date) {
488488
if (App.data.accessInfo == null || devInfo == null ||
489-
TextUtils.isEmpty(devInfo?.deviceName)
489+
TextUtils.isEmpty(devInfo?.DeviceName)
490490
) return
491491

492-
var id = "${App.data.accessInfo?.productId}/${devInfo?.deviceName}"
493-
var command = Command.getDayTimeBlocks(devInfo!!.channel, date)
492+
var id = "${App.data.accessInfo?.productId}/${devInfo?.DeviceName}"
493+
var command = Command.getDayTimeBlocks(devInfo!!.Channel, date)
494494
var resp = sendCmd(id, command)
495495

496496
if (TextUtils.isEmpty(resp)) return
@@ -517,7 +517,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
517517
delay(1000)
518518
if (!isShowing) currentPlayerState = false
519519
Log.d(TAG, "playVideo currentPlayerState $currentPlayerState")
520-
setPlayerUrl(Command.getLocalVideoUrl(it.channel, startTime, endTime), offset)
520+
setPlayerUrl(Command.getLocalVideoUrl(it.Channel, startTime, endTime), offset)
521521
tv_all_time.text = CommonUtils.formatTime(endTime * 1000 - startTime * 1000)
522522
video_seekbar.max = (endTime - startTime).toInt()
523523
}
@@ -566,8 +566,8 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
566566

567567
if (offset > 0) {
568568
devInfo?.let { dev ->
569-
var seekCommand = Command.seekLocalVideo(dev.channel, offset)
570-
var id = "${App.data.accessInfo?.productId}/${dev.deviceName}"
569+
var seekCommand = Command.seekLocalVideo(dev.Channel, offset)
570+
var id = "${App.data.accessInfo?.productId}/${dev.DeviceName}"
571571

572572
var seekResp = sendCmd(id, seekCommand)
573573
var commandResp = JSON.parseObject(seekResp, CommandResp::class.java)
@@ -605,14 +605,14 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
605605

606606
private fun startConnect() {
607607
if (App.data.accessInfo == null || devInfo == null ||
608-
TextUtils.isEmpty(devInfo?.deviceName)
608+
TextUtils.isEmpty(devInfo?.DeviceName)
609609
) return
610610

611611
Thread(Runnable {
612-
var id = "${App.data.accessInfo?.productId}/${devInfo?.deviceName}"
612+
var id = "${App.data.accessInfo?.productId}/${devInfo?.DeviceName}"
613613
var started = XP2P.startServiceWithXp2pInfo(
614614
id,
615-
App.data.accessInfo?.productId, devInfo?.deviceName, ""
615+
App.data.accessInfo?.productId, devInfo?.DeviceName, ""
616616
)
617617
if (started != 0) {
618618
launch(Dispatchers.Main) {
@@ -627,7 +627,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
627627
// countDownLatchs.put("${App.data.accessInfo!!.productId}/${it.deviceName}", tmpCountDownLatch)
628628
// tmpCountDownLatch.await()
629629
urlPrefix =
630-
XP2P.delegateHttpFlv("${App.data.accessInfo!!.productId}/${it.deviceName}")
630+
XP2P.delegateHttpFlv("${App.data.accessInfo!!.productId}/${it.DeviceName}")
631631

632632
// 启动成功后,开始开启守护线程
633633
// keepConnect(id)
@@ -657,7 +657,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
657657
while (XP2P.startServiceWithXp2pInfo(
658658
id,
659659
App.data.accessInfo!!.productId,
660-
devInfo?.deviceName,
660+
devInfo?.DeviceName,
661661
""
662662
) != 0
663663
) {
@@ -827,7 +827,7 @@ class VideoLocalPlaybackFragment : VideoPlaybackBaseFragment(), TextureView.Surf
827827

828828
App.data.accessInfo?.let { access ->
829829
devInfo?.let {
830-
XP2P.stopService("${access.productId}/${it.deviceName}")
830+
XP2P.stopService("${access.productId}/${it.DeviceName}")
831831
}
832832
}
833833
XP2P.setCallback(null)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface
309309
}
310310
radio_playback.setOnClickListener {
311311
var dev = DevInfo()
312-
dev.deviceName = presenter.getDeviceName()
312+
dev.DeviceName = presenter.getDeviceName()
313313
VideoPlaybackActivity.startPlaybackActivity(this@VideoPreviewActivity, dev)
314314
}
315315
radio_photo.setOnClickListener {
@@ -611,9 +611,9 @@ class VideoPreviewActivity : VideoBaseActivity(), EventView, TextureView.Surface
611611
var bundle = Bundle()
612612
intent.putExtra(VideoConst.VIDEO_CONFIG, bundle)
613613
var devInfo = DevUrl2Preview()
614-
devInfo.devName = dev.deviceName
614+
devInfo.devName = dev.DeviceName
615615
devInfo.Status = dev.Status
616-
devInfo.channel = dev.channel
616+
devInfo.channel = dev.Channel
617617
bundle.putString(VideoConst.VIDEO_CONFIG, JSON.toJSONString(devInfo))
618618
context.startActivity(intent)
619619
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,9 @@ class WlanVideoPreviewActivity : VideoBaseActivity(), TextureView.SurfaceTexture
372372
var bundle = Bundle()
373373
intent.putExtra(VideoConst.VIDEO_CONFIG, bundle)
374374
var devInfo = DevUrl2Preview()
375-
devInfo.devName = dev.deviceName
375+
devInfo.devName = dev.DeviceName
376376
devInfo.Status = dev.Status
377-
devInfo.channel = dev.channel
378-
devInfo.address = dev.address
379-
devInfo.port = dev.port
377+
devInfo.channel = dev.Channel
380378
bundle.putString(VideoConst.VIDEO_CONFIG, JSON.toJSONString(devInfo))
381379
context.startActivity(intent)
382380
}

0 commit comments

Comments
 (0)