예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="device"></param>
        /// <param name="targetSource"></param>
        /// <param name="signalType"></param>
        /// <returns></returns>
        public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType)
        {
            var routeTable = new RouteDescriptor(source, destination, signalType);

            Debug.Console(0, destination, "Attempting to build source route from {0}***", source.Key);
            if (!destination.GetRouteToSource(source, null, null, signalType, 0, routeTable))
            {
                routeTable = null;
            }

            Debug.Console(0, destination, "Route{0} discovered ***", routeTable == null ? " NOT" : "");
            return(routeTable);
        }
예제 #2
0
        /// <summary>
        /// Builds a RouteDescriptor that contains the steps necessary to make a route between devices.
        /// Routes of type AudioVideo will be built as two separate routes, audio and video. If
        /// a route is discovered, a new RouteDescriptor is returned.  If one or both parts
        /// of an audio/video route are discovered a route descriptor is returned.  If no route is
        /// discovered, then null is returned
        /// </summary>
        public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType)
        {
            var routeDescr = new RouteDescriptor(source, destination, signalType);

            // if it's a single signal type, find the route
            if ((signalType & (eRoutingSignalType.Audio & eRoutingSignalType.Video)) == (eRoutingSignalType.Audio & eRoutingSignalType.Video))
            {
                Debug.Console(1, destination, "Attempting to build source route from {0}", source.Key);
                if (!destination.GetRouteToSource(source, null, null, signalType, 0, routeDescr))
                {
                    routeDescr = null;
                }
            }
            // otherwise, audioVideo needs to be handled as two steps.
            else
            {
                Debug.Console(1, destination, "Attempting to build audio and video routes from {0}", source.Key);
                var audioSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Audio, 0, routeDescr);
                if (!audioSuccess)
                {
                    Debug.Console(1, destination, "Cannot find audio route to {0}", source.Key);
                }
                var videoSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Video, 0, routeDescr);
                if (!videoSuccess)
                {
                    Debug.Console(1, destination, "Cannot find video route to {0}", source.Key);
                }
                if (!audioSuccess && !videoSuccess)
                {
                    routeDescr = null;
                }
            }

            //Debug.Console(1, destination, "Route{0} discovered", routeDescr == null ? " NOT" : "");
            return(routeDescr);
        }
예제 #3
0
        /// <summary>
        /// Gets any existing RouteDescriptor for a destination, clears it using ReleaseRoute
        /// and then attempts a new Route and if sucessful, stores that RouteDescriptor
        /// in RouteDescriptorCollection.DefaultCollection
        /// </summary>
        public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType)
        {
            destination.ReleaseRoute();

            if (source == null)
            {
                return;
            }
            var newRoute = destination.GetRouteToSource(source, signalType);

            if (newRoute == null)
            {
                return;
            }
            RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(newRoute);
            Debug.Console(2, destination, "Executing full route");
            newRoute.ExecuteRoutes();
        }
예제 #4
0
        /// <summary>
        /// Gets any existing route for a destination, clears it, and then
        /// </summary>
        public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType)
        {
            var sw = new Stopwatch();

            sw.Start();

            destination.ReleaseRoute();

            if (source == null)
            {
                return;
            }
            var newRoute = destination.GetRouteToSource(source, signalType);

            if (newRoute == null)
            {
                return;
            }
            RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(newRoute);
            Debug.Console(2, destination, "Executing new route");
            newRoute.ExecuteRoutes();
            sw.Stop();
            Debug.Console(2, destination, "Route took {0} ms", sw.ElapsedMilliseconds);
        }