private void UpdateModelWithLocalDevice <T>(T[] localSources, IDictionary <string, IInputDevice> model) where T : LocalSource { foreach (var s in localSources) { if (!model.TryGetValue(s.Id, out var videoInput)) { videoInput = _coreData.Create <IInputDevice>(); videoInput.Name = s.Name; videoInput.State = s.State; videoInput.Type = s.Type; model[s.Id] = videoInput; } else { videoInput.State = s.State; } } foreach (var item in model) { if (!localSources.Any(s => s.Id == item.Key)) { item.Value.State = InputDeviceState.Removed; } } }
public MainTargetsModel(StaticFilesCacheService staticFilesCacheService, CoreData coreData, ConnectionService connectionService, IAppResources resources, TranscodingModel transcoding) { _staticFilesCacheService = staticFilesCacheService; CoreData = coreData; _connectionService = connectionService; _resources = resources; AppData = resources.AppData; Transcoding = transcoding; CustomTarget = CoreData.Create <ITarget>(s => { s.Flags = TargetFlags.Key | TargetFlags.Url; s.Name = "Custom"; s.WebUrl = ""; }); }
internal string AddResource(string fileName, byte[] data, ResourceType type) { var name = Path.GetFileNameWithoutExtension(fileName); var res = _coreData.Create <IResource>(); var now = DateTime.UtcNow; res.LastUse = now; res.Data = data; res.Info = new ResourceInfo { Added = now, Type = GetResourceType(fileName, type), Name = name, DataHash = GetHash(data) }; var id = IdGenerator.New(); SaveToFile(id, data); lock (_cache) _cache[id] = data; _coreData.Root.Resources[id] = res; return(id); }
private void DoSelected(TargetModel model) { var channel = CoreData.Create <IChannel>(s => s.TargetId = model?.Source?.Id); CoreData.Root.Channels[IdGenerator.New()] = channel; }
public void Start() { TariffUrl = _connectionService.UserName == null ? _appResources.AppData.PricingUrlForNotRegistered : _appResources.AppData.PricingUrl; var settings = CoreData.Root.Settings; var claims = _connectionService.Claims; if (CoreData.Root.Transcoders.Count == 0) { var trans = CoreData.Create <ITranscoder>(); trans.Bitrate = Math.Min(2500, settings.Bitrate); trans.Fps = Math.Min(30, settings.Fps); trans.Resolution = new Resolution(1280, 720); if (settings.Resolution?.Width < trans.Resolution?.Width) { trans.Resolution = settings.Resolution; } CoreData.Root.Transcoders[IdGenerator.New()] = trans; } TranscodingEnabled = claims.Transcoders > 0; _transId = CoreData.Root.Transcoders.First().Key; var transcoder = CoreData.Root.Transcoders[_transId];; Transcoder.Value = transcoder; OriginalFpss = StreamSettings.FpsList.Select(s => new TrascodingComboboxValue { Name = s.ToString(), Value = s, Good = s <= claims.TranscoderInputLimit.Fps }).ToArray(); OriginalResolutions = StreamSettings.Resolutions.Select(s => new TrascodingComboboxValue { Name = s.ToString(), Value = s, Good = s.Height <= claims.TranscoderInputLimit.Height }).ToArray(); Resolutions = StreamSettings.Resolutions.Where(s => s.Height <= claims.TranscoderOutputLimit.Height).ToArray(); FpsList = StreamSettings.FpsList.Where(s => s <= claims.TranscoderOutputLimit.Fps).ToArray(); if (claims.TranscoderOutputLimit.Fps < transcoder.Fps) { transcoder.Fps = claims.TranscoderOutputLimit.Fps; } if (claims.TranscoderOutputLimit.Height < transcoder.Resolution.Height) { transcoder.Resolution = Resolutions[0]; } MaxResolution = $"Original stream's resolution exceeds maximum allowed {Resolutions[0].Width}x{Resolutions[0].Height}. TRANSCODING WILL NOT WORK."; MaxFps = $"Original stream's FPS (frames per second) exceeds maximum allowed {claims.TranscoderInputLimit.Fps}. TRANSCODING WILL NOT WORK."; OriginalFpsCurrent.OnChange = (a, b) => { if (b?.Value is int newValue) { settings.Fps = newValue; } }; OriginalResolutionCurrent.OnChange = (a, b) => { if (b?.Value is Resolution newValue) { settings.Resolution = newValue; } }; CoreData.Subscriptions.SubscribeForAnyProperty <IChannel>((s, c, p, v) => Refresh()); CoreData.Subscriptions.SubscribeForAnyProperty <ITranscoder>((s, c, p, v) => Refresh()); CoreData.Subscriptions.SubscribeForAnyProperty <ISettings>((s, c, p, v) => Refresh()); Refresh(); }