Example #1
0
        /// <summary>
        /// Beendet eine Aufzeichnung.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        /// <param name="key">Die Identifikation der Aufzeichnung.</param>
        public void StopRecordingFeed(string sourceName, string key)
        {
            // Look it up
            var source = m_provider.Translate(sourceName);

            if (source == null)
            {
                throw new ArgumentException("unbekannter sender", "sourceName");
            }

            // Find the feed
            var feed = FindFeed(source);

            if (feed == null)
            {
                return;
            }
            else if (!feed.IsRecording(key))
            {
                return;
            }

            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // Mark as active
                tx.DisableRecording(feed, key);

                // Avoid cleanup
                tx.Commit();
            }
        }
Example #2
0
        /// <summary>
        /// Versucht einen Sender für die primäre Anzeige zu aktivieren.
        /// </summary>
        /// <param name="source">Der gewünschte Sender.</param>
        /// <param name="tx">Die aktuelle Änderungsumgebung.</param>
        /// <returns>Gesetzt, wenn die Aktivierung erfolgreich war.</returns>
        private Device EnsurePrimaryFeed(SourceSelection source, FeedTransaction tx)
        {
            // Make sure we can receive it
            var device = EnsureFeed(source);

            if (device != null)
            {
                return(device);
            }

            // See if there is any device we can free
            var availableDevice =
                m_devices
                .Where(cancidate => cancidate.ReusePossible)
                .Aggregate(default(Device), (best, test) => ((best != null) && (best.SecondaryFeeds.Count() <= test.SecondaryFeeds.Count())) ? best : test);

            // None
            if (availableDevice == null)
            {
                return(null);
            }

            // Stop all secondaries
            foreach (var secondaryFeed in availableDevice.SecondaryFeeds)
            {
                tx.DisableSecondaryView(secondaryFeed);
            }

            // Run test again - can not fail
            return(EnsureFeed(source));
        }
Example #3
0
        /// <summary>
        /// Beendet alle Aufträge.
        /// </summary>
        public void Shutdown()
        {
            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // All feeds
                foreach (var feed in Feeds)
                {
                    // Primary
                    if (feed.IsPrimaryView)
                    {
                        tx.DisablePrimaryView(feed);
                    }

                    // Secondary
                    if (feed.IsSecondaryView)
                    {
                        tx.DisableSecondaryView(feed);
                    }

                    // Recording
                    foreach (var recording in feed.Recordings.ToArray())
                    {
                        tx.DisableRecording(feed, recording);
                    }
                }

                // Process all
                tx.Commit();
            }
        }
Example #4
0
        /// <summary>
        /// Verändert die primäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Die neue primäre Anzeige.</param>
        /// <returns>Gesetzt, wenn die Änderung erfolgreich war.</returns>
        public bool TryStartPrimaryFeed(string sourceName)
        {
            // Look it up
            var source = m_provider.Translate(sourceName);

            if (source == null)
            {
                throw new ArgumentException("unbekannter sender", "sourceName");
            }

            // Find the feed
            var feed = FindFeed(source);

            if (feed != null)
            {
                if (feed.IsPrimaryView)
                {
                    return(true);
                }
            }

            // Device we schedule on
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // See if we are secondary
                if (feed != null)
                {
                    if (feed.IsSecondaryView)
                    {
                        tx.DisableSecondaryView(feed);
                    }
                }

                // Locate the current primary view
                var previous = PrimaryView;
                if (previous != null)
                {
                    tx.DisablePrimaryView(previous);
                }

                // Make sure we can receive it
                device = EnsurePrimaryFeed(source, tx);
                if (device == null)
                {
                    return(false);
                }

                // Avoid cleanup
                tx.Commit();
            }

            // Schedule for report
            device.FireWhenAvailable(source.Source, OnPrimaryViewChanged);

            // Report success
            return(true);
        }
