-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(windows_media): add
MediaCapture
APIs (#301)
- Loading branch information
1 parent
009e6d1
commit 81584de
Showing
362 changed files
with
34,924 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
/// Represents the size of a bitmap, in pixels. | ||
final class BitmapSize implements WinRTStruct { | ||
BitmapSize(this.width, this.height); | ||
|
||
final int width; | ||
final int height; | ||
|
||
@override | ||
Pointer<NativeBitmapSize> toNative({Allocator allocator = malloc}) { | ||
final nativeStructPtr = allocator<NativeBitmapSize>(); | ||
nativeStructPtr.ref | ||
..width = width | ||
..height = height; | ||
return nativeStructPtr; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (identical(this, other)) return true; | ||
return other is BitmapSize && | ||
width == other.width && | ||
height == other.height; | ||
} | ||
|
||
@override | ||
int get hashCode => width.hashCode ^ height.hashCode; | ||
} | ||
|
||
/// @nodoc | ||
extension PointerNativeBitmapSizeConversion on Pointer<NativeBitmapSize> { | ||
/// Converts this [NativeBitmapSize] to a Dart [BitmapSize]. | ||
BitmapSize toDart() { | ||
final ref = this.ref; | ||
return BitmapSize(ref.width, ref.height); | ||
} | ||
|
||
/// Creates a `List<BitmapSize>` from `Pointer<NativeBitmapSize>`. | ||
/// | ||
/// [length] must not be greater than the number of elements stored inside the | ||
/// `Pointer<NativeBitmapSize>`. | ||
List<BitmapSize> toList({int length = 1}) => | ||
[for (var i = 0; i < length; i++) elementAt(i).toDart()]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
import 'iaudiobuffer.dart'; | ||
|
||
/// Represents a buffer containing audio data. | ||
class AudioBuffer extends IInspectable | ||
implements IAudioBuffer, IMemoryBuffer, IClosable { | ||
AudioBuffer.fromPtr(super.ptr); | ||
|
||
late final _iAudioBuffer = IAudioBuffer.from(this); | ||
|
||
@override | ||
int get capacity => _iAudioBuffer.capacity; | ||
|
||
@override | ||
int get length => _iAudioBuffer.length; | ||
|
||
@override | ||
set length(int value) => _iAudioBuffer.length = value; | ||
|
||
late final _iMemoryBuffer = IMemoryBuffer.from(this); | ||
|
||
@override | ||
IMemoryBufferReference? createReference() => _iMemoryBuffer.createReference(); | ||
|
||
late final _iClosable = IClosable.from(this); | ||
|
||
@override | ||
void close() => _iClosable.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: deprecated_member_use_from_same_package | ||
|
||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
/// Defines the access mode of an AudioBuffer returned by | ||
/// AudioFrame.LockBuffer. | ||
enum AudioBufferAccessMode implements WinRTEnum { | ||
read(0), | ||
readWrite(1), | ||
write(2); | ||
|
||
@override | ||
final int value; | ||
|
||
const AudioBufferAccessMode(this.value); | ||
|
||
factory AudioBufferAccessMode.from(int value) => | ||
AudioBufferAccessMode.values.firstWhere((e) => e.value == value, | ||
orElse: () => throw ArgumentError.value( | ||
value, 'value', 'No enum value with that value')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
import 'audiobuffer.dart'; | ||
import 'audiobufferaccessmode.dart'; | ||
import 'iaudioframe.dart'; | ||
import 'iaudioframefactory.dart'; | ||
import 'imediaframe.dart'; | ||
|
||
/// Represents a single frame of audio data. | ||
class AudioFrame extends IInspectable | ||
implements IAudioFrame, IMediaFrame, IClosable { | ||
AudioFrame.fromPtr(super.ptr); | ||
|
||
static const _className = 'Windows.Media.AudioFrame'; | ||
|
||
factory AudioFrame.create(int capacity) => createActivationFactory( | ||
IAudioFrameFactory.fromPtr, _className, IID_IAudioFrameFactory) | ||
.create(capacity); | ||
|
||
late final _iAudioFrame = IAudioFrame.from(this); | ||
|
||
@override | ||
AudioBuffer? lockBuffer(AudioBufferAccessMode mode) => | ||
_iAudioFrame.lockBuffer(mode); | ||
|
||
late final _iMediaFrame = IMediaFrame.from(this); | ||
|
||
@override | ||
String get type => _iMediaFrame.type; | ||
|
||
@override | ||
bool get isReadOnly => _iMediaFrame.isReadOnly; | ||
|
||
@override | ||
set relativeTime(Duration? value) => _iMediaFrame.relativeTime = value; | ||
|
||
@override | ||
Duration? get relativeTime => _iMediaFrame.relativeTime; | ||
|
||
@override | ||
set systemRelativeTime(Duration? value) => | ||
_iMediaFrame.systemRelativeTime = value; | ||
|
||
@override | ||
Duration? get systemRelativeTime => _iMediaFrame.systemRelativeTime; | ||
|
||
@override | ||
set duration(Duration? value) => _iMediaFrame.duration = value; | ||
|
||
@override | ||
Duration? get duration => _iMediaFrame.duration; | ||
|
||
@override | ||
set isDiscontinuous(bool value) => _iMediaFrame.isDiscontinuous = value; | ||
|
||
@override | ||
bool get isDiscontinuous => _iMediaFrame.isDiscontinuous; | ||
|
||
@override | ||
IPropertySet? get extendedProperties => _iMediaFrame.extendedProperties; | ||
|
||
late final _iClosable = IClosable.from(this); | ||
|
||
@override | ||
void close() => _iClosable.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: deprecated_member_use_from_same_package | ||
|
||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
/// Defines the audio processing modes. | ||
enum AudioProcessing implements WinRTEnum { | ||
default_(0), | ||
raw(1); | ||
|
||
@override | ||
final int value; | ||
|
||
const AudioProcessing(this.value); | ||
|
||
factory AudioProcessing.from(int value) => | ||
AudioProcessing.values.firstWhere((e) => e.value == value, | ||
orElse: () => throw ArgumentError.value( | ||
value, 'value', 'No enum value with that value')); | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/windows_media/lib/src/capture/advancedcapturedphoto.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
import '../devices/advancedphotomode.dart'; | ||
import 'capturedframe.dart'; | ||
import 'iadvancedcapturedphoto.dart'; | ||
import 'iadvancedcapturedphoto2.dart'; | ||
|
||
/// Represents a photo captured using system-provided computational | ||
/// photography techniques provided by the AdvancedPhotoCapture class. | ||
class AdvancedCapturedPhoto extends IInspectable | ||
implements IAdvancedCapturedPhoto, IAdvancedCapturedPhoto2 { | ||
AdvancedCapturedPhoto.fromPtr(super.ptr); | ||
|
||
late final _iAdvancedCapturedPhoto = IAdvancedCapturedPhoto.from(this); | ||
|
||
@override | ||
CapturedFrame? get frame => _iAdvancedCapturedPhoto.frame; | ||
|
||
@override | ||
AdvancedPhotoMode get mode => _iAdvancedCapturedPhoto.mode; | ||
|
||
@override | ||
Object? get context => _iAdvancedCapturedPhoto.context; | ||
|
||
late final _iAdvancedCapturedPhoto2 = IAdvancedCapturedPhoto2.from(this); | ||
|
||
@override | ||
Rect? get frameBoundsRelativeToReferencePhoto => | ||
_iAdvancedCapturedPhoto2.frameBoundsRelativeToReferencePhoto; | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/windows_media/lib/src/capture/advancedphotocapture.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
import 'advancedcapturedphoto.dart'; | ||
import 'iadvancedphotocapture.dart'; | ||
|
||
/// Provides methods for capturing photos using system-provided | ||
/// computational photography techniques. | ||
class AdvancedPhotoCapture extends IInspectable | ||
implements IAdvancedPhotoCapture { | ||
AdvancedPhotoCapture.fromPtr(super.ptr); | ||
|
||
late final _iAdvancedPhotoCapture = IAdvancedPhotoCapture.from(this); | ||
|
||
@override | ||
Future<AdvancedCapturedPhoto?> captureAsync() => | ||
_iAdvancedPhotoCapture.captureAsync(); | ||
|
||
@override | ||
Future<AdvancedCapturedPhoto?> captureWithContextAsync(Object? context) => | ||
_iAdvancedPhotoCapture.captureWithContextAsync(context); | ||
|
||
@override | ||
int add_OptionalReferencePhotoCaptured(Pointer<COMObject> handler) => | ||
_iAdvancedPhotoCapture.add_OptionalReferencePhotoCaptured(handler); | ||
|
||
@override | ||
void remove_OptionalReferencePhotoCaptured(int token) => | ||
_iAdvancedPhotoCapture.remove_OptionalReferencePhotoCaptured(token); | ||
|
||
@override | ||
int add_AllPhotosCaptured(Pointer<COMObject> handler) => | ||
_iAdvancedPhotoCapture.add_AllPhotosCaptured(handler); | ||
|
||
@override | ||
void remove_AllPhotosCaptured(int token) => | ||
_iAdvancedPhotoCapture.remove_AllPhotosCaptured(token); | ||
|
||
@override | ||
Future<void> finishAsync() => _iAdvancedPhotoCapture.finishAsync(); | ||
} |
Oops, something went wrong.