Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When Camera turned OFF and then ON, remote device not get reflected with new stream. #434

Open
Vinayak006 opened this issue Apr 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Vinayak006
Copy link

Problem
So when the camera is turned off, and then turned on, I don't know how to reflect changes to remote device

Code

Future<void> handleCamera(final String callId) async {
    // stopping the stream here
        localStream
            ?.getVideoTracks()
            .forEach((final MediaStreamTrack element) async {
          await element.stop();
        });
        call.mute(false);
        localVideoRenderer?.srcObject = null;
        localStream = null;
     // starting the stream
        final MediaStream mediaStream = await navigator.mediaDevices
            .getUserMedia(<String, dynamic>{"video": true});
        localVideoRenderer?.srcObject = mediaStream;
        localStream = mediaStream;
        call.unmute(false);
      }
  }

Expected behavior
When local camera is turned on, remote device should get the new mediastream

System Infomation()
Flutter SDK Version: 3.19.5
sip_ua Version: 0.5.8

@Vinayak006 Vinayak006 added the bug Something isn't working label Apr 24, 2024
@VadimKV44
Copy link

I am not showing the remote video stream. I'm calling the mobile application from the site, the site has its own video stream and the video stream of the phone, but the video stream from the site is not displayed on the phone, can you tell me what the problem is?
MediaStream? remoteStream;
RTCVideoRenderer? remoteRenderer = RTCVideoRenderer();
EdgeInsetsGeometry? localVideoMargin;
double? localVideoHeight;
double? localVideoWidth;
String error = '';
bool showError = false;

Call? _call;
Call? get getCall => _call;
set setCall(Call call) => _call = call;

void initRender(CallState callState) async {
try {
await remoteRenderer!.initialize();
_handelStreams(callState);
} catch (e) {
logger.e(e);
showError = true;
error = 'Ошибка при обработке видео';
}
notifyListeners();
}

void _handelStreams(CallState event) async {
MediaStream? stream = event.stream;

logger.i('MYLOGGER STATE: ${event.state}');
logger.i('MYLOGGER VIDEO: ${event.video}');
if (event.originator == 'remote') {
  try {
    logger.i('MYLOGGER STREAM: ${stream}');
    remoteRenderer?.srcObject = stream;
    remoteStream = stream;
    if (remoteStream!.getVideoTracks().isEmpty) {
      showError = true;
      error = 'Не найден видеопоток';
    }
  } catch (e) {
    logger.e(e);
    showError = true;
    error = 'Ошибка при обработке видео';
  }
}
notifyListeners();

}

@Vinayak006
Copy link
Author

Vinayak006 commented Apr 26, 2024

You need call the "_handleStreams()" function in 'callStateChanged()' funtion, not inside the 'initRenderers()' @VadimKV44

@VadimKV44
Copy link

@Vinayak006 I did as you said, but it didn't help. When making a video call, after accepting the call, there is also a black screen instead of a video, but the call itself ends after a few seconds. As I understood it in the video codec, flutter_webrtc has the V8 codec by default, and I receive a video stream in H264 format. I have been looking for a long time to change it, but I have not found it, please tell me if there is such a possibility at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants