Documentation

This commit is contained in:
David Zhao
2021-08-30 15:31:12 -07:00
parent 583e08c5b1
commit d011bc7d3d
19 changed files with 383 additions and 16 deletions
+2
View File
@@ -11,6 +11,8 @@ class AudioTrack extends Track {
AudioTrack(String name, MediaStreamTrack track, this.mediaStream)
: super(TrackType.AUDIO, name, track);
/// Start playing audio track. On web platform, create an audio element and
/// start playback
start() {
if (!(this is LocalAudioTrack)) {
audio.startAudio(getCid(), mediaTrack);
+1
View File
@@ -8,6 +8,7 @@ class LocalAudioTrack extends AudioTrack {
LocalAudioTrack(String name, MediaStreamTrack track, MediaStream stream)
: super(name, track, stream);
/// Creates a new audio track from the default audio input device.
static Future<LocalAudioTrack> createTrack(
[LocalAudioTrackOptions? options]) async {
try {
@@ -11,6 +11,7 @@ class LocalTrackPublication extends TrackPublication {
this.track = track;
}
/// Mute or unmute the current track. When muted, track will stop sending data
set muted(bool val) {
if (val == muted) {
return;
+5
View File
@@ -4,12 +4,15 @@ import '../errors.dart';
import 'options.dart';
import 'video_track.dart';
/// A video track from the local device. Use static methods in this class to create
/// video tracks.
class LocalVideoTrack extends VideoTrack {
RTCRtpSender? get sender => transceiver?.sender;
LocalVideoTrack(String name, MediaStreamTrack mediaTrack, MediaStream stream)
: super(name, mediaTrack, stream);
/// Creates a LocalVideoTrack from camera input.
static Future<LocalVideoTrack> createCameraTrack(
[LocalVideoTrackOptions? options]) async {
if (options == null) {
@@ -24,6 +27,8 @@ class LocalVideoTrack extends VideoTrack {
}
}
/// Restarts the track with new options. This is useful when switching between
/// front and back cameras.
Future<void> restartTrack([LocalVideoTrackOptions? options]) async {
if (sender == null) {
return Future.error(TrackCreateError('could not restart track'));
+2
View File
@@ -1,3 +1,4 @@
/// Options when creating a LocalVideoTrack.
class LocalVideoTrackOptions {
CameraPosition position = CameraPosition.FRONT;
VideoParameter params;
@@ -65,4 +66,5 @@ class VideoPresets {
];
}
/// Options when creating an LocalAudioTrack. Placeholder for now.
class LocalAudioTrackOptions {}
@@ -4,6 +4,8 @@ import '../participant/remote_participant.dart';
import 'track.dart';
import 'track_publication.dart';
/// Represents a track publication from a RemoteParticipant. Provides methods to
/// control if we should subscribe to the track, and its quality (for video).
class RemoteTrackPublication extends TrackPublication {
RemoteParticipant _participant;
bool _unsubscribed = false;
@@ -37,6 +39,8 @@ class RemoteTrackPublication extends TrackPublication {
_sendUpdateTrackSettings();
}
/// for internal use
/// {@nodoc}
set muted(bool val) {
if (val == muted) {
return;
+1
View File
@@ -10,6 +10,7 @@ class TrackDimension {
TrackDimension(this.width, this.height);
}
/// Wrapper around a MediaStreamTrack with additional metadata.
class Track {
static const ScreenShareName = "screen";
+3
View File
@@ -1,6 +1,8 @@
import '../proto/livekit_models.pb.dart';
import 'track.dart';
/// Represents a track that's published to the server. This class contains
/// metadata associated with tracks.
class TrackPublication {
Track? track;
String name;
@@ -19,6 +21,7 @@ class TrackPublication {
updateFromInfo(info);
}
/// True when the track is published with name [Track.ScreenShareName].
bool get isScreenShare =>
kind == TrackType.VIDEO && name == Track.ScreenShareName;
+2
View File
@@ -13,6 +13,8 @@ class VideoTrack extends Track with ChangeNotifier {
MediaStream? get mediaStream => _mediaStream;
/// internal use
/// {@nodoc}
set mediaStream(MediaStream? stream) {
_mediaStream = stream;
notifyListeners();