File tree 3 files changed +23
-4
lines changed
3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
1
import 'dart:async' ;
2
2
import 'dart:convert' ;
3
3
import 'dart:typed_data' show Uint8List;
4
+ import 'dart:ffi' as ffi;
4
5
5
6
import 'package:agora_rtc_engine/src/agora_base.dart' ;
6
7
import 'package:agora_rtc_engine/src/agora_media_base.dart' ;
@@ -211,6 +212,23 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl
211
212
212
213
await _globalVideoViewController
213
214
.attachVideoFrameBufferManager (irisMethodChannel.getNativeHandle ());
215
+
216
+ irisMethodChannel.addHotRestartListener (_hotRestartListener);
217
+ }
218
+
219
+ void _hotRestartListener (Object ? message) {
220
+ assert (() {
221
+ // Free `IrisVideoFrameBufferManager` when hot restart
222
+ final nativeBindingDelegate = IrisApiEngineNativeBindingDelegateProvider ()
223
+ .provideNativeBindingDelegate ()
224
+ as NativeIrisApiEngineBindingsDelegate ;
225
+ nativeBindingDelegate.initialize ();
226
+ nativeBindingDelegate.binding.FreeIrisVideoFrameBufferManager (
227
+ ffi.Pointer .fromAddress (
228
+ _globalVideoViewController.videoFrameBufferManagerIntPtr));
229
+
230
+ return true ;
231
+ }());
214
232
}
215
233
216
234
@override
@@ -262,7 +280,7 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl
262
280
263
281
await super .release (sync : sync );
264
282
265
- // await apiCaller.disposeAsync( );
283
+ irisMethodChannel. removeHotRestartListener (_hotRestartListener );
266
284
267
285
await irisMethodChannel.dispose ();
268
286
_instance = null ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ ffi.DynamicLibrary _loadLib() {
27
27
28
28
class NativeIrisApiEngineBindingsDelegate extends NativeBindingDelegate {
29
29
late final bindings.NativeIrisApiEngineBinding _binding;
30
+ bindings.NativeIrisApiEngineBinding get binding => _binding;
30
31
31
32
@override
32
33
void initialize () {
@@ -173,9 +174,9 @@ class NativeIrisApiEngineBindingsDelegate extends NativeBindingDelegate {
173
174
}
174
175
175
176
class IrisApiEngineNativeBindingDelegateProvider
176
- implements NativeBindingDelegateProvider {
177
+ extends NativeBindingsProvider {
177
178
@override
178
- NativeBindingDelegate provide () {
179
+ NativeBindingDelegate provideNativeBindingDelegate () {
179
180
return NativeIrisApiEngineBindingsDelegate ();
180
181
}
181
182
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ dependencies:
17
17
ffi : ' >=1.1.2'
18
18
async : ^2.8.2
19
19
meta : ^1.7.0
20
- iris_method_channel : ^1.0.0
20
+ iris_method_channel : ^1.1.0-rc.2
21
21
dev_dependencies :
22
22
flutter_test :
23
23
sdk : flutter
You can’t perform that action at this time.
0 commit comments