-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathrtc_video_renderer.dart
76 lines (59 loc) · 1.69 KB
/
rtc_video_renderer.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import 'media_stream.dart';
class RTCVideoValue {
const RTCVideoValue({
this.width = 0.0,
this.height = 0.0,
this.rotation = 0,
this.renderVideo = false,
});
static const RTCVideoValue empty = RTCVideoValue();
final double width;
final double height;
final int rotation;
final bool renderVideo;
double get aspectRatio {
if (width == 0.0 || height == 0.0) {
return 1.0;
}
return (rotation == 90 || rotation == 270)
? height / width
: width / height;
}
RTCVideoValue copyWith({
double? width,
double? height,
int? rotation,
bool renderVideo = true,
}) {
return RTCVideoValue(
width: width ?? this.width,
height: height ?? this.height,
rotation: rotation ?? this.rotation,
renderVideo: this.width != 0 && this.height != 0 && renderVideo,
);
}
@override
String toString() =>
'$runtimeType(width: $width, height: $height, rotation: $rotation)';
}
abstract class VideoRenderer {
VideoRenderer();
/// When the video size changes, or the native texture
/// changes (angle or size), notify the user to redraw the Widget.
Function? onResize;
/// When the first frame is rendered, notify the user that video started playing.
Function? onFirstFrameRendered;
int get videoWidth;
int get videoHeight;
RTCVideoValue get videoValue => RTCVideoValue();
bool get muted;
set muted(bool mute);
///Return true if the audioOutput have been succesfully changed
Future<bool> audioOutput(String deviceId);
bool get renderVideo;
int? get textureId;
Future<void> initialize();
MediaStream? get srcObject;
set srcObject(MediaStream? stream);
Future<void> dispose();
}