Skip to content
Merged
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
6 changes: 1 addition & 5 deletions example/lib/widgets/controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {

void _unpublishAll() async {
final result = await context.showUnPublishDialog();
if (result == true) {
await participant.unpublishAllTracks();
// Force to update UI for now
participant.notifyListeners();
}
if (result == true) await participant.unpublishAllTracks();
}

void _muteAudio() {
Expand Down
10 changes: 4 additions & 6 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ packages:
flutter_webrtc:
dependency: transitive
description:
path: "."
ref: master
resolved-ref: "32d83d85fa2faebcd37a19534f8a84273b12cbce"
url: "https://github.com/flutter-webrtc/flutter-webrtc"
source: git
version: "0.6.8"
name: flutter_webrtc
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.9"
google_fonts:
dependency: "direct main"
description:
Expand Down
4 changes: 2 additions & 2 deletions lib/livekit_client.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Flutter Client SDK to LiveKit.
library livekit_client;

export 'src/exceptions.dart';
export 'src/events.dart';
export 'src/exceptions.dart';
export 'src/livekit.dart';
export 'src/managers/event.dart';
export 'src/options.dart';
Expand All @@ -21,5 +21,5 @@ export 'src/track/remote_track_publication.dart';
export 'src/track/track.dart';
export 'src/track/track_publication.dart';
export 'src/track/video_track.dart';
export 'src/types.dart' show RTCConfiguration, RTCIceServer, RTCIceTransportPolicy, Reliability;
export 'src/types.dart';
export 'src/widget/video_track_renderer.dart';
69 changes: 2 additions & 67 deletions lib/src/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class ActiveSpeakersChangedEvent with RoomEvent {
});
}

class AudioPlaybackChangedEvent with RoomEvent {
const AudioPlaybackChangedEvent();
}

/// When a new [Track] is published to [Room] *after* the current participant has
/// joined. It will not fire for tracks that are already published.
/// Emitted by [Room] and [RemoteParticipant].
Expand All @@ -87,8 +83,8 @@ class TrackPublishedEvent with RoomEvent, ParticipantEvent {
/// The participant has unpublished one of their [Track].
/// Emitted by [Room] and [RemoteParticipant].
class TrackUnpublishedEvent with RoomEvent, ParticipantEvent {
final RemoteParticipant participant;
final RemoteTrackPublication publication;
final Participant participant;
final TrackPublication publication;
const TrackUnpublishedEvent({
required this.participant,
required this.publication,
Expand Down Expand Up @@ -217,13 +213,6 @@ class EngineReconnectedEvent with EngineEvent {
const EngineReconnectedEvent();
}

// class EngineParticipantUpdateEvent with EngineEvent {
// final List<lk_models.ParticipantInfo> participants;
// const EngineParticipantUpdateEvent({
// required this.participants,
// });
// }

class EngineTrackAddedEvent with EngineEvent {
final rtc.MediaStreamTrack track;
final rtc.MediaStream stream;
Expand Down Expand Up @@ -253,60 +242,6 @@ class EngineRemoteMuteChangedEvent with EngineEvent {
});
}

// added
abstract class EngineIceStateUpdatedEvent with EngineEvent {
final rtc.RTCIceConnectionState iceState;
final bool isPrimary;
const EngineIceStateUpdatedEvent({
required this.iceState,
required this.isPrimary,
});
}

class EngineSubscriberIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
const EngineSubscriberIceStateUpdatedEvent({
required rtc.RTCIceConnectionState state,
required bool isPrimary,
}) : super(
iceState: state,
isPrimary: isPrimary,
);
}

class EnginePublisherIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
const EnginePublisherIceStateUpdatedEvent({
required rtc.RTCIceConnectionState state,
required bool isPrimary,
}) : super(
iceState: state,
isPrimary: isPrimary,
);
}

//
// Track events
//

class TrackMessageEvent with TrackEvent {
const TrackMessageEvent();
}

class TrackUpdateSettingsEvent with TrackEvent {
const TrackUpdateSettingsEvent();
}

class TrackUpdateSubscriptionEvent with TrackEvent {
const TrackUpdateSubscriptionEvent();
}

class TrackAudioPlaybackStartedEvent with TrackEvent {
const TrackAudioPlaybackStartedEvent();
}

class TrackAudioPlaybackFailedEvent with TrackEvent {
const TrackAudioPlaybackFailedEvent();
}

//
// Signal events
//
Expand Down
37 changes: 37 additions & 0 deletions lib/src/internal/events.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// added
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
import 'package:meta/meta.dart';

import '../events.dart';

@internal
abstract class EngineIceStateUpdatedEvent with EngineEvent {
final rtc.RTCIceConnectionState iceState;
final bool isPrimary;
const EngineIceStateUpdatedEvent({
required this.iceState,
required this.isPrimary,
});
}

@internal
class EngineSubscriberIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
const EngineSubscriberIceStateUpdatedEvent({
required rtc.RTCIceConnectionState state,
required bool isPrimary,
}) : super(
iceState: state,
isPrimary: isPrimary,
);
}

