Skip to content

Commit bbac993

Browse files
committed
test video 输入页面增加双中转开关和协议选择
1 parent 1ab8127 commit bbac993

File tree

3 files changed

+101
-20
lines changed

3 files changed

+101
-20
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Intent
55
import android.os.Bundle
66
import android.text.InputType
77
import android.view.View
8+
import android.widget.RadioButton
89
import androidx.core.content.ContextCompat
910
import com.tencent.iot.explorer.link.core.utils.SharePreferenceUtil
1011
import com.tencent.iot.explorer.link.demo.R
@@ -16,6 +17,8 @@ import kotlinx.android.synthetic.main.activity_video_input_authorize.product_id_
1617
import kotlinx.android.synthetic.main.activity_video_test_input.btn_paste
1718
import kotlinx.android.synthetic.main.activity_video_test_input.device_name_layout
1819
import kotlinx.android.synthetic.main.activity_video_test_input.p2p_info_layout
20+
import kotlinx.android.synthetic.main.activity_video_test_input.rg_protocol
21+
import kotlinx.android.synthetic.main.activity_video_test_input.swt_cross
1922
import kotlinx.android.synthetic.main.blue_title_layout.iv_back
2023
import kotlinx.android.synthetic.main.blue_title_layout.tv_title
2124
import kotlinx.android.synthetic.main.input_item_layout.view.ev_content
@@ -25,6 +28,8 @@ import kotlinx.coroutines.MainScope
2528

2629
class VideoTestInputActivity : VideoBaseActivity(), CoroutineScope by MainScope() {
2730

31+
private var isStartCross = false
32+
private var protocol = "auto"
2833
override fun getContentView(): Int {
2934
return R.layout.activity_video_test_input
3035
}
@@ -82,9 +87,15 @@ class VideoTestInputActivity : VideoBaseActivity(), CoroutineScope by MainScope(
8287
}
8388
}
8489
}
90+
swt_cross.setOnCheckedChangeListener { _, checked ->
91+
isStartCross = checked
92+
}
93+
rg_protocol.setOnCheckedChangeListener { group, checkedId ->
94+
protocol = group.findViewById<RadioButton>(checkedId).tag.toString()
95+
}
8596
}
8697

