public VideoDisplayWindow(IMission mission, IDeployment deployment)
        {
            InitializeComponent();

            Mission = mission;
            Deployment = deployment;
            Title = String.Format("Video - {0} > {1}", mission.Name, deployment.DateTime.ToString());

            var app = Application.Current as App;
            if (app == null)
            {
                throw new Exception("Something has gone arye!");
            }

            triggerStateChangedHandler = new TriggerStateChangedHandler(ControllerTriggerStateChanged);
            buttonStateChangedHandler = new ButtonStateChangedHandler(ControllerButtonStateChanged);

            deviceManager = (Application.Current as App).DeviceManager;
            if (deployment.Devices.Count > 0)
            {
                deviceManager.ActiveDevice = deployment.Devices[0];
                deviceManager.ActiveDevice.MessageReceived += new DeviceMessageHandler(ActiveDeviceMessageReceived);
            }

            headsUpDisplay.YawOffset = Settings.Default.YawOffset;
            this.Dispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate
            {
                if (deployment.Devices.Count > 0)
                {
                    IDevice device = deployment.Devices[0];
                    device.FrameReady += DeviceFrameReady;
                    device.Open();
                    try
                    {
                        IDevice activeDevice = deviceManager.ActiveDevice;
                        deviceManager.ActiveDevice.StartVideoCapture(1000);
                        activeDevice.FinRange = Settings.Default.FinRange;
                        activeDevice.TopFinOffset = Settings.Default.TopFinOffset;
                        activeDevice.RightFinOffset = Settings.Default.RightFinOffset;
                        activeDevice.BottomFinOffset = Settings.Default.BottomFinOffset;
                        activeDevice.LeftFinOffset = Settings.Default.LeftFinOffset;
                        activeDevice.CTD = true;

                    }
                    catch (Exception ex)
                    {
                        StringBuilder message = new StringBuilder(ex.ToString());
                        Exception inner = ex.InnerException;
                        while (inner != null)
                        {
                            message.AppendLine(inner.ToString());
                            inner = inner.InnerException;
                        }
                        MessageBox.Show(message.ToString(), "Error Initializing Capture:" + ex.Message);
                        this.Close();
                    }
                }
                return null;
            }), null);
        }
 public DashboardWindow(IMission mission, IDeployment deployment)
 {
     InitializeComponent();
     Mission = mission;
     Deployment = deployment;
     deviceManager = (Application.Current as App).DeviceManager;
     if (deployment.Devices.Count > 0)
     {
         deviceManager.ActiveDevice = deployment.Devices[0];
         deviceManager.ActiveDevice.MessageReceived += ActiveDeviceMessageReceived;
     }
     controllerAxisChangedHandler = ControllerAxisChanged;
     controllerConnectionChangedHandler = ControllerConnectionChanged;
     bitmapFrameCapturedHandler = VideoDisplayWindowBitmapFrameCaptured;
     this.Title = String.Format("Dashboard - {0} > {1}", mission.Name, deployment.DateTime.ToString());
     YawOffsetSlider.ValueChanged += YawOffsetSliderValueChanged;
     PitchOffsetSlider.ValueChanged += PitchOffsetSliderValueChanged;
     FinRangeSlider.ValueChanged += FinRangeSliderValueChanged;
     TopFinOffsetSlider.ValueChanged += TopFinOffsetSliderValueChanged;
     RightFinOffsetSlider.ValueChanged += RightFinOffsetSliderValueChanged;
     BottomFinOffsetSlider.ValueChanged += BottomFinOffsetSliderValueChanged;
     LeftFinOffsetSlider.ValueChanged += LeftFinOffsetSliderValueChanged;
     illuminationSlider.ValueChanged += IlluminationSliderValueChanged;
     focusSlider.ValueChanged += focusSliderValueChanged;
     buoyancySlider.ValueChanged += buoyancySliderValueChanged;
 }
Exemple #3
0
        internal HMDManager(IFactory factory, IDeviceManager manager)
        {
            if (factory == null)
                throw new ArgumentNullException();

            if (manager == null)
                throw new ArgumentNullException();

            _factory = factory;
            _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
            _manager = manager;
            _handler = new InternalMessageHandler(this);
            _manager.MessageHandler = _handler;
            _nativeResources = new Dictionary<DeviceKey, DeviceResources>();
            _devices = new Dictionary<DeviceKey, HMD>();
            _defaultprofile = manager.DeviceDefaultProfile;

            // Initially, we must to enumerate all devices, which are currently attached
            // to the computer.
            using (var handles = _manager.HMDDevices)
            {
                foreach (var handle in handles)
                {
                    AddDevice(handle);
                }
            }
        }
Exemple #4
0
        public void Load(IServiceProvider serviceProvider)
        {
            try
            {
                s_traceContext = (ITraceContext)serviceProvider.GetService(typeof(ITraceContext));

                //must have the icelib sdk license to get the session as a service
                s_session = (Session)serviceProvider.GetService(typeof(Session));
                s_connection = new Connection.Connection(s_session);
            }
            catch (ArgumentNullException)
            {
                s_traceContext.Error("unable to get Icelib Session, is the ICELIB SDK License available?");
                Debug.Fail("unable to get service.  Is the ICELIB SDK licence available?");
                throw;
            }

            s_interactionManager = new InteractionManager(s_session, (IQueueService)serviceProvider.GetService(typeof(IQueueService)), s_traceContext);
            s_statusManager = new CicStatusService(s_session, s_traceContext);
            s_notificationService = (INotificationService)serviceProvider.GetService(typeof(INotificationService));

            s_settingsManager = new SettingsManager();
            s_deviceManager = new DeviceManager(s_traceContext, new SpokesDebugLogger(s_traceContext));

            s_statusChanger = new StatusChanger(s_session, s_statusManager, s_deviceManager, s_settingsManager);
            s_notificationServer = new NotificationServer(s_deviceManager, s_settingsManager, s_notificationService);

            s_hookSwitchManager = new InteractionSyncManager(s_interactionManager, s_deviceManager, (IQueueService)serviceProvider.GetService(typeof(IQueueService)), s_traceContext, s_connection);

            s_outboundEventNotificationService = new OutboundEventNotificationService(s_session, s_statusManager, s_deviceManager, s_traceContext);

            s_traceContext.Always("Plantronics AddIn Loaded");
        }
Exemple #5
0
 public override void Initialize(Context context)
 {
     this.context = context;
     deviceManager = context.DeviceManager;
     devices = deviceManager.GetDevice();
     progressPanel.Left = (Width - progressPanel.Width) / 2;
     progressPanel.Top = (Height - progressPanel.Height) / 2;
 }
Exemple #6
0
        public Context()
        {
            Dispatcher dispatcher = new Dispatcher(this);
            processDispatcher = dispatcher;
            serviceDispatcher = dispatcher;

            deviceManager = new DeviceManager();
        }
Exemple #7
0
 public AuthService(IUserManager userManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager, ISessionManager sessionManager, IDeviceManager deviceManager)
 {
     AuthorizationContext = authorizationContext;
     _config = config;
     DeviceManager = deviceManager;
     SessionManager = sessionManager;
     ConnectManager = connectManager;
     UserManager = userManager;
 }
 public StatusViewModel(IDeviceManager deviceSettings)
 {
     _deviceManager = deviceSettings;
     UpdateValues();
     _deviceManager.HeadsetConnected +=OnSettingsChanged;
     _deviceManager.HeadsetDisconnected += OnSettingsChanged;
     _deviceManager.MuteChanged += OnSettingsChanged;
     _deviceManager.PlantronicsDeviceAttached += OnSettingsChanged;
     _deviceManager.PlantronicsDeviceDetached += OnSettingsChanged;
 }
Exemple #9
0
        /// <summary>
        /// Initializes the Device Driver System.
        /// </summary>
        public static void Initialize()
        {
            // Create the Device Driver Manager
            deviceDriverRegistry = new DeviceDriverRegistry(PlatformArchitecture.X86);

            // Create Resource Manager
            resourceManager = new ResourceManager();

            // Create Device Manager
            deviceManager = new DeviceManager();
        }
        public NotificationServer( IDeviceManager deviceManager, ISettingsManager settingsManager, INotificationService addinNotificationService)
        {
            _addinNotificationService = addinNotificationService;
            _deviceManager = deviceManager;
            _settingsManager = settingsManager;

            _deviceManager.PlantronicsDeviceAttached += OnPlantronicsDeviceAttached;
            _deviceManager.HeadsetConnected += OnHeadsetConnected;
            _deviceManager.PlantronicsDeviceDetached += OnPlantronicsDeviceDetached;
            _deviceManager.HeadsetDisconnected += OnHeadsetDisconnected;
        }
Exemple #11
0
        public Voltmeter(IDeviceManager deviceManager, ITaskQueue eventsQueue)
        {
            Contract.Requires<ArgumentNullException>(deviceManager != null);
            Contract.Requires<ArgumentNullException>(eventsQueue != null);

            DeviceManager = deviceManager;
            EventsQueue = eventsQueue;
            Readings = new ElectricReadings();
            Use10BitVoltage = true;
            PollingInterval = DeviceConstants.MinPollingInterval;
        }
Exemple #12
0
        public StatusChanger(Session icSession, ICicStatusService cicStatusService, IDeviceManager deviceManager, ISettingsManager settingsManager )
        {
            _settingsManager = settingsManager;
            _deviceManager = deviceManager;
            _cicStatusService = cicStatusService;
            _icSession = icSession;

            _deviceManager.PlantronicsDeviceAttached += OnPlantronicsDeviceAttached;
            _deviceManager.HeadsetConnected += OnHeadsetConnected;
            _deviceManager.PlantronicsDeviceDetached += OnPlantronicsDeviceDetached;
            _deviceManager.HeadsetDisconnected += OnHeadsetDisconnected;
        }
Exemple #13
0
 public Notifications(IInstallationManager installationManager, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config, IDeviceManager deviceManager)
 {
     _installationManager = installationManager;
     _userManager = userManager;
     _logger = logger;
     _taskManager = taskManager;
     _notificationManager = notificationManager;
     _libraryManager = libraryManager;
     _sessionManager = sessionManager;
     _appHost = appHost;
     _config = config;
     _deviceManager = deviceManager;
 }
Exemple #14
0
 public BlockingModel(IDeviceManager deviceManager, IDictionary<string, int> inputs, IDictionary<string, int> relays)
 {
     try
     {
         _logger = NLog.LogManager.GetCurrentClassLogger();
     }
     catch
     {
         _logger = null;
     }
     _deviceManager = deviceManager;
     _inputs = inputs;
     _relays = relays;
 }
Exemple #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
 /// </summary>
 protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer)
 {
     JsonSerializer = jsonSerializer;
     ZipClient = zipClient;
     MediaSourceManager = mediaSourceManager;
     DeviceManager = deviceManager;
     SubtitleEncoder = subtitleEncoder;
     DlnaManager = dlnaManager;
     FileSystem = fileSystem;
     ServerConfigurationManager = serverConfig;
     UserManager = userManager;
     LibraryManager = libraryManager;
     IsoManager = isoManager;
     MediaEncoder = mediaEncoder;
 }
        public DeviceMonitor(IDeviceManager deviceManager, string searchPattern)
        {
            Contract.Requires<ArgumentNullException>(deviceManager != null);
            Contract.Requires<ArgumentNullException>(searchPattern != null);
            DeviceManager = deviceManager;
            DeviceManager.DeviceChanged += OnAvailabilityDeviceChanged;
            SearchPattern = searchPattern;

            var availableDevices =
                DeviceManager
                    .EnumerateAllDevices()
                    .Where(d => d.Path.Contains(SearchPattern))
                    .OrderBy(d => d.Path);

            AvailableDevices = new BindingList<DeviceInformation>(availableDevices.ToList());
        }
Exemple #17
0
 public StateModel(IDeviceManager deviceManager, IDictionary<string, int> inputs, IDictionary<string, int> relays)
 {
     try
     {
         _logger = NLog.LogManager.GetCurrentClassLogger();
     }
     catch
     {
         _logger = null;
     }
     _deviceManager = deviceManager;
     _deviceManager.PanelStateChanged += _deviceManager_PanelStateChanged;
     _deviceManager.WeightMeasured += _deviceManager_WeightMeasured;
     _inputs = inputs;
     _relays = relays;
 }
Exemple #18
0
        public RenderContext(IDeviceManager deviceManager, Control control)
        {
            if (deviceManager == null)
            {
                throw new ArgumentNullException("deviceManager", "Device Manager cannot be null");
            }

            if (control == null)
            {
                throw new ArgumentNullException("control", "Control cannot be null");
            }

            this.deviceManager = deviceManager;
            this.deviceContext = deviceManager.DeviceContext;
            this.control = control;

            createSwapChain();
        }
        public VoltmeterViewModel(IDeviceManager deviceManager, ITimer timer = null)
        {
            Contract.Requires<ArgumentNullException>(deviceManager != null);
            Bindings = new BindingManager();
            Voltmeter = new Model.Voltmeter(deviceManager, new CurrentContextTaskQueue());
            DeviceMonitor = new DeviceMonitor(deviceManager, DeviceConstants.SearchPattern);
            StopWatch = new Stopwatch();
            Timer = timer ?? new UiTimer
            {
                AutoReset = true,
                Interval = TimeSpan.FromMilliseconds(50),
            };
            Timer.Tick += (s, e) => { if (IsRunning) this.Notify(PropertyChanged, me => me.SessionDuration); };
            AvailableDevices.ListChanged += (s, e) => AutoSelectDevice(forceDeviceChange: false);

            AddDisplayValues();
            AddBindings();
            AutoSelectDevice(forceDeviceChange: true);
        }
