<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rew Islam</title>
	<atom:link href="http://rewtube.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rewtube.com</link>
	<description></description>
	<lastBuildDate>Sun, 12 Jun 2011 18:47:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Creating a list of attached webcams</title>
		<link>http://rewtube.com/creating-a-list-of-attached-webcams/</link>
		<comments>http://rewtube.com/creating-a-list-of-attached-webcams/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 07:54:18 +0000</pubDate>
		<dc:creator>Ruhul Islam</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[QTKit]]></category>

		<guid isPermaLink="false">http://rewtube.com/?p=6</guid>
		<description><![CDATA[This article describes how you can get the data you need to create a list of webcams attached to your Mac.]]></description>
			<content:encoded><![CDATA[<p>Many applications that use a video input such as a webcam or a DV camera often give you the option of selecting which device to use, if you have more than one device available.</p>
<p>This is an example taken from the preferences page of Skype:</p>
<p><a href="http://rewtube.com/wp-content/uploads/image1.png"><img class="aligncenter size-full wp-image-7" title="Webcam list" src="http://rewtube.com/wp-content/uploads/image1.png" alt="Webcam list taken from Skype preferences" width="349" height="68" /></a></p>
<p><a href="http://rewtube.com/wp-content/uploads/image1.png"></a><a href="http://rewtube.com/wp-content/uploads/image2.png"><img class="aligncenter size-full wp-image-8" title="Webcam list" src="http://rewtube.com/wp-content/uploads/image2.png" alt="Webcam list taken from Skype (options open)" width="349" height="68" /></a></p>
<p>The following will describe how we can access the data to create such a list, the specifics of creating a list (for example a <a title="NSPopUpButton documentation" href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPopUpButton_Class/Reference/Reference.html" target="_blank">NSPopUpButton</a>) will be left out.</p>
<p>All the information you need is found within the class <a title="QTCaptureDevice documentation" href="http://developer.apple.com/library/mac/#documentation/QuickTime/Reference/QTCaptureDevice_Class/Reference/Reference.html" target="_blank">QTCaptureDevice</a>. There are four class methods:</p>
<ul>
<li>defaultInputDeviceWithMediaType:</li>
<li>deviceWithUniqueID:</li>
<li>inputDevices</li>
<li>inputDevicesWithMediaType:</li>
</ul>
<p>The first method mentions a &#8216;media type&#8217;. QTCaptureDevice represents more than just webcams, it also includes microphones and DV cameras. There are three media types:</p>
<ul>
<li>QTMediaTypeVideo &#8211; devices with video output: iSignt cameras and other webcams</li>
<li>QTMediaTypeMuxed &#8211; devices with a mix of audio and video: DV cameras</li>
<li>QTMediaTypeSound &#8211; devices with audio output: microphones</li>
</ul>
<p>Using the above information we can access all the data we need create our list. First we need a list of devices:</p>
<pre class="brush: objc; title: ; notranslate">NSArray *inputDevices = [QTCaptureDevice inputDevices];</pre>
<p>This is an array of all devices, of all media types. If you loop through this array you&#8217;ll need to check each item to see if it is the media type you want:</p>
<pre class="brush: objc; title: ; notranslate">for(QTCaptureDevice *device in inputDevices) {

	if([device hasMediaType:QTMediaTypeVideo]) {

		// do what you need with the device

	}
}</pre>
<p>All we need now is to access the name of the device, this is provided by the instance method of QTCaptureDevice:</p>
<pre class="brush: objc; title: ; notranslate">[device localizedDisplayName];</pre>
<p>This will provide the name such as &#8220;Build-in iSight&#8221;.</p>
<p>This should provide all the information required to create a list of webcams attached to your Mac.</p>
]]></content:encoded>
			<wfw:commentRss>http://rewtube.com/creating-a-list-of-attached-webcams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

