Skip to content

Commit 1a3cfb7

Browse files
committed
Merge branch 'featurn_v1.1x' into new_mian
2 parents df06be7 + e42170a commit 1a3cfb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2514
-1747
lines changed

app/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ android {
1111

1212
defaultConfig {
1313
applicationId "com.tencent.iot.twcall"
14-
minSdkVersion 21
14+
minSdkVersion 23
1515
targetSdkVersion 29
1616
versionCode 1
17-
versionName "1.0"
17+
versionName "1.1.0"
1818

1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2020
}
@@ -57,5 +57,6 @@ dependencies {
5757
implementation libs.crashreport
5858
implementation libs.androidx.core.ktx
5959
implementation libs.kotlinx.coroutines.android
60-
implementation 'com.tencent.iot.video:video-device-android:1.0.5-SNAPSHOT'
60+
implementation libs.gson
61+
implementation 'com.tencent.iot.video:video-device-android:1.0.6.03-SNAPSHOT'
6162
}

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
6+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
7+
<uses-permission
8+
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
9+
tools:ignore="ScopedStorage" />
310

411
<application
12+
android:name="com.IvDemoApplication"
513
android:allowBackup="true"
614
android:icon="@mipmap/ic_launcher"
715
android:label="@string/app_name"
@@ -12,6 +20,7 @@
1220

1321
<activity
1422
android:name="com.example.ivdemo.MainActivity"
23+
android:exported="true"
1524
android:theme="@style/Theme.TWAppTheme">
1625
<intent-filter>
1726
<action android:name="android.intent.action.MAIN" />
@@ -21,30 +30,35 @@
2130
<activity
2231
android:name="com.example.ivdemo.IPCActivity"
2332
android:configChanges="orientation|keyboardHidden|screenSize"
33+
android:exported="false"
2434
android:theme="@style/Theme.TWAppTheme" />
2535
<activity
26-
android:name="com.example.ivdemo.VoipLoginActivity"
36+
android:name="com.example.ivdemo.TweCallLoginActivity"
2737
android:configChanges="orientation|keyboardHidden|screenSize"
28-
android:label="@string/title_activity_voip"
38+
android:exported="false"
39+
android:label="@string/title_activity_twe_call"
2940
android:theme="@style/Theme.TWAppTheme" />
3041
<activity
31-
android:name="com.example.ivdemo.VoipActivity"
42+
android:name="com.example.ivdemo.TweCallActivity"
3243
android:configChanges="orientation|keyboardHidden|screenSize"
33-
android:label="@string/title_activity_voip"
44+
android:exported="false"
45+
android:label="@string/title_activity_twe_call"
3446
android:theme="@style/Theme.TWAppTheme" />
3547
<activity
3648
android:name="com.example.ivdemo.DuplexVideoActivity"
3749
android:configChanges="orientation|keyboardHidden|screenSize"
50+
android:exported="false"
3851
android:theme="@style/Theme.TWAppTheme" />
3952

4053
<activity
4154
android:name="com.example.ivdemo.OTAUpgradeActivity"
4255
android:configChanges="orientation|keyboardHidden|screenSize"
56+
android:exported="false"
4357
android:theme="@style/Theme.TWAppTheme" />
44-
4558
<activity
46-
android:name="com.example.ivdemo.SettingActivity"
59+
android:name="com.example.ivdemo.CustomDuplexVideoActivity"
4760
android:configChanges="orientation|keyboardHidden|screenSize"
61+
android:exported="false"
4862
android:theme="@style/Theme.TWAppTheme" />
4963
</application>
5064
</manifest>

app/src/main/assets/voip_setting.json

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com
2+
3+
import android.app.Application
4+
5+
class IvDemoApplication : Application() {
6+
override fun onCreate() {
7+
super.onCreate()
8+
}
9+
}

app/src/main/java/com/example/ivdemo/BaseIPCActivity.kt

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,25 @@ import com.tencent.iot.video.device.consts.P2pEventType
1515
import com.tencent.iot.video.device.model.AvDataInfo
1616
import com.tencent.iot.video.device.model.AvtInitInfo
1717
import com.tencent.iot.video.device.model.SysInitInfo
18+
import kotlinx.coroutines.CoroutineScope
1819
import kotlinx.coroutines.Dispatchers
20+
import kotlinx.coroutines.cancel
1921
import kotlinx.coroutines.launch
2022
import org.json.JSONObject
2123

22-
private val TAG = IPCActivity::class.java.simpleName
24+
private val TAG = BaseIPCActivity::class.java.simpleName
2325

2426
abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDeviceCallback,
2527
IvAvtCallback {
28+
protected val defaultScope = CoroutineScope(Dispatchers.Default)
2629
protected val productId: String? by lazy { intent.getStringExtra("productId") }
2730
protected val deviceName: String? by lazy { intent.getStringExtra("deviceName") }
2831
protected val deviceKey: String? by lazy { intent.getStringExtra("deviceKey") }
2932
protected val binding by lazy { getViewBinding() }
33+
protected var visitor: Int = 0
34+
protected var channel: Int = 0
35+
protected var videoResType: Int = 0
36+
protected var isOnline = false
3037
private val region = "china"
3138

3239
override fun onCreate(savedInstanceState: Bundle?) {
@@ -63,21 +70,27 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
6370
protected abstract fun initView()
6471

6572
override fun onDestroy() {
66-
lifecycleScope.launch(Dispatchers.Default) {
67-
VideoNativeInterface.getInstance().exitIvAvt()
68-
VideoNativeInterface.getInstance().exitIvDm()
69-
VideoNativeInterface.getInstance().exitIvSys()
70-
}
7173
super.onDestroy()
74+
defaultScope.launch(Dispatchers.Default) {
75+
val exitIvAvt = VideoNativeInterface.getInstance().exitIvAvt()
76+
Log.d(TAG, "exit avt res:$exitIvAvt")
77+
val exitIvDm = VideoNativeInterface.getInstance().exitIvDm()
78+
Log.d(TAG, "exit dm res:$exitIvDm")
79+
val exitIvSys = VideoNativeInterface.getInstance().exitIvSys()
80+
Log.d(TAG, "exit sys res:$exitIvSys")
81+
cancel()
82+
}
7283
}
7384

7485
override fun onOnline(netDateTime: Long) {
7586
Log.d(TAG, "onOnline netDateTime--->$netDateTime")
87+
isOnline = true
7688
showToast("设备上线")
7789
}
7890

7991
override fun onOffline(status: Int) {
8092
Log.d(TAG, "onOffline status--->$status")
93+
isOnline = false
8194
showToast("设备下线")
8295
}
8396

@@ -86,14 +99,23 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
8699
}
87100

88101
override fun onGetAvEncInfo(visitor: Int, channel: Int, videoResType: Int): AvDataInfo {
102+
this.visitor = visitor
103+
this.channel = channel
104+
this.videoResType = videoResType
89105
return AvDataInfo.createDefaultAvDataInfo(videoResType)
90106
}
91107

92108
override fun onStartRealPlay(visitor: Int, channel: Int, videoResType: Int) {
109+
this.visitor = visitor
110+
this.channel = channel
111+
this.videoResType = videoResType
93112
Log.d(TAG, "onStartRealPlay visitor $visitor channel $channel res_type $videoResType")
94113
}
95114

96115
override fun onStopRealPlay(visitor: Int, channel: Int, videoResType: Int) {
116+
this.visitor = visitor
117+
this.channel = channel
118+
this.videoResType = videoResType
97119
Log.d(TAG, "onStopRealPlay visitor $visitor channel $channel res_type $videoResType")
98120
}
99121

@@ -107,6 +129,8 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
107129
sample_rate: Int,
108130
sample_num: Int
109131
): Int {
132+
this.visitor = visitor
133+
this.channel = channel
110134
Log.d(TAG, "onStartRecvAudioStream visitor $visitor")
111135
return 0
112136
}
@@ -119,11 +143,15 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
119143
width: Int,
120144
frameRate: Int
121145
): Int {
146+
this.visitor = visitor
147+
this.channel = channel
122148
Log.d(TAG, "onStartRecvVideoStream video stream is not supported in this activity")
123149
return 0
124150
}
125151