Exemple #20
0
 public Scenario(IDeviceManager deviceManager, IDictionary<string, int> inputs, IDictionary<string, int> relays, Timings timings)
     : this()
 {
     _deviceManager = deviceManager;
     _inputs = inputs;
     _relays = relays;
     _timings = timings;
     _blockingModel = new BlockingModel(_deviceManager, inputs, relays);
     _state = new StateModel(_deviceManager, inputs, relays);
     _state.StataTrackChanged += OnStataTrackChanged;
     _state.StateInDoorChanged += OnStateInDoorChanged;
     _state.StateLiftChanged += OnStateLiftChanged;
     _state.StateOutDoorChanged += OnStateOutDoorChanged;
     _state.StateSawChanged += OnStateSawChanged;
     _state.LampOnOffPeriodChanged += _state_LampOnOffPeriodChanged;
     _state.CorrectStart += _state_CorrectStart;
     _state.CloseDoorToLastRoomChanged += _state_CloseDoorToLastRoomChanged;
     _state.IsLock += _state_IsLock;
     _state.IsAlarmStopChange += _state_IsAlarmStopChange;
 }
Exemple #21
0
        /// <summary>
        /// Initializes the Device Driver System.
        /// </summary>
        public static void Initialize()
        {
            // Create Resource Manager
            resourceManager = new ResourceManager();

            // Create Device Manager
            deviceManager = new DeviceManager();

            // Create the Device Driver Manager
            deviceDriverRegistry = new DeviceDriverRegistry(PlatformArchitecture.X86);

            // Setup hardware abstraction interface
            IHardwareAbstraction hardwareAbstraction = new Mosa.CoolWorld.x86.HAL.HardwareAbstraction();

            // Set device driver system to the hardware HAL
            Mosa.DeviceSystem.HAL.SetHardwareAbstraction(hardwareAbstraction);

            // Set the interrupt handler
            Mosa.DeviceSystem.HAL.SetInterruptHandler(ResourceManager.InterruptManager.ProcessInterrupt);
        }
Exemple #22
0
        private OculusOrientation()
        {
            manager = Factory.CreateDeviceManager();
            fusion = Factory.CreateSensorFusion();
            var devices = manager.HMDDevices;
            if (devices.Length <= 0)
            {
                throw new Exception("No Oculus Hardware found");
            }
            var handle = devices[0];
            Console.WriteLine("Found an HMD device: " + handle.DeviceInfo.DisplayDevice);

            device = handle.CreateDevice();

            fusion.AttachedDevice = device.Sensor;

            fusion.IsPredictionEnabled = true;

            updateThread = new Thread(new ThreadStart(updateOrientation));
            updateThread.Start();
        }
        public OutboundEventNotificationService(Session session, ICicStatusService statusService, IDeviceManager deviceManager, ITraceContext traceContext)
        {
            _deviceManager = deviceManager;
            _session = session;
            _traceContext = traceContext;
            _statusService = statusService;
            _statusService.UserStatusChanged += OnUserStatusChanged;

            _session.ConnectionStateChanged += OnConnectionStateChanged;

            _deviceManager.HeadsetConnected += OnDeviceEvent;
            _deviceManager.HeadsetDisconnected += OnDeviceEvent;
            _deviceManager.MuteChanged += OnDeviceEvent;
            _deviceManager.PlantronicsDeviceAttached += OnDeviceEvent;
            _deviceManager.PlantronicsDeviceDetached += OnDeviceEvent;

            _serverParams = new ServerParameters(_session);
            _serverParams.StartWatching(new []{ShouldSendHandlerNotificationParam, WebServerUrlParam});

            PostToWebService();
        }
        public InteractionSyncManager(IInteractionManager interactionManager, IDeviceManager deviceManager, IQueueService queueService, ITraceContext traceContext, IConnection connection)
        {
            _interactionManager = interactionManager;
            _deviceManager = deviceManager;
            _traceContext = traceContext;

            _connection = connection;
            _connection.UpChanged += OnConnectionUpChanged;

            _deviceManager.CallAnsweredByDevice += OnCallAnsweredByDevice;
            _deviceManager.CallEndedByDevice += OnCallEndedByDevice;
            _deviceManager.MuteChanged += OnMuteChangedByDevice;
            _deviceManager.OnCall += OnOnCall;
            //    _deviceManager.TalkButtonPressed += OnTalkButtonPressed;
            _deviceManager.TalkButtonHeld += OnTalkButtonHeld;

            _myInteractions = queueService.GetMyInteractions(new[] { InteractionAttributes.State, InteractionAttributes.Muted });
            _myInteractions.InteractionAdded += OnInteractionAdded;
            _myInteractions.InteractionChanged += OnInteractionChanged;
            _myInteractions.InteractionRemoved += OnInteractionRemoved;
        }
        public DataViewModel(WindowsFormsHost windowsFormsHostGrapData, IDialogService dialogService)
        {
            _deviceManager = UnityConfig.GetConfiguredContainer().Resolve<IDeviceManager>();
            ViewDataCommand = new RelayCommand(_ => ViewData());
            WriteDataCommand = new RelayCommand(_ => WriteData());
            StopCommand = new RelayCommand(_ => Stop());
            ChannelEnabledCommand = new RelayCommand(_ => ChannelEnabled());
            Capacity = Settings.Default.BufferDisplayLength;
            for (int i = 0; i < NumberOfCahnnels; i++)
            {
                datas.Add(new RollingPointPairList(Capacity));
            }
            this.dataService = null;
            //
            this.windowsFormsHostGrapData = windowsFormsHostGrapData;
            this.dialogService = dialogService;
            this.zedGraphControlData = (ZedGraphControl)this.windowsFormsHostGrapData.Child;
            Capacity = Convert.ToInt16(windowsFormsHostGrapData.ActualWidth)-1;
            PrepareGraph();

            var e2020 = UnityConfig.GetConfiguredContainer().Resolve<IE2010>();
            this.dataService = null;

            e2020.OnData += UpdateData;
            StartDate = DateTime.UtcNow;

            if (!_deviceManager.mE2010.OpenLDevice())
            {
                this.windowsFormsHostGrapData.Visibility = Visibility.Hidden;
            }
            else
            {
                this.windowsFormsHostGrapData.Visibility = Visibility.Visible;
            }

            LastUpdateTime = DateTime.MinValue;
            Settings.Default.PropertyChanged += DefaultOnPropertyChanged;
            Settings.Default.SettingsSaving += DefaultOnSettingsSaving;
            this.windowsFormsHostGrapData.InvalidateVisual();
        }
Exemple #26
0
 public BookService(IDeviceManager deviceManager)
     : base(deviceManager)
 {
 }
 public WindowsAssetManager(IDeviceManager deviceManager, string contentPath)
     : base(deviceManager)
 {
     _contentPath = contentPath;
 }
 /// <summary>
 /// The channels controller constructor
 /// </summary>
 /// <param name="channelsManager">The channels manager</param>
 public ChannelsController(IChannelsManager channelsManager, IDeviceManager deviceManager)
 {
     _channelsManager = channelsManager;
     _deviceManager   = deviceManager;
 }
