예제 #1
0
        private BaseGraph OpenPhysicalGraph(StreamSourceInfo sourceConfig)
        {
            BaseGraph returnedGraph = null;

            AppLogger.Message(String.Format("OpenPhysicalGraph {0}", sourceConfig.SourceName));
            // CheckSecurity(sourceConfig, openGraphRequest);
            try
            {
                if (GraphManager.ShutdownInProgress)
                {
                    throw new Exception("OpenGraph is disabled--the media server is shutting down.");
                }
                try
                {
                    lock (GraphManager.GraphMap)
                    {
                        AppLogger.Message("   Try to fetch existing graph");
                        returnedGraph = GraphManager.GraphMap[sourceConfig.SourceName];
                    }
                }
                catch
                {
                    lock (GraphManager.GraphMap)
                    {
                        AppLogger.Message("   Constructing new graph...");
                        returnedGraph = BaseGraph.CreateInstance(sourceConfig, this.OpenGraphRequest);
                        GraphManager.GraphMap[sourceConfig.SourceName] = returnedGraph;
                    }
                }
            }
            catch (Exception exception)
            {
                AppLogger.Message(String.Format("Unable to OpenGraph {0}", exception.Message));
                throw new Exception("Unable to OpenGraph because " + exception.Message, exception);
            }
            if (returnedGraph.NumberOfClients >= sourceConfig.MaxClients)
            {
                string message = "Connect aborted - the maximum number of clients has been reached." + Environment.NewLine;
                message += "Source was " + sourceConfig.SourceName + Environment.NewLine;
                message += "Current connected users:" + Environment.NewLine;
                foreach (string username in returnedGraph.ClientList)
                {
                    message += username + Environment.NewLine;
                }
                throw new SourceHasMaxClientsException(message);
            }
            return(returnedGraph);
        }
예제 #2
0
 public static void StartPushGraphs()
 {
     try
     {
         StreamSources streamSources = StreamSources.LoadFromFile(false);
         StartSources  startSources  = StartSources.LoadFromFile(false);
         if ((streamSources != null) && (startSources != null))
         {
             foreach (StartSource startSource in startSources.Items)
             {
                 StreamSourceInfo streamSourceInfo = streamSources.FindSource(startSource.SourceName);
                 if (streamSourceInfo != null)
                 {
                     AppLogger.Message(String.Format("Starting source {0}", streamSourceInfo.SourceName));
                     if (streamSourceInfo.DeviceAddress != null)
                     {
                         AppLogger.Message(String.Format("Starting Channel={0} Input={1}", streamSourceInfo.DeviceAddress.Channel, streamSourceInfo.DeviceAddress.Input));
                     }
                     OpenGraphRequest openGraphRequest = new OpenGraphRequest();
                     openGraphRequest.Id         = Guid.NewGuid();
                     openGraphRequest.SourceName = streamSourceInfo.SourceName;
                     openGraphRequest.UserName   = "******";
                     BaseGraph graph = BaseGraph.CreateInstance(streamSourceInfo, openGraphRequest);
                     graph.Run();
                     if (graph != null)
                     {
                         _graphMap.Add(streamSourceInfo.SourceName, graph);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         AppLogger.Dump(e);
     }
 }
예제 #3
0
 public static void StartGraph(string sourceName)
 {
     if (_graphMap.ContainsKey(sourceName) == false)
     {
         StreamSources streamSources = StreamSources.LoadFromFile(false);
         if (streamSources != null)
         {
             StreamSourceInfo streamSourceInfo = streamSources.FindSource(sourceName);
             if (streamSourceInfo != null)
             {
                 OpenGraphRequest openGraphRequest = new OpenGraphRequest();
                 openGraphRequest.Id         = Guid.NewGuid();
                 openGraphRequest.SourceName = streamSourceInfo.SourceName;
                 openGraphRequest.UserName   = "******";
                 BaseGraph graph = BaseGraph.CreateInstance(streamSourceInfo, openGraphRequest);
                 graph.Run();
                 if (graph != null)
                 {
                     _graphMap.Add(streamSourceInfo.SourceName, graph);
                 }
             }
         }
     }
 }