Skip to content

Commit

Permalink
Minor updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
larryaasen committed Sep 27, 2024
1 parent 5432a8e commit e801e2f
Show file tree
Hide file tree
Showing 20 changed files with 545 additions and 164 deletions.
32 changes: 16 additions & 16 deletions apps/dive_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -246,34 +246,34 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
url: "https://pub.dev"
source: hosted
version: "0.18.1"
version: "0.19.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand All @@ -294,18 +294,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.15.0"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -459,10 +459,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.2"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -491,10 +491,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.5"
web:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion apps/dive_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
dive_ui:
path: ../../packages/dive_ui

intl: ^0.18.0
intl: ^0.19.0

dev_dependencies:
flutter_test:
Expand Down
13 changes: 6 additions & 7 deletions packages/dive/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import 'package:dive/dive.dart';
void main() async {
configDiveApp();

await DiveExample()
..run();
await DiveExample().run();
}

class DiveExample {
final _elements = DiveCoreElements();
final _diveCore = DiveCore();
bool _initialized = false;

void run() async {
_initialize();
Future<void> run() async {
await _initialize();
}

void _initialize() async {
Future<void> _initialize() async {
if (_initialized) return;
_initialized = true;

Expand All @@ -30,7 +29,7 @@ class DiveExample {
DiveAudioSource.create('main audio').then((source) {
if (source != null) {
_elements.addAudioSource(source);
_elements.state..currentScene!.addSource(source);
_elements.state.currentScene!.addSource(source);
}
});

Expand Down Expand Up @@ -70,7 +69,7 @@ class DiveExample {
const streamDuration = 30;
print('Dive Example 1: Waiting $streamDuration seconds.');

Future.delayed(Duration(seconds: streamDuration), () {
Future.delayed(const Duration(seconds: streamDuration), () {
print('Dive Example 1: Stopping stream.');
output.stop();

Expand Down
6 changes: 4 additions & 2 deletions packages/dive/lib/src/dive_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class DiveInput {
class DiveInputs {
static List<DiveInput> fromType(String typeId) =>
obslib.inputsFromType(typeId).map(DiveInput.fromMap).toList();
static List<DiveInput> audio() => obslib.audioInputs().map(DiveInput.fromMap).toList();
static List<DiveInput> video() => obslib.videoInputs().map(DiveInput.fromMap).toList();
static List<DiveInput> audio() =>
obslib.audioInputs().map(DiveInput.fromMap).toList();
static List<DiveInput> video() =>
obslib.videoInputs().map(DiveInput.fromMap).toList();
}
2 changes: 1 addition & 1 deletion packages/dive/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
equatable: ^2.0.5

# From Dart Team: provides internationalization and localization facilities, including message translation, plurals and genders, date/number formatting and parsing, and bidirectional text.
intl: ^0.18.0
intl: ^0.19.0

# From Dart Team: cross-platform path manipulation library
path: ^1.8.3
Expand Down
54 changes: 44 additions & 10 deletions packages/dive_av/example/lib/camera_controller_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import 'dart:ui';

import 'package:dive_av/dive_av.dart';
import 'package:flutter/material.dart';
import 'package:uvc/uvc.dart';
// import 'package:uvc_flutter/uvc_flutter.dart';

import 'camera_settings_section.dart';

class CameraControllerScreen extends StatefulWidget {
const CameraControllerScreen({super.key});
Expand All @@ -20,6 +24,11 @@ class _MyAppState extends State<CameraControllerScreen>
DiveAVInputType? _selectedInputType;
Map? _selectedSource;
late final AppLifecycleListener _listener;

// UVC
UvcLib? _uvc;
UvcControl? _camera;

bool _exiting = false;

@override
Expand All @@ -35,23 +44,29 @@ class _MyAppState extends State<CameraControllerScreen>
});
// ignore: avoid_print
print('Exiting.');
await _removeTexture();
_closeSource();
_uvc?.dispose();

return AppExitResponse.exit;
},
);
}

@override
dispose() {
_listener.dispose();
_removeTexture();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

Future<void> initPlatformState() async {
try {
// _uvc = UvcLib(libraryName: UvcFlutter.libusbLibraryName);

_inputTypes = await _diveAvPlugin.inputsFromType('video');
_selectedInputType = _inputTypes.isEmpty ? null : _inputTypes.first;

setState(() {});

await _setupSource();
Expand All @@ -73,12 +88,16 @@ class _MyAppState extends State<CameraControllerScreen>
padding: const EdgeInsets.all(16.0),
child: _exiting
? const Text('Exiting...')
: Column(
children: [
_dropdownRow(),
const SizedBox(height: 8.0),
_texture(),
],
: SingleChildScrollView(
child: Column(
children: [
_dropdownRow(),
const SizedBox(height: 8.0),
_texture(),
const SizedBox(height: 16.0),
_settings(),
],
),
),
),
),
Expand All @@ -102,7 +121,7 @@ class _MyAppState extends State<CameraControllerScreen>
items: items.toList(),
onChanged: (DiveAVInputType? value) {
setState(() {
_removeTexture();
_closeSource();
_selectedInputType = value;
_setupSource();
});
Expand All @@ -113,6 +132,19 @@ class _MyAppState extends State<CameraControllerScreen>
);
}

Widget _settings() {
return _camera == null
? const SizedBox.shrink()
: CameraSettingsSection(camera: _camera!);
}

void _closeSource() async {
await _removeTexture();

_camera?.close();
_camera = null;
}

Future<void> _setupSource() async {
if (_selectedInputType == null) {
return;
Expand All @@ -122,8 +154,11 @@ class _MyAppState extends State<CameraControllerScreen>
final sourceId = await _diveAvPlugin
.createVideoSource(_selectedInputType!.uniqueID, textureId: textureId);
// ignore: avoid_print
print('created video source: $sourceId');
print('dive_av: created video source: $sourceId');
if (sourceId != null) {
_camera = _uvc?.control(
vendorId: _selectedInputType!.vendorID,
productId: _selectedInputType!.productID);
setState(() {
_selectedSource = {
'textureId': textureId,
Expand All @@ -138,7 +173,6 @@ class _MyAppState extends State<CameraControllerScreen>
if (_selectedSource == null) return const SizedBox.shrink();
final textureId = _selectedSource!['textureId'];
return Container(
width: 400,
clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
Expand Down
55 changes: 55 additions & 0 deletions packages/dive_av/example/lib/camera_settings_section.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2024 Larry Aasen. All rights reserved.

import 'package:flutter/material.dart';
import 'package:uvc/uvc.dart';

import 'checkbox_control.dart';
import 'slider_control.dart';

class CameraSettingsSection extends StatefulWidget {
const CameraSettingsSection({super.key, required this.camera});

final UvcControl camera;

@override
State<CameraSettingsSection> createState() => _CameraSettingsSectionState();
}

class _CameraSettingsSectionState extends State<CameraSettingsSection> {
@override
void dispose() {
super.dispose();
}

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(8.0),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
color: Colors.black12,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SliderControl(
title: 'Brightness:', controller: widget.camera.brightness),
SliderControl(title: 'Contrast:', controller: widget.camera.contrast),
SliderControl(
title: 'Saturation:', controller: widget.camera.saturation),
SliderControl(
title: 'Sharpness:', controller: widget.camera.sharpness),
SliderControl(
title: 'White Balance:', controller: widget.camera.whiteBalance),
SliderControl(title: 'Pan:', controller: widget.camera.pan),
SliderControl(title: 'Tilt:', controller: widget.camera.tilt),
SliderControl(title: 'Zoom:', controller: widget.camera.zoom),
SliderControl(
titleWidget: CheckboxControl(
title: 'Auto:', controller: widget.camera.focusAuto),
controller: widget.camera.focus),
],
),
);
}
}
Loading

0 comments on commit e801e2f

Please sign in to comment.