/// Call session data model for audio/video calling /// Stores all information about an active call enum CallType { audio, video } enum CallDirection { outgoing, incoming } enum CallStatus { idle, checkingPermissions, outgoingRinging, incomingRinging, connecting, connected, ended } class CallSession { final String callId; final CallType type; final CallDirection direction; final String peerId; // Employee number final String peerName; final String? peerAvatar; final DateTime startTime; String? sessionId; // For SDP/ICE correlation String? sdpOffer; String? sdpAnswer; CallSession({ required this.callId, required this.type, required this.direction, required this.peerId, required this.peerName, this.peerAvatar, required this.startTime, this.sessionId, this.sdpOffer, this.sdpAnswer, }); Map toJson() => { 'callId': callId, 'type': type.name, 'direction': direction.name, 'peerId': peerId, 'peerName': peerName, 'peerAvatar': peerAvatar, 'startTime': startTime.toIso8601String(), 'sessionId': sessionId, 'sdpOffer': sdpOffer, 'sdpAnswer': sdpAnswer, }; factory CallSession.fromJson(Map json) => CallSession( callId: json['callId'], type: CallType.values.firstWhere((e) => e.name == json['type']), direction: CallDirection.values.firstWhere((e) => e.name == json['direction']), peerId: json['peerId'], peerName: json['peerName'], peerAvatar: json['peerAvatar'], startTime: DateTime.parse(json['startTime']), sessionId: json['sessionId'], sdpOffer: json['sdpOffer'], sdpAnswer: json['sdpAnswer'], ); CallSession copyWith({ String? callId, CallType? type, CallDirection? direction, String? peerId, String? peerName, String? peerAvatar, DateTime? startTime, String? sessionId, String? sdpOffer, String? sdpAnswer, }) { return CallSession( callId: callId ?? this.callId, type: type ?? this.type, direction: direction ?? this.direction, peerId: peerId ?? this.peerId, peerName: peerName ?? this.peerName, peerAvatar: peerAvatar ?? this.peerAvatar, startTime: startTime ?? this.startTime, sessionId: sessionId ?? this.sessionId, sdpOffer: sdpOffer ?? this.sdpOffer, sdpAnswer: sdpAnswer ?? this.sdpAnswer, ); } bool get isVideo => type == CallType.video; bool get isAudio => type == CallType.audio; bool get isIncoming => direction == CallDirection.incoming; bool get isOutgoing => direction == CallDirection.outgoing; }