Skip to content

Commit 7b87c29

Browse files
committed
Update.
1 parent b38d5a8 commit 7b87c29

File tree

5 files changed

+131
-7
lines changed

5 files changed

+131
-7
lines changed

analysis_options.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
include: package:pedantic/analysis_options.yaml
2+
3+
linter:
4+
rules:
5+
- always_declare_return_types
6+
- avoid_empty_else
7+
- await_only_futures
8+
- avoid_returning_null_for_void
9+
- camel_case_extensions
10+
- camel_case_types
11+
- cancel_subscriptions
12+
- directives_ordering
13+
- flutter_style_todos
14+
- sort_constructors_first
15+
- sort_unnamed_constructors_first
16+
- sort_pub_dependencies
17+
- type_init_formals
18+
- unnecessary_brace_in_string_interps
19+
- unnecessary_const
20+
- unnecessary_new
21+
- unnecessary_getters_setters
22+
- unnecessary_null_aware_assignments
23+
- unnecessary_null_in_if_null_operators
24+
- unnecessary_overrides
25+
- unnecessary_parenthesis
26+
- unnecessary_statements
27+
- unnecessary_string_interpolations
28+
- unnecessary_this
29+
- unrelated_type_equality_checks
30+
- use_rethrow_when_possible
31+
- valid_regexps
32+
- void_checks
33+
34+
analyzer:
35+
errors:
36+
# treat missing required parameters as a warning (not a hint)
37+
missing_required_param: warning
38+
# treat missing returns as a warning (not a hint)
39+
missing_return: warning
40+
# allow having TODOs in the code
41+
todo: ignore
42+
# allow self-reference to deprecated members (we do this because otherwise we have
43+
# to annotate every member in every test, assert, etc, when we deprecate something)
44+
deprecated_member_use_from_same_package: ignore
45+
# Ignore analyzer hints for updating pubspecs when using Future or
46+
# Stream and not importing dart:async
47+
# Please see https://github.com/flutter/flutter/pull/24528 for details.
48+
sdk_version_async_exported_from_core: ignore

lib/src/factory.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import 'media_recorder.dart';
12
import 'media_stream.dart';
23
import 'navigator.dart';
34
import 'rtc_peerconnection.dart';
5+
import 'rtc_video_renderer.dart';
46

57
abstract class RTCFactory {
68
Future<RTCPeerConnection> createPeerConnection(
@@ -9,5 +11,9 @@ abstract class RTCFactory {
911

1012
Future<MediaStream> createLocalMediaStream(String label);
1113

14+
MediaRecorder mediaRecorder();
15+
16+
VideoRenderer videoRenderer();
17+
1218
Navigator get navigator;
1319
}

lib/src/rtc_video_renderer.dart

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import 'media_stream.dart';
2+
3+
class RTCVideoValue {
4+
const RTCVideoValue({
5+
this.width = 0.0,
6+
this.height = 0.0,
7+
this.rotation = 0,
8+
this.renderVideo = false,
9+
});
10+
static const RTCVideoValue empty = RTCVideoValue();
11+
final double width;
12+
final double height;
13+
final int rotation;
14+
final bool renderVideo;
15+
double get aspectRatio {
16+
if (width == 0.0 || height == 0.0) {
17+
return 1.0;
18+
}
19+
return (rotation == 90 || rotation == 270)
20+
? height / width
21+
: width / height;
22+
}
23+
24+
RTCVideoValue copyWith({
25+
double? width,
26+
double? height,
27+
int? rotation,
28+
bool renderVideo = true,
29+
}) {
30+
return RTCVideoValue(
31+
width: width ?? this.width,
32+
height: height ?? this.height,
33+
rotation: rotation ?? this.rotation,
34+
renderVideo: this.width != 0 && this.height != 0 && renderVideo,
35+
);
36+
}
37+
38+
@override
39+
String toString() =>
40+
'$runtimeType(width: $width, height: $height, rotation: $rotation)';
41+
}
42+
43+
abstract class VideoRenderer {
44+
VideoRenderer();
45+
46+
Function? onResize;
47+
48+
int get videoWidth;
49+
50+
int get videoHeight;
51+
52+
bool get muted;
53+
set muted(bool mute);
54+
55+
///Return true if the audioOutput have been succesfully changed
56+
Future<bool> audioOutput(String deviceId);
57+
58+
bool get renderVideo;
59+
60+
int? get textureId;
61+
62+
Future<void> initialize();
63+
64+
MediaStream? get srcObject;
65+
66+
set srcObject(MediaStream? stream);
67+
68+
Future<void> dispose();
69+
}

lib/webrtc_interface.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
library webrtc_interface;
22

33
export 'src/enums.dart';
4+
export 'src/factory.dart';
5+
export 'src/media_recorder.dart';
46
export 'src/media_stream.dart';
57
export 'src/media_stream_track.dart';
68
export 'src/mediadevices.dart';
9+
export 'src/navigator.dart';
710
export 'src/rtc_data_channel.dart';
811
export 'src/rtc_dtmf_sender.dart';
912
export 'src/rtc_ice_candidate.dart';
@@ -16,3 +19,4 @@ export 'src/rtc_rtp_transceiver.dart';
1619
export 'src/rtc_session_description.dart';
1720
export 'src/rtc_stats_report.dart';
1821
export 'src/rtc_track_event.dart';
22+
export 'src/rtc_video_renderer.dart';

pubspec.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
name: webrtc_interface
2-
description: WebRTC Interface for Dart.
2+
description: WebRTC Interface for Dart-Web/Flutter.
33
version: 1.0.0
44
homepage: https://flutter-webrtc.org
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"
88

9-
dependencies:
10-
sdp_transform: ^0.3.2
11-
129
dev_dependencies:
13-
dart_code_metrics: ^4.4.0
14-
pedantic: ^1.11.0
15-
test: ^1.15.7
10+
import_sorter: ^4.6.0
11+
pedantic: ^1.11.1
12+
test: any

0 commit comments

Comments
 (0)