@internal
class EnginePublisherIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
const EnginePublisherIceStateUpdatedEvent({
required rtc.RTCIceConnectionState state,
required bool isPrimary,
}) : super(
iceState: state,
isPrimary: isPrimary,
);
}
12 changes: 8 additions & 4 deletions lib/src/participant/local_participant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,11 @@ class LocalParticipant extends Participant {

/// Unpublish a track that's already published
@override
Future<void> unpublishTrack(String trackSid, {bool notify = false}) async {
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
final pub = trackPublications.remove(trackSid);
if (pub is! LocalTrackPublication) return;

// final existing = tracks.values.where((element) => element.track == track);
// if (existing.isEmpty) return;
// final pub = existing.first;
final track = pub.track;
if (track != null) {
await track.stop();
Expand All @@ -178,6 +175,13 @@ class LocalParticipant extends Participant {
}
}
}

if (notify) {
[events, roomEvents].emit(TrackUnpublishedEvent(
participant: this,
publication: pub,
));
}
}

/// Publish a new data payload to the room.
Expand Down
6 changes: 1 addition & 5 deletions lib/src/participant/remote_participant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class RemoteParticipant extends Participant {
}

@override
Future<void> unpublishTrack(String trackSid, {bool notify = false}) async {
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
final pub = trackPublications.remove(trackSid);
if (pub is! RemoteTrackPublication) return;
Expand All @@ -166,10 +166,6 @@ class RemoteParticipant extends Participant {
track: track,
publication: pub,
));

// if (track is AudioTrack) {
// await AudioManager().decrementSubscriptionCounter();
// }
}

if (notify) {
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'constants.dart';
import 'events.dart';
import 'exceptions.dart';
import 'extensions.dart';
import 'internal/events.dart';
import 'logger.dart';
import 'managers/delay.dart';
import 'managers/event.dart';
Expand Down
10 changes: 4 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ packages:
flutter_webrtc:
dependency: "direct main"
description:
path: "."
ref: master
resolved-ref: "32d83d85fa2faebcd37a19534f8a84273b12cbce"
url: "https://github.com/flutter-webrtc/flutter-webrtc"
source: git
version: "0.6.8"
name: flutter_webrtc
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.9"
http:
dependency: "direct main"
description:
Expand Down
10 changes: 2 additions & 8 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ dependencies:
logging: ^1.0.2
uuid: ^3.0.4
synchronized: ^3.0.0
protobuf: ^2.0.0

flutter_webrtc:
# This will use custom webrtc build from
# https://github.com/webrtc-sdk/Specs/releases
git:
url: https://github.com/flutter-webrtc/flutter-webrtc
ref: master
protobuf: ^2.0.0
flutter_webrtc: ^0.6.9

dev_dependencies:
flutter_test:
Expand Down