view dstep/qtkit/QTCaptureSession.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.QTCaptureSession;

import dstep.foundation.Foundation;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;
import dstep.qtkit.QTCaptureConnection;
import dstep.qtkit.QTCaptureInput;
import dstep.qtkit.QTCaptureOutput;
import dstep.qtkit.QTKitDefines;

import bindings = dstep.qtkit.QTCaptureSession_bindings;

private
{
	NSString QTCaptureSessionRuntimeErrorNotification_;
	NSString QTCaptureSessionErrorKey_;
}

NSString QTCaptureSessionRuntimeErrorNotification ()
{
	if (QTCaptureSessionRuntimeErrorNotification_)
		return QTCaptureSessionRuntimeErrorNotification_;

	return QTCaptureSessionRuntimeErrorNotification_ = new NSString(bindings.QTCaptureSessionRuntimeErrorNotification);
}

NSString QTCaptureSessionErrorKey ()
{
	if (QTCaptureSessionErrorKey_)
		return QTCaptureSessionErrorKey_;

	return QTCaptureSessionErrorKey_ = new NSString(bindings.QTCaptureSessionErrorKey);
}

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

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

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

	void removeInput (QTCaptureInput input)
	{
		return invokeObjcSelf!(void, "removeInput:", QTCaptureInput)(input);
	}

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

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

	void removeOutput (QTCaptureOutput output)
	{
		return invokeObjcSelf!(void, "removeOutput:", QTCaptureOutput)(output);
	}

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

	void startRunning ()
	{
		return invokeObjcSelf!(void, "startRunning");
	}

	void stopRunning ()
	{
		return invokeObjcSelf!(void, "stopRunning");
	}

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