Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Nov 19, 2021
1 parent b38d5a8 commit 7b87c29
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 7 deletions.
48 changes: 48 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include: package:pedantic/analysis_options.yaml

linter:
rules:
- always_declare_return_types
- avoid_empty_else
- await_only_futures
- avoid_returning_null_for_void
- camel_case_extensions
- camel_case_types
- cancel_subscriptions
- directives_ordering
- flutter_style_todos
- sort_constructors_first
- sort_unnamed_constructors_first
- sort_pub_dependencies
- type_init_formals
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_new
- unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
- void_checks

analyzer:
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
# allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
sdk_version_async_exported_from_core: ignore
6 changes: 6 additions & 0 deletions lib/src/factory.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'media_recorder.dart';
import 'media_stream.dart';
import 'navigator.dart';
import 'rtc_peerconnection.dart';
import 'rtc_video_renderer.dart';

abstract class RTCFactory {
Future<RTCPeerConnection> createPeerConnection(
Expand All @@ -9,5 +11,9 @@ abstract class RTCFactory {

Future<MediaStream> createLocalMediaStream(String label);

MediaRecorder mediaRecorder();

VideoRenderer videoRenderer();

Navigator get navigator;
}
69 changes: 69 additions & 0 deletions lib/src/rtc_video_renderer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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();

Function? onResize;

int get videoWidth;

int get videoHeight;

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();
}
4 changes: 4 additions & 0 deletions lib/webrtc_interface.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
library webrtc_interface;

export 'src/enums.dart';
export 'src/factory.dart';
export 'src/media_recorder.dart';
export 'src/media_stream.dart';
export 'src/media_stream_track.dart';
export 'src/mediadevices.dart';
export 'src/navigator.dart';
export 'src/rtc_data_channel.dart';
export 'src/rtc_dtmf_sender.dart';
export 'src/rtc_ice_candidate.dart';
Expand All @@ -16,3 +19,4 @@ export 'src/rtc_rtp_transceiver.dart';
export 'src/rtc_session_description.dart';
export 'src/rtc_stats_report.dart';
export 'src/rtc_track_event.dart';
export 'src/rtc_video_renderer.dart';
11 changes: 4 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: webrtc_interface
description: WebRTC Interface for Dart.
description: WebRTC Interface for Dart-Web/Flutter.
version: 1.0.0
homepage: https://flutter-webrtc.org

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
sdp_transform: ^0.3.2

dev_dependencies:
dart_code_metrics: ^4.4.0
pedantic: ^1.11.0
test: ^1.15.7
import_sorter: ^4.6.0
pedantic: ^1.11.1
test: any

0 comments on commit 7b87c29

Please sign in to comment.