Skip to content

Commit d6d928a

Browse files
committed
增加多设备拉流
1 parent e7e9c09 commit d6d928a

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,65 +21,65 @@ class MultiVideoTestInputActivity : VideoBaseActivity<ActivityMultiDeviceInputBi
2121
// 设备1
2222
device1ProductIdLayout.tvTip.setText(R.string.product_id_text)
2323
device1ProductIdLayout.evContent.setHint(R.string.hint_product_id)
24-
device1ProductIdLayout.evContent.setText("CE3P21B2JW")
24+
device1ProductIdLayout.evContent.setText("")
2525
device1ProductIdLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
2626

2727
device1DeviceNameLayout.tvTip.setText(R.string.device_name_text)
2828
device1DeviceNameLayout.evContent.setHint(R.string.hint_device_name)
29-
device1DeviceNameLayout.evContent.setText("4C_40300001_152384222_4")
29+
device1DeviceNameLayout.evContent.setText("")
3030
device1DeviceNameLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
3131

3232
device1P2pInfoLayout.tvTip.setText(R.string.p2p_info_text)
3333
device1P2pInfoLayout.evContent.setHint(R.string.hint_p2p_info)
34-
device1P2pInfoLayout.evContent.setText("XP2P1HNek+BperPLzEXSyb67SI7k%2.4.50")
34+
device1P2pInfoLayout.evContent.setText("")
3535
device1P2pInfoLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
3636

3737
// 设备2
3838
device2ProductIdLayout.tvTip.setText(R.string.product_id_text)
3939
device2ProductIdLayout.evContent.setHint(R.string.hint_product_id)
40-
device2ProductIdLayout.evContent.setText("CE3P21B2JW")
40+
device2ProductIdLayout.evContent.setText("")
4141
device2ProductIdLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
4242

4343
device2DeviceNameLayout.tvTip.setText(R.string.device_name_text)
4444
device2DeviceNameLayout.evContent.setHint(R.string.hint_device_name)
45-
device2DeviceNameLayout.evContent.setText("4C_40300001_162157562_78")
45+
device2DeviceNameLayout.evContent.setText("")
4646
device2DeviceNameLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
4747

4848
device2P2pInfoLayout.tvTip.setText(R.string.p2p_info_text)
4949
device2P2pInfoLayout.evContent.setHint(R.string.hint_p2p_info)
50-
device2P2pInfoLayout.evContent.setText("XP2PiMbQ1FQE+6ovftkH0GeChw==%2.4.50")
50+
device2P2pInfoLayout.evContent.setText("")
5151
device2P2pInfoLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
5252

5353
// 设备3
5454
device3ProductIdLayout.tvTip.setText(R.string.product_id_text)
5555
device3ProductIdLayout.evContent.setHint(R.string.hint_product_id)
56-
device3ProductIdLayout.evContent.setText("CE3P21B2JW")
56+
device3ProductIdLayout.evContent.setText("")
5757
device3ProductIdLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
5858

5959
device3DeviceNameLayout.tvTip.setText(R.string.device_name_text)
6060
device3DeviceNameLayout.evContent.setHint(R.string.hint_device_name)
61-
device3DeviceNameLayout.evContent.setText("4C_40300001_162157562_54")
61+
device3DeviceNameLayout.evContent.setText("")
6262
device3DeviceNameLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
6363

6464
device3P2pInfoLayout.tvTip.setText(R.string.p2p_info_text)
6565
device3P2pInfoLayout.evContent.setHint(R.string.hint_p2p_info)
66-
device3P2pInfoLayout.evContent.setText("XP2Pgvn3TmlXF16x+9WTJvSt96EI%2.4.50")
66+
device3P2pInfoLayout.evContent.setText("")
6767
device3P2pInfoLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
6868

6969
// 设备4
7070
device4ProductIdLayout.tvTip.setText(R.string.product_id_text)
7171
device4ProductIdLayout.evContent.setHint(R.string.hint_product_id)
72-
device4ProductIdLayout.evContent.setText("CE3P21B2JW")
72+
device4ProductIdLayout.evContent.setText("")
7373
device4ProductIdLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
7474

