Open Vinayak006 opened 11 months ago
getting same error. any solution?
I can confirm this behavior. It happens often, but not always. It seems to be usually appearing the first time the app is started after other apps are being used, or the first time user agrees with the permissions. Smells to me like a race condition, but I'm not expert in the code.
Will be more than glad to help debug the issue and fix it, because it is definitely a show stopper for the project I am working.
Ok, I figured out the problem. Technically, this isn't a bug. When you use RTCVideoRenderer, you have to call and await initialize(). So you can't just make it in the render function, it has to be created before, and it has to be initialized and awaite before use:
// create temp variable while initializng
var tempRenderer = RTCVideoRenderer()
await tempRenderer.initialize()
tempRenderer!.srcObject = ...
// now set your real item
renderer = tempRenderer;
// setstate, etc
Then in your render function
if(renderer == null)
return Container()
so you don't errors before it's ready
void _handelStreams(CallState event) async {
MediaStream? stream = event.stream;
if (event.originator == 'local') {
if (_localRenderer != null) {
await _localRenderer!.initialize();
_localRenderer!.srcObject = stream;
}
_localStream = stream;
if (!kIsWeb && !WebRTC.platformIsDesktop) {
stream?.getAudioTracks().first.enableSpeakerphone(false);
}
}
if (event.originator == 'remote') {
if (_remoteRenderer != null) {
await _remoteRenderer!.initialize();
_remoteRenderer!.srcObject = stream;
}
_remoteStream = stream;
}
setState(() {
_resizeLocalVideo();
});
}
instead of initializing the _localRenderer and _remoteRenderer in _initRenderers() , do initialize it after the stream has been intialized.
Thank you @turbobuilt !! You did it!
Describe the bug When I make a call, I get the error "Call initialize before setting the stream". I am using the asterisk test server.
To Reproduce Steps to reproduce the behaviour:
Expected behaviour A call must be created and a connection must be established.
System Infomation() Flutter SDK Version: 3.16.3 sip_ua Version: 0.5.8