Skip to content

Commit

Permalink
Added SIP support
Browse files Browse the repository at this point in the history
  • Loading branch information
Decoder07 committed Mar 27, 2024
1 parent f23908c commit 4f0aa02
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 91 deletions.
7 changes: 7 additions & 0 deletions packages/hms_room_kit/lib/src/assets/icons/sip_call.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import 'package:tuple/tuple.dart';
import 'package:hmssdk_flutter/hmssdk_flutter.dart';

///Project imports
import 'package:hms_room_kit/hms_room_kit.dart';
import 'package:hms_room_kit/src/widgets/toasts/hms_toasts_type.dart';
import 'package:hms_room_kit/src/layout_api/hms_room_layout.dart';
import 'package:hms_room_kit/src/layout_api/hms_theme_colors.dart';
import 'package:hms_room_kit/src/model/participant_store.dart';
import 'package:hms_room_kit/src/widgets/common_widgets/hms_subheading_text.dart';
import 'package:hms_room_kit/src/widgets/bottom_sheets/participants_view_all_bottom_sheet.dart';
import 'package:hms_room_kit/src/model/peer_track_node.dart';
import 'package:hms_room_kit/src/widgets/common_widgets/hms_title_text.dart';
import 'package:hms_room_kit/src/meeting/meeting_store.dart';

