Exemple #1
0
        /// <summary>
        /// Disconnects the player that was passed to the Attach method
        /// </summary>
        public void Detach()
        {
            if (IsAttached)
            {
                if (reportTimer != null)
                {
#if SILVERLIGHT
                    reportTimer.Dispose();
#else
                    reportTimer.Cancel();
#endif
                    reportTimer = null;
                }
                if (pollingTimer != null)
                {
#if SILVERLIGHT
                    pollingTimer.Dispose();
#else
                    pollingTimer.Cancel();
#endif
                    pollingTimer = null;
                }
                DetachEvents();
                Player                        = null;
                AdaptiveMonitor               = null;
                streamLoadedLog               = null;
                qualityReportAggregator       = null;
                downloadErrorReportAggregator = null;

                LoggingSources.Clear();

                IsAttached = false;
            }
        }
Exemple #2
0
        async void Player_StreamLoaded(object sender, object e)
        {
            isPaused = true;
            AddLog(new StreamEventLog(StreamEventType.Loaded, TimeSpan.Zero, Player.Duration));

            var loadedLog = new StreamLoadedLog(Player.Source);

            if (AdaptiveMonitor != null)
            {
                loadedLog.MaxBitrate = AdaptiveMonitor.MaxBitrate;
                loadedLog.MinBitrate = AdaptiveMonitor.MinBitrate;
            }

            EdgeServerResult edgeResult = EdgeServerResult.Empty;

            if (Player.Source.IsAbsoluteUri)
            {
                var sourceRoot = GetUrlWithoutQueryString(Player.Source);
                try
                {
                    edgeResult = await GetEdgeServerAsync(new Uri(sourceRoot, UriKind.Absolute));
                }
                catch (OperationCanceledException) { /* ignore */ }
            }

            loadedLog.EdgeServer = edgeResult.EdgeServer;
            loadedLog.ClientIp   = edgeResult.ClientIP;
            AddLog(loadedLog);
            streamLoadedLog = loadedLog;
        }
Exemple #3
0
        /// <summary>
        /// Connects a player that needs to be monitored
        /// </summary>
        public void Attach(IPlayerMonitor player, IAdaptiveMonitor adaptiveMonitor, IEnvironmentMonitor environmentMonitor, IEdgeServerMonitor edgeServerMonitor)
        {
            if (!IsAttached)
            {
                IsAttached = true;

                if (player == null)
                {
                    throw new ArgumentNullException("player");
                }
                streamLoadedLog = null;

                EdgeServerMonitor  = edgeServerMonitor;
                AdaptiveMonitor    = adaptiveMonitor;
                Player             = player;
                EnvironmentMonitor = environmentMonitor;

                if (Configuration.TrackQuality)
                {
                    qualityReportAggregator = new QualityReportAggregator(Configuration.QualityConfig);
                }
                if (Configuration.TrackDownloadErrors)
                {
                    downloadErrorReportAggregator = new DownloadErrorReportAggregator();
                }

                AttachEvents();

                if (Configuration.PollingInterval > TimeSpan.Zero)
                {
#if SILVERLIGHT
                    pollingTimer = new Timer(pollingTimer_Tick, null, Configuration.PollingInterval, Configuration.PollingInterval);
#else
                    pollingTimer = ThreadPoolTimer.CreatePeriodicTimer(pollingTimer_Tick, Configuration.PollingInterval);
#endif
                }
                if (Configuration.AggregationInterval > TimeSpan.Zero)
                {
#if SILVERLIGHT
                    reportTimer = new Timer(reportTimer_Tick, null, Configuration.AggregationInterval, Configuration.AggregationInterval);
#else
                    reportTimer = ThreadPoolTimer.CreatePeriodicTimer(reportTimer_Tick, Configuration.AggregationInterval);
#endif
                }
            }
        }
Exemple #4
0
 void Player_StreamClosed(object sender, object e)
 {
     isPaused = true;
     AddLog(new StreamEventLog(StreamEventType.Unloaded, Player.Position, Player.Duration));
     streamLoadedLog = null;
 }