Video optimizations (#18)
* use events for `VideoTrackRenderer` * logger * implemented visibility detection * optimize code with 1 param debounce func * stop pending visibility event when disposed * clean up * mark internal * report to track * call dispose on pub and track * use internal events to receive visibility events * clean up visibility for disposed track * listen to track visibility events on pub * re-design * quickly re-enable * clean up * clean up
This commit is contained in:
@@ -45,37 +45,29 @@ class LocalParticipant extends Participant {
|
||||
throw TrackPublishException('track already exists');
|
||||
}
|
||||
|
||||
// await AudioManager().incrementPublishCounter();
|
||||
final trackInfo = await engine.addTrack(
|
||||
cid: track.getCid(),
|
||||
name: track.name,
|
||||
kind: track.kind,
|
||||
);
|
||||
|
||||
try {
|
||||
final trackInfo = await engine.addTrack(
|
||||
cid: track.getCid(),
|
||||
name: track.name,
|
||||
kind: track.kind,
|
||||
);
|
||||
await track.start();
|
||||
|
||||
await track.start();
|
||||
final transceiverInit = rtc.RTCRtpTransceiverInit(
|
||||
direction: rtc.TransceiverDirection.SendOnly,
|
||||
);
|
||||
// addTransceiver cannot pass in a kind parameter due to a bug in flutter-webrtc (web)
|
||||
track.transceiver = await engine.publisher?.pc.addTransceiver(
|
||||
track: track.mediaStreamTrack,
|
||||
kind: rtc.RTCRtpMediaType.RTCRtpMediaTypeAudio,
|
||||
init: transceiverInit,
|
||||
);
|
||||
await engine.negotiate();
|
||||
|
||||
final transceiverInit = rtc.RTCRtpTransceiverInit(
|
||||
direction: rtc.TransceiverDirection.SendOnly,
|
||||
);
|
||||
// addTransceiver cannot pass in a kind parameter due to a bug in flutter-webrtc (web)
|
||||
track.transceiver = await engine.publisher?.pc.addTransceiver(
|
||||
track: track.mediaStreamTrack,
|
||||
kind: rtc.RTCRtpMediaType.RTCRtpMediaTypeAudio,
|
||||
init: transceiverInit,
|
||||
);
|
||||
await engine.negotiate();
|
||||
|
||||
final pub = LocalTrackPublication(trackInfo, track, this);
|
||||
addTrackPublication(pub);
|
||||
notifyListeners();
|
||||
return pub;
|
||||
} catch (e) {
|
||||
// In any case there was an exception, revert the count.
|
||||
// await AudioManager().decrementPublishCounter();
|
||||
rethrow;
|
||||
}
|
||||
final pub = LocalTrackPublication(trackInfo, track, this);
|
||||
addTrackPublication(pub);
|
||||
notifyListeners();
|
||||
return pub;
|
||||
}
|
||||
|
||||
/// Publish a video track to the room
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'participant.dart';
|
||||
/// Represents other participant in the [Room].
|
||||
class RemoteParticipant extends Participant {
|
||||
final SignalClient _client;
|
||||
|
||||
SignalClient get client => _client;
|
||||
|
||||
RemoteParticipant(
|
||||
@@ -92,8 +91,6 @@ class RemoteParticipant extends Participant {
|
||||
final Track track;
|
||||
if (pub.kind == lk_models.TrackType.AUDIO) {
|
||||
// audio track
|
||||
// await AudioManager().incrementSubscriptionCounter();
|
||||
|
||||
final audioTrack = AudioTrack(pub.name, mediaTrack, stream);
|
||||
await audioTrack.start();
|
||||
track = audioTrack;
|
||||
@@ -162,7 +159,7 @@ class RemoteParticipant extends Participant {
|
||||
if (pub is! RemoteTrackPublication) {
|
||||
// no publication exists for trackSid
|
||||
// or publication is not RemoteTrackPublication
|
||||
// logger.warning('pub is not RemoteTrackPublication');
|
||||
|
||||
await pub?.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user