Example #5
0
        /// <summary>
        /// Beginnt eine Aufzeichnung.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        /// <param name="key">Die Identifikation der Aufzeichnung.</param>
        /// <returns>Gesetzt, wenn der Start erfolgreich war.</returns>
        public bool TryStartRecordingFeed(string sourceName, string key)
        {
            // Look it up
            var source = m_provider.Translate(sourceName);

            if (source == null)
            {
                throw new ArgumentException("unbekannter sender", "sourceName");
            }

            // Find the feed
            var feed = FindFeed(source);

            if (feed != null)
            {
                if (feed.IsRecording(key))
                {
                    return(false);
                }
            }

            // Device to use
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // Make sure we can receive it
                device = EnsureRecordingFeed(source, tx);
                if (device == null)
                {
                    return(false);
                }

                // Avoid cleanup
                tx.Commit();
            }

            // Report recording
            device.FireWhenAvailable(source.Source, key, OnRecordingChanged);

            // May want to make it primary
            if (PrimaryView == null)
            {
                device.FireWhenAvailable(source.Source, OnPrimaryViewChanged);
            }

            // Report success
            return(true);
        }
Example #6
0
        /// <summary>
        /// Verändert eine sekundäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        /// <returns>Gesetzt, wenn die Änderung erfolgreich war.</returns>
        public bool TryStartSecondaryFeed(string sourceName)
        {
            // Look it up
            var source = m_provider.Translate(sourceName);

            if (source == null)
            {
                throw new ArgumentException("unbekannter sender", "sourceName");
            }

            // Find the feed
            var feed = FindFeed(source);

            if (feed != null)
            {
                if (feed.IsSecondaryView)
                {
                    return(true);
                }
                else if (feed.IsPrimaryView)
                {
                    return(false);
                }
            }

            // The device we use
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // Make sure we can receive it
                device = EnsureFeed(source);
                if (device == null)
                {
                    return(false);
                }

                // Avoid cleanup
                tx.Commit();
            }

            // Report as active as soon as available
            device.FireWhenAvailable(source.Source, OnSecondaryViewChanged);

            // Report success
            return(true);
        }
Example #7
0
        /// <summary>
        /// Stellt sicher, dass eine Aufzeichnung gestartet werden kann.
        /// </summary>
        /// <param name="source">Der gewünschte Sender.</param>
        /// <param name="tx">Die aktuelle Änderungsumgebung.</param>
        /// <returns>Gesetzt, wenn die Aufzeichnung möglich war.</returns>
        private Device EnsureRecordingFeed( SourceSelection source, FeedTransaction tx )
        {
            // Make sure we can receive it
            var device = EnsurePrimaryFeed( source, tx );
            if (device != null)
                return device;

            // See if there is a primary
            var primary = PrimaryView;
            if (primary == null)
                return null;

            // Switch off primary
            tx.DisablePrimaryView( primary );

            // Try again - may fail
            return EnsurePrimaryFeed( source, tx );
        }
Example #8
0
        /// <summary>
        /// Versucht einen Sender für die primäre Anzeige zu aktivieren.
        /// </summary>
        /// <param name="source">Der gewünschte Sender.</param>
        /// <param name="tx">Die aktuelle Änderungsumgebung.</param>
        /// <returns>Gesetzt, wenn die Aktivierung erfolgreich war.</returns>
        private Device EnsurePrimaryFeed( SourceSelection source, FeedTransaction tx )
        {
            // Make sure we can receive it
            var device = EnsureFeed( source );
            if (device != null)
                return device;

            // See if there is any device we can free
            var availableDevice =
                m_devices
                    .Where( cancidate => cancidate.ReusePossible )
                    .Aggregate( default( Device ), ( best, test ) => ((best != null) && (best.SecondaryFeeds.Count() <= test.SecondaryFeeds.Count())) ? best : test );

            // None
            if (availableDevice == null)
                return null;

            // Stop all secondaries
            foreach (var secondaryFeed in availableDevice.SecondaryFeeds)
                tx.DisableSecondaryView( secondaryFeed );

            // Run test again - can not fail
            return EnsureFeed( source );
        }
Example #9
0
        /// <summary>
        /// Stellt sicher, dass eine Aufzeichnung gestartet werden kann.
        /// </summary>
        /// <param name="source">Der gewünschte Sender.</param>
        /// <param name="tx">Die aktuelle Änderungsumgebung.</param>
        /// <returns>Gesetzt, wenn die Aufzeichnung möglich war.</returns>
        private Device EnsureRecordingFeed(SourceSelection source, FeedTransaction tx)
        {
            // Make sure we can receive it
            var device = EnsurePrimaryFeed(source, tx);

            if (device != null)
            {
                return(device);
            }

            // See if there is a primary
            var primary = PrimaryView;

            if (primary == null)
            {
                return(null);
            }

            // Switch off primary
            tx.DisablePrimaryView(primary);

            // Try again - may fail
            return(EnsurePrimaryFeed(source, tx));
        }
