simonmitchell / rocc Goto Github PK
View Code? Open in Web Editor NEWA Swift framework for remote control of digital Cameras
License: MIT License
A Swift framework for remote control of digital Cameras
License: MIT License
Set camera to a European language which uses "," as the decimal separator instead of ".". See that aperture values fail to parse and therefore the Event
object fails to include
Aperture values are not parsed, and therefore not available to consumers of this library.
Aperture values should be correctly parsed and handed on to users of the library!
2.0.0
N/A
a6500
Yes! Firmware is fully up to date
Try and call getCameraFunction
rapidly after just connecting to RX0.
The function call returns a 40401 error (Camera not ready)
This function call should not return a 40401
1.0.2
iOS 13.2.1
Sony RX0
Change focus mode or Drive mode
The camera does not reflect the changes
The drive mode and Focus mode on the camera should be updated to reflect the change in the app as with shutter, iso and aperture
2.0
13.5
Sony A9
Firmware 6.0
Unfortunately whilst we have recently added support for control of the a9ii (see 2.0.0 release branch), it seems that either in the latest a9ii firmware, or just on the a9ii Sony have changed the format of the live view stream.
Luckily I managed to find a user with experience using WireShark so we have a trace of this data which I have put part of here
I have tried to attempt to break this payload down... it seems to have some resemblance of an RTP stream (In particular, ffmpeg seems to think it's mjpeg) but the format does not match RFC 2435.
I'm not sure whether we aim to try and reverse-engineer their protocol entirely, or if we simply try and do a hacky fix to simply remove their RTP headers from the stream of data (Which could break in the future). I'm not even sure if there's a reliable way to detect RTP headers in the Data
, or if we even get sent them or they're removed by URLSession!
Here's my attempt at breaking down the stream:
// RTP Header
HEX: 88
Binary: 10 | 0 | 0 | 1000 |
Version 2 | No Padding | No extension header | 8 CSRC Identifiers |
00 // No type, marker, e.t.c
00 00 // Sequence number 0
00 5e 00 00 // Timestamp (24064)
10 00 00 00 // SSRC Identifier (16)
// CSRC Identifiers (8 of them)
78 00 00 00
0d 0a 37 38
0d 0a 65 00
00 00 00 00
00 00 01 00
00 00 00 00
00 00 02 00
00 00 00 00
00 // Type-specific, not the correct type for JPEG stream
00 00 00 // Fragment Offset, this never goes above zero so can't be right!
00 // Type (0)
00 // Q (0)
03 // Width (3 * 8) = 24... this can't be right!
00 // Height (0 * 8) = 0
00 00
03 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00
0a 00 00 80 07 00 00 00 00 00
00 00 00 00 00 00 0a 00 00 80
07 00 00 00 00 00 00 00 00 00
00 00 0a 00 00 80 07 00 00 00
00 00 00 00 00 00 00 00 0a 00
00 80 07 00 00 00 00 00
00 00
00 00 0d 0a 35 45 30 30 0d 0a
// Beginning of JPEG segment
ff d8 ff db 00 84 00 03 03 03
03 03 03 05 05 05 05 05 05 05
05 05 0a 08 05 05 08 0a 0d 0a
Take photos in a loop (either using code and Rocc, or Camrote)
The app hangs after a while, waiting for a callback that never arrives
The routine continues until the battery is drained :)
f3763b8 / Camrote 1.6.5
iOS 14.2
RX100 VII
Yes
What's NVDA? :)
I think I've seen this hanging in every possible completion callback in https://github.com/simonmitchell/rocc/blob/master/Sources/Manufacturer%20Implementations/Sony/PTP%20IP%20Camera/SonyPTPIPCamera+TakePicture.swift#L22 Moreover, my app waits for photo download before starting a new capture, and sometimes it hangs there, too (i.e. no JPEG is recognized even though objectAdded and objectRemoved events were received as usual).
My current hypothesis is that when we execute a command that is immediately followed by getAllDevicePropDesc
(because some event was received) the camera assumes that responses to previous queries were included in "all device props" and doesn't bother dealing with old commands. This is supported by the fact that transactionId of responses seems to always monotonic (warning: this is not scientific, that's just what I saw with my sample sequences).
Unfortunately, so far I wasn't able to reliably serialize commands (so that getAllDevicePropDesc
is called only after all previous commands finished) without any side effects. I also tried timing out all completion callbacks that were awaiting transactionIds older than the last received one. Again, that didn't seem to fully resolve the issue and caused problems with exposure settings.
Another idea is that there might be some field in getAllDevicePropDesc
that instructs how to handle outstanding requests.
I'm a bit reluctant to attach my Wireshark sessions here because:
In terms of next steps, I'm working on a custom Wireshark dissector that will more reliably detect Sony PTPIP packets based on this work: https://github.com/sboisson/wireshark-ptpip (GPL alert, don't base your apps on that, use only as an external validation tool). My hope is that it'll be easier to spot differences between Sony's app behavior and Rocc.
This issue will be a log of my plan of action and implementation of support for camera manufacturers other than Sony in ROCC!
I want ROCC (as well as Camrote) to be as useful a tool as possible for as many photographers and developers as possible. Until now my main focus has been on Sony cameras (with that being the brand of camera I own) but after implementing PTP/IP for Sony’s latest lineup of cameras I – unbeknownst to me – did a lot of the groundwork for supporting a lot of other manufacturers!
As Camrote (as well as other iOS apps) rely on a stable library for controlling Sony cameras it is vitally important that none of the work done when refactoring PTP/IP support (a necessity to reduce complexity and duplicate code across manufacturers) breaks support for these models.
For this reason, the number one priority is releasing v2.0.0 of Camrote along with an extensive suite of tests for Sony devices using PTP/IP support. This is already underway but requires some time as it is a painstaking process making sure hex packets being sent and received are spot-on.
It is also important to make Camrote as accessible as possible to devs, so I will also be concentrating on adding support for SPM in this release if possible without refactoring large areas of the codebase.
I am very optimistic that support for other manufacturers will be able to be added without any breaking changes now that Sony PTP/IP support has been completed, however this may need to be re-assessed at a later date depending on implementation discoveries when trying to refactor or implement support for other manufacturers.
Whilst adding support is theoretically possible without me having test devices (which I am unable to afford at present) I am hoping I will be able to lean heavily on technical folk in the photographical community to test beta releases of Camrote, or even to develop support for other manufacturers themselves via forking and submitting pull requests to this repo.
Once I have refactored the project to a point where I think this is possible (using a wireshark dump of the Canon remote app provided by a kind Reddit user) I will create a guide on how to implement and test other manufacturers, and likely also produce a demo app to test functionality without having to write any code.
SonyPTPIPCamera
SonyPTPIPCamera
to PTPIPCamera
using libgphoto2 as a guide for what standard behaviour is and overriding non-standard behaviour in SonyPTPIPCamera
ROCC (And Camrote) are very much part-time ventures for me, and I’m not at a point in my life when I can invest money (or large amounts of time) in them! There are many ways you can support the ongoing development, both financially and non-financially!
This is the first library that I have ever sole-developed that has had such a large scope and has had this many stars... I am not by any stretch of the imagination an expert in computer science or networking technologies so any advice/insight etc on any of the code or approaches is greatly appreciated!
I do not have the money to buy devices from all manufacturers, but any money that is donated via the Camrote website, via my buymeacoffee or via the “fund me” options in Camrote (please don’t use this, as Apple get a 30% cut) will go directly towards buying test gear!
Once i have guidelines out for how to add support for other manufacturers (or even before) please contribute to ROCC (in any way) to make sure it’s as good and as stable as possible.
If you don’t have the money to contribute financially, but happen to have a camera from another manufacturer please, please, please provide annotated Wireshark dumps from the remote control app your manufacturer provides! I will be providing instructions on how to do this shortly...
We all have old cameras lying around (sadly my old Canon was too old to have a WiFi chip), if you do, and it’s just gathering dust, or broken horribly (but still controllable remotely) then please consider donating it to the cause! If you want details on how you can do this then please contact me: [email protected]
Thank you for taking the time to read this! I look forward to all of your input
Things like WhiteBalance.Value.mode
can be changed to an enum rather than a string!
PTP IP on Sony has new shooting modes which are returned by the stillCaptureMode
object in events. Instead of adding a still capture mode property, I'd like to enhance ShootMode
to include Bracketed
and other relevant ones returned via PTP IP and then munge the data in ROCC to support this.
hello
I would like to ask, can ROCC frame support SONY camera to view photos and download on SD card?
Can I receive information about newly taken and deleted photos?
Cheers.
Add super slow rec ("super slow rec"
) to shoot mode enum
"Hi, I’m using an A7RIV and started by playing around with Sony’s app before trying yours. The reason being, like many photographers I use back button focus and turn off AF w/ shutter. Unfortunately, that means in Sony’s app that I can’t focus unless I turn it back on. Is this a camera limitation or is there any way you can get around this via your app?"
NWConnectionGroup is a much more usable API than CFSocket... CFSocket is ancient, and difficult to use, and means we have to handle network changes ourselves. If we can move over to using the Networking framework (At least on iOS 14 for now) we can remove some of the tricky reachability stuff we have going on and let Apple handle it for us.
Will need to think of a clever way to keep support for both so we can still support iOS < 14, perhaps making UDPClient
a protocol and setting it using an if #available(
statement in the initialiser of the UDP device discovery.
Add support for popular package managers:
Connect to camera observe isConnected after:
camera.connect { (error, isInTransferMode) in
isConnected is false
isConnected should be true
Mac OS iOS 13.3.1 Sony A9
iOS 13.3.1
Sony A9
The library can no longer connect to Sony α9 cameras after the 5.0 firmware released for them, the API description files which Sony make available on the camera have changed reasonably drastically and no longer contain an array of services
in the X_ScalarWebAPI_DeviceInfo
of dd.xml
:
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0" xmlns:av="urn:schemas-sony-com:av">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
<friendlyName>ILCE-9</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
<manufacturerURL>http://www.sony.com/</manufacturerURL>
<modelDescription>SonyRemoteCamera</modelDescription>
<modelName>SonyImagingDevice</modelName>
<modelURL>http://www.sony.net/</modelURL>
<UDN>uuid:00000000-0005-0010-8000-60f189acc029</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-sony-com:service:DigitalImaging:1</serviceType>
<serviceId>urn:schemas-sony-com:serviceId:DigitalImaging</serviceId>
<SCPDURL>/DigitalImagingDesc.xml</SCPDURL>
<controlURL>/upnp/control/DigitalImaging</controlURL>
<eventSubURL></eventSubURL>
</service>
</serviceList>
<av:X_ScalarWebAPI_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_ScalarWebAPI_ImagingDevice>
<av:X_ScalarWebAPI_LiveView_URL>http://192.168.122.1:60152/liveviewstream?%211234%21%2a%3a%2a%3aimage%2fjpeg%3a%2a%21%21%21%21%21</av:X_ScalarWebAPI_LiveView_URL>
<av:X_ScalarWebAPI_DefaultFunction>RemoteShooting</av:X_ScalarWebAPI_DefaultFunction>
</av:X_ScalarWebAPI_ImagingDevice>
</av:X_ScalarWebAPI_DeviceInfo>
</device>
</root>
There is still reference to X_ScalarWebAPI
so I am hopeful with a few small tweaks full-behaviour will be re-instated, but there could be more to it: Like Sony moving to PTP (We see reference to PTP versions in digitalImagingDescription.xml
)
An attempt to hard-code the expected services has been made here which will be going out to testers of Camrote later today! 🤞 it's as simple as this, otherwise we're looking at significant amounts of work and needing access to an α9 body, which is something I can't personally afford currently!
Create a demo (iOS for now) project so when people want to get started with ROCC they don't have to flesh out a whole app UI and perform connection to the Camera's WiFi network e.t.c. this should be basic, and provide a standard UI for each of the functions available! Not going to be pretty but it will work and help people debug issues on particular models!
There is a vast list of error command response codes. The awaitData function should be enhanced to return a Result
object to its completion closure and in the case of a bad response code should error. The command response code can be ignored if an end data packet is received as some cameras don’t send it in this case, but otherwise should be heeded
Maybe by having different protocols for if the camera supports polled events (Continuously hitting endpoint like smart remote control API) or if it responds to events sent by the camera that a new event is ready (PTP IP). See Issue #1 for further ideas on this!
Something is happening currently to certain camera models (perhaps not formatting SD card regularly even, as one user reported this fixing his issue) which means that our code isn’t finding date folders via UPnP for all dates that the camera has stored.
Some preliminary investigation shows that on Camrote we start by searching for a folder with ObjectID “0” we then get a single result which is “PhotoRoot”... which also has a unique identifier based single folder, and when we ask this for all subfolders we don’t get all of the date folders. It’s possible we need to paginate the request to this folder or make it sort in ascending date order rather than descending or similar.
Need to call first:
Cmd_Request OpenSession command
Cmd_Request GetDeviceInfo command
Cmd_Request sdioGetExtDeviceInfo command
Try and connect to RX100-M2
getVersions
call returns a 404 (Not found)
Should be able to connect correctly to the device.
N/A
Sony RX100-M2
Unsure...
Ddoes the manufacturer source support RAW file transfer? I think that would make this library really stand out!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.