Organize events (#13)
* move internal events & remove unused events * `TrackUnpublishedEvent` for local tracks * update example since we have local track unpublish events * use flutter_webrtc 0.6.9
This commit is contained in:
@@ -47,11 +47,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
|||||||
|
|
||||||
void _unpublishAll() async {
|
void _unpublishAll() async {
|
||||||
final result = await context.showUnPublishDialog();
|
final result = await context.showUnPublishDialog();
|
||||||
if (result == true) {
|
if (result == true) await participant.unpublishAllTracks();
|
||||||
await participant.unpublishAllTracks();
|
|
||||||
// Force to update UI for now
|
|
||||||
participant.notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _muteAudio() {
|
void _muteAudio() {
|
||||||
|
|||||||
@@ -110,12 +110,10 @@ packages:
|
|||||||
flutter_webrtc:
|
flutter_webrtc:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
path: "."
|
name: flutter_webrtc
|
||||||
ref: master
|
url: "https://pub.dartlang.org"
|
||||||
resolved-ref: "32d83d85fa2faebcd37a19534f8a84273b12cbce"
|
source: hosted
|
||||||
url: "https://github.com/flutter-webrtc/flutter-webrtc"
|
version: "0.6.9"
|
||||||
source: git
|
|
||||||
version: "0.6.8"
|
|
||||||
google_fonts:
|
google_fonts:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/// Flutter Client SDK to LiveKit.
|
/// Flutter Client SDK to LiveKit.
|
||||||
library livekit_client;
|
library livekit_client;
|
||||||
|
|
||||||
export 'src/exceptions.dart';
|
|
||||||
export 'src/events.dart';
|
export 'src/events.dart';
|
||||||
|
export 'src/exceptions.dart';
|
||||||
export 'src/livekit.dart';
|
export 'src/livekit.dart';
|
||||||
export 'src/managers/event.dart';
|
export 'src/managers/event.dart';
|
||||||
export 'src/options.dart';
|
export 'src/options.dart';
|
||||||
@@ -21,5 +21,5 @@ export 'src/track/remote_track_publication.dart';
|
|||||||
export 'src/track/track.dart';
|
export 'src/track/track.dart';
|
||||||
export 'src/track/track_publication.dart';
|
export 'src/track/track_publication.dart';
|
||||||
export 'src/track/video_track.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';
|
export 'src/widget/video_track_renderer.dart';
|
||||||
|
|||||||
+2
-67
@@ -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
|
/// When a new [Track] is published to [Room] *after* the current participant has
|
||||||
/// joined. It will not fire for tracks that are already published.
|
/// joined. It will not fire for tracks that are already published.
|
||||||
/// Emitted by [Room] and [RemoteParticipant].
|
/// Emitted by [Room] and [RemoteParticipant].
|
||||||
@@ -87,8 +83,8 @@ class TrackPublishedEvent with RoomEvent, ParticipantEvent {
|
|||||||
/// The participant has unpublished one of their [Track].
|
/// The participant has unpublished one of their [Track].
|
||||||
/// Emitted by [Room] and [RemoteParticipant].
|
/// Emitted by [Room] and [RemoteParticipant].
|
||||||
class TrackUnpublishedEvent with RoomEvent, ParticipantEvent {
|
class TrackUnpublishedEvent with RoomEvent, ParticipantEvent {
|
||||||
final RemoteParticipant participant;
|
final Participant participant;
|
||||||
final RemoteTrackPublication publication;
|
final TrackPublication publication;
|
||||||
const TrackUnpublishedEvent({
|
const TrackUnpublishedEvent({
|
||||||
required this.participant,
|
required this.participant,
|
||||||
required this.publication,
|
required this.publication,
|
||||||
@@ -217,13 +213,6 @@ class EngineReconnectedEvent with EngineEvent {
|
|||||||
const EngineReconnectedEvent();
|
const EngineReconnectedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// class EngineParticipantUpdateEvent with EngineEvent {
|
|
||||||
// final List<lk_models.ParticipantInfo> participants;
|
|
||||||
// const EngineParticipantUpdateEvent({
|
|
||||||
// required this.participants,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
class EngineTrackAddedEvent with EngineEvent {
|
class EngineTrackAddedEvent with EngineEvent {
|
||||||
final rtc.MediaStreamTrack track;
|
final rtc.MediaStreamTrack track;
|
||||||
final rtc.MediaStream stream;
|
final rtc.MediaStream stream;
|
||||||
@@ -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
|
// Signal events
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -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,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -151,14 +151,11 @@ class LocalParticipant extends Participant {
|
|||||||
|
|
||||||
/// Unpublish a track that's already published
|
/// Unpublish a track that's already published
|
||||||
@override
|
@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');
|
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||||
final pub = trackPublications.remove(trackSid);
|
final pub = trackPublications.remove(trackSid);
|
||||||
if (pub is! LocalTrackPublication) return;
|
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;
|
final track = pub.track;
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
await track.stop();
|
await track.stop();
|
||||||
@@ -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.
|
/// Publish a new data payload to the room.
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class RemoteParticipant extends Participant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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');
|
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||||
final pub = trackPublications.remove(trackSid);
|
final pub = trackPublications.remove(trackSid);
|
||||||
if (pub is! RemoteTrackPublication) return;
|
if (pub is! RemoteTrackPublication) return;
|
||||||
@@ -166,10 +166,6 @@ class RemoteParticipant extends Participant {
|
|||||||
track: track,
|
track: track,
|
||||||
publication: pub,
|
publication: pub,
|
||||||
));
|
));
|
||||||
|
|
||||||
// if (track is AudioTrack) {
|
|
||||||
// await AudioManager().decrementSubscriptionCounter();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notify) {
|
if (notify) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'constants.dart';
|
|||||||
import 'events.dart';
|
import 'events.dart';
|
||||||
import 'exceptions.dart';
|
import 'exceptions.dart';
|
||||||
import 'extensions.dart';
|
import 'extensions.dart';
|
||||||
|
import 'internal/events.dart';
|
||||||
import 'logger.dart';
|
import 'logger.dart';
|
||||||
import 'managers/delay.dart';
|
import 'managers/delay.dart';
|
||||||
import 'managers/event.dart';
|
import 'managers/event.dart';
|
||||||
|
|||||||
+4
-6
@@ -98,12 +98,10 @@ packages:
|
|||||||
flutter_webrtc:
|
flutter_webrtc:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
name: flutter_webrtc
|
||||||
ref: master
|
url: "https://pub.dartlang.org"
|
||||||
resolved-ref: "32d83d85fa2faebcd37a19534f8a84273b12cbce"
|
source: hosted
|
||||||
url: "https://github.com/flutter-webrtc/flutter-webrtc"
|
version: "0.6.9"
|
||||||
source: git
|
|
||||||
version: "0.6.8"
|
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
+1
-7
@@ -16,13 +16,7 @@ dependencies:
|
|||||||
uuid: ^3.0.4
|
uuid: ^3.0.4
|
||||||
synchronized: ^3.0.0
|
synchronized: ^3.0.0
|
||||||
protobuf: ^2.0.0
|
protobuf: ^2.0.0
|
||||||
|
flutter_webrtc: ^0.6.9
|
||||||
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
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user