Example #10
0
        /// <summary>
        /// Beendet eine Aufzeichnung.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        /// <param name="key">Die Identifikation der Aufzeichnung.</param>
        public void StopRecordingFeed( string sourceName, string key )
        {
            // Look it up
            var source = m_provider.Translate( sourceName );
            if (source == null)
                throw new ArgumentException( "unbekannter sender", "sourceName" );

            // Find the feed
            var feed = FindFeed( source );
            if (feed == null)
                return;
            else if (!feed.IsRecording( key ))
                return;

            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // Mark as active
                tx.DisableRecording( feed, key );

                // Avoid cleanup
                tx.Commit();
            }
        }
Example #11
0
        /// <summary>
        /// Beginnt eine Aufzeichnung.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        /// <param name="key">Die Identifikation der Aufzeichnung.</param>
        /// <returns>Gesetzt, wenn der Start erfolgreich war.</returns>
        public bool TryStartRecordingFeed( string sourceName, string key )
        {
            // Look it up
            var source = m_provider.Translate( sourceName );
            if (source == null)
                throw new ArgumentException( "unbekannter sender", "sourceName" );

            // Find the feed
            var feed = FindFeed( source );
            if (feed != null)
                if (feed.IsRecording( key ))
                    return false;

            // Device to use
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // Make sure we can receive it
                device = EnsureRecordingFeed( source, tx );
                if (device == null)
                    return false;

                // Avoid cleanup
                tx.Commit();
            }

            // Report recording
            device.FireWhenAvailable( source.Source, key, OnRecordingChanged );

            // May want to make it primary
            if (PrimaryView == null)
                device.FireWhenAvailable( source.Source, OnPrimaryViewChanged );

            // Report success
            return true;
        }
Example #12
0
        /// <summary>
        /// Beendet alle Aufträge.
        /// </summary>
        public void Shutdown()
        {
            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // All feeds
                foreach (var feed in Feeds)
                {
                    // Primary
                    if (feed.IsPrimaryView)
                        tx.DisablePrimaryView( feed );

                    // Secondary
                    if (feed.IsSecondaryView)
                        tx.DisableSecondaryView( feed );

                    // Recording
                    foreach (var recording in feed.Recordings.ToArray())
                        tx.DisableRecording( feed, recording );
                }

                // Process all
                tx.Commit();
            }
        }
Example #13
0
        /// <summary>
        /// Verändert eine sekundäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        /// <returns>Gesetzt, wenn die Änderung erfolgreich war.</returns>
        public bool TryStartSecondaryFeed( string sourceName )
        {
            // Look it up
            var source = m_provider.Translate( sourceName );
            if (source == null)
                throw new ArgumentException( "unbekannter sender", "sourceName" );

            // Find the feed
            var feed = FindFeed( source );
            if (feed != null)
                if (feed.IsSecondaryView)
                    return true;
                else if (feed.IsPrimaryView)
                    return false;

            // The device we use
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // Make sure we can receive it
                device = EnsureFeed( source );
                if (device == null)
                    return false;

                // Avoid cleanup
                tx.Commit();
            }

            // Report as active as soon as available
            device.FireWhenAvailable( source.Source, OnSecondaryViewChanged );

            // Report success
            return true;
        }
Example #14
0
        /// <summary>
        /// Verändert die primäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Die neue primäre Anzeige.</param>
        /// <returns>Gesetzt, wenn die Änderung erfolgreich war.</returns>
        public bool TryStartPrimaryFeed( string sourceName )
        {
            // Look it up
            var source = m_provider.Translate( sourceName );
            if (source == null)
                throw new ArgumentException( "unbekannter sender", "sourceName" );

            // Find the feed
            var feed = FindFeed( source );
            if (feed != null)
                if (feed.IsPrimaryView)
                    return true;

            // Device we schedule on
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // See if we are secondary
                if (feed != null)
                    if (feed.IsSecondaryView)
                        tx.DisableSecondaryView( feed );

                // Locate the current primary view
                var previous = PrimaryView;
                if (previous != null)
                    tx.DisablePrimaryView( previous );

                // Make sure we can receive it
                device = EnsurePrimaryFeed( source, tx );
                if (device == null)
                    return false;

                // Avoid cleanup
                tx.Commit();
            }

            // Schedule for report
            device.FireWhenAvailable( source.Source, OnPrimaryViewChanged );

            // Report success
            return true;
        }