Exemple #29
0
 public AppSyncProvider(IDeviceManager deviceManager)
 {
     _deviceManager = deviceManager;
 }
Exemple #30
0
 public UserService(IUserManager userManager, ISessionManager sessionMananger, IServerConfigurationManager config, INetworkManager networkManager, IDeviceManager deviceManager, IAuthorizationContext authContext, ILoggerFactory loggerFactory)
 {
     _userManager     = userManager;
     _sessionMananger = sessionMananger;
     _config          = config;
     _networkManager  = networkManager;
     _deviceManager   = deviceManager;
     _authContext     = authContext;
     _logger          = loggerFactory.CreateLogger(nameof(UserService));
 }
Exemple #31
0
 public ChangesQueueController(IDeviceManager deviceManager, ILogger log) : base(deviceManager, log)
 {
 }
Exemple #32
0
 internal static void IniatializeMMEEffectManager(IDeviceManager deviceManager)
 {
     //Effects of variable registration class registration
     EffectSubscriber = new EffectSubscriberDictionary
     {
         new WorldMatrixSubscriber(),
         new ProjectionMatrixSubscriber(),
         new ViewMatrixSubscriber(),
         new WorldInverseMatrixSubscriber(),
         new WorldTransposeMatrixSubscriber(),
         new WorldInverseTransposeMatrixSubscriber(),
         new ViewInverseMatrixSubscriber(),
         new ViewTransposeMatrixSubscriber(),
         new ViewInverseTransposeMatrixSubsriber(),
         new ProjectionInverseMatrixSubscriber(),
         new ProjectionTransposeMatrixSubscriber(),
         new ProjectionInverseTransposeMatrixSubscriber(),
         new WorldViewMatrixSubscriber(),
         new WorldViewInverseMatrixSubscriber(),
         new WorldViewTransposeMatrixSubscriber(),
         new ViewProjectionMatrixSubscriber(),
         new ViewProjectionInverseMatrixSubscriber(),
         new ViewProjectionTransposeMatrixSubscriber(),
         new ViewProjectionInverseTransposeMatrixSubscriber(),
         new WorldViewProjectionMatrixSubscriber(),
         new WorldViewProjectionInverseMatrixSubscriber(),
         new WorldViewProjectionTransposeMatrixSubscriber(),
         new WorldViewProjectionInverseTransposeMatrixSubscriber(),
         //Material
         new DiffuseVectorSubscriber(),
         new AmbientVectorSubscriber(),
         new SpecularVectorSubscriber(),
         new SpecularPowerSubscriber(),
         new ToonVectorSubscriber(),
         new EdgeVectorSubscriber(),
         new GroundShadowColorVectorSubscriber(),
         new MaterialTextureSubscriber(),
         new MaterialSphereMapSubscriber(),
         new MaterialToonTextureSubscriber(),
         new AddingTextureSubscriber(),
         new MultiplyingTextureSubscriber(),
         new AddingSphereTextureSubscriber(),
         new MultiplyingSphereTextureSubscriber(),
         new EdgeThicknessSubscriber(),
         //Position/方向
         new PositionSubscriber(),
         new DirectionSubscriber(),
         //Time
         new TimeSubScriber(),
         new ElapsedTimeSubScriber(),
         //Mouse
         new MousePositionSubscriber(),
         new LeftMouseDownSubscriber(),
         new MiddleMouseDownSubscriber(),
         new RightMouseDownSubscriber(),
         //Screen information
         new ViewPortPixelSizeScriber(),
         //Constant buffer
         new BasicMaterialConstantSubscriber(),
         new FullMaterialConstantSubscriber(),
         //Control object
         new ControlObjectSubscriber(),
         new RenderColorTargetSubscriber(),
         new RenderDepthStencilTargetSubscriber(),
     };
     PeculiarEffectSubscriber = new PeculiarEffectSubscriberDictionary
     {
         new OpAddSubscriber(),
         new ParthfSubscriber(),
         new SpAddSubscriber(),
         new SubsetCountSubscriber(),
         new TranspSubscriber(),
         new Use_SpheremapSubscriber(),
         new Use_TextureSubscriber(),
         new Use_ToonSubscriber(),
         new VertexCountSubscriber()
     };
     //Initialize the effect compile-time macros
     EffectMacros = new List <ShaderMacro>();
     EffectMacros.Add(new ShaderMacro(MMFDefinition));         //Define constant MMF
     EffectMacros.Add(new ShaderMacro(ApplicationDefinition)); //Application of constant definition
     EffectMacros.Add(new ShaderMacro("MMM_LightCount", "3"));
     if (deviceManager.DeviceFeatureLevel == FeatureLevel.Level_11_0)
     {
         EffectMacros.Add(new ShaderMacro("DX_LEVEL_11_0"));
     }
     else
     {
         EffectMacros.Add(new ShaderMacro("DX_LEVEL_10_1"));
     }
     EffectInclude = new BasicEffectIncluder();
 }
 protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer)
 {
     ImageProcessor = imageProcessor;
     HttpClient = httpClient;
 }
Exemple #34
0
 public UserService(IUserManager userManager, ISessionManager sessionMananger, IServerConfigurationManager config, INetworkManager networkManager, IDeviceManager deviceManager, IAuthorizationContext authContext)
 {
     _userManager     = userManager;
     _sessionMananger = sessionMananger;
     _config          = config;
     _networkManager  = networkManager;
     _deviceManager   = deviceManager;
     _authContext     = authContext;
 }
 public DeviceController(IDeviceManager deviceManager, ILogger logger)
 {
     _deviceManager = deviceManager;
     _logger        = logger;
 }
Exemple #36
0
 protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer)
     : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer)
 {
 }
        // ReSharper disable once TooManyDependencies
        public SamsungSmartThingsService(ILogManager logManager, IHttpClient httpClient, IJsonSerializer jsonSerializer, IDeviceManager deviceManager)
        {
            logger = logManager.GetLogger(GetType().Name);

            this.httpClient     = httpClient;
            this.jsonSerializer = jsonSerializer;
            this.deviceManager  = deviceManager;
        }
Exemple #38
0
 public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
 {
     NetworkManager = networkManager;
 }
Exemple #39
0
 public Notifications(IInstallationManager installationManager, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config, IDeviceManager deviceManager, ITimerFactory timerFactory)
 {
     _installationManager = installationManager;
     _userManager         = userManager;
     _logger              = logger;
     _taskManager         = taskManager;
     _notificationManager = notificationManager;
     _libraryManager      = libraryManager;
     _sessionManager      = sessionManager;
     _appHost             = appHost;
     _config              = config;
     _deviceManager       = deviceManager;
     _timerFactory        = timerFactory;
 }
Exemple #40
0
 public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, imageProcessor, httpClient)
 {
 }
Exemple #41
0
 public DeviceDeleteCommandHandler(IDeviceManager deviceManager)
 {
     _logger             = LogManager.GetLogger <TemperatureDataMessageHandler>();
     this._deviceManager = deviceManager;
 }
