|
|
|
|
@ -18,14 +18,14 @@ class StartVideoCall extends StatefulWidget {
|
|
|
|
|
StartVideoCall({@required this.signaling, @required this.session});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
StartVideoCallState createState() => StartVideoCallState(session: session, signaling: signaling);
|
|
|
|
|
StartVideoCallState createState() => StartVideoCallState(session: session, signaling: signaling);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
Signaling _signaling;
|
|
|
|
|
SessionOneToOne _session;
|
|
|
|
|
|
|
|
|
|
StartVideoCallState({@required SessionOneToOne session, @required Signaling signaling}){
|
|
|
|
|
StartVideoCallState({@required SessionOneToOne session, @required Signaling signaling}) {
|
|
|
|
|
this._session = session;
|
|
|
|
|
this._signaling = signaling;
|
|
|
|
|
}
|
|
|
|
|
@ -40,6 +40,7 @@ class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer();
|
|
|
|
|
|
|
|
|
|
MediaStream get localMediaStream => _signaling.localStream;
|
|
|
|
|
|
|
|
|
|
MediaStream get remoteMediaStream => _signaling.remoteStreams.first;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -100,10 +101,8 @@ class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _setupEventListeners() async {
|
|
|
|
|
if(_session == null)
|
|
|
|
|
return;
|
|
|
|
|
if (_session == null) return;
|
|
|
|
|
|
|
|
|
|
// _signaling ??= Signaling(widget.host, session: _session)..connect();
|
|
|
|
|
|
|
|
|
|
@ -129,14 +128,11 @@ class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
_signaling?.callAccepted(_session);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_signaling?.onCallAccepted = ((event) {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
_signaling?.onCallAccepted = ((event) {});
|
|
|
|
|
|
|
|
|
|
_signaling?.onLocalStream = ((stream) {
|
|
|
|
|
_localRenderer.srcObject = stream;
|
|
|
|
|
setState(() {
|
|
|
|
|
});
|
|
|
|
|
setState(() {});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_signaling?.onAddRemoteStream = ((_, stream) {
|
|
|
|
|
@ -159,14 +155,14 @@ class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
// _signaling?.muteMic();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Function _onAudioEnable(){
|
|
|
|
|
Function _onAudioEnable() {
|
|
|
|
|
print("================= Audio Event Triggered ===================");
|
|
|
|
|
final audioTrack = localMediaStream.getAudioTracks()[0];
|
|
|
|
|
final micEnabled = audioTrack.enabled;
|
|
|
|
|
localMediaStream.getAudioTracks()[0].enabled = !micEnabled;
|
|
|
|
|
_audioButton.add(!micEnabled);
|
|
|
|
|
// _audioButton.add(!mute);
|
|
|
|
|
// Helper.setMicrophoneMute(!mute, audioTrack);
|
|
|
|
|
// _audioButton.add(!mute);
|
|
|
|
|
// Helper.setMicrophoneMute(!mute, audioTrack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Function _onVideoEnabled() {
|
|
|
|
|
@ -183,8 +179,7 @@ class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onShowBar() {
|
|
|
|
|
setState(() {
|
|
|
|
|
});
|
|
|
|
|
setState(() {});
|
|
|
|
|
_onButtonBarVisibleStreamController.add(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -200,13 +195,12 @@ class StartVideoCallState extends State<StartVideoCall> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _onHangup({bool byRemote = false}) async {
|
|
|
|
|
print("================= HangUp Event Triggered ===================");
|
|
|
|
|
print("================= $byRemote ===================");
|
|
|
|
|
if(byRemote){
|
|
|
|
|
|
|
|
|
|
if (byRemote) {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
_signaling.bye(_session);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|