7575
device4DeviceNameLayout.tvTip.setText(R.string.device_name_text)
7676
device4DeviceNameLayout.evContent.setHint(R.string.hint_device_name)
77-
device4DeviceNameLayout.evContent.setText("4C_40300001_162157562_57")
77+
device4DeviceNameLayout.evContent.setText("")
7878
device4DeviceNameLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
7979

8080
device4P2pInfoLayout.tvTip.setText(R.string.p2p_info_text)
8181
device4P2pInfoLayout.evContent.setHint(R.string.hint_p2p_info)
82-
device4P2pInfoLayout.evContent.setText("XP2PAbTOrSl+BGVu3siirwE+Joda%2.4.50")
82+
device4P2pInfoLayout.evContent.setText("")
8383
device4P2pInfoLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
8484
}
8585
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class VideoOptionsActivity : VideoBaseActivity<ActivityVideoOptionsBinding>() {
1313
with(binding) {
1414
btnVideo.setOnClickListener { jumpActivity(VideoInputAuthorizeActivity::class.java) }
1515
btnVideoWlan.setOnClickListener { jumpActivity(VideoWlanDetectActivity::class.java) }
16-
btnVideoLink.setOnClickListener { jumpActivity(VideoTestInputActivity::class.java) }
16+
btnVideoLink.setOnClickListener { showConnectionTypeDialog() }
1717
}
1818
}
1919

2020
private fun showConnectionTypeDialog() {
2121
val options = arrayOf("单设备直连", "多设备直连")
2222
AlertDialog.Builder(this)
23-
.setTitle("选择连接方式")
23+
.setTitle("请选择设备连接方式")
2424
.setItems(options) { _, which ->
2525
when (which) {
2626
0 -> jumpActivity(VideoTestInputActivity::class.java)

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ class VideoTestActivity : VideoBaseActivity<ActivityVideoTestBinding>(), XP2PCal
118118
binding.tvVideoQuality.text = getString(R.string.video_quality_medium_str)
119119

120120
XP2P.setCallback(this)
121-
// val filaPath = getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS)?.absolutePath + "/data_video.flv"
122-
// XP2P.recordstreamPath(filaPath) //自定义采集裸流路径
121+
val filaPath = getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS)?.absolutePath + "/data_video.flv"
122+
XP2P.recordstreamPath(filaPath) //自定义采集裸流路径
123123
val wm = this.getSystemService(WINDOW_SERVICE) as WindowManager
124124
val dm = DisplayMetrics()
125125
wm.defaultDisplay.getMetrics(dm)
@@ -172,7 +172,7 @@ class VideoTestActivity : VideoBaseActivity<ActivityVideoTestBinding>(), XP2PCal
172172

173173
private fun delegateHttpFlv() {
174174
val id = "${productId}/${deviceName}"
175-
// XP2P.recordstream(id) //开启自定义采集裸流
175+
XP2P.recordstream(id) //开启自定义采集裸流
176176
val prefix = XP2P.delegateHttpFlv(id)
177177
if (prefix.isNotEmpty()) {
178178
urlPrefix = prefix
@@ -466,15 +466,12 @@ class VideoTestActivity : VideoBaseActivity<ActivityVideoTestBinding>(), XP2PCal
466466
player.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "threads", 2)
467467
player.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1)
468468
player.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "sync-av-start", 0)
469-
player.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 5)
470-
player.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 512 * 1024)
471469
player.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1)
472470
player.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-auto-rotate", 1)
473471
player.setOption(
474472
IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-handle-resolution-change", 1
475473
)
476-
player.setFrameSpeed(1.5f)
477-
player.setMaxPacketNum(2)
474+
player.setMaxPacketNum(10001)
478475
while (!::surface.isInitialized) {
479476
delay(50)
480477
L.e("delay for waiting surface.")

0 commit comments

Comments
 (0)