Exemple #42
0
        /// <summary>
        /// Applies the device profile to the streamstate.
        /// </summary>
        /// <param name="state">A <see cref="StreamState"/> instance.</param>
        /// <param name="deviceManager">The <see cref="IDeviceManager"/> instance.</param>
        /// <param name="profileManager">The <see cref="IDeviceProfileManager"/> instance.</param>
        /// <param name="request">A <see cref="HttpRequest"/> instance.</param>
        /// <param name="deviceProfileId">Optional. Device profile id. </param>
        /// <param name="static">True if static.</param>
        private static void ApplyDeviceProfileSettings(
            StreamState state,
            IDeviceManager deviceManager,
            IDeviceProfileManager profileManager,
            HttpRequest request,
            string?deviceProfileId,
            bool? @static)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (deviceManager == null)
            {
                throw new ArgumentNullException(nameof(deviceManager));
            }

            if (!string.IsNullOrWhiteSpace(deviceProfileId))
            {
                state.DeviceProfile = profileManager.GetProfile(Guid.Parse(deviceProfileId));

                if (state.DeviceProfile == null)
                {
                    var caps = deviceManager.GetCapabilities(deviceProfileId);
                    state.DeviceProfile = profileManager.GetProfile(
                        request.Headers,
                        request.HttpContext.Connection.RemoteIpAddress ?? IPAddress.Loopback,
                        caps?.DeviceProfile);
                }
            }

            var profile = state.DeviceProfile;

            if (profile == null)
            {
                // Don't use settings from the default profile.
                // Only use a specific profile if it was requested.
                return;
            }

            var audioCodec = state.ActualOutputAudioCodec;
            var videoCodec = state.ActualOutputVideoCodec;

            var mediaProfile = !state.IsVideoRequest
                ? profile.GetAudioMediaProfile(state.OutputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate, state.OutputAudioSampleRate, state.OutputAudioBitDepth)
                : profile.GetVideoMediaProfile(
                state.OutputContainer,
                audioCodec,
                videoCodec,
                state.OutputWidth,
                state.OutputHeight,
                state.TargetVideoBitDepth,
                state.OutputVideoBitrate,
                state.TargetVideoProfile,
                state.TargetVideoLevel,
                state.TargetFramerate,
                state.TargetPacketLength,
                state.TargetTimestamp,
                state.IsTargetAnamorphic,
                state.IsTargetInterlaced,
                state.TargetRefFrames,
                state.TargetVideoStreamCount,
                state.TargetAudioStreamCount,
                state.TargetVideoCodecTag,
                state.IsTargetAVC);

            if (mediaProfile != null)
            {
                state.MimeType = mediaProfile.MimeType;
            }

            if (@static.HasValue && @static.Value)
            {
                return;
            }

            var transcodingProfile = !state.IsVideoRequest ? profile.GetAudioTranscodingProfile(state.OutputContainer, audioCodec) : profile.GetVideoTranscodingProfile(state.OutputContainer, audioCodec, videoCodec);

            if (transcodingProfile == null)
            {
                return;
            }

            state.EstimateContentLength = transcodingProfile.EstimateContentLength;
            // state.EnableMpegtsM2TsMode = transcodingProfile.EnableMpegtsM2TsMode;
            state.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;

            if (state.VideoRequest == null)
            {
                return;
            }

            state.VideoRequest.CopyTimestamps            = transcodingProfile.CopyTimestamps;
            state.VideoRequest.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest;
        }
Exemple #43
0
 public AuthService(IUserManager userManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager, ISessionManager sessionManager, IDeviceManager deviceManager)
 {
     AuthorizationContext = authorizationContext;
     _config        = config;
     DeviceManager  = deviceManager;
     SessionManager = sessionManager;
     ConnectManager = connectManager;
     UserManager    = userManager;
 }
Exemple #44
0
        static void Main(string[] args)
        {
            #region 1. Get the application settings
            //First lets read the value of those variables from the App.config file.
            //You can read it from whatever way you want. Just remember to keep your AppSecret safe.
            _appId = ConfigurationManager.AppSettings["AppId"];
            _appSecret = ConfigurationManager.AppSettings["AppSecret"];
            _customerId = ConfigurationManager.AppSettings["CustomerId"];
            _port = ConfigurationManager.AppSettings["Port"];
            #endregion

            #region 2. Initialize the main objects
            //Now, lets create the BC Device channel.
            //The default implementation for Windows, Mac, and Linux, uses a serial port to communicate with the terminal/pinpad.
            //You must set the app.config with the correct port your system is using in order to this to work.
            _channel = new SerialDeviceConnectionChannel(_port);

            //Now, create an instance of IDeviceManager.
            //The BCDeviceManager constructor has a IBCDeviceConnectionChannel parameter so it can be used to deal with underlying device communication protocol.
            //The Device Manager is implements all the steps required process a transaction from the terminal perspective. It includes deal with EMV, Magnetic and Contactless readers and the printer.
            //The BCDeviceManager also has the BC protocol defined by ABECS fully implemented, which means that you can use whatever device you want as long as it has internally implemented the BC protocol.
            _deviceManager = new BCDeviceManager(_channel);

            //Now lets initialize PlatformContext with the variable you previously crated for the customerId, appId, appSecret and the deviceManager.
            //The PIEnvironment sets to which platform environment the SDK will point to. Currently only Dev and Prod are supported. Note that you have AppId and Secret for each one of those platforms.
            //This class set a context for the whole transaction process and the Initialize() method must be called only once per application execution.
            //Usually you will call this at your application startup and never call it again no matter how much transactions you will perform.
            PlatformContext.Initialize(_customerId, _appId, _appSecret, _deviceManager, PIEnvironment.Dev);
            #endregion

            #region 3. Login into the platform
            //Now lets login into the platform to acquire an access token.
            //From the PlatformContext you can call GetService<T> to get almost all services provided by the SDK. You don't have to instantiate by yourself.
            //In the following line we are getting the IAuthService which is responsible for all the authentication process of the platform.
            //The Login() method without parameters uses the appId and appSecret to authenticate the application.
            //So it will return a token for a specific application back to the _token variable so it can be used to perform transactions.
            _token = PlatformContext.GetService<IAuthService>().Login();

            //Just for the sake of information we are printing the token and customerId if everything is OK.
            if (!string.IsNullOrWhiteSpace(_token))
            {
                Console.WriteLine("---=== Login ===---");
                Console.WriteLine("Access Token: " + _token);
                Console.WriteLine("Customer Id: " + PlatformContext.CustomerToken);
            }
            else
            {
                Console.WriteLine("Unauthorized. Please check your application Id and secret!");
                Console.ReadLine();
                return;
            }
            #endregion

            #region 4. Setup the Transaction Orchestrator
            //Now the most important service on the platform...
            //TrasactionOrchestrator works as (the name already said that) an orchestrator for the transaction process.
            //It implements the default transaction process for a card transaction for EMV, Magnetic and Contactless transaction, and also provide some facilities to list transaction history and cancel/confirm a transaction.
            //Again, we get an instance of it using PlatformContext.GetService<T>() method, since it will deal with all the internal deals to create it.
            _transactionOrchestrator = PlatformContext.GetService<ITransactionOrchestrator>();

            //Now we need to hook 4 events to the TransactionOrchestrator intance. It will gives you an asynchronous way to handle some important events that happens during he transaction flow.

            //OnError event will be fired whenever an error happens inside the transaction process. Depending of the erro (in most of the cases) that transaction was aborted and depending of its state, reverter by the servers on the underlying acquirer.
            _transactionOrchestrator.OnError += OnError;
            //OnProgressChanged is basically fired when the state of the transaction changed. Usually the user interface of the payment application should present a message to the user based on it.
            _transactionOrchestrator.OnProgressChanged += TransactionOrchestratorOnProgressChanged;
            //Quite self-described, this event is fired when the transaction process is finished. The event subscriber receives a TransactionResult instance, which has the final result of a given transaction.
            //Note that not always all properties of this object are filled. It depends on wether the underlying acquirer returns or not the information when the transaction is completed.
            _transactionOrchestrator.OnTransactionFinished += TransactionOrchestratorOnTransactionFinished;
            //This event is fired when the transaction process requires some user input. One use case for this event is in the transactions made by Magnetic cards. The server can request the CVV code or the PIN.
            //When this event is fired, the transaction is put on hold and will wait until a call to _transactionOrchestrator.PushData(data) is made.
            //When this event is fired, it may provide some information about the requested data that must be pushed to the server.
            _transactionOrchestrator.OnDataRequested += TransactionOrchestratorOnDataRequested;
            #endregion

            #region 4.1 (Optional) Listen for BC events
            //Totatally optional, this event is in place to comply with BC implementation. It is fired whenever the pinpad/terminal wants to notify the application about some of their actions.
            //This is not required by any means and is just here for the sake of clarity and conformance with BC.
            _channel.Notify += OnBCChannelNotify;
            #endregion

            #region 5. Perform the transaction
            //Now, the best part... Send the transaction! :)
            //Just create a TerminalTransactionParameters and set its fields based on the transaction type you want.
            var parameters = new TerminalTransactionParameters
            {
                Mode = TransactionMode.Credit,
                Type = TransactionType.Authorization,
                //The amount is a decimals, do 20 would be equivalent to R$ 20,00, and 10.5 would be R$ 10,50.
                Amount = 20,
                Parcel = 1
            };

            //Call the ExecuteTransaction(TransactionParameters, AccessToken) method in order to execute the transaction.
            _transactionOrchestrator.ExecuteTransaction(parameters, _token);
            #endregion

            //Lets just hold the console open simulating a real application running and then disconnect when the transaction finish.
            Console.ReadLine();

            (_deviceManager as IMobileDeviceManager).Disconnect();
        }
