view dstep/qtkit/QTCaptureDevice.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents
children b9de51448c6b
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Sep 28, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.qtkit.QTCaptureDevice;

import dstep.foundation.Foundation;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;
import dstep.qtkit.QTKitDefines;

import bindings = dstep.qtkit.QTCaptureDevice_bindings;

alias NSUInteger QTCaptureDeviceAVCTransportControlsPlaybackMode;
alias NSInteger QTCaptureDeviceAVCTransportControlsSpeed;

private
{
	NSString QTCaptureDeviceWasConnectedNotification_;
	NSString QTCaptureDeviceWasDisconnectedNotification_;
	NSString QTCaptureDeviceFormatDescriptionsWillChangeNotification_;
	NSString QTCaptureDeviceFormatDescriptionsDidChangeNotification_;
	NSString QTCaptureDeviceAttributeWillChangeNotification_;
	NSString QTCaptureDeviceAttributeDidChangeNotification_;
	NSString QTCaptureDeviceChangedAttributeKey_;
	NSString QTCaptureDeviceSuspendedAttribute_;
	NSString QTCaptureDeviceLinkedDevicesAttribute_;
	NSString QTCaptureDeviceAvailableInputSourcesAttribute_;
	NSString QTCaptureDeviceInputSourceIdentifierAttribute_;
	NSString QTCaptureDeviceInputSourceIdentifierKey_;
	NSString QTCaptureDeviceInputSourceLocalizedDisplayNameKey_;
	NSString QTCaptureDeviceAVCTransportControlsAttribute_;
	NSString QTCaptureDeviceAVCTransportControlsPlaybackModeKey_;
	NSString QTCaptureDeviceAVCTransportControlsSpeedKey_;
}

NSString QTCaptureDeviceWasConnectedNotification ()
{
	if (QTCaptureDeviceWasConnectedNotification_)
		return QTCaptureDeviceWasConnectedNotification_;

	return QTCaptureDeviceWasConnectedNotification_ = new NSString(bindings.QTCaptureDeviceWasConnectedNotification);
}

NSString QTCaptureDeviceWasDisconnectedNotification ()
{
	if (QTCaptureDeviceWasDisconnectedNotification_)
		return QTCaptureDeviceWasDisconnectedNotification_;

	return QTCaptureDeviceWasDisconnectedNotification_ = new NSString(bindings.QTCaptureDeviceWasDisconnectedNotification);
}

NSString QTCaptureDeviceFormatDescriptionsWillChangeNotification ()
{
	if (QTCaptureDeviceFormatDescriptionsWillChangeNotification_)
		return QTCaptureDeviceFormatDescriptionsWillChangeNotification_;

	return QTCaptureDeviceFormatDescriptionsWillChangeNotification_ = new NSString(bindings.QTCaptureDeviceFormatDescriptionsWillChangeNotification);
}

NSString QTCaptureDeviceFormatDescriptionsDidChangeNotification ()
{
	if (QTCaptureDeviceFormatDescriptionsDidChangeNotification_)
		return QTCaptureDeviceFormatDescriptionsDidChangeNotification_;

	return QTCaptureDeviceFormatDescriptionsDidChangeNotification_ = new NSString(bindings.QTCaptureDeviceFormatDescriptionsDidChangeNotification);
}

NSString QTCaptureDeviceAttributeWillChangeNotification ()
{
	if (QTCaptureDeviceAttributeWillChangeNotification_)
		return QTCaptureDeviceAttributeWillChangeNotification_;

	return QTCaptureDeviceAttributeWillChangeNotification_ = new NSString(bindings.QTCaptureDeviceAttributeWillChangeNotification);
}

NSString QTCaptureDeviceAttributeDidChangeNotification ()
{
	if (QTCaptureDeviceAttributeDidChangeNotification_)
		return QTCaptureDeviceAttributeDidChangeNotification_;

	return QTCaptureDeviceAttributeDidChangeNotification_ = new NSString(bindings.QTCaptureDeviceAttributeDidChangeNotification);
}

NSString QTCaptureDeviceChangedAttributeKey ()
{
	if (QTCaptureDeviceChangedAttributeKey_)
		return QTCaptureDeviceChangedAttributeKey_;

	return QTCaptureDeviceChangedAttributeKey_ = new NSString(bindings.QTCaptureDeviceChangedAttributeKey);
}

