public static async Task <bool> ReOpenLiveviewStream(DeviceApiHolder api, StreamProcessor liveview) { DebugUtil.Log("Reopen liveview stream"); liveview.CloseConnection(); await Task.Delay(2000).ConfigureAwait(false); return(await OpenLiveviewStream(api, liveview).ConfigureAwait(false)); }
public TargetDevice(SonyCameraDeviceInfo info, HostName local) { Udn = info.UDN; DeviceName = info.ModelName; FriendlyName = info.FriendlyName; LocalAddress = local; _Api = new DeviceApiHolder(info); _Status = new CameraStatus(); _Observer = new StatusObserver(this); }
public static async Task <bool> CloseLiveviewStream(DeviceApiHolder api, StreamProcessor liveview) { DebugUtil.Log("Close liveview stream"); try { liveview.CloseConnection(); await api.Camera.StopLiveviewAsync().ConfigureAwait(false); return(true); } catch (RemoteApiException e) { DebugUtil.Log("Failed to stopLiveview: " + e.code); return(false); } }
public static async Task StopContinuousShooting(DeviceApiHolder api) { int retry = 5; while (retry-- > 0) { try { await api.Camera.StopContShootingAsync(); break; } catch (RemoteApiException) { } DebugUtil.Log("failed to stop cont shooting. retry count: " + retry); await Task.Delay(TimeSpan.FromMilliseconds(200)); } }
private static async Task <bool> TakePicture(DeviceApiHolder api, Geoposition position, bool awaiting = false) { DebugUtil.Log("Taking picture sequence"); try { var urls = awaiting // ? await api.Camera.AwaitTakePictureAsync().ConfigureAwait(false) // : await api.Camera.ActTakePictureAsync().ConfigureAwait(false); DebugUtil.Log("Success taking picture"); if (ApplicationSettings.GetInstance().IsPostviewTransferEnabled) { foreach (var url in urls) { try { var uri = new Uri(url); MediaDownloader.Instance.EnqueuePostViewImage(uri, position); } catch (Exception e) { DebugUtil.Log(e.Message); DebugUtil.Log(e.StackTrace); return(false); } } return(true); } else { return(true); } } catch (RemoteApiException e) { if (e.code != StatusCode.StillCapturingNotFinished) { DebugUtil.Log("Failed to take picture: " + e.code); throw e; } } DebugUtil.Log("Take picture timeout: await for completion"); return(await TakePicture(api, position, true).ConfigureAwait(false)); }
public static async Task <bool> OpenLiveviewStream(DeviceApiHolder api, StreamProcessor liveview) { DebugUtil.Log("Open liveview stream"); try { var url = await api.Camera.StartLiveviewAsync().ConfigureAwait(false); return(await liveview.OpenConnection(new Uri(url)).ConfigureAwait(false)); } catch (RemoteApiException e) { DebugUtil.Log("Failed to startLiveview: " + e.code); return(false); } catch (Exception e) { DebugUtil.Log("Unknown error while opening liveview stream: " + e.StackTrace); return(false); } }
public static async Task <bool> TakePicture(DeviceApiHolder api, Geoposition position) { return(await TakePicture(api, position, false).ConfigureAwait(false)); }