Skip to content

Commit

Permalink
增加设备直连入口、更新xp2p snapshot版本
Browse files Browse the repository at this point in the history
  • Loading branch information
neilyhe committed Feb 21, 2025
1 parent bbac993 commit 990949e
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 76 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 @@ -49,7 +49,7 @@ dependencies {
// api('com.tencent.iot.thirdparty.android:xp2p-sdk:latest.integration') {
// changing = true
// }
api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.53'
api 'com.tencent.iot.thirdparty.android:xp2p-sdk:2.4.54-SNAPSHOT'
api 'com.tencent.iot.thirdparty.android:media-server:1.0.7'
api 'io.github.sundoggynew:iot-soundtouch:1.0.0'
api 'io.github.sundoggynew:iot-voice-changer:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.tencent.iot.explorer.link.demo.video

import com.tencent.iot.explorer.link.demo.R
import com.tencent.iot.explorer.link.demo.BaseActivity
import com.tencent.iot.explorer.link.demo.VideoBaseActivity
import com.tencent.iot.explorer.link.demo.video.preview.VideoTestActivity
import kotlinx.android.synthetic.main.activity_video_options.*
import kotlinx.android.synthetic.main.activity_video_options.btn_video
import kotlinx.android.synthetic.main.activity_video_options.btn_video_link
import kotlinx.android.synthetic.main.activity_video_options.btn_video_wlan

class VideoOptionsActivity : VideoBaseActivity() {
override fun getContentView(): Int {
Expand All @@ -15,8 +15,8 @@ class VideoOptionsActivity : VideoBaseActivity() {

override fun setListener() {
btn_video.setOnClickListener { jumpActivity(VideoInputAuthorizeActivity::class.java) }
// btn_video_wlan.setOnClickListener { jumpActivity(VideoWlanDetectActivity::class.java) }
btn_video_test.setOnClickListener { jumpActivity(VideoTestInputActivity::class.java) }
btn_video_wlan.setOnClickListener { jumpActivity(VideoWlanDetectActivity::class.java) }
btn_video_link.setOnClickListener { jumpActivity(VideoTestInputActivity::class.java) }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.tencent.iot.explorer.link.demo.video

import android.text.InputType
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.fastjson.JSONArray
import com.tencent.iot.explorer.link.core.utils.SharePreferenceUtil
import com.tencent.iot.explorer.link.demo.App
Expand All @@ -25,7 +23,6 @@ import kotlinx.android.synthetic.main.fragment_video_device.*
import kotlinx.android.synthetic.main.input_item_layout.view.*
import kotlinx.coroutines.*
import java.util.*
import kotlin.collections.ArrayList

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

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

launch (Dispatchers.Main) {
var jsonArrStr = SharePreferenceUtil.getString(this@VideoWlanDetectActivity, VideoConst.VIDEO_WLAN_CONFIG, VideoConst.VIDEO_ACCESS_INFOS)
val jsonArrStr = SharePreferenceUtil.getString(this@VideoWlanDetectActivity, VideoConst.VIDEO_WLAN_CONFIG, VideoConst.VIDEO_ACCESS_INFOS)
jsonArrStr?.let {
var accessInfos = JSONArray.parseArray(jsonArrStr, AccessInfo::class.java)
val accessInfos = JSONArray.parseArray(jsonArrStr, AccessInfo::class.java)
accessInfos?.let {
if (accessInfos.size > 0) {
var accessInfo = accessInfos.get(accessInfos.size - 1)
val accessInfo = accessInfos.get(accessInfos.size - 1)
client_token_layout.ev_content.setText(accessInfo.accessToken)
product_id_layout.ev_content.setText(accessInfo.productId)
}
}
}
}

var layoutManager = LinearLayoutManager(this@VideoWlanDetectActivity)
adapter = WlanDevsAdapter(this@VideoWlanDetectActivity, datas)
devs_lv.setLayoutManager(layoutManager)
devs_lv.setAdapter(adapter)
devs_lv.adapter = adapter
adapter?.setOnItemClicked(onItemClicked)
}

Expand Down Expand Up @@ -97,7 +92,7 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
super.onPause()
}

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

var accessInfo = AccessInfo()
val accessInfo = AccessInfo()
accessInfo.accessToken = client_token_layout.ev_content.text.toString()
accessInfo.productId = product_id_layout.ev_content.text.toString()

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

datas.clear()
var detectBody = WlanDetectBody()
val detectBody = WlanDetectBody()
detectBody.productId = accessInfo.productId
detectBody.clientToken = accessInfo.accessToken
}
Expand All @@ -137,7 +132,7 @@ class VideoWlanDetectActivity : VideoBaseActivity() , CoroutineScope by MainScop
}

private fun checkAccessInfo(accessInfo: AccessInfo) {
var accessInfos: MutableList<AccessInfo> = ArrayList()
val accessInfos: MutableList<AccessInfo> = ArrayList()
accessInfos.add(accessInfo)
SharePreferenceUtil.saveString(this@VideoWlanDetectActivity, VideoConst.VIDEO_WLAN_CONFIG, VideoConst.VIDEO_ACCESS_INFOS, JSONArray.toJSONString(accessInfos))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ class VideoPreviewActivity : VideoPreviewBaseActivity(), EventView,
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.appSecret =
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.userId =
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;查找日志是需提供此userid字段
appConfig.autoConfigFromDevice = false //是否启动跟随配置,需要控制台配置
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ class VideoPreviewMJPEGActivity : VideoPreviewBaseActivity(), EventView,
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.appSecret =
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.userId =
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
appConfig.autoConfigFromDevice = true
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
appConfig.crossStunTurn = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ class VideoPushStreamActivity : VideoPreviewBaseActivity(), EventView,
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.appSecret =
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.userId =
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
appConfig.autoConfigFromDevice = true
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
appConfig.crossStunTurn = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ import tv.danmaku.ijk.media.player.IjkMediaPlayer
import java.lang.ref.WeakReference
import java.util.Locale

open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope by MainScope(),
TextureView.SurfaceTextureListener,
IMediaPlayer.OnInfoListener {
class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope by MainScope(),
TextureView.SurfaceTextureListener, IMediaPlayer.OnInfoListener {

private val player = IjkMediaPlayer()
lateinit var surface: Surface
private var productId: String = ""
private var deviceName: String = ""
private var xp2pInfo: String = ""
private val channel: Int = 0
private var urlPrefix = ""
private var audioRecordUtil: AudioRecordUtil? = null

private var screenWidth = 0
private var screenHeight = 0
private var startShowVideoTime = 0L
Expand All @@ -88,9 +90,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
private val MSG_UPDATE_HUD = 1
private var permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
private var filePath: String? = null
private var audioRecordUtil: AudioRecordUtil? = null

@Volatile
private var speakAble = false
private var audioAble = true
private var orientationV = true
Expand All @@ -100,8 +100,6 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
BuildConfig.TencentIotLinkSDKDemoAppkey //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.appSecret =
BuildConfig.TencentIotLinkSDKDemoAppSecret //为explorer平台注册的应用信息(https://console.cloud.tencent.com/iotexplorer/v2/instance/app/detai) explorer控制台- 应用开发 - 选对应的应用下的 appkey/appsecret
appConfig.userId =
"" //用户纬度(每个手机区分开)使用用户自有的账号系统userid;若无请配置为[TIoTCoreXP2PBridge sharedInstance].getAppUUID; 查找日志是需提供此userid字段
appConfig.autoConfigFromDevice = false
appConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
appConfig.crossStunTurn = false
Expand Down Expand Up @@ -220,7 +218,7 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
radio_record.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
filePath = CommonUtils.generateFileDefaultPath()
var ret = player.startRecord(filePath)
val ret = player.startRecord(filePath)
if (ret != 0) {
ToastDialog(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//import java.util.*
//
//
//class WlanVideoPreviewActivity : VideoPreviewBaseActivity(), TextureView.SurfaceTextureListener,
//class WlanVideoPreviewActivity : VideoBaseActivity(), TextureView.SurfaceTextureListener,
// XP2PCallback, CoroutineScope by MainScope() {
//
// var tag = WlanVideoPreviewActivity::class.simpleName
Expand Down Expand Up @@ -71,9 +71,6 @@
// var port = 0
// var address = ""
// var channel = 0
// override fun updateXp2pInfo(xp2pInfo: String) {
// TODO("Not yet implemented")
// }
//
// override fun getContentView(): Int {
// return R.layout.activity_video_preview
Expand Down
28 changes: 12 additions & 16 deletions sdkdemo/src/main/res/layout/activity_video_detect_devs.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:background="@color/white">

<include
android:id="@+id/v_title"
Expand All @@ -12,50 +12,46 @@
<View
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="@id/v_title"
android:background="@color/black_1A000000"
/>
app:layout_constraintTop_toBottomOf="@id/v_title" />

<include
android:id="@+id/product_id_layout"
layout="@layout/input_item_layout"
android:layout_width="match_parent"
android:layout_height="56dp"
app:layout_constraintTop_toBottomOf="@id/v_title"
/>
app:layout_constraintTop_toBottomOf="@id/v_title" />

<include
android:id="@+id/client_token_layout"
layout="@layout/input_item_layout"
android:layout_width="match_parent"
android:layout_height="56dp"
app:layout_constraintTop_toBottomOf="@id/product_id_layout"
/>
app:layout_constraintTop_toBottomOf="@id/product_id_layout" />

<Button
android:id="@+id/btn_detect"
android:layout_width="match_parent"
android:layout_height="45dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/client_token_layout"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="16dp"
android:background="@drawable/background_blue_btn"
android:text="@string/search_devs"
android:textColor="@color/white"
android:textSize="@dimen/ts_17"
android:background="@drawable/background_blue_btn"
/>
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/client_token_layout" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/devs_lv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
app:layout_constraintTop_toBottomOf="@id/btn_detect"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
/>
app:layout_constraintTop_toBottomOf="@id/btn_detect" />

</androidx.constraintlayout.widget.ConstraintLayout>
20 changes: 3 additions & 17 deletions sdkdemo/src/main/res/layout/activity_video_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn_video_pro"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:background="@drawable/background_blue_cell_btn"
android:text="@string/video_pro"
android:textAllCaps="false"
android:textColor="@color/blue_0052D9"
android:textSize="@dimen/ts_17"
app:layout_constraintTop_toBottomOf="@id/btn_video" />

<Button
android:id="@+id/btn_video_wlan"
android:layout_width="match_parent"
Expand All @@ -100,17 +86,17 @@
android:textAllCaps="false"
android:textColor="@color/blue_0052D9"
android:textSize="@dimen/ts_17"
app:layout_constraintTop_toBottomOf="@id/btn_video_pro" />
app:layout_constraintTop_toBottomOf="@id/btn_video" />

<Button
android:id="@+id/btn_video_test"
android:id="@+id/btn_video_link"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:background="@drawable/background_blue_cell_btn"
android:text="@string/video_test"
android:text="@string/video_link"
android:textAllCaps="false"
android:textColor="@color/blue_0052D9"
android:textSize="@dimen/ts_17"
Expand Down
13 changes: 8 additions & 5 deletions sdkdemo/src/main/res/layout/activity_video_test_input.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
Expand All @@ -11,12 +12,13 @@

<Button
android:id="@+id/btn_paste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_marginStart="16dp"
android:background="@drawable/btn_rad4_color_e6e6e6"
android:layout_marginTop="8dp"
android:background="@drawable/background_blue_cell"
android:text="粘贴"
android:textStyle="bold"
android:textColor="@color/blue_0052D9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_title" />

Expand Down Expand Up @@ -63,7 +65,8 @@
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/tv_cross"
app:layout_constraintStart_toEndOf="@+id/tv_cross"
app:layout_constraintTop_toTopOf="@+id/tv_cross" />
app:layout_constraintTop_toTopOf="@+id/tv_cross"
tools:ignore="UseSwitchCompatOrMaterialXml" />

<TextView
android:id="@+id/textView"
Expand Down
2 changes: 1 addition & 1 deletion sdkdemo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<string name="iot_test_demo_name">IoT Video TEST</string>
<string name="welcome">欢迎使用腾讯云 IoT Video</string>
<string name="video">IoT Video(消费版)</string>
<string name="video_pro">IoT Video(行业版)</string>
<string name="video_wlan">IoT Video(局域网)</string>
<string name="video_link">IoT Video(设备直连)</string>
<string name="video_test">IoT Video Test</string>
<string name="video_client_token">Client token</string>
<string name="search_devs">探测设备</string>
Expand Down

0 comments on commit 990949e

Please sign in to comment.