Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X app remote camera control over wi-fi

Tags:

objective-c

I would like to build a program for Mac OS X to remote control my DSLR camera. The camera I have has a WiFi adapter so, I would like the control be done over WiFi. I have a good understanding of C, basic intermediate knowledge of Objective C / Xcode but no experience with WiFi which framework should I use for the connection to the camera and the communication between the camera and the computer? thanks!

like image 268
user1888762 Avatar asked Nov 12 '22 15:11

user1888762


1 Answers

If you're referring to PTP over IP (PTP/IP), as far as I understand it this is only used for transferring media to/from the camera (not sure what remote control functionality is possible) and it is basically a TCP/IP connection. You would need to establish a TCP connection. As NSBum suggested this would require NSInputStream and NSOutputStream, as well as having a class as a NSStreamDelegate to handle stream events such as the Camera communicating with the computer.

As for the actual protocol, this should be handled by the SDK you downloaded, if it's not here's some documentation that may help you get started: gPhoto PTP/IP Documentation

And some code to show NSInputStream and NSOutputStream:

// This would either be part of a Class init method or called at some point after
CFReadStreamRef readStream;
    CFWriteStreamRef writeStream;
    CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.1.2", 1234, &readStream, &writeStream);
    inputStream = (__bridge NSInputStream *)readStream;
    outputStream = (__bridge NSOutputStream *)writeStream;

[inputStream setDelegate:self];
[outputStream setDelegate:self];

[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[inputStream open];
[outputStream open];

And for writing to the outputStream as a general example:

// data is of class NSData, the following writes the data bytes to the outputStream
[outputStream write:[data bytes] maxLength:[data length]];

Your NSStreamDelegate will also need to provide an implementation of this method:

- (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent

Documentation: NSStreamDelegate Protocol Reference (Also on the left sidebar is a link to the Stream Programming Guide)

like image 55
jamie_c Avatar answered Nov 15 '22 07:11

jamie_c