public VideoSyncManager(PrioritizedHeuristicsSettings heuristicSettings)
 {
     HeuristicSettings = heuristicSettings;
     HeuristicManager = new PrioritizedHeuristicsManager();
     HeuristicManager.Clear();
     HeuristicManager.MaxReenableAttempts = heuristicSettings.MaxReenableAttempts;
     HeuristicManager.MonitorIntervalInMilliseconds = heuristicSettings.PollingFrequencyMillis;
     HeuristicManager.RecommendationChanged += HeuristicManager_RecommendationChanged;
 }
 public VideoSyncManager(PrioritizedHeuristicsSettings heuristicSettings)
 {
     HeuristicSettings = heuristicSettings;
     HeuristicManager  = new PrioritizedHeuristicsManager();
     HeuristicManager.Clear();
     HeuristicManager.MaxReenableAttempts           = heuristicSettings.MaxReenableAttempts;
     HeuristicManager.MonitorIntervalInMilliseconds = heuristicSettings.PollingFrequencyMillis;
     HeuristicManager.RecommendationChanged        += HeuristicManager_RecommendationChanged;
 }
        private static PrioritizedHeuristicsSettings ReadSettings()
        {
            var result = new PrioritizedHeuristicsSettings
            {
                MaxReenableAttempts    = DefaultMaxReenableAttempts,
                PollingFrequencyMillis = DefaultPollingFrequencyMillis,
                PrimaryMinBitRate      = DefaultPrimaryMinBitrate,
                PrimaryMinFrameRate    = DefaultPrimaryMinFramerate,
                SecondaryMinBitRate    = DefaultSecondaryMinBitrate,
                SecondaryMinFrameRate  = DefaultSecondaryMinFramerate,
                SyncToleranceMillis    = DefaultSyncToleranceMillis
            };

            try
            {
                XDocument document = XDocument.Load(HeuristicsSettingsFileName);

                result.MaxReenableAttempts    = 10;
                result.PollingFrequencyMillis = document.Root.Descendants(PollingFrequencySettingName)
                                                .First()
                                                .GetValueAsInt().Value;

                result.PrimaryMinBitRate = (ulong)document.Root.Descendants(PrimaryMinBitrateSettingName)
                                           .First()
                                           .GetValueAsLong().Value;

                result.PrimaryMinFrameRate = document.Root.Descendants(PrimaryMinFrameRateSettingName)
                                             .First()
                                             .GetValueAsInt().Value;

                result.SecondaryMinBitRate = (ulong)document.Root.Descendants(SecondaryMinBitrateSettingName)
                                             .First()
                                             .GetValueAsLong().Value;

                result.SecondaryMinFrameRate = document.Root.Descendants(SecondaryMinFrameRateSettingName)
                                               .First()
                                               .GetValueAsInt().Value;

                XElement syncToleranceMillisNode = document.Root.Descendants(SyncToleranceMillisSettingName)
                                                   .FirstOrDefault();

                if (syncToleranceMillisNode != null && syncToleranceMillisNode.GetValueAsInt().HasValue)
                {
                    result.SyncToleranceMillis = syncToleranceMillisNode.GetValueAsInt().Value;
                }
            }
            catch
            {
                //Eat errors and use defaults
            }


            return(result);
        }
 /// <summary>
 /// Loads the plug-in.
 /// </summary>
 public void Load()
 {
     try
     {
         _settings    = ReadSettings();
         _syncManager = new VideoSyncManager(_settings);
         IsLoaded     = true;
         PluginLoaded.IfNotNull(i => i(this));
     }
     catch (Exception err)
     {
         PluginLoadFailed.IfNotNull(i => i(this, err));
     }
 }
        private static PrioritizedHeuristicsSettings ReadSettings()
        {
            var result = new PrioritizedHeuristicsSettings
            {
                MaxReenableAttempts = DefaultMaxReenableAttempts,
                PollingFrequencyMillis = DefaultPollingFrequencyMillis,
                PrimaryMinBitRate = DefaultPrimaryMinBitrate,
                PrimaryMinFrameRate =  DefaultPrimaryMinFramerate,
                SecondaryMinBitRate = DefaultSecondaryMinBitrate,
                SecondaryMinFrameRate = DefaultSecondaryMinFramerate,
                SyncToleranceMillis = DefaultSyncToleranceMillis
            };

            try
            {
                XDocument document = XDocument.Load(HeuristicsSettingsFileName);

                result.MaxReenableAttempts = 10;
                result.PollingFrequencyMillis = document.Root.Descendants(PollingFrequencySettingName)
                    .First()
                    .GetValueAsInt().Value;

                result.PrimaryMinBitRate = (ulong)document.Root.Descendants(PrimaryMinBitrateSettingName)
                                                        .First()
                                                        .GetValueAsLong().Value;

                result.PrimaryMinFrameRate = document.Root.Descendants(PrimaryMinFrameRateSettingName)
                    .First()
                    .GetValueAsInt().Value;

                result.SecondaryMinBitRate = (ulong)document.Root.Descendants(SecondaryMinBitrateSettingName)
                                                            .First()
                                                            .GetValueAsLong().Value;

                result.SecondaryMinFrameRate = document.Root.Descendants(SecondaryMinFrameRateSettingName)
                    .First()
                    .GetValueAsInt().Value;

                XElement syncToleranceMillisNode = document.Root.Descendants(SyncToleranceMillisSettingName)
                    .FirstOrDefault();

                if (syncToleranceMillisNode != null && syncToleranceMillisNode.GetValueAsInt().HasValue)
                {
                    result.SyncToleranceMillis = syncToleranceMillisNode.GetValueAsInt().Value;
                }
            }
            catch
            {
                //Eat errors and use defaults
            }


            return result;
        }
 /// <summary>
 /// Loads the plug-in.
 /// </summary>
 public void Load()
 {
     try
     {
         _settings = ReadSettings();
         _syncManager = new VideoSyncManager(_settings);
         IsLoaded = true;
         PluginLoaded.IfNotNull(i => i(this));
     }
     catch (Exception err)
     {
         PluginLoadFailed.IfNotNull(i => i(this, err));
     }
 }