Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example for manual subscription. #431

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions example/lib/pages/connect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class _ConnectPageState extends State<ConnectPage> {
static const _storeKeyE2EE = 'e2ee';
static const _storeKeySharedKey = 'shared-key';
static const _storeKeyMultiCodec = 'multi-codec';
static const _storeKeyAutoSubscribe = 'auto-subscribe';

final _uriCtrl = TextEditingController();
final _tokenCtrl = TextEditingController();
Expand All @@ -38,6 +39,7 @@ class _ConnectPageState extends State<ConnectPage> {
bool _busy = false;
bool _e2ee = false;
bool _multiCodec = false;
bool _autoSubscribe = false;
String _preferredCodec = 'Preferred Codec';

@override
Expand Down Expand Up @@ -96,6 +98,7 @@ class _ConnectPageState extends State<ConnectPage> {
_dynacast = prefs.getBool(_storeKeyDynacast) ?? true;
_e2ee = prefs.getBool(_storeKeyE2EE) ?? false;
_multiCodec = prefs.getBool(_storeKeyMultiCodec) ?? false;
_autoSubscribe = prefs.getBool(_storeKeyAutoSubscribe) ?? true;
});
}

Expand All @@ -110,6 +113,7 @@ class _ConnectPageState extends State<ConnectPage> {
await prefs.setBool(_storeKeyDynacast, _dynacast);
await prefs.setBool(_storeKeyE2EE, _e2ee);
await prefs.setBool(_storeKeyMultiCodec, _multiCodec);
await prefs.setBool(_storeKeyAutoSubscribe, _autoSubscribe);
}

Future<void> _connect(BuildContext ctx) async {
Expand Down Expand Up @@ -139,6 +143,7 @@ class _ConnectPageState extends State<ConnectPage> {
e2ee: _e2ee,
e2eeKey: e2eeKey,
simulcast: _simulcast,
autoSubscribe: _autoSubscribe,
adaptiveStream: _adaptiveStream,
dynacast: _dynacast,
preferredCodec: _preferredCodec,
Expand All @@ -164,6 +169,13 @@ class _ConnectPageState extends State<ConnectPage> {
});
}

void _setAutoSubscribe(bool? value) async {
if (value == null || _autoSubscribe == value) return;
setState(() {
_autoSubscribe = value;
});
}

void _setE2EE(bool? value) async {
if (value == null || _e2ee == value) return;
setState(() {
Expand Down Expand Up @@ -260,6 +272,19 @@ class _ConnectPageState extends State<ConnectPage> {
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Auto Subscribe'),
Switch(
value: _autoSubscribe,
onChanged: (value) => _setAutoSubscribe(value),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 5),
child: Row(
Expand Down
5 changes: 5 additions & 0 deletions example/lib/pages/prejoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class JoinArgs {
this.e2ee = false,
this.e2eeKey,
this.simulcast = true,
this.autoSubscribe = true,
this.adaptiveStream = true,
this.dynacast = true,
this.preferredCodec = 'VP8',
Expand All @@ -27,6 +28,7 @@ class JoinArgs {
final bool e2ee;
final String? e2eeKey;
final bool simulcast;
final bool autoSubscribe;
final bool adaptiveStream;
final bool dynacast;
final String preferredCodec;
Expand Down Expand Up @@ -209,6 +211,9 @@ class _PreJoinPageState extends State<PreJoinPage> {
maxFrameRate: 30, params: _selectedVideoParameters),
e2eeOptions: e2eeOptions,
),
connectOptions: ConnectOptions(
autoSubscribe: args.autoSubscribe,
),
fastConnectOptions: FastConnectOptions(
microphone: TrackOption(track: _audioTrack),
camera: TrackOption(track: _videoTrack),
Expand Down
Loading
Loading