public CameraModel Create(CreateCameraModel createCameraModel) { var streamSourceData = StreamSourceData.CreateStreamSourceData(createCameraModel.ScopeId, createCameraModel.VideoSource, false); var camera = Container.Cameras.Create(streamSourceData); return(new CameraModel { StreamId = camera.StreamId.Value }); }
public VideoProcessor Add(VideoProcessor videoProcessor) { bool createScope = false; if (videoProcessor.StreamId != 0) { throw new ProcessingException($"Unable to set readonly property {nameof(videoProcessor.StreamId)}"); } if (videoProcessor.Enabled.HasValue && videoProcessor.Enabled.Value && string.IsNullOrEmpty(videoProcessor.VideoSource)) { throw new ProcessingException( $"Unable to enable {nameof(VideoProcessor)}, {nameof(videoProcessor.VideoSource)} is empty"); } if (!videoProcessor.ScopeId.HasValue) { createScope = true; Log.LogWarning($"Property {nameof(videoProcessor.ScopeId)} is not set. New Scope will be created."); } if (createScope) { var scope = ApiProvider.Scopes.Create(); videoProcessor.ScopeId = scope.Id; } var createCameraModel = new CreateCameraModel { ScopeId = videoProcessor.ScopeId.Value, VideoSource = videoProcessor.VideoSource }; var camera = ApiProvider.Cameras.Create(createCameraModel); videoProcessor.StreamId = camera.StreamId; Edit(videoProcessor); videoProcessor = Read(camera.StreamId); return(videoProcessor); }