Skip to content

Commit

Permalink
chore(llc): Added missing ClientDetails to sfu join request (#678)
Browse files Browse the repository at this point in the history
* Added missing ClientDetails to sfu join request

* dep upgraded

---------

Co-authored-by: Deven Joshi <[email protected]>
  • Loading branch information
Brazol and deven98 authored May 20, 2024
1 parent 032038f commit 8483d64
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dogfooding/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
crypto: ^3.0.3
cupertino_icons: ^1.0.5
device_info_plus: ^9.0.3
device_info_plus: ^10.1.0
envied: ^0.3.0+3
firebase_auth: ^4.7.3
firebase_core: ^2.15.1
Expand Down
86 changes: 86 additions & 0 deletions packages/stream_video/lib/src/call/session/call_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import 'dart:convert';
import 'dart:io';

import 'package:collection/collection.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
import 'package:rxdart/rxdart.dart';
import 'package:system_info2/system_info2.dart';
import 'package:webrtc_interface/webrtc_interface.dart';

import '../../../protobuf/video/sfu/event/events.pb.dart' as sfu_events;
Expand Down Expand Up @@ -90,6 +92,8 @@ class CallSession extends Disposable {
StreamSubscription<Map<String, dynamic>>? _statsSubscription;
Timer? _peerConnectionCheckTimer;

sfu_models.ClientDetails? _clientDetails;

SharedEmitter<CallStats> get stats => _stats;
late final _stats = MutableSharedEmitterImpl<CallStats>();

Expand All @@ -107,10 +111,88 @@ class CallSession extends Disposable {
onCancel: () => Result.error('UpdateViewportVisibility cancelled'),
);

Future<void> _ensureClientDetails() async {
if (_clientDetails != null) return;

try {
sfu_models.Device? device;
sfu_models.Browser? browser;

var os = sfu_models.OS(
name: SysInfo.operatingSystemName,
version: SysInfo.operatingSystemVersion,
architecture: SysInfo.rawKernelArchitecture,
);

if (CurrentPlatform.isAndroid) {
final deviceInfo = await DeviceInfoPlugin().androidInfo;
os = sfu_models.OS(
name: 'Android',
version: deviceInfo.version.release,
architecture: SysInfo.rawKernelArchitecture,
);
device = sfu_models.Device(
name: '${deviceInfo.manufacturer} : ${deviceInfo.model}',
);
} else if (CurrentPlatform.isIos) {
final deviceInfo = await DeviceInfoPlugin().iosInfo;
os = sfu_models.OS(
name: 'iOS',
version: deviceInfo.systemVersion,
architecture: SysInfo.rawKernelArchitecture,
);
device = sfu_models.Device(
name: deviceInfo.model,
);
} else if (CurrentPlatform.isWeb) {
final browserInfo = await DeviceInfoPlugin().webBrowserInfo;
browser = sfu_models.Browser(
name: browserInfo.browserName.name,
version: browserInfo.vendorSub,
);
} else if (CurrentPlatform.isMacOS) {
final deviceInfo = await DeviceInfoPlugin().macOsInfo;
device = sfu_models.Device(
name: deviceInfo.model,
version: deviceInfo.osRelease,
);
} else if (CurrentPlatform.isWindows) {
final deviceInfo = await DeviceInfoPlugin().windowsInfo;
device = sfu_models.Device(
name: deviceInfo.productName,
version: deviceInfo.buildNumber.toString(),
);
} else if (CurrentPlatform.isLinux) {
final deviceInfo = await DeviceInfoPlugin().linuxInfo;
device = sfu_models.Device(
name: deviceInfo.name,
version: deviceInfo.version,
);
}

final versionSplit = streamVideoVersion.split('.');
_clientDetails = sfu_models.ClientDetails(
sdk: sfu_models.Sdk(
type: sfu_models.SdkType.SDK_TYPE_FLUTTER,
major: versionSplit.first,
minor: versionSplit.skip(1).first,
patch: versionSplit.last,
),
os: os,
device: device,
browser: browser,
);
} catch (e) {
_logger.e(() => '[_ensureClientDetails] failed: $e');
}
}

Future<Result<None>> start() async {
try {
_logger.d(() => '[start] no args');

await _ensureClientDetails();

await _eventsSubscription?.cancel();
await _rtcManagerSubject?.close();

Expand Down Expand Up @@ -140,6 +222,7 @@ class CallSession extends Disposable {
sfuWS.send(
sfu_events.SfuRequest(
joinRequest: sfu_events.JoinRequest(
clientDetails: _clientDetails,
token: config.sfuToken,
sessionId: sessionId,
subscriberSdp: genericSdp,
Expand Down Expand Up @@ -202,13 +285,16 @@ class CallSession extends Disposable {
final genericSdp = await RtcManager.getGenericSdp();
_logger.v(() => '[fastReconnect] genericSdp.len: ${genericSdp.length}');

await _ensureClientDetails();

await _eventsSubscription?.cancel();
_eventsSubscription = sfuWS.events.listen(_onSfuEvent);
await sfuWS.connect();

sfuWS.send(
sfu_events.SfuRequest(
joinRequest: sfu_events.JoinRequest(
clientDetails: _clientDetails,
token: config.sfuToken,
sessionId: sessionId,
subscriberSdp: genericSdp,
Expand Down
2 changes: 2 additions & 0 deletions packages/stream_video/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
collection: ^1.18.0
connectivity_plus: ^6.0.3
dart_webrtc: ^1.4.0
device_info_plus: ^10.1.0
equatable: ^2.0.5
fixnum: ^1.1.0
flutter:
Expand All @@ -30,6 +31,7 @@ dependencies:
sdp_transform: ^0.3.2
state_notifier: ^1.0.0
synchronized: ^3.1.0
system_info2: ^4.0.0
tart: ^0.5.1
uuid: ^4.2.1
web: ^0.5.1
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ environment:

dependencies:
cupertino_icons: ^1.0.5
device_info_plus: ^9.0.3
device_info_plus: ^10.1.0
envied: ^0.3.0+3
flutter:
sdk: flutter
Expand Down

0 comments on commit 8483d64

Please sign in to comment.