87-
var loginClickedListener = object : View.OnClickListener {
98+
private var loginClickedListener = object : View.OnClickListener {
8899
override fun onClick(v: View?) {
89100
if (product_id_layout.ev_content.text.isNullOrEmpty()) {
90101
show(getString(R.string.hint_product_id))
@@ -120,8 +131,8 @@ class VideoTestInputActivity : VideoBaseActivity(), CoroutineScope by MainScope(
120131
intent.putExtra("productId", product_id_layout.ev_content.text.toString())
121132
intent.putExtra("deviceName", device_name_layout.ev_content.text.toString())
122133
intent.putExtra("p2pInfo", p2p_info_layout.ev_content.text.toString())
123-
val bundle = Bundle()
124-
intent.putExtra(VideoConst.VIDEO_CONFIG, bundle)
134+
intent.putExtra("isStartCross", isStartCross)
135+
intent.putExtra("protocol", protocol)
125136
startActivity(intent)
126137
}
127138
}

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
7777
private var deviceName: String = ""
7878
private var xp2pInfo: String = ""
7979
private val channel: Int = 0
80-
var urlPrefix = ""
81-
var screenWidth = 0
82-
var screenHeight = 0
83-
var startShowVideoTime = 0L
84-
var showVideoTime = 0L
85-
var connectTime = 0L
86-
var showTip = false
87-
var firstIn = true
88-
val MSG_UPDATE_HUD = 1
89-
var permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
90-
var filePath: String? = null
91-
var audioRecordUtil: AudioRecordUtil? = null
80+
private var urlPrefix = ""
81+
private var screenWidth = 0
82+
private var screenHeight = 0
83+
private var startShowVideoTime = 0L
84+
private var showVideoTime = 0L
85+
private var connectTime = 0L
86+
private var showTip = false
87+
private var firstIn = true
88+
private val MSG_UPDATE_HUD = 1
89+
private var permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
90+
private var filePath: String? = null
91+
private var audioRecordUtil: AudioRecordUtil? = null
9292

9393
@Volatile
94-
var speakAble = false
95-
var audioAble = true
96-
var orientationV = true
94+
private var speakAble = false
95+
private var audioAble = true
96+
private var orientationV = true
9797

9898
private val xP2PAppConfig = XP2PAppConfig().also { appConfig ->
9999
appConfig.appKey =
@@ -115,6 +115,15 @@ open class VideoTestActivity : VideoBaseActivity(), XP2PCallback, CoroutineScope
115115
productId = intent.getStringExtra("productId")?.toString() ?: ""
116116
deviceName = intent.getStringExtra("deviceName")?.toString() ?: ""
117117
xp2pInfo = intent.getStringExtra("p2pInfo")?.toString() ?: ""
118+
xP2PAppConfig.autoConfigFromDevice = intent.getBooleanExtra("isStartCross", false)
119+
val protocol = intent.getStringExtra("protocol")?.toString() ?: "auto"
120+
if (protocol == "udp") {
121+
xP2PAppConfig.type = XP2PProtocolType.XP2P_PROTOCOL_UDP
122+
} else if (protocol == "tcp") {
123+
xP2PAppConfig.type = XP2PProtocolType.XP2P_PROTOCOL_TCP
124+
} else {
125+
xP2PAppConfig.type = XP2PProtocolType.XP2P_PROTOCOL_AUTO
126+
}
118127
audioRecordUtil = AudioRecordUtil(
119128
this,
120129
"${productId}/${deviceName}",

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

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
android:id="@+id/btn_paste"
1414
android:layout_width="wrap_content"
1515
android:layout_height="wrap_content"
16+
android:layout_marginStart="16dp"
1617
android:background="@drawable/btn_rad4_color_e6e6e6"
1718
android:text="粘贴"
1819
android:textStyle="bold"
@@ -46,20 +47,80 @@
4647
android:layout_height="56dp"
4748
app:layout_constraintTop_toBottomOf="@id/device_name_layout" />
4849

50+
<TextView
51+
android:id="@+id/tv_cross"
52+
android:layout_width="wrap_content"
53+
android:layout_height="wrap_content"
54+
android:layout_marginStart="16dp"
55+
android:layout_marginTop="16dp"
56+
android:text="是否开启双中转:"
57+
app:layout_constraintStart_toStartOf="parent"
58+
app:layout_constraintTop_toBottomOf="@id/p2p_info_layout" />
59+
60+
<Switch
61+
android:id="@+id/swt_cross"
62+
android:layout_width="wrap_content"
63+
android:layout_height="wrap_content"
64+
app:layout_constraintBottom_toBottomOf="@+id/tv_cross"
65+
app:layout_constraintStart_toEndOf="@+id/tv_cross"
66+
app:layout_constraintTop_toTopOf="@+id/tv_cross" />
67+
68+
<TextView
69+
android:id="@+id/textView"
70+
android:layout_width="wrap_content"
71+
android:layout_height="wrap_content"
72+
android:layout_marginStart="16dp"
73+
android:layout_marginTop="8dp"
74+
android:text="选择协议:"
75+
app:layout_constraintStart_toStartOf="parent"
76+
app:layout_constraintTop_toBottomOf="@+id/tv_cross" />
77+
78+
<RadioGroup
79+
android:id="@+id/rg_protocol"
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:orientation="horizontal"
83+
app:layout_constraintBottom_toBottomOf="@+id/textView"
84+
app:layout_constraintStart_toEndOf="@+id/textView"
85+
app:layout_constraintTop_toTopOf="@+id/textView">
86+
87+
<RadioButton
88+
android:id="@+id/rb_auto"
89+
android:layout_width="wrap_content"
90+
android:layout_height="wrap_content"
91+
android:checked="true"
92+
android:tag="auto"
93+
android:text="auto" />
94+
95+
<RadioButton
96+
android:id="@+id/rb_udp"
97+
android:layout_width="wrap_content"
98+
android:layout_height="wrap_content"
99+
android:tag="udp"
100+
android:text="udp" />
101+
102+
<RadioButton
103+
android:id="@+id/rb_tcp"
104+
android:layout_width="wrap_content"
105+
android:layout_height="wrap_content"
106+
android:tag="tcp"
107+
android:text="tcp" />
108+
</RadioGroup>
109+
49110
<Button
50111
android:id="@+id/btn_login"
51112
android:layout_width="match_parent"
52113
android:layout_height="45dp"
53114
android:layout_marginStart="16dp"
54-
android:layout_marginTop="40dp"
115+
android:layout_marginTop="50dp"
55116
android:layout_marginEnd="16dp"
56117
android:background="@drawable/background_blue_btn"
57118
android:text="@string/login"
58119
android:textColor="@color/white"
59120
android:textSize="@dimen/ts_17"
60121
app:layout_constraintEnd_toEndOf="parent"
61122
app:layout_constraintStart_toStartOf="parent"
62-
app:layout_constraintTop_toBottomOf="@id/p2p_info_layout" />
123+
app:layout_constraintTop_toBottomOf="@id/tv_cross" />
63124

64125

65126
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)