Exemple #45
0
        public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, ISecurityManager securityManager, IInstallationManager installationManager, INetworkManager network, IDeviceManager deviceManager)
            : base()
        {
            if (jsonSerializer == null)
            {
                throw new ArgumentNullException("jsonSerializer");
            }

            _appHost             = appHost;
            _securityManager     = securityManager;
            _installationManager = installationManager;
            _network             = network;
            _deviceManager       = deviceManager;
            _jsonSerializer      = jsonSerializer;
        }
Exemple #46
0
 public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor, environmentInfo)
 {
 }
Exemple #47
0
        public MainController(IWindow view, IMainFactory factory)
        {
            if (view == null)
            {
                throw new ArgumentNullException(typeof(IWindow).ToString());
            }
            this.view       = view;
            this.Dispatcher = view.Window.Dispatcher;
            if (factory == null)
            {
                throw new ArgumentNullException(typeof(IMainFactory).ToString());
            }
            this.repository = factory.CreateISyncRepository();
            if (this.repository == null)
            {
                throw new ApplicationInitializationException(typeof(ISyncRepository).ToString());
            }

            this.MainViewModel = factory.CreateIMainViewModel(this);
            if (this.MainViewModel == null)
            {
                throw new ApplicationInitializationException(typeof(IMainViewModel).ToString());
            }

            this.deviceManager = factory.CreateIDeviceManager();
            if (this.deviceManager == null)
            {
                throw new ApplicationInitializationException(typeof(IDeviceManager).ToString());
            }
            this.deviceEnumerationListener = factory.CreateIDeviceEnumerationListener();
            if (this.deviceEnumerationListener == null)
            {
                throw new ApplicationInitializationException(typeof(IDeviceEnumerationListener).ToString());
            }
            this.errorLogger = factory.CreateIErrorLogger();
            if (this.errorLogger == null)
            {
                throw new ApplicationInitializationException(typeof(IErrorLogger).ToString());
            }
            this.sqmHelper = factory.CreateISqmHelper();
            if (this.sqmHelper == null)
            {
                throw new ApplicationInitializationException(typeof(ISqmHelper).ToString());
            }
            this.preloader = factory.CreateISyncSourcePreloader();
            if (this.preloader == null)
            {
                throw new ApplicationInitializationException(typeof(ISyncSourcePreloader).ToString());
            }
            bool flag  = ((string)GlobalSetting.GetApplicationSetting("MusicSyncSource")) == "ITunes";
            bool flag2 = ((string)GlobalSetting.GetApplicationSetting("MusicSyncSource")) == "WindowsLibraries";

            if (!flag && !flag2)
            {
                GlobalSetting.SetApplicationSetting("MusicSyncSource", "WindowsLibraries");
            }
            bool flag3 = ITunesMusicSyncSource.IsITunesInstalled();

            if (flag && !flag3)
            {
                if (!((bool)GlobalSetting.GetApplicationSetting("FirstRun")))
                {
                    MessageBox.Show(Resources.iTunesMissingWillSwitchMessage, Resources.iTunesMissingWillSwitchTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                GlobalSetting.SetApplicationSetting("MusicSyncSource", "WindowsLibraries");
                //this.MainViewModel.AppSettingsViewModel.Init();
            }
            this.deviceEnumerationListener.EventArrived += new EventArrivedEventHandler(this.OnConnectedDevicesChanged);
            GlobalSetting.SettingChange = (EventHandler <ApplicationSettingsChangeEventArgs>)Delegate.Combine(GlobalSetting.SettingChange, new EventHandler <ApplicationSettingsChangeEventArgs>(this.OnApplicationSettingChanged));
        }
Exemple #48
0
 public void SetUp()
 {
     deviceManager   = MockRepository.GenerateStub <IDeviceManager> ();
     configGenerator = new DeviceConfigurationGenerator(deviceManager);
 }
Exemple #49
0
 public UniversalAudioService(IServerConfigurationManager serverConfigurationManager, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, IDeviceManager deviceManager, ISubtitleEncoder subtitleEncoder, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, INetworkManager networkManager, IEnvironmentInfo environmentInfo)
 {
     ServerConfigurationManager = serverConfigurationManager;
     UserManager          = userManager;
     LibraryManager       = libraryManager;
     IsoManager           = isoManager;
     MediaEncoder         = mediaEncoder;
     FileSystem           = fileSystem;
     DlnaManager          = dlnaManager;
     DeviceManager        = deviceManager;
     SubtitleEncoder      = subtitleEncoder;
     MediaSourceManager   = mediaSourceManager;
     ZipClient            = zipClient;
     JsonSerializer       = jsonSerializer;
     AuthorizationContext = authorizationContext;
     ImageProcessor       = imageProcessor;
     NetworkManager       = networkManager;
     EnvironmentInfo      = environmentInfo;
 }
 protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer)
 {
     ImageProcessor = imageProcessor;
 }
 public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager)
 {
 }
