@@ -40,6 +40,15 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
4040 private val region = " china"
4141 private val isUserCongestionCtrl = true
4242
43+ @Volatile
44+ protected var sysInitResCode = - 1
45+
46+ @Volatile
47+ protected var dmInitResCode = - 1
48+
49+ @Volatile
50+ protected var avtInitResCode = - 1
51+
4352 override fun onCreate (savedInstanceState : Bundle ? ) {
4453 super .onCreate(savedInstanceState)
4554 if (! checkPerformCreate()) return
@@ -63,10 +72,18 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
6372 // start run JNI iot_video_demo
6473 checkDefaultThreadActiveAndExecuteTask {
6574 val sysInitInfo = SysInitInfo (productId, deviceName, deviceKey, region)
66- val sysInit = VideoNativeInterface .getInstance().initIvSystem(sysInitInfo, this )
67- Log .d(TAG , " initIvSystem,resCode:$sysInit " )
68- val dmInit = VideoNativeInterface .getInstance().initIvDm()
69- Log .d(TAG , " initIvDm,resCode:$dmInit " )
75+ sysInitResCode = VideoNativeInterface .getInstance().initIvSystem(sysInitInfo, this )
76+ Log .d(TAG , " initIvSystem,resCode:$sysInitResCode " )
77+ if (sysInitResCode != 0 ) {
78+ showToast(" initIvSystem fail,resCode:$sysInitResCode " )
79+ return @checkDefaultThreadActiveAndExecuteTask
80+ }
81+ dmInitResCode = VideoNativeInterface .getInstance().initIvDm()
82+ Log .d(TAG , " initIvDm,resCode:$dmInitResCode " )
83+ if (dmInitResCode != 0 ) {
84+ showToast(" initIvDm fail,resCode:$dmInitResCode " )
85+ return @checkDefaultThreadActiveAndExecuteTask
86+ }
7087 val congestion = CongestionCtrlInfo ()
7188 if (isUserCongestionCtrl) { // 启用水位告警以及告警的有高中低三挡水位值,当 p2p 内部缓存的水位到达这个值的时候会收到 onNotify回调
7289 congestion.lowMark = 200 * 1024
@@ -79,8 +96,12 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
7996 }
8097 val avtInitInfo = AvtInitInfo ()
8198 avtInitInfo.congestion = congestion
82- val avtInit = VideoNativeInterface .getInstance().initIvAvt(avtInitInfo, this )
83- Log .d(TAG , " initIvAvt,resCode:$avtInit " )
99+ avtInitResCode = VideoNativeInterface .getInstance().initIvAvt(avtInitInfo, this )
100+ Log .d(TAG , " initIvAvt,resCode:$avtInitResCode " )
101+ if (avtInitResCode != 0 ) {
102+ showToast(" initIvDm fail,resCode:$avtInitResCode " )
103+ return @checkDefaultThreadActiveAndExecuteTask
104+ }
84105 }
85106 }
86107
@@ -91,12 +112,18 @@ abstract class BaseIPCActivity<VB : ViewBinding> : AppCompatActivity(), IvDevice
91112 override fun onDestroy () {
92113 super .onDestroy()
93114 checkDefaultThreadActiveAndExecuteTask {
94- val exitIvAvt = VideoNativeInterface .getInstance().exitIvAvt()
95- Log .d(TAG , " exit avt resCode:$exitIvAvt " )
96- val exitIvDm = VideoNativeInterface .getInstance().exitIvDm()
97- Log .d(TAG , " exit dm resCode:$exitIvDm " )
98- val exitIvSys = VideoNativeInterface .getInstance().exitIvSys()
99- Log .d(TAG , " exit sys resCode:$exitIvSys " )
115+ if (avtInitResCode == 0 ) {
116+ val exitIvAvt = VideoNativeInterface .getInstance().exitIvAvt()
117+ Log .d(TAG , " exit avt resCode:$exitIvAvt " )
118+ }
119+ if (dmInitResCode == 0 ) {
120+ val exitIvDm = VideoNativeInterface .getInstance().exitIvDm()
121+ Log .d(TAG , " exit dm resCode:$exitIvDm " )
122+ }
123+ if (sysInitResCode == 0 ) {
124+ val exitIvSys = VideoNativeInterface .getInstance().exitIvSys()
125+ Log .d(TAG , " exit sys resCode:$exitIvSys " )
126+ }
100127 defaultThread.shutdown()
101128 }
102129 }
0 commit comments