126152
override fun onStopRecvStream(visitor: Int, channel: Int, streamType: Int): Int {
153+
this.visitor = visitor
154+
this.channel = channel
127155
Log.d(TAG, "onStopRecvStream visitor $visitor stream_type $streamType stopped")
128156
return 0
129157
}
@@ -136,6 +164,7 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
136164
pts: Long,
137165
seq: Long
138166
): Int {
167+
this.visitor = visitor
139168
Log.d(
140169
TAG,
141170
"onRecvStream visitor $visitor stream_type $streamType data$data len$len pts$pts seq$seq"
@@ -144,6 +173,9 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
144173
}
145174

146175
override fun onNotify(event: Int, visitor: Int, channel: Int, videoResType: Int) {
176+
this.visitor = visitor
177+
this.channel = channel
178+
this.videoResType = videoResType
147179
Log.w(TAG, "onNotify()")
148180
var msg = ""
149181
when (event) {
@@ -175,6 +207,9 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
175207
videoResType: Int,
176208
args: String?
177209
): String {
210+
this.visitor = visitor
211+
this.channel = channel
212+
this.videoResType = videoResType
178213
Log.d(
179214
TAG,
180215
"onRecvCommand command $command visitor $visitor channel$channel videoResType$videoResType args$args"
@@ -293,17 +328,22 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
293328
}
294329

295330
override fun onDownloadFile(status: Int, visitor: Int, channel: Int): Int {
331+
this.visitor = visitor
332+
this.channel = channel
296333
Log.d(TAG, "onDownloadFile status $status visitor $visitor channel$channel")
297334
return 0
298335
}
299336

300337
override fun onGetPeerOuterNet(visitor: Int, channel: Int, netInfo: String?) {
338+
this.visitor = visitor
339+
this.channel = channel
301340
Log.d(TAG, "onGetPeerOuterNet visitor $visitor channel $channel netInfo$netInfo")
302341
}
303342

304-
private fun showToast(msg: String) {
343+
fun showToast(msg: String) {
344+
Log.d(TAG, "msg:$msg")
305345
lifecycleScope.launch {
306-
Toast.makeText(this@BaseIPCActivity, msg, Toast.LENGTH_SHORT).show();
346+
Toast.makeText(this@BaseIPCActivity.applicationContext, msg, Toast.LENGTH_SHORT).show();
307347
}
308348
}
309349
}

0 commit comments

Comments
 (0)