Exemple #52
0
 public UserService(IUserManager userManager, ISessionManager sessionMananger, IServerConfigurationManager config, INetworkManager networkManager, IDeviceManager deviceManager)
 {
     _userManager     = userManager;
     _sessionMananger = sessionMananger;
     _config          = config;
     _networkManager  = networkManager;
     _deviceManager   = deviceManager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PartitionManager"/> class.
 /// </summary>
 /// <param name="deviceManager">The device manager.</param>
 public PartitionManager(IDeviceManager deviceManager)
 {
     this.deviceManager = deviceManager;
 }
Exemple #54
0
        private static void ApplyDeviceProfileSettings(StreamState state, IDlnaManager dlnaManager, IDeviceManager deviceManager, HttpRequest request, string?deviceProfileId, bool? @static)
        {
            var headers = request.Headers;

            if (!string.IsNullOrWhiteSpace(deviceProfileId))
            {
                state.DeviceProfile = dlnaManager.GetProfile(deviceProfileId);
            }
            else if (!string.IsNullOrWhiteSpace(deviceProfileId))
            {
                var caps = deviceManager.GetCapabilities(deviceProfileId);

                state.DeviceProfile = caps == null?dlnaManager.GetProfile(headers) : caps.DeviceProfile;
            }

            var profile = state.DeviceProfile;

            if (profile == null)
            {
                // Don't use settings from the default profile.
                // Only use a specific profile if it was requested.
                return;
            }

            var audioCodec = state.ActualOutputAudioCodec;
            var videoCodec = state.ActualOutputVideoCodec;

            var mediaProfile = !state.IsVideoRequest
                ? profile.GetAudioMediaProfile(state.OutputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate, state.OutputAudioSampleRate, state.OutputAudioBitDepth)
                : profile.GetVideoMediaProfile(
                state.OutputContainer,
                audioCodec,
                videoCodec,
                state.OutputWidth,
                state.OutputHeight,
                state.TargetVideoBitDepth,
                state.OutputVideoBitrate,
                state.TargetVideoProfile,
                state.TargetVideoLevel,
                state.TargetFramerate,
                state.TargetPacketLength,
                state.TargetTimestamp,
                state.IsTargetAnamorphic,
                state.IsTargetInterlaced,
                state.TargetRefFrames,
                state.TargetVideoStreamCount,
                state.TargetAudioStreamCount,
                state.TargetVideoCodecTag,
                state.IsTargetAVC);

            if (mediaProfile != null)
            {
                state.MimeType = mediaProfile.MimeType;
            }

            if (!(@static.HasValue && @static.Value))
            {
                var transcodingProfile = !state.IsVideoRequest ? profile.GetAudioTranscodingProfile(state.OutputContainer, audioCodec) : profile.GetVideoTranscodingProfile(state.OutputContainer, audioCodec, videoCodec);

                if (transcodingProfile != null)
                {
                    state.EstimateContentLength = transcodingProfile.EstimateContentLength;
                    // state.EnableMpegtsM2TsMode = transcodingProfile.EnableMpegtsM2TsMode;
                    state.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;

                    if (state.VideoRequest != null)
                    {
                        state.VideoRequest.CopyTimestamps            = transcodingProfile.CopyTimestamps;
                        state.VideoRequest.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest;
                    }
                }
            }
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="SmartDomService" /> class.
 /// </summary>
 /// <param name="deviceManager">The device manager.</param>
 /// <param name="deviceRepository">The device repository.</param>
 public SmartDomService(IDeviceManager deviceManager, IGenericRepository<Device> deviceRepository)
 {
     this.deviceManager = deviceManager;
     this.deviceRepository = deviceRepository;
 }
 public DeviceAccessEntryPoint(IUserManager userManager, IAuthenticationRepository authRepo, IDeviceManager deviceManager, ISessionManager sessionManager)
 {
     _userManager    = userManager;
     _authRepo       = authRepo;
     _deviceManager  = deviceManager;
     _sessionManager = sessionManager;
 }
 public DeviceAccessEntryPoint(IUserManager userManager, IDeviceManager deviceManager, ISessionManager sessionManager)
 {
     _userManager    = userManager;
     _deviceManager  = deviceManager;
     _sessionManager = sessionManager;
 }
Exemple #58
0
        /// <summary>
        /// Gets the current streaming state.
        /// </summary>
        /// <param name="streamingRequest">The <see cref="StreamingRequestDto"/>.</param>
        /// <param name="httpRequest">The <see cref="HttpRequest"/>.</param>
        /// <param name="authorizationContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
        /// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
        /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
        /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
        /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
        /// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
        /// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
        /// <param name="subtitleEncoder">Instance of the <see cref="ISubtitleEncoder"/> interface.</param>
        /// <param name="configuration">Instance of the <see cref="IConfiguration"/> interface.</param>
        /// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param>
        /// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
        /// <param name="transcodingJobHelper">Initialized <see cref="TranscodingJobHelper"/>.</param>
        /// <param name="transcodingJobType">The <see cref="TranscodingJobType"/>.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
        /// <returns>A <see cref="Task"/> containing the current <see cref="StreamState"/>.</returns>
        public static async Task <StreamState> GetStreamingState(
            StreamingRequestDto streamingRequest,
            HttpRequest httpRequest,
            IAuthorizationContext authorizationContext,
            IMediaSourceManager mediaSourceManager,
            IUserManager userManager,
            ILibraryManager libraryManager,
            IServerConfigurationManager serverConfigurationManager,
            IMediaEncoder mediaEncoder,
            IFileSystem fileSystem,
            ISubtitleEncoder subtitleEncoder,
            IConfiguration configuration,
            IDlnaManager dlnaManager,
            IDeviceManager deviceManager,
            TranscodingJobHelper transcodingJobHelper,
            TranscodingJobType transcodingJobType,
            CancellationToken cancellationToken)
        {
            EncodingHelper encodingHelper = new EncodingHelper(mediaEncoder, fileSystem, subtitleEncoder, configuration);

            // Parse the DLNA time seek header
            if (!streamingRequest.StartTimeTicks.HasValue)
            {
                var timeSeek = httpRequest.Headers["TimeSeekRange.dlna.org"];

                streamingRequest.StartTimeTicks = ParseTimeSeekHeader(timeSeek.ToString());
            }

            if (!string.IsNullOrWhiteSpace(streamingRequest.Params))
            {
                ParseParams(streamingRequest);
            }

            streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query);

            var url = httpRequest.Path.Value.Split('.').Last();

            if (string.IsNullOrEmpty(streamingRequest.AudioCodec))
            {
                streamingRequest.AudioCodec = encodingHelper.InferAudioCodec(url);
            }

            var enableDlnaHeaders = !string.IsNullOrWhiteSpace(streamingRequest.Params) ||
                                    string.Equals(httpRequest.Headers["GetContentFeatures.DLNA.ORG"], "1", StringComparison.OrdinalIgnoreCase);

            var state = new StreamState(mediaSourceManager, transcodingJobType, transcodingJobHelper)
            {
                Request           = streamingRequest,
                RequestedUrl      = url,
                UserAgent         = httpRequest.Headers[HeaderNames.UserAgent],
                EnableDlnaHeaders = enableDlnaHeaders
            };

            var auth = authorizationContext.GetAuthorizationInfo(httpRequest);

            if (!auth.UserId.Equals(Guid.Empty))
            {
                state.User = userManager.GetUserById(auth.UserId);
            }

            if (state.IsVideoRequest && !string.IsNullOrWhiteSpace(state.Request.VideoCodec))
            {
                state.SupportedVideoCodecs = state.Request.VideoCodec.Split(',', StringSplitOptions.RemoveEmptyEntries);
                state.Request.VideoCodec   = state.SupportedVideoCodecs.FirstOrDefault();
            }

            if (!string.IsNullOrWhiteSpace(streamingRequest.AudioCodec))
            {
                state.SupportedAudioCodecs = streamingRequest.AudioCodec.Split(',', StringSplitOptions.RemoveEmptyEntries);
                state.Request.AudioCodec   = state.SupportedAudioCodecs.FirstOrDefault(i => mediaEncoder.CanEncodeToAudioCodec(i))
                                             ?? state.SupportedAudioCodecs.FirstOrDefault();
            }

            if (!string.IsNullOrWhiteSpace(streamingRequest.SubtitleCodec))
            {
                state.SupportedSubtitleCodecs = streamingRequest.SubtitleCodec.Split(',', StringSplitOptions.RemoveEmptyEntries);
                state.Request.SubtitleCodec   = state.SupportedSubtitleCodecs.FirstOrDefault(i => mediaEncoder.CanEncodeToSubtitleCodec(i))
                                                ?? state.SupportedSubtitleCodecs.FirstOrDefault();
            }

            var item = libraryManager.GetItemById(streamingRequest.Id);

            state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);

            MediaSourceInfo?mediaSource = null;

            if (string.IsNullOrWhiteSpace(streamingRequest.LiveStreamId))
            {
                var currentJob = !string.IsNullOrWhiteSpace(streamingRequest.PlaySessionId)
                    ? transcodingJobHelper.GetTranscodingJob(streamingRequest.PlaySessionId)
                    : null;

                if (currentJob != null)
                {
                    mediaSource = currentJob.MediaSource;
                }

                if (mediaSource == null)
                {
                    var mediaSources = await mediaSourceManager.GetPlaybackMediaSources(libraryManager.GetItemById(streamingRequest.Id), null, false, false, cancellationToken).ConfigureAwait(false);

                    mediaSource = string.IsNullOrEmpty(streamingRequest.MediaSourceId)
                        ? mediaSources[0]
                        : mediaSources.Find(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.InvariantCulture));

                    if (mediaSource == null && Guid.Parse(streamingRequest.MediaSourceId) == streamingRequest.Id)
                    {
                        mediaSource = mediaSources[0];
                    }
                }
            }
            else
            {
                var liveStreamInfo = await mediaSourceManager.GetLiveStreamWithDirectStreamProvider(streamingRequest.LiveStreamId, cancellationToken).ConfigureAwait(false);

                mediaSource = liveStreamInfo.Item1;
                state.DirectStreamProvider = liveStreamInfo.Item2;
            }

            encodingHelper.AttachMediaSourceInfo(state, mediaSource, url);

            string?containerInternal = Path.GetExtension(state.RequestedUrl);

            if (!string.IsNullOrEmpty(streamingRequest.Container))
            {
                containerInternal = streamingRequest.Container;
            }

            if (string.IsNullOrEmpty(containerInternal))
            {
                containerInternal = streamingRequest.Static ?
                                    StreamBuilder.NormalizeMediaSourceFormatIntoSingleContainer(state.InputContainer, state.MediaPath, null, DlnaProfileType.Audio)
                    : GetOutputFileExtension(state);
            }

            state.OutputContainer = (containerInternal ?? string.Empty).TrimStart('.');

            state.OutputAudioBitrate = encodingHelper.GetAudioBitrateParam(streamingRequest.AudioBitRate, state.AudioStream);

            state.OutputAudioCodec = streamingRequest.AudioCodec;

            state.OutputAudioChannels = encodingHelper.GetNumAudioChannelsParam(state, state.AudioStream, state.OutputAudioCodec);

            if (state.VideoRequest != null)
            {
                state.OutputVideoCodec   = state.Request.VideoCodec;
                state.OutputVideoBitrate = encodingHelper.GetVideoBitrateParamValue(state.VideoRequest, state.VideoStream, state.OutputVideoCodec);

                encodingHelper.TryStreamCopy(state);

                if (state.OutputVideoBitrate.HasValue && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
                {
                    var resolution = ResolutionNormalizer.Normalize(
                        state.VideoStream?.BitRate,
                        state.VideoStream?.Width,
                        state.VideoStream?.Height,
                        state.OutputVideoBitrate.Value,
                        state.VideoStream?.Codec,
                        state.OutputVideoCodec,
                        state.VideoRequest.MaxWidth,
                        state.VideoRequest.MaxHeight);

                    state.VideoRequest.MaxWidth  = resolution.MaxWidth;
                    state.VideoRequest.MaxHeight = resolution.MaxHeight;
                }
            }

            ApplyDeviceProfileSettings(state, dlnaManager, deviceManager, httpRequest, streamingRequest.DeviceProfileId, streamingRequest.Static);

            var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
                ? GetOutputFileExtension(state)
                : ('.' + state.OutputContainer);

            state.OutputFilePath = GetOutputFilePath(state, ext !, serverConfigurationManager, streamingRequest.DeviceId, streamingRequest.PlaySessionId);

            return(state);
        }
Exemple #59
0
 public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, INetworkManager networkManager)
     : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer)
 {
     NetworkManager = networkManager;
 }
 public SessionsService(ISessionManager sessionManager, IServerApplicationHost appHost, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo, IDeviceManager deviceManager, ISessionContext sessionContext)
 {
     _sessionManager = sessionManager;
     _userManager    = userManager;
     _authContext    = authContext;
     _authRepo       = authRepo;
     _deviceManager  = deviceManager;
     _sessionContext = sessionContext;
     _appHost        = appHost;
 }