///[ParticipantsBottomSheet] is the bottom sheet that is shown when the user
Expand Down Expand Up @@ -483,26 +482,47 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
children: [
Selector<
ParticipantsStore,
int>(
selector: (_, participantsStore) => (participantsStore.peer.networkQuality?.quality ??
-1),
bool>(
builder: (_,
networkQuality,
isSIPPeer,
__) {
return networkQuality != -1 && networkQuality < 3
return isSIPPeer
? CircleAvatar(
radius: 16,
backgroundColor: HMSThemeColors.surfaceBright,
child: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/sip_call.svg",
height: 12,
width: 12,
colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn),
))
: const SizedBox();
},
selector: (_, participantsStore) =>
participantsStore.peer.type ==
HMSPeerType.sip),
Selector<
ParticipantsStore,
Tuple2<int,
bool>>(
selector: (_, participantsStore) => Tuple2(
participantsStore.peer.networkQuality?.quality ?? -1,
participantsStore.peer.type != HMSPeerType.sip),
builder: (_, participantData, __) {
return participantData.item1 != -1 && participantData.item1 < 3 && participantData.item2
? Padding(
padding: const EdgeInsets.only(right: 16.0),
child: CircleAvatar(
radius: 16,
backgroundColor: HMSThemeColors.surfaceDefault,
child: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/network_$networkQuality.svg",
"packages/hms_room_kit/lib/src/assets/icons/network_${participantData.item1}.svg",
height: 16,
width: 16,
),
),
)
: Container();
: const SizedBox();
}),
Selector<
ParticipantsStore,
Expand All @@ -527,7 +547,7 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
),
),
)
: Container();
: const SizedBox();
}),
_kebabMenu(
currentPeer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ class _RecipientSelectorWidgetState extends State<RecipientSelectorWidget> {
child: Column(
children: data.item1
.where((peer) =>
peer.isLocal == false)

///Don't show local and SIP peers
peer.isLocal == false &&
peer.type != HMSPeerType.sip)
.map((peer) => ListTile(
onTap: () {
setState(() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
///Package imports
library;

///Package import
import 'package:flutter/cupertino.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:hmssdk_flutter/hmssdk_flutter.dart';

///Project imports
import 'package:hms_room_kit/src/layout_api/hms_theme_colors.dart';
import 'package:hms_room_kit/src/model/peer_track_node.dart';
import 'package:hms_room_kit/src/widgets/peer_widgets/network_icon_widget.dart';
import 'package:hms_room_kit/src/widgets/peer_widgets/peer_name.dart';

Expand Down Expand Up @@ -35,6 +39,16 @@ class NameAndNetwork extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
///Phone icon is only rendered if its a SIP peer
if (context.read<PeerTrackNode>().peer.type == HMSPeerType.sip)
Padding(
padding: const EdgeInsets.only(right: 2.0),
child: SvgPicture.asset(
'packages/hms_room_kit/lib/src/assets/icons/sip_call.svg',
height: 12,
semanticsLabel: "fl_sip_call_icon_label",
),
),
PeerName(
maxWidth: maxWidth,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library;

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:hmssdk_flutter/hmssdk_flutter.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';

Expand All @@ -22,20 +23,24 @@ class NetworkIconWidget extends StatelessWidget {
return Selector<PeerTrackNode, Tuple2<int?, bool>>(
builder: (_, networkQuality, __) {
///If the track is degraded, we render the degraded network icon
///If the network quality is not null and not -1, we render the network icon
return networkQuality.item2
? SvgPicture.asset(
'packages/hms_room_kit/lib/src/assets/icons/degraded_network.svg',
height: 20,
semanticsLabel: "fl_network_icon_label",
)
: (networkQuality.item1 != null && networkQuality.item1 != -1)
///If the network quality is not null and not -1,
///and the peer is a regular peer
///we render the network icon
return context.read<PeerTrackNode>().peer.type == HMSPeerType.regular
? networkQuality.item2
? SvgPicture.asset(
'packages/hms_room_kit/lib/src/assets/icons/network_${networkQuality.item1}.svg',
'packages/hms_room_kit/lib/src/assets/icons/degraded_network.svg',
height: 20,
semanticsLabel: "fl_network_icon_label",
)
: Container();
: (networkQuality.item1 != null && networkQuality.item1 != -1)
? SvgPicture.asset(
'packages/hms_room_kit/lib/src/assets/icons/network_${networkQuality.item1}.svg',
height: 20,
semanticsLabel: "fl_network_icon_label",
)
: const SizedBox()
: const SizedBox();
},
selector: (_, peerTrackNode) => Tuple2(peerTrackNode.networkQuality,
peerTrackNode.track?.isDegraded ?? false));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///Package imports
library;

///Package imports
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';

///Project imports
import 'package:hms_room_kit/src/layout_api/hms_theme_colors.dart';
import 'package:hms_room_kit/hms_room_kit.dart';
import 'package:hms_room_kit/src/model/peer_track_node.dart';
import 'package:hms_room_kit/src/widgets/common_widgets/hms_subheading_text.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package live.hms.hmssdk_flutter

import live.hms.video.sdk.models.HMSPeer
import live.hms.video.sdk.models.HMSPeerType
import live.hms.video.sdk.models.enums.HMSPeerUpdate

class HMSPeerExtension {
Expand All @@ -14,6 +15,7 @@ class HMSPeerExtension {
args["is_local"] = peer.isLocal
args["role"] = HMSRoleExtension.toDictionary(peer.hmsRole)
args["metadata"] = peer.metadata
args["type"] = getValueFromPeerType(peer.type)
args["is_hand_raised"] = peer.isHandRaised
args["customer_user_id"] = peer.customerUserID
args["audio_track"] = HMSTrackExtension.toDictionary(peer.audioTrack)
Expand Down Expand Up @@ -45,5 +47,13 @@ class HMSPeerExtension {
else -> "defaultUpdate"
}
}

private fun getValueFromPeerType(peerType: HMSPeerType): String {
return when(peerType){
HMSPeerType.SIP -> "sip"
HMSPeerType.REGULAR -> "regular"
else -> "regular"
}
}
}
}
10 changes: 5 additions & 5 deletions packages/hmssdk_flutter/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ PODS:
- HMSHLSPlayerSDK (0.0.2):
- HMSAnalyticsSDK (= 0.0.2)
- HMSNoiseCancellationModels (1.0.0)
- HMSSDK (1.7.0):
- HMSSDK (1.8.0):
- HMSAnalyticsSDK (= 0.0.2)
- HMSWebRTC (= 1.0.5118)
- hmssdk_flutter (1.10.0):
- Flutter
- HMSBroadcastExtensionSDK (= 0.0.9)
- HMSHLSPlayerSDK (= 0.0.2)
- HMSNoiseCancellationModels (= 1.0.0)
- HMSSDK (= 1.7.0)
- HMSSDK (= 1.8.0)
- HMSWebRTC (1.0.5118)
- MLImage (1.0.0-beta4)
- MLKitBarcodeScanning (3.0.0):
Expand Down Expand Up @@ -293,8 +293,8 @@ SPEC CHECKSUMS:
HMSBroadcastExtensionSDK: d80fe325f6c928bd8e5176290b5a4b7ae15d6fbb
HMSHLSPlayerSDK: 6a54ad4d12f3dc2270d1ecd24019d71282a4f6a3
HMSNoiseCancellationModels: a3bda1405a16015632f4bcabd46ce48f35103b02
HMSSDK: 421b4ce83a601bbda283b3b9fbcd1da6898d2a84
hmssdk_flutter: 8f60b63db6286c0b92d9224585362ade6d7e1602
HMSSDK: c893d1381a47ed02760ef6d06625b9aa5251f998
hmssdk_flutter: 997715f0bedfcb22750fb95549672bf3fea380ff
HMSWebRTC: 4487c7200f1e9358412c1d8cd974edd2766467dc
MLImage: 7bb7c4264164ade9bf64f679b40fb29c8f33ee9b
MLKitBarcodeScanning: 04e264482c5f3810cb89ebc134ef6b61e67db505
Expand All @@ -313,4 +313,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 9fb9f6e431a2c6c79942252e94b241ac7972ac90

COCOAPODS: 1.15.2
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1340;
LastUpgradeCheck = 1510;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = 100ms;
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
12 changes: 12 additions & 0 deletions packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class HMSPeerExtension {
"peer_id": peer.peerID,
"name": peer.name,
"is_local": peer.isLocal,
"type": getPeerType(peer.type),
"is_hand_raised": peer.isHandRaised,
"customer_description": peer.metadata ?? "",
"customer_user_id": peer.customerUserID ?? "",
Expand Down Expand Up @@ -72,4 +73,15 @@ class HMSPeerExtension {
return "defaultUpdate"
}
}

private static func getPeerType(_ peerType: HMSPeerType) -> String {
switch peerType {
case .sip:
return "sip"
case .regular:
return "regular"
@unknown default:
return "regular"
}
}
}
2 changes: 1 addition & 1 deletion packages/hmssdk_flutter/lib/assets/sdk-versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"flutter": "1.10.0",
"ios": "1.7.0",
"ios": "1.8.0",
"iOSBroadcastExtension": "0.0.9",
"iOSHLSPlayerSDK": "0.0.2",
"iOSNoiseCancellationModels": "1.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/hmssdk_flutter/lib/hmssdk_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export 'src/enum/hms_simulcast_layer.dart';
export 'src/enum/hms_audio_mode.dart';
export 'src/enum/hms_hls_playback_state.dart';
export 'src/enum/hms_poll_enum.dart';
export 'src/enum/hms_peer_type.dart';

//EXCEPTIONS
export 'src/exceptions/hms_exception.dart';
Expand Down
13 changes: 13 additions & 0 deletions packages/hmssdk_flutter/lib/src/enum/hms_peer_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///[HMSPeerType] contains peer types i.e peer joined using SIP or using the application
enum HMSPeerType { sip, regular }

extension HMSPeerTypevalues on HMSPeerType {
static HMSPeerType getPeerTypeFromString(String peerType) {
switch (peerType) {
case "sip":
return HMSPeerType.sip;
default:
return HMSPeerType.regular;
}
}
}
54 changes: 29 additions & 25 deletions packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class HMSLocalPeer extends HMSPeer {
List<HMSTrack>? auxiliaryTracks,
HMSNetworkQuality? networkQuality,
DateTime? joinedAt,
DateTime? updatedAt})
DateTime? updatedAt,
HMSPeerType type = HMSPeerType.regular})
: super(
isLocal: isLocal,
name: name,
Expand All @@ -41,32 +42,35 @@ class HMSLocalPeer extends HMSPeer {
auxiliaryTracks: auxiliaryTracks,
networkQuality: networkQuality,
joinedAt: joinedAt,
updatedAt: updatedAt);
updatedAt: updatedAt,
type: type);

factory HMSLocalPeer.fromMap(Map map) {
return HMSLocalPeer(
peerId: map['peer_id'],
name: map['name'],
isLocal: map['is_local'],
isHandRaised: map['is_hand_raised'],
role: HMSRole.fromMap(map['role']),
metadata: map['metadata'],
customerUserId: map['customer_user_id'],
audioTrack: map["audio_track"] != null
? HMSLocalAudioTrack.fromMap(map: map["audio_track"])
: null,
videoTrack: map["video_track"] != null
? HMSLocalVideoTrack.fromMap(map: map["video_track"])
: null,
networkQuality: map["network_quality"] != null
? HMSNetworkQuality.fromMap(map["network_quality"])
: null,
joinedAt: map.containsKey("joined_at")
? HMSDateExtension.convertDateFromEpoch(map["joined_at"])
: null,
updatedAt: map.containsKey("updated_at")
? HMSDateExtension.convertDateFromEpoch(map["updated_at"])
: null,
);
peerId: map['peer_id'],
name: map['name'],
isLocal: map['is_local'],
isHandRaised: map['is_hand_raised'],
role: HMSRole.fromMap(map['role']),
metadata: map['metadata'],
customerUserId: map['customer_user_id'],
audioTrack: map["audio_track"] != null
? HMSLocalAudioTrack.fromMap(map: map["audio_track"])
: null,
videoTrack: map["video_track"] != null
? HMSLocalVideoTrack.fromMap(map: map["video_track"])
: null,
networkQuality: map["network_quality"] != null
? HMSNetworkQuality.fromMap(map["network_quality"])
: null,
joinedAt: map.containsKey("joined_at")
? HMSDateExtension.convertDateFromEpoch(map["joined_at"])
: null,
updatedAt: map.containsKey("updated_at")
? HMSDateExtension.convertDateFromEpoch(map["updated_at"])
: null,
type: map.containsKey("type")
? HMSPeerTypevalues.getPeerTypeFromString(map["type"])
: HMSPeerType.regular);
}
}
Loading

0 comments on commit 4f0aa02

Please sign in to comment.