NSString QTCaptureDeviceSuspendedAttribute ()
{
	if (QTCaptureDeviceSuspendedAttribute_)
		return QTCaptureDeviceSuspendedAttribute_;

	return QTCaptureDeviceSuspendedAttribute_ = new NSString(bindings.QTCaptureDeviceSuspendedAttribute);
}

NSString QTCaptureDeviceLinkedDevicesAttribute ()
{
	if (QTCaptureDeviceLinkedDevicesAttribute_)
		return QTCaptureDeviceLinkedDevicesAttribute_;

	return QTCaptureDeviceLinkedDevicesAttribute_ = new NSString(bindings.QTCaptureDeviceLinkedDevicesAttribute);
}

NSString QTCaptureDeviceAvailableInputSourcesAttribute ()
{
	if (QTCaptureDeviceAvailableInputSourcesAttribute_)
		return QTCaptureDeviceAvailableInputSourcesAttribute_;

	return QTCaptureDeviceAvailableInputSourcesAttribute_ = new NSString(bindings.QTCaptureDeviceAvailableInputSourcesAttribute);
}

NSString QTCaptureDeviceInputSourceIdentifierAttribute ()
{
	if (QTCaptureDeviceInputSourceIdentifierAttribute_)
		return QTCaptureDeviceInputSourceIdentifierAttribute_;

	return QTCaptureDeviceInputSourceIdentifierAttribute_ = new NSString(bindings.QTCaptureDeviceInputSourceIdentifierAttribute);
}

NSString QTCaptureDeviceInputSourceIdentifierKey ()
{
	if (QTCaptureDeviceInputSourceIdentifierKey_)
		return QTCaptureDeviceInputSourceIdentifierKey_;

	return QTCaptureDeviceInputSourceIdentifierKey_ = new NSString(bindings.QTCaptureDeviceInputSourceIdentifierKey);
}

NSString QTCaptureDeviceInputSourceLocalizedDisplayNameKey ()
{
	if (QTCaptureDeviceInputSourceLocalizedDisplayNameKey_)
		return QTCaptureDeviceInputSourceLocalizedDisplayNameKey_;

	return QTCaptureDeviceInputSourceLocalizedDisplayNameKey_ = new NSString(bindings.QTCaptureDeviceInputSourceLocalizedDisplayNameKey);
}

NSString QTCaptureDeviceAVCTransportControlsAttribute ()
{
	if (QTCaptureDeviceAVCTransportControlsAttribute_)
		return QTCaptureDeviceAVCTransportControlsAttribute_;

	return QTCaptureDeviceAVCTransportControlsAttribute_ = new NSString(bindings.QTCaptureDeviceAVCTransportControlsAttribute);
}

NSString QTCaptureDeviceAVCTransportControlsPlaybackModeKey ()
{
	if (QTCaptureDeviceAVCTransportControlsPlaybackModeKey_)
		return QTCaptureDeviceAVCTransportControlsPlaybackModeKey_;

	return QTCaptureDeviceAVCTransportControlsPlaybackModeKey_ = new NSString(bindings.QTCaptureDeviceAVCTransportControlsPlaybackModeKey);
}

NSString QTCaptureDeviceAVCTransportControlsSpeedKey ()
{
	if (QTCaptureDeviceAVCTransportControlsSpeedKey_)
		return QTCaptureDeviceAVCTransportControlsSpeedKey_;

	return QTCaptureDeviceAVCTransportControlsSpeedKey_ = new NSString(bindings.QTCaptureDeviceAVCTransportControlsSpeedKey);
}

enum
{
	QTCaptureDeviceAVCTransportControlsNotPlayingMode = 0,
	QTCaptureDeviceAVCTransportControlsPlayingMode = 1
}

enum
{
	QTCaptureDeviceAVCTransportControlsFastestReverseSpeed = -19000,
	QTCaptureDeviceAVCTransportControlsVeryFastReverseSpeed = -16000,
	QTCaptureDeviceAVCTransportControlsFastReverseSpeed = -13000,
	QTCaptureDeviceAVCTransportControlsNormalReverseSpeed = -10000,
	QTCaptureDeviceAVCTransportControlsSlowReverseSpeed = -7000,
	QTCaptureDeviceAVCTransportControlsVerySlowReverseSpeed = -4000,
	QTCaptureDeviceAVCTransportControlsSlowestReverseSpeed = -1000,
	QTCaptureDeviceAVCTransportControlsStoppedSpeed = 0,
	QTCaptureDeviceAVCTransportControlsSlowestForwardSpeed = 1000,
	QTCaptureDeviceAVCTransportControlsVerySlowForwardSpeed = 4000,
	QTCaptureDeviceAVCTransportControlsSlowForwardSpeed = 7000,
	QTCaptureDeviceAVCTransportControlsNormalForwardSpeed = 10000,
	QTCaptureDeviceAVCTransportControlsFastForwardSpeed = 13000,
	QTCaptureDeviceAVCTransportControlsVeryFastForwardSpeed = 16000,
	QTCaptureDeviceAVCTransportControlsFastestForwardSpeed = 19000
}

class QTCaptureDevice : NSObject, INSCoding
{
	mixin (ObjcWrap);

	static NSArray inputDevices ()
	{
		return invokeObjcSelfClass!(NSArray, "inputDevices");
	}

	static NSArray inputDevicesWithMediaType (NSString mediaType)
	{
		return invokeObjcSelfClass!(NSArray, "inputDevicesWithMediaType:", NSString)(mediaType);
	}

	static QTCaptureDevice defaultInputDeviceWithMediaType (NSString mediaType)
	{
		return invokeObjcSelfClass!(QTCaptureDevice, "defaultInputDeviceWithMediaType:", NSString)(mediaType);
	}

	static QTCaptureDevice deviceWithUniqueID (NSString deviceUniqueID)
	{
		return invokeObjcSelfClass!(QTCaptureDevice, "deviceWithUniqueID:", NSString)(deviceUniqueID);
	}

	NSString uniqueID ()
	{
		return invokeObjcSelf!(NSString, "uniqueID");
	}

	NSString modelUniqueID ()
	{
		return invokeObjcSelf!(NSString, "modelUniqueID");
	}

	NSString localizedDisplayName ()
	{
		return invokeObjcSelf!(NSString, "localizedDisplayName");
	}

	NSArray formatDescriptions ()
	{
		return invokeObjcSelf!(NSArray, "formatDescriptions");
	}

	bool hasMediaType (NSString mediaType)
	{
		return invokeObjcSelf!(bool, "hasMediaType:", NSString)(mediaType);
	}

	NSDictionary deviceAttributes ()
	{
		return invokeObjcSelf!(NSDictionary, "deviceAttributes");
	}

	void setDeviceAttributes (NSDictionary deviceAttributes)
	{
		return invokeObjcSelf!(void, "setDeviceAttributes:", NSDictionary)(deviceAttributes);
	}

	bool attributeIsReadOnly (NSString attributeKey)
	{
		return invokeObjcSelf!(bool, "attributeIsReadOnly:", NSString)(attributeKey);
	}

	Object attributeForKey (NSString attributeKey)
	{
		return invokeObjcSelf!(Object, "attributeForKey:", NSString)(attributeKey);
	}

	void setAttribute (Object attribute, NSString attributeKey)
	{
		return invokeObjcSelf!(void, "setAttribute:forKey:", Object, NSString)(attribute, attributeKey);
	}

	bool isConnected ()
	{
		return invokeObjcSelf!(bool, "isConnected");
	}

	bool isInUseByAnotherApplication ()
	{
		return invokeObjcSelf!(bool, "isInUseByAnotherApplication");
	}

	bool isOpen ()
	{
		return invokeObjcSelf!(bool, "isOpen");
	}

	bool open (ref NSError errorPtr)
	{
		id error;
		
		if (errorPtr)
			error = errorPtr.objcObject;
		
		bool result = invokeObjcSelf!(bool, "open:", id*)(&error);
		
		if (error)
			errorPtr = new NSError(error);
		
		return result;
	}

	void close ()
	{
		return invokeObjcSelf!(void, "close");
	}
	
	void encodeWithCoder (NSCoder aCoder)
	{
		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
	}
	
	QTCaptureDevice initWithCoder (NSCoder aDecoder)
	{
		return invokeObjcSelf!(QTCaptureDevice, "initWithCoder:", NSCoder)(aDecoder);
	}
}