forked from flutter-webrtc/flutter-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia_stream_track.dart
53 lines (44 loc) · 1.28 KB
/
media_stream_track.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'dart:async';
import 'package:flutter/services.dart';
import 'utils.dart';
class MediaStreamTrack {
MethodChannel _channel = WebRTC.methodChannel();
String _trackId;
String _label;
String _kind;
bool _enabled;
MediaStreamTrack(this._trackId, this._label, this._kind, this._enabled);
set enabled(bool enabled) {
_channel.invokeMethod('mediaStreamTrackSetEnable',
<String, dynamic>{'trackId': _trackId, 'enabled': enabled});
_enabled = enabled;
}
bool get enabled => _enabled;
String get label => _label;
String get kind => _kind;
String get id => _trackId;
///Future contains isFrontCamera
///Throws error if switching camera failed
Future<bool> switchCamera() =>
_channel.invokeMethod(
'mediaStreamTrackSwitchCamera',
<String, dynamic>{'trackId': _trackId},
);
void setVolume(double volume) async {
await _channel.invokeMethod(
'setVolume',
<String, dynamic>{'trackId': _trackId, 'volume': volume},
);
}
captureFrame(String filePath) =>
_channel.invokeMethod(
'captureFrame',
<String, dynamic>{'trackId':_trackId, 'path': filePath},
);
Future<void> dispose() async {
await _channel.invokeMethod(
'trackDispose',
<String, dynamic>{'trackId': _trackId},
);
}
}