0

on https://developer.sony.com/develop/cameras/ I could find remote API only for DSC-HX60

Sosus
  • 31
  • 3

3 Answers3

0

Actually that table is showing all of the camera's that support the Camera Remote API as well as which features of the API you can use with each camera. If you have a camera that is on that list you just need to check which features of the API your camera supports and then you can begin developing.

https://developer.sony.com/develop/cameras/get-started/

pg316
  • 1,380
  • 1
  • 8
  • 7
0

I have found that the camera remote API sample does not work out of the box from Sony for DSC-HX50v with firmware version 1.00.

I have had success with the timelapse-sony program though. Thank you ThibaudM! There is a reference to this forum post that may shed light on what is going on with HX50V. It looks like limited wifi control is available.

Dear Sony engineer, will you please request an updated firmware version release for this model that supports full camera control via wifi?

highvelcty
  • 131
  • 1
  • 4
0

So I was looking into these apis in order to (ab)use my HX50V camera as a webcam. In the end the amount of remote control available is too limited for me but this seems to be the right place to share what I did find.

The below is based on connections from a PC, not a smartphone, and applies to other Sony models as well. All of this is documented in the Sony SDK but I hope to make things a bit more concise.

1. Setup a wifi connection to your camera

  • Enable Ctrl with Smartphone via the camera menu
  • Connect your computer wifi to your camera's SSID, in my case, "DIRECT-XXXX:DSC-HX50V" where XXXX and the rest may be different depending on your camera model (I suggest having a wired network connection, otherwise: no internet for you while tampering with your camera).
  • This connection will timeout, as in: the wifi disconnects, when not enough requests are sent. It is just a matter of reconnecting the wifi to enable requests to be sent again.

2. Discover your camera api URL: SSDP (optional)

A list of known Sony camera api urls is available in ThibaudM's configs in the mentioned timelapse-sony project, but for a generic solution you need to do this first. Skip to 3. if you're not interested in a generic approach and already know your camera api URL.

The Sony SDK says you need to do a SSDP M-Search discovery request to find out your camera's api. (Page 10 of the developer's guide). This is a UDP broadcast in a specific form that returns UPnP devices. Below is a ready-to-run powershell script (modified code from here)

#Use unused port or it will fail
$LocalEndPoint = New-Object System.Net.IPEndPoint([ipaddress]::Any,$Port)

$MulticastEndPoint = New-Object System.Net.IPEndPoint([ipaddress]::Parse("239.255.255.250"),1900)
$UDPSocket = New-Object System.Net.Sockets.Socket([System.Net.Sockets.AddressFamily]::InterNetwork,[System.Net.Sockets.SocketType]::Dgram,[System.Net.Sockets.ProtocolType]::Udp)
$UDPSocket.SetSocketOption([System.Net.Sockets.SocketOptionLevel]::Socket, [System.Net.Sockets.SocketOptionName]::ReuseAddress,$true)

$UDPSocket.Bind($LocalEndPoint)
$UDPSocket.SetSocketOption([System.Net.Sockets.SocketOptionLevel]::IP,[System.Net.Sockets.SocketOptionName]::AddMembership, (New-Object System.Net.Sockets.MulticastOption($MulticastEndPoint.Address, [ipaddress]::Any)))
$UDPSocket.SetSocketOption([System.Net.Sockets.SocketOptionLevel]::IP, [System.Net.Sockets.SocketOptionName]::MulticastTimeToLive, 2)
$UDPSocket.SetSocketOption([System.Net.Sockets.SocketOptionLevel]::IP, [System.Net.Sockets.SocketOptionName]::MulticastLoopback, $true)

#Write-Host "UDP-Socket setup done...`r`n"
#All SSDP Search
$SearchString = @"
M-SEARCH * HTTP/1.1
HOST:239.255.255.250:1900
MAN:"ssdp:discover"
ST:urn:schemas-sony-com:service:ScalarWebAPI:1
MX:3


"@
#^ 2 enters are important! leave in place.

$UDPSocket.SendTo([System.Text.Encoding]::UTF8.GetBytes($SearchString), [System.Net.Sockets.SocketFlags]::None, $MulticastEndPoint) | Out-Null

#Write-Host "M-Search sent...`r`n"

[byte[]]$RecieveBuffer = New-Object byte[] 64000
[int]$RecieveBytes = 0

$Response_RAW = ""
$Timer = [System.Diagnostics.Stopwatch]::StartNew()
$Delay = $True
while($Delay){
    #15 Second delay so it does not run forever
    if($Timer.Elapsed.TotalSeconds -ge 5){Remove-Variable Timer; $Delay = $false}
    if($UDPSocket.Available -gt 0){
        $RecieveBytes = $UDPSocket.Receive($RecieveBuffer, [System.Net.Sockets.SocketFlags]::None)

        if($RecieveBytes -gt 0){
            $Text = "$([System.Text.Encoding]::UTF8.GetString($RecieveBuffer, 0, $RecieveBytes))"
            $Response_RAW += $Text
        }
    }
}

$UDPSocket.Close()

$Response_RAW

This will output something like this:

HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
EXT: 
LOCATION: http://10.0.0.1:1900/scalarwebapi_dd.xml
SERVER: FedoraCore/2 UPnP/1.0 MINT-X/1.8.1
ST: urn:schemas-sony-com:service:ScalarWebAPI:1
USN: uuid:00000000-0005-0010-8000-abcdabcdabcd::urn:schemas-sony-com:service:ScalarWebAPI:1

LOCATION is the interesting bit here.

or if you have access to a C# environment and are feeling lucky, use this oneliner instead:

//ATT: this needs a project reference to COM library *UPnP 1.0 Type Library (Control Point)*
Console.WriteLine((new UPNPLib.UPnPDeviceFinder().FindByType("urn:schemas-sony-com:service:ScalarWebAPI:1", 0).OfType<UPnPDevice>().FirstOrDefault() as UPNPLib.IUPnPDeviceDocumentAccess)?.GetDocumentURL() ?? "nothing found");

(If no results show up for either of these, replace urn:schemas-sony-com:service:ScalarWebAPI:1 with ssdp:all and find your device info in the lists returned)

2.5 Discover your camera api URL part deux: XML (still optional)

All of this probing just gives you one url to work with which sort of looks like this: http://10.0.0.1:1900/scalarwebapi_dd.xml This is not the API url! (yet)

You can open it in a browser and should see something like this

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device>
        <deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
        <friendlyName>DSC-HX50V</friendlyName>
        <manufacturer>Sony Corporation</manufacturer>
        <manufacturerURL>http://www.sony.com/</manufacturerURL>
        <modelDescription>SonyRemoteCamera</modelDescription>
        <modelName>SonyImagingDevice</modelName>
        <modelURL>http://www.sony.net/</modelURL>
        <serialNumber/>
        <UDN>uuid:00000000-0005-0010-8000-784b8705bcbc</UDN>
        <serviceList>
            <service>
                <serviceType>urn:schemas-sony-com:service:ScalarWebAPI:1</serviceType>
                <serviceId>urn:schemas-sony-com:serviceId:ScalarWebAPI</serviceId>
                <SCPDURL/>
                <controlURL/>
                <eventSubURL/>
            </service>
        </serviceList>
        <av:X_ScalarWebAPI_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
            <av:X_ScalarWebAPI_Version>1.0</av:X_ScalarWebAPI_Version>
            <av:X_ScalarWebAPI_ServiceList>
                <av:X_ScalarWebAPI_Service>
                    <av:X_ScalarWebAPI_ServiceType>camera</av:X_ScalarWebAPI_ServiceType>
                    <av:X_ScalarWebAPI_ActionList_URL>http://10.0.0.1:10000/sony</av:X_ScalarWebAPI_ActionList_URL>
                    <av:X_ScalarWebAPI_AccessType/>
                </av:X_ScalarWebAPI_Service>
            </av:X_ScalarWebAPI_ServiceList>
        </av:X_ScalarWebAPI_DeviceInfo>
    </device>
</root>

The API url is here: <av:X_ScalarWebAPI_ActionList_URL>http://10.0.0.1:10000/sony</av:X_ScalarWebAPI_ActionList_URL>

This is documented in Chapter "Step 3. Call the APIs." of the Sony SDK Development guide.

Note! for the DSC-HX50V this documentation is incorrect! The endpoint for camera is not http://10.0.0.1:10000/sony/camera but http://10.0.0.1:10000/camera. Another endpoint I found responsive but could not get any helpful things from is http://10.0.0.1:10000/guide http://10.0.0.1:10000/sony only seems to return empty responses.

3. Query the API

Now that we finally have an API url we can query the capabilities of your Sony camera api by calling getAvailableApiList (for the /camera endpoint) and getMethodTypes (more detailed, works for other endpoints as well). This is documented in Sony_CameraRemoteAPIbeta_API-Reference_v2.40.pdf p.251-254 which is also included in the Sony SDK

Example: So for my HX50V for example I sent a HTTP POST request (using PostMan) to http://10.0.0.1:10000/camera

POST body:

{
    "version":"1.0",
    "id":1234,
    "method":"getAvailableApiList",
    "params":[]
}
  • Got this response:
{
    "id": 1235,
    "result": [
        [
            "getMethodTypes",
            "getAvailableApiList",
            "setShootMode",
            "getShootMode",
            "getSupportedShootMode",
            "getAvailableShootMode",
            "setFlashMode",
            "getFlashMode",
            "getSupportedFlashMode",
            "getAvailableFlashMode",
            "setSelfTimer",
            "getSelfTimer",
            "getSupportedSelfTimer",
            "getAvailableSelfTimer",
            "startLiveview",
            "stopLiveview",
            "actTakePicture",
            "startMovieRec",
            "stopMovieRec",
            "actZoom",
            "getApplicationInfo",
            "getVersions",
            "receiveEvent"
        ]
    ]
}

Reading this list, it turns out the HX50V has a fixed LiveView, which is set to a dismal 640x480 px. This is where my attempt at turning this camera in a webcam ended.

Other cameras do have support for the "Liveview size" api. It's all in a huge table on page 11 in the Sony API reference - Except the HX50V is not listed.

Timelapses are still a possibility, though, but USB charging is disabled when connected via Wifi for some unfathomable reason, so it won't be possible to have the camera going for days on end without some extra batteries.

Anyway, I hope this helps someone trying to figure out the Sony Apis.

H B
  • 701
  • 6
  • 9