File: programming/cocoa/UKTurboExport.zip/UKTurboExport/UKTurbo264.m


//
//  UKTurbo264.m
//  UKTurboExport
//
//  Created by Uli Kusterer on 09.02.08.
//  Copyright 2008 M. Uli Kusterer. All rights reserved.
//
 
// -----------------------------------------------------------------------------
//	Headers:
// -----------------------------------------------------------------------------
 
#import "UKTurbo264.h"
#import <QTKit/QTKit.h>
#import <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/usb/IOUSBLib.h>
 
 
// -----------------------------------------------------------------------------
//	Constants:
// -----------------------------------------------------------------------------
 
// Keys for our presets dictionary:
"UKTurbo264PresetIdentifier""UKTurbo264PresetDisplayName""UKTurbo264PresetInternalID";
 
// Keys for our presets dictionary:
"UKTurbo264DeviceCountChangedNotification";
 
// Keys for notifications' userInfo dictionaries:
"UKTurbo264DeviceHasFirmware""UKTurbo264DeviceVendorID""UKTurbo264DeviceProductID";
 
// The type of the Turbo.264 settings atom:
#define kTurboAtomPreset				'TPst'
 
// The different presets:
#define kTurboPresetIPodBest			'IpdB'
#define kTurboPresetIPodSmallest		'IpdS'
#define kTurboPresetPSP					'PspH'
#define kTurboPresetAppleTV				'ApTV'
#define kTurboPresetIPhone				'iPhn'
 
// Turbo device IDs:
#define kNumDifferentTurboDevices		3
#define	kTurboVendorID					0x0FD9
#define kTurboProductIDV1_NoFW			0x0004
#define kTurboProductIDV1				0x0005
#define kTurboProductIDV2				0x0006
 
 
// -----------------------------------------------------------------------------
//	Private methods:
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	Private structs:
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	Globals:
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	Return the shared instance of the Turbo-264 singleton:
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	init:
//		Allocate our ivars struct. This struct is used so we can safely export
//		this class to plug-ins or whatever without having to worry that things
//		will break if they subclass this class and we update it.
//		Unlikely, but better safe than sorry.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	dealloc:
//		Get rid of our ivars struct.
// -----------------------------------------------------------------------------
// Since this is a singleton, we'll just leak the IOKit iterators etc.
		//	for now.
// -----------------------------------------------------------------------------
//	isAvailable:
//		Returns YES if any Turbo devices are attached and the Turbo Component
//		is installed.
// -----------------------------------------------------------------------------
// Turbo Component not installed.
// -----------------------------------------------------------------------------
//	exportPresets:
//		Returns a list of all available export presets. You can use this to
//		populate a menu or whatever.
// -----------------------------------------------------------------------------
// No component installed.
// Can't export to anything.
"com.elgato.turbo.preset.ipod-best""iPod High",@"iPod export format""com.elgato.turbo.preset.ipod-smallest""iPod Standard",@"iPod export format""com.elgato.turbo.preset.psp""Sony PSP",@"PSP export format""com.elgato.turbo.preset.apple-tv""Apple TV",@"Apple TV export format""com.elgato.turbo.preset.iphone""iPhone",@"iPhone export format"// -----------------------------------------------------------------------------
//	exportPresetForID:
//		Returns the preset associated with the specified identifier, or NIL if
//		there is none available. You can use this to find the last preset your
//		app used with Turbo by saving the UKTurbo264PresetIdentifierKey from
//		the preset dictionary to prefs and then using this method to recover
//		the full and current dictionary corresponding to it.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	exportSettingsFromPreset:
//		Returns an NSData block suitable for use as the QTMovieExportSettings
//		entry in the attributes dictionary of QTMovie's writeToFile: method.
//		Use this to tell QTKit what preset to actually use when exporting to
//		Turbo.
// -----------------------------------------------------------------------------
// Find the Turbo component 'class':
"Could not find the Turbo component."// Show settings dialog to user:
"MovieExportGetSettingsAsAtomContainer returned %d.""Error %d trying to apply export settings.""Error %d calling MovieExportSetSettingsFromAtomContainer."// -----------------------------------------------------------------------------
//	writeToFileAttributesForPreset:
//		Returns an attributes dictionary ready to be passed to QTMovie's
//		-writeToFile: method that sets up everything for a Turbo export using
//		the specified preset.
// -----------------------------------------------------------------------------
// Turbo Component not installed.
// No need to listen for devices, couldn't use them anyway.
// Create a notification port attached to the current run loop so
		//	IOKit notifications can be sent through it:
// Match our device:
"%d Turbo devices attached.""%d Turbo devices attached."

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.