Skip to content

Commit

Permalink
Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Sep 5, 2021
1 parent 22a3cbe commit 6aa63eb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
15 changes: 10 additions & 5 deletions lib/controllers/ion_controller.dart
Expand Up @@ -35,23 +35,28 @@ class IonController extends GetxController {
return _prefs!;
}

setup(host) {
setup(
{required String host,
required String room,
required String name}) async {
_baseConnector = new IonBaseConnector(host);
_biz = new IonAppBiz(_baseConnector!);
_sfu = new IonSDKSFU(_baseConnector!);
_sid = room;
_name = name;
}

connect() async {
await _biz!.connect();
await _sfu!.connect();
}

joinBIZ(String roomID, String displayName) async {
_biz!.join(sid: roomID, uid: _uid, info: {'name': '$displayName'});
joinBIZ() async {
_biz!.join(sid: _sid, uid: _uid, info: {'name': '$_name'});
}

joinSFU(String roomID, String displayName) async {
_sfu!.join(roomID, displayName);
joinSFU() async {
_sfu!.join(_sid, _uid);
}

close() async {
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Expand Up @@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: true,
unknownRoute: GetPage(name: 'not-found', page: () => NotFound()),
unknownRoute: GetPage(name: '/not-found', page: () => NotFound()),
enableLog: true,
theme: mDefaultTheme,
logWriterCallback: Logger.write,
Expand Down
12 changes: 6 additions & 6 deletions lib/pages/meeting/meeting_page.dart
Expand Up @@ -108,9 +108,12 @@ class MeetingController extends GetxController {
//https://your-backend-address.com
var host = prefs.getString('server') ?? '127.0.0.1';
host = 'http://' + host + ':5551';
//join BIZ
name.value = prefs.getString('display_name') ?? 'Guest';
room.value = prefs.getString('room') ?? 'room1';

//init sfu and biz clients
_ionController.setup(host);
_ionController.setup(host: host, name: name.value, room: room.value);

sfu!.ontrack = (MediaStreamTrack track, RemoteStream stream) async {
if (track.kind == 'video') {
Expand All @@ -123,7 +126,7 @@ class MeetingController extends GetxController {
if (success) {
try {
//join SFU
await sfu!.join(room.value, name.value);
await _ionController.joinSFU();

var resolution = prefs.getString('resolution') ?? 'hd';
var codec = prefs.getString('codec') ?? 'vp8';
Expand Down Expand Up @@ -188,10 +191,7 @@ class MeetingController extends GetxController {
//connect to BIZ and SFU
await _ionController.connect();

//join BIZ
name.value = prefs.getString('display_name') ?? 'Guest';
room.value = prefs.getString('room') ?? 'room1';
_ionController.joinBIZ(room.value, name.value);
_ionController.joinBIZ();
}

_removeAdapter(String mid) {
Expand Down
25 changes: 13 additions & 12 deletions lib/pages/settings/settings_page.dart
Expand Up @@ -169,10 +169,11 @@ class SettingsView extends GetView<SettingsController> {
),
Padding(
padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0),
child: Obx( () => _buildRowFixTitleRadio(
_codecItems, controller._codec.value, (value) {
controller._codec.value = value;
})),
child: Obx(() => _buildRowFixTitleRadio(
_codecItems, controller._codec.value,
(value) {
controller._codec.value = value;
})),
),
],
),
Expand All @@ -189,10 +190,10 @@ class SettingsView extends GetView<SettingsController> {
Padding(
padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0),
child: Obx(() => _buildRowFixTitleRadio(
_resolutionItems, controller._resolution.value,
(value) {
controller._resolution.value = value;
})),
_resolutionItems,
controller._resolution.value, (value) {
controller._resolution.value = value;
})),
),
],
),
Expand All @@ -209,10 +210,10 @@ class SettingsView extends GetView<SettingsController> {
Padding(
padding: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0),
child: Obx(() => _buildRowFixTitleRadio(
_bandwidthItems, controller._bandwidth.value,
(value) {
controller._bandwidth.value = value;
})),
_bandwidthItems, controller._bandwidth.value,
(value) {
controller._bandwidth.value = value;
})),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Expand Up @@ -23,7 +23,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
flutter_ion: ^0.5.3
flutter_ion: ^0.5.4
shared_preferences: ^2.0.5
date_format: ^2.0.2
quiver: ^3.0.0
Expand Down

0 comments on commit 6aa63eb

Please sign in to comment.