equality for video types

This commit is contained in:
Hiroshi Horie
2022-02-25 16:17:52 +09:00
parent b5c3499a5c
commit e7b158f41d
3 changed files with 40 additions and 0 deletions
+13
View File
@@ -24,6 +24,19 @@ class VideoDimensions {
width ?? this.width,
height ?? this.height,
);
// ----------------------------------------------------------------------
// equality
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is VideoDimensions &&
width == other.width &&
height == other.height;
@override
int get hashCode => Object.hash(width, height);
}
extension VideoDimensionsHelpers on VideoDimensions {
+13
View File
@@ -15,6 +15,19 @@ class VideoEncoding {
@override
String toString() =>
'${runtimeType}(maxFramerate: ${maxFramerate}, maxBitrate: ${maxBitrate})';
// ----------------------------------------------------------------------
// equality
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is VideoEncoding &&
maxFramerate == other.maxFramerate &&
maxBitrate == other.maxBitrate;
@override
int get hashCode => Object.hash(maxFramerate, maxBitrate);
}
/// Convenience extension for [VideoEncoding].
+14
View File
@@ -15,6 +15,20 @@ class VideoParameters {
required this.encoding,
});
// ----------------------------------------------------------------------
// equality
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is VideoParameters &&
description == other.description &&
dimensions == other.dimensions &&
encoding == other.encoding;
@override
int get hashCode => Object.hash(description, dimensions, encoding);
//
// TODO: Return constraints that will work for all platforms (Web & Mobile)
// https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia