Skip to content

Commit

Permalink
Added settings for stream width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Jan 8, 2025
1 parent 3e8f1df commit 613785b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 26 deletions.
56 changes: 38 additions & 18 deletions lib/src/models/view/builders/video_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ class CameraDetailsBuilder extends ValueBuilder<CameraDetails> {
/// Statuses the user can set the camera to.
static const okStatuses = [CameraStatus.CAMERA_ENABLED, CameraStatus.CAMERA_DISABLED];

/// The camera resolution's height. See [CameraDetails.resolutionHeight].
final NumberBuilder<int> resolutionHeight;
/// The camera resolution's capture width. See [CameraDetails.resolutionWidth].
final NumberBuilder<int> captureWidth;

/// The camera resolution's width. See [CameraDetails.resolutionWidth].
final NumberBuilder<int> resolutionWidth;
/// The camera resolution's capture height. See [CameraDetails.resolutionHeight].
final NumberBuilder<int> captureHeight;

/// The camera resolution's stream width. See [CameraDetails.streamWidth].
final NumberBuilder<int> streamWidth;

/// The camera resolution's stream height. See [CameraDetails.streamHeight].
final NumberBuilder<int> streamHeight;

/// The quality of the camera, as a percentage. See [CameraDetails.quality].
final NumberBuilder<int> quality;
Expand Down Expand Up @@ -39,32 +45,46 @@ class CameraDetailsBuilder extends ValueBuilder<CameraDetails> {
bool autofocus = true;

@override
List<ValueBuilder<dynamic>> get otherBuilders => [resolutionHeight, resolutionWidth, quality, fps];
List<ValueBuilder<dynamic>> get otherBuilders => [
captureWidth,
captureHeight,
streamWidth,
streamHeight,
quality,
fps,
];

/// Creates a [ValueBuilder] view model to change a [CameraDetails].
CameraDetailsBuilder(CameraDetails data) :
resolutionHeight = NumberBuilder(data.resolutionHeight, min: 0, max: 300),
resolutionWidth = NumberBuilder(data.resolutionWidth, min: 0, max: 300),
CameraDetailsBuilder(CameraDetails data) :
captureWidth = NumberBuilder(data.resolutionWidth, min: 0, max: 1920),
captureHeight = NumberBuilder(data.resolutionHeight, min: 0, max: 1080),
streamWidth = NumberBuilder(data.streamWidth, min: 0, max: 800),
streamHeight = NumberBuilder(data.streamHeight, min: 0, max: 600),
quality = NumberBuilder(data.quality, min: 0, max: 100),
fps = NumberBuilder(data.fps, min: 0, max: 60),
name = data.name,
status = CameraStatus.CAMERA_ENABLED,
autofocus = data.autofocus;

@override
bool get isValid => resolutionHeight.isValid
&& resolutionWidth.isValid
&& quality.isValid
&& fps.isValid
&& okStatuses.contains(status);
@override
bool get isValid =>
captureWidth.isValid &&
captureHeight.isValid &&
streamWidth.isValid &&
streamHeight.isValid &&
quality.isValid &&
fps.isValid &&
okStatuses.contains(status);


@override
CameraDetails get value => CameraDetails(
resolutionHeight: resolutionHeight.value,
resolutionWidth: resolutionWidth.value,
quality: quality.value,
fps: fps.value,
resolutionWidth: captureWidth.value,
resolutionHeight: captureHeight.value,
streamWidth: streamWidth.value,
streamHeight: streamHeight.value,
quality: quality.value,
fps: fps.value,
name: name,
status: status,
focus: 0,
Expand Down
47 changes: 39 additions & 8 deletions lib/src/widgets/atomic/camera_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,46 @@ class CameraDetailsEditor extends ReactiveWidget<CameraDetailsBuilder> {
items: CameraDetailsBuilder.okStatuses,
),
),
NumberEditor(
name: "Resolution height",
model: model.resolutionHeight,
titleFlex: 2,
Row(
children: [
Flexible(
child: NumberEditor(
name: "Capture Width",
model: model.captureWidth,
width: 5,
titleFlex: 3,
),
),
Flexible(
child: NumberEditor(
name: "Capture Height",
model: model.captureHeight,
width: 5,
titleFlex: 3,
),
),

],
),
NumberEditor(
name: "Resolution width",
model: model.resolutionWidth,
titleFlex: 2,
Row(
children: [
Flexible(
child: NumberEditor(
name: "Stream Width",
model: model.streamWidth,
width: 5,
titleFlex: 3,
),
),
Flexible(
child: NumberEditor(
name: "Stream Height",
model: model.streamHeight,
width: 5,
titleFlex: 3,
),
),
],
),
NumberEditor(
name: "Quality (0-100)",
Expand Down

0 comments on commit 613785b

Please sign in to comment.