Exemple #1
0
        public SRM314(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest)
            : base(sourceConfig, openGraphRequest)
        {
            InitializeNetworkSink();

            _currentVideoSettings = new VideoSettings();

            _crossbar      = AddFilterByName(FilterCategory.AMKSCrossbar, "Sensoray 314 Crossbar");
            _captureFilter = AddFilterByName(FilterCategory.AMKSCapture, "Sensoray 314 A/V Capture");

            //instantiate BDA VES and get reference to capture pin
            _ves           = AddFilterByName(FilterCategory.WDMStreamingEncoderDevices, "Sensoray 314 BDA MPEG VES Encoder");
            _vesCapturePin = DsFindPin.ByName(_ves, "Capture");

            //instantiate frame rate filter and get control interface
            _frameRateFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "FC Frame Rate Filter");
            _frameRate       = (IFCFrameRateAPI)_frameRateFilter;



            SetInputAndSystem();

            _frameRate.set_InputFramerate(15.0);

            ChangeProfile(CurrentProfile);

            ConnectFilters(_crossbar, "0: Video Decoder Out", _captureFilter, "Analog Video In", false);
            ConnectFilters(_captureFilter, "Analog ITU Video", _ves, "Analog ITU Video", false);
            // ConnectFilterToNetMux(_ves, "Capture", "Input 01");
            ConnectFilters(_ves, "Capture", _frameRateFilter, "Input", false);
            ConnectFilterToNetMux(_frameRateFilter, "Output", "Input 01");
            ConnectNetMuxToNetSnk();
        }
Exemple #2
0
        public CaptureSourceDVR(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest)
            : base(sourceConfig, openGraphRequest)
        {
            AppLogger.Message("In CaptureSourceDVR constructor - CurrentProfile is " + CurrentProfile.Name);

            _captureFilter = AddFilterByName(FilterCategory.VideoInputDevice, sourceConfig.Description);

            _videoEncoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Encoder (4.0)");

//            _transcoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Transcoder");

            InitializeSink();

            ConnectFilters(_captureFilter, "Capture", _videoEncoder, "XForm In");

//            ConnectFilters(_videoEncoder, "XForm Out", _transcoder, "Input");

//            ConnectFilterToMux(_transcoder, "Output", "Input 01");

            ConnectFilterToMux(_videoEncoder, "XForm Out", "Input 01");

            ConnectMuxToSink();

            _videoEncoderControl = (ILMH264Encoder)_videoEncoder;
            _videoEncoderControl.EnableRateControl = true;
            _videoEncoderControl.BitRate           = CurrentProfile.Video.ConstantBitRate * 1024;
            _videoEncoderControl.OutputFormat      = eH264OUTPUTFORMAT.H264FORMAT_IPOD; // seems to work the best
        }
Exemple #3
0
        protected void SetDSP_and_Camera(StreamSourceInfo sourceConfig)
        {
            int hr;

            IntPtr nativeVariant = Marshal.AllocCoTaskMem(64);

            ICodecAPI codecAPI_H264 = GetCodecAPI();

            if (sourceConfig.DeviceAddress == null)
            {
                throw new SourceConfigException("DeviceAddress may not be null!");
            }

            AppLogger.Message(String.Format("MangoDVR SetDSP_and_Camera Channel={0} Input={1}", sourceConfig.DeviceAddress.Channel, sourceConfig.DeviceAddress.Input));
            Marshal.GetNativeVariantForObject(sourceConfig.DeviceAddress.Channel, nativeVariant);
            hr = codecAPI_H264.SetValue(CodecAPIParam.DSP, nativeVariant);
            DsError.ThrowExceptionForHR(hr);

            Marshal.GetNativeVariantForObject(sourceConfig.DeviceAddress.Input, nativeVariant);
            hr = codecAPI_H264.SetValue(CodecAPIParam.Cam, nativeVariant);
            DsError.ThrowExceptionForHR(hr);

            hr = Marshal.ReleaseComObject(codecAPI_H264);
            DsError.ThrowExceptionForHR(hr);

            Marshal.FreeCoTaskMem(nativeVariant);
        }
Exemple #4
0
 public WinTV500(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
 {
     _captureDevice  = FindDevice(FilterCategory.AMKSCapture, @"Hauppauge WinTV PVR PCI II Capture");
     _tunerDevice    = FindDevice(FilterCategory.AMKSTVTuner, @"Hauppauge WinTV PVR PCI II TvTuner");
     _audioDevice    = FindDevice(FilterCategory.AMKSTVAudio, @"Hauppauge WinTV PVR PCI II TvAudio");
     _crossbarDevice = FindDevice(FilterCategory.AMKSCrossbar, @"Hauppauge WinTV PVR PCI II Crossbar");
     _encoderDevice  = FindDevice(FilterCategory.WDMStreamingEncoderDevices, @"Hauppauge WinTV PVR PCI II Encoder");
     CreateWinTVGraph();
 }
Exemple #5
0
 public BouncingBallDVR(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
 {
     _captureFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "Bouncing Ball");
     _videoEncoder  = AddFilterByName(FilterCategory.VideoCompressorCategory, "LEAD H264 Encoder (4.0)");
     ConnectFilters(_captureFilter, "A Bouncing Ball!", _videoEncoder, "XForm In");
     ConnectFilterToMux(_videoEncoder, "XForm Out", "Input 01");
     ConnectMuxToSink();
     InitializeSink();
     this.SaveGraphFile(@"C:\Temp\balldvr.grf");
 }
Exemple #6
0
        /// <summary>
        /// Reads the favorites from the disk and displays the icons.
        /// </summary>
        /// <remarks>throws no exceptions</remarks>
        public void LoadFavorites()
        {
            if (pFavorites.InvokeRequired)
            {
                pFavorites.BeginInvoke(new Action(LoadFavorites));
                return;
            }

            try
            {
                pFavorites.Controls.Clear();
                pFavorites.Visible = false;

                if (FavoriteServer.ServerAddress == null)
                {
                    return;
                }

                using (Client.ServerConfig serverConfig = new Client.ServerConfig(FavoriteServer.ServerAddress))
                {
                    ServerInfo serverInfo = serverConfig.GetServerInfo();
                    foreach (Favorites.FavoritesItem i in FavoriteServer.Items)
                    {
                        try
                        {
                            StreamSourceInfo sourceInfo = serverInfo.StreamSources.FindSource(i.SourceName);
                            Thumbnail        st         = new Thumbnail();
                            st.ServerInfo = serverInfo;
                            st.SourceInfo = sourceInfo;
                            if (i.IconFilename != null)
                            {
                                st.IconFilename = i.IconFilename;
                            }
                            st.Cursor       = Cursors.Hand;
                            st.DragStarted += new MouseEventHandler(Thumbnail_DragStarted);
                            DragDropManager.RegisterNonTarget(st);
                            pFavorites.Controls.Add(st);
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine("Couldn't load source: " + i.SourceName + " > " + ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.DumpToDebug(ex);
                Debug.WriteLine("Can't contact favorite server (" + FavoriteServer.ServerAddress + "): " + ex.Message);
            }

            pFavorites.Visible = (pFavorites.Controls.Count > 0);
        }
Exemple #7
0
        /// <summary>
        /// Attempts to locate a graph in the map, given the source name. Also verifies that the provided
        /// source name has been actually configured in the server's source configuration.
        /// </summary>
        /// <param name="SourceName">source name to retreive</param>
        /// <returns>the graph instance associated with the given source name.</returns>
        /// <exception cref="T:FutureConcepts.Media.SourceConfigException">
        /// Thrown if the given sourcename is not configured in the server's source config
        /// </exception>
        /// <exception cref="T:System.Exception">
        /// Thrown if no such graph has been instantiated; Can also be thrown if the server configuration does not exist.
        /// </exception>
        public static BaseGraph FindGraph(string SourceName)
        {
            StreamSourceInfo source = StreamSources.LoadFromFile().FindSource(SourceName);

            lock (_graphMap)
            {
                BaseGraph graph = _graphMap[source.SourceName];
                if (graph == null)
                {
                    throw new Exception("A graph for source " + SourceName + " does not exist.");
                }
                return(graph);
            }
        }
        /// <summary>
        /// Opens the microwave control service
        /// </summary>
        /// <param name="sourceName">source name to open</param>
        public void Open(ClientConnectRequest request)
        {
            try
            {
                this.clientRequest = request;
                AppLogger.Message(request.UserName + " MicrowaveControlService.Open " + request.SourceName);

                if (!ResourceManager.Acquire <ResourceManager.MutexRule>(request.SourceName,
                                                                         typeof(MicrowaveControlService),
                                                                         request.UserName))
                {
                    string owner = ResourceManager.GetOwner(request.SourceName, typeof(MicrowaveControlService));
                    throw new SourceHasMaxClientsException("The microwave receiver is in use by " + ((owner == null) ? "<unknown>" : owner) + ".");
                }
                resourceAcquired = true;

                StreamSourceInfo sourceConfig = StreamSources.LoadFromFile().FindSource(request.SourceName);
                if (sourceConfig.MicrowaveControl == null)
                {
                    throw new SourceConfigException("Source does not have MicrowaveControl section defined!");
                }
                microwaveConfig = sourceConfig.MicrowaveControl;

                //get client callback
                clientCallback = OperationContext.Current.GetCallbackChannel <IMicrowaveControl2Callback>();

                //create microwave receiver instance
                microwaveReceiver = MicrowaveControlService2.CreateInstance(microwaveConfig);
                if (!microwaveReceiver.Connected)
                {
                    throw new SourceConfigException("Communication with the microwave receiver could not be established.");
                }
                microwaveReceiver.ReceiverTuningChange      += new EventHandler <MicrowaveReceiver.ReceiverEventArgs>(microwaveReceiver_ReceiverTuningChange);
                microwaveReceiver.ReceiverLinkQualityChange += new EventHandler <MicrowaveReceiver.ReceiverEventArgs>(microwaveReceiver_ReceiverLinkQualityChange);
                microwaveReceiver.ReceiverConnectionChange  += new EventHandler(microwaveReceiver_ReceiverConnectionChange);

                scanner = new PeakScan(microwaveReceiver);
                scanner.ScanCompleted += new EventHandler <ScanCompleteEvent>(scanner_ScanCompleted);

                //load cached presets
                LoadSavedPresets();

                microwaveReceiver.StartPollingLinkQuality();
            }
            catch (Exception exc)
            {
                AppLogger.Dump(exc);
                throw;
            }
        }
Exemple #9
0
        public FastVDODVR(StreamSourceInfo streamSourceInfo, OpenGraphRequest openGraphRequest)
            : base(streamSourceInfo, openGraphRequest)
        {
            //maximum number of retries before blowing away graph/connection
            int MaxRetries = 1;

            for (int retry = 1; retry <= MaxRetries; retry++)
            {
                try
                {
                    InitializeSmartCapture(CurrentProfile);
                    InitializeSink();
                    _captureFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "FastVDO-SmartCapture QBoxSplitter");
                    _transcoder    = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "H.264 Byte Stream Transform");
                    AppLogger.Message("Attempting to connect capture filter (Video) to transform (XForm In)");
                    ConnectFilters(_captureFilter, "Video", _transcoder, "XForm In");
                    AppLogger.Message("Attempting to connect transform (XForm Out) to mux (Input 01)");
                    ConnectFilterToMux(_transcoder, "XForm Out", "Input 01");
                    ConnectMuxToSink();
                    break;  //this worked, so stop retrying
                }
                catch (Exception exc)
                {
                    ErrorLogger.DumpToDebug(exc);
                    if (_deviceContext != IntPtr.Zero)
                    {
                        try
                        {
                            AppLogger.Message("Resetting FVDO device");
                            NativeMethods.SCReset(_deviceContext);
                            Thread.Sleep(2000);
                        }
                        catch (Exception exc2)
                        {
                            ErrorLogger.DumpToDebug(exc2);
                        }
                    }
                    //on the last retry, give up
                    if (retry == MaxRetries)
                    {
                        this.Dispose();
                        throw;
                    }
                    else
                    {
                        CloseSmartCapture();
                    }
                }
            }
        }
Exemple #10
0
        public ScreenCapture(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            InitializeSink();

            _captureFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD Screen Capture (2.0)");
            if (_captureFilter == null)
            {
                throw new Exception("screen capture filter not found");
            }
            _videoEncoder = AddFilterByName(FilterCategory.VideoCompressorCategory, "LEAD Screen Capture Encoder (2.0)");
            ConnectFilters(_captureFilter, "Capture", _videoEncoder, "XForm In");
            ConnectFilterToMux(_videoEncoder, "XForm Out", "Input 01");
            ConnectMuxToSink();
        }
Exemple #11
0
        public StreamingAndRecording(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            InitializeNetworkSink();

            int hr;

            _tee = (IBaseFilter) new InfTee();
            hr   = _graphBuilder.AddFilter(_tee, "Inf Tee");
            DsError.ThrowExceptionForHR(hr);

            _recordSink       = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "DVR Writer");
            _recordSinkFilter = (IFileSinkFilter)_recordSink;
            _recordSinkFilter.SetFileName(@"c:\test.lts", new AMMediaType());
            _dvrWriter = (IDVRWriterApi)_recordSink;
        }
Exemple #12
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);
        }
Exemple #13
0
        public DVRtoMPEG2TS(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            AppLogger.Message("In DVRtoMPEG2TS - CurrentProfile is " + CurrentProfile.Name);

            InitializeSink();

            _captureFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD DVR Source");
            IFileSourceFilter fileSource = (IFileSourceFilter)_captureFilter;

            String[]    sourceNameParts = sourceConfig.SourceName.Split('-');
            DVRSettings dvrSettings     = DVRSettings.LoadFromFile();
            int         hr = fileSource.Load(dvrSettings.RootFolder + sourceNameParts[0] + @"/Stream.LBL", null);

            DsError.ThrowExceptionForHR(hr);
            ILMDVRSource sourceControl = (ILMDVRSource)_captureFilter;

            sourceControl.ResetToDefaultsEx(LMDVRSource_APILEVEL.LMDVRSource_APILEVEL_1);

            _demux                          = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD MPEG2 Transport Demultiplexer");
            _demuxControl                   = (ILMMpgDmx)_demux;
            _demuxControl.AutoLive          = true;
            _demuxControl.AutoLiveTolerance = .5;

//            _currentVideoSettings = new VideoSettings();
//            _currentVideoSettings.CodecType = CurrentProfile.Video.CodecType;

            ConnectFilters(_captureFilter, "Output", _demux, "Input 01");

            if (CurrentProfile.Video != null)
            {
                VideoSettings settings = CurrentProfile.Video;
                _videoDecoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Decoder (3.0)");
                _videoEncoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Encoder (4.0)");
                ConnectFilters(_demux, "H.264 Video", _videoDecoder, "XForm In");
                ConnectFilters(_videoDecoder, "XForm Out", _videoEncoder, "XForm In");
                LMH264EncoderLib.ILMH264Encoder encoderConfig = (LMH264EncoderLib.ILMH264Encoder)_videoEncoder;
                encoderConfig.EnableRateControl = true;
                encoderConfig.BitRate           = settings.ConstantBitRate * 1024;
                ConnectFilterToMux(_videoEncoder, "XForm Out", "Input 01");
            }
            else
            {
                ConnectFilterToMux(_demux, "H.264 Video", "Input 01");
            }
            ConnectMuxToSink();
        }
Exemple #14
0
        public StreamingTVGraph(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest)
            : base(sourceConfig, openGraphRequest)
        {
            InitializeNetworkSink();

            this.TVConfig = sourceConfig.TVTuner;

            try
            {
                this.KnownChannels = ChannelCollection.LoadFromFile(GetKnownChannelsStoreFilename());
            }
            catch (Exception ex)
            {
                this.KnownChannels = new ChannelCollection();
                AppLogger.Dump(ex);
            }
        }
Exemple #15
0
        protected BaseGraph OpenGraph()
        {
            AppLogger.Message(String.Format("OpenGraph {0}", ClientConnectRequest.SourceName));

            //retreives the correct source config based on the OpenGraphRequest
            StreamSourceInfo sourceConfig = GetSourceConfig();

            //handles logical groups
            if (sourceConfig.SourceType == SourceType.LogicalGroup)
            {
                StreamSources sources = StreamSources.LoadFromFile();
                foreach (string physicalName in sourceConfig.LogicalGroupSourceNames)
                {
                    StreamSourceInfo physicalSourceConfig = sources.FindSource(physicalName);
                    BaseGraph graph = GraphManager.TryFindGraph(physicalName);
                    if (graph == null)
                    {
                        return(OpenPhysicalGraph(physicalSourceConfig));
                    }
                    else
                    {
                        if (graph.NumberOfClients < physicalSourceConfig.MaxClients)
                        {
                            return(OpenPhysicalGraph(physicalSourceConfig));
                        }
                    }
                }
                throw new Exception("no sources available for " + ClientConnectRequest.SourceName);
            }
            else
            {
                try
                {
                    return(OpenPhysicalGraph(sourceConfig));
                }
                catch (SourceHasMaxClientsException e)
                {
                    throw e;
                }
                catch (Exception exc)
                {
                    AppLogger.Dump(exc);
                    throw new Exception("Source " + ClientConnectRequest.SourceName + " is not currently available", exc);
                }
            }
        }
Exemple #16
0
        public RTSPDeviceControl(StreamSourceInfo streamSourceInfo, String serverAddress)
        {
            _sourceInfo                 = streamSourceInfo;
            _sessionDescription         = new SessionDescription();
            _sessionDescription.SinkURL = _sourceInfo.SinkAddress;
            Profile profile = new Profile();

            profile.Name = "RTSP:RTSP";
            ProfileGroup profileGroup = new ProfileGroup();

            profileGroup.Name = "RTSP";
            profileGroup.Items.Add(profile);
            ProfileGroups profileGroups = new ProfileGroups();

            profileGroups.Items.Add(profileGroup);
            _sessionDescription.ProfileGroups      = profileGroups;
            _sessionDescription.CurrentProfileName = "RTSP:RTSP";
        }
Exemple #17
0
        /// <summary>
        /// Connects to given address and parses xml to extract all IP addresses
        /// of all nodes advertising given service type
        /// </summary>
        /// <param name="type">Type of service to retrieve.</param>
        /// <param name="address">IP address to get xml from - Note that the file /xml/services is added onto this IP.</param>
        /// <param name="exc">If an exception was thrown while retrieving services, it is returned here.</param>
        /// <returns>list of Advertised Service Objects</returns>
        public static SourceDiscoveryGroup QueryWowza(String hostAddress, String username, String password)
        {
            SourceDiscoveryGroup result = new SourceDiscoveryGroup();
            string page = "";
            String url  = String.Format(@"http://{0}/serverinfo", hostAddress);

            try
            {
                page = GetResponseString(url, username, password);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
                return(result);
            }
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(page);
            XmlNodeList appNodes = xmldoc.SelectNodes("/WowzaMediaServerPro/VHost/Application");

            foreach (XmlNode appNode in appNodes)
            {
                XmlNode appNameNode = appNode.SelectSingleNode("Name");
                if (appNameNode.InnerText == "live" || appNameNode.InnerText == "axbro")
                {
                    XmlNode appInstanceNode = appNode.SelectSingleNode("ApplicationInstance");
                    if (appInstanceNode != null)
                    {
                        XmlNodeList rtpSessions = appInstanceNode.SelectNodes("RTPSession");
                        foreach (XmlNode rtpSession in rtpSessions)
                        {
                            XmlNode          uriNode = rtpSession.SelectSingleNode("URI");
                            String           uri     = uriNode.InnerText;
                            StreamSourceInfo source  = new StreamSourceInfo();
//                            source.ClientURL = uri;
                            source.Description = uri;
                            result.Sources.Add(source);
                        }
                    }
                }
            }
            return(result);
        }
Exemple #18
0
        public HttpGetDeviceControl(StreamSourceInfo streamSourceInfo, String serverAddress)
        {
            _sourceInfo         = streamSourceInfo;
            _sessionDescription = new SessionDescription();
//            _sessionDescription.ClientURL = streamSourceInfo.ClientURL;
            Profile profile = new Profile();

            profile.Name = "RTSP:RTSP";
            ProfileGroup profileGroup = new ProfileGroup();

            profileGroup.Name = "RTSP";
            profileGroup.Items.Add(profile);
            ProfileGroups profileGroups = new ProfileGroups();

            profileGroups.Items.Add(profileGroup);
            _sessionDescription.ProfileGroups      = profileGroups;
            _sessionDescription.CurrentProfileName = "RTSP:RTSP";
//            _sessionDescription.SinkProtocolType = SinkProtocolType.RTSP;
        }
Exemple #19
0
        public DVRLeadNetSink(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            AppLogger.Message("In DVRNetSink constructor - CurrentProfile is " + CurrentProfile.Name);

            InitializeNetworkSink();

            _captureFilter = DVRGraphHelper.GetAndConfigureDVRSourceForSink(_graphBuilder, sourceConfig);

            _demux                          = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD MPEG2 Transport Demultiplexer");
            _demuxControl                   = (ILMMpgDmx)_demux;
            _demuxControl.AutoLive          = true;
            _demuxControl.AutoLiveTolerance = .5;

            ConnectFilters(_captureFilter, "Output", _demux, "Input 01");

            ConnectFilterToNetMux(_demux, "H.264 Video", "Input 01");

            ConnectNetMuxToNetSnk();
        }
Exemple #20
0
 public static IDeviceControl Create(StreamSourceInfo streamSourceInfo, String serverAddress)
 {
     if (streamSourceInfo.SinkAddress.StartsWith(@"udp://"))
     {
         return(new RTSPDeviceControl(streamSourceInfo, serverAddress));
     }
     else if (streamSourceInfo.SourceType == SourceType.RTSP || streamSourceInfo.SourceType == SourceType.RTSP_Elecard)
     {
         return(new RTSPDeviceControl(streamSourceInfo, serverAddress));
     }
     else if (streamSourceInfo.SourceType == SourceType.HTTP_GET)
     {
         return(new HttpGetDeviceControl(streamSourceInfo, serverAddress));
     }
     else
     {
         return(new LTSFDeviceControl(streamSourceInfo, serverAddress));
     }
 }
Exemple #21
0
        public MangoDVR(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            InitializeSink();

//            _transcoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Transcoder");

            _captureFilter = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "Mango Capture");

            _currentVideoSettings           = new VideoSettings();
            _currentVideoSettings.CodecType = CurrentProfile.Video.CodecType;

            SetDSP_and_Camera(sourceConfig);
            ChangeProfile(CurrentProfile);

//            ConnectFilters(_captureFilter, "H264", _transcoder, "Input");
//            ConnectFilterToMux(_transcoder, "Output", "Input 01");
            ConnectFilterToMux(_captureFilter, "H264", "Input 01");
            ConnectMuxToSink();
        }
Exemple #22
0
        public void Open(ClientConnectRequest request)
        {
            try
            {
                clientRequest = request;
                AppLogger.Message(request.UserName + " CameraControlService.Open " + request.SourceName);

                StreamSourceInfo sourceConfig = StreamSources.LoadFromFile().FindSource(request.SourceName);
                if (sourceConfig.CameraControl == null)
                {
                    throw new SourceConfigException("Source does not have CameraControl defined!");
                }

                //lock against the camera control address -- this allows multiple sources to share the same camera.
                //    if the particular camera control does not require an address, then lock against the source name
                this.ResourceID = string.IsNullOrEmpty(sourceConfig.CameraControl.Address) ?
                                  request.SourceName :
                                  sourceConfig.CameraControl.Address;

                if (!ResourceManager.Acquire <ResourceManager.MutexRule>(this.ResourceID,
                                                                         typeof(CameraControlService),
                                                                         request.UserName))
                {
                    string owner = ResourceManager.GetOwner(this.ResourceID, typeof(CameraControlService));
                    throw new SourceHasMaxClientsException("The camera control is in use by " +
                                                           (string.IsNullOrEmpty(owner) ? "<unknown>" : owner) + ".");
                }
                resourceAcquired = true;

                CameraControl = sourceConfig.CameraControl;
                Plugin        = CameraControls.PluginFactory.Create(CameraControl, this);
                LoadSavedPositions();
            }
            catch (Exception exc)
            {
                AppLogger.Dump(exc);
                //throw new Exception("Unable to open camera control for " + sourceName, exc);
                throw;
            }
        }
Exemple #23
0
        private StreamViewerControl FindViewerMatching(StreamSourceInfo streamSourceInfo)
        {
            StreamViewerControl        result = null;
            List <StreamViewerControl> list   = new List <StreamViewerControl>();

            list.Add(StreamA);
            list.Add(StreamB);
            list.Add(StreamC);
            list.Add(StreamD);
            foreach (StreamViewerControl streamViewerControl in list)
            {
                if ((streamViewerControl.SourceInfo != null) && (streamViewerControl.SourceInfo.SinkAddress != null))
                {
                    if (streamViewerControl.SourceInfo.SinkAddress == streamSourceInfo.SinkAddress)
                    {
                        result = streamViewerControl;
                        break;
                    }
                }
            }
            return(result);
        }
Exemple #24
0
        public BaseGraph(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest)
        {
            int hr = 0;

            SourceConfig     = sourceConfig;
            OpenGraphRequest = openGraphRequest;

            // An exception is thrown if cast fail
            _graphBuilder        = (IGraphBuilder) new FilterGraph();
            _captureGraphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            _mediaControl        = (IMediaControl)_graphBuilder;

            // Attach the filter graph to the capture graph
            hr = _captureGraphBuilder.SetFiltergraph(_graphBuilder);
            DsError.ThrowExceptionForHR(hr);

#if DEBUG_ROTENTRY
            _rot = new DsROTEntry(_graphBuilder);
#endif

            LoadProfileGroups();

            //the first listed ProfileGroup is the default ProfileGroup
            if (ProfileGroups.Items.Count == 0)
            {
                throw new SourceConfigException("No Profile Groups loaded!");
            }
            ProfileGroup profileGroup = ProfileGroups.Items[0];
            DefaultProfileName = profileGroup.Name + ":" + profileGroup.DefaultProfileName;

            if (OpenGraphRequest.Profile != null)
            {
                CurrentProfile = OpenGraphRequest.Profile;
            }
            else
            {
                CurrentProfile = FindProfile(DefaultProfileName);
            }
        }
Exemple #25
0
        public ASFNetSink(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest)
            : base(sourceConfig, openGraphRequest)
        {
            _eventTimer          = new System.Timers.Timer();
            _eventTimer.Elapsed += new System.Timers.ElapsedEventHandler(_eventTimer_Elapsed);
            _eventTimer.Interval = 100;

            int             hr;
            IFileSinkFilter pTmpSink;

            hr = _captureGraphBuilder.SetOutputFileName(MediaSubType.Asf, SourceConfig.SourceName.Replace(':', '_') + @".asf", out _asfFilter, out pTmpSink);
            DsError.ThrowExceptionForHR(hr);

            ConfigureWriterFilter();

            CreateNetworkWriterSink();

            OpenSink();

            AddSinkToWriter();

            _eventTimer.Start();
        }
Exemple #26
0
        private void CheckSecurity(StreamSourceInfo sourceConfig)
        {
            // Enable this code when authentication/authorization is needed
            ServiceSecurityContext sc = ServiceSecurityContext.Current;

            if (sc != null)
            {
                AppLogger.Message("We have a security context");
                IIdentity id1 = sc.PrimaryIdentity;
                if (id1 != null)
                {
                    AppLogger.Message(String.Format("Primary identity {0}", id1.Name));
                }
                IIdentity id2 = sc.WindowsIdentity;
                if (id2 != null)
                {
                    AppLogger.Message(String.Format("Windows identity {0}", id2.Name));
                }
                AuthorizationContext ctx = sc.AuthorizationContext;
                if (ctx != null)
                {
                    foreach (ClaimSet claimSet in ctx.ClaimSets)
                    {
                        foreach (Claim claim in claimSet)
                        {
                            AppLogger.Message("ClaimType: " + claim.ClaimType);
                            AppLogger.Message("Resource: " + claim.Resource);
                            AppLogger.Message("Right: " + claim.Right);
                        }
                    }
                }
                else
                {
                    AppLogger.Message("No auth context");
                }
            }
        }
Exemple #27
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);
     }
 }
Exemple #28
0
        public StreamingGraph(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            _netMux              = AddFilterByName(FilterCategory.LegacyAmFilterCategory, @"LEAD Network Multiplexer (2.0)");
            _lmNetMux            = (ILMNetMux)_netMux;
            _lmNetMux.LiveSource = SourceConfig.LiveSource;
            AppLogger.Message(String.Format("LiveSource={0}", LiveSource));
//            _lmNetMux.MaxQueueDuration = SourceConfig.MaxQueueDuration;
//            _lmNetMux.MaxQueueDuration = SourceConfig.MaxQueueDuration;
            AppLogger.Message(String.Format("MaxQueueDuration={0}", _lmNetMux.MaxQueueDuration));
            _netSnk = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD Network Sink (2.0)");

            //parse the app.config to see if we are disabling either of these.
            bool.TryParse(ConfigurationManager.AppSettings["DispatchClientsUpdate"], out this.DispatchClientsUpdate);
            bool.TryParse(ConfigurationManager.AppSettings["DispatchProfileUpdate"], out this.DispatchProfileUpdate);
            if (!this.DispatchProfileUpdate)
            {
                AppLogger.Message("   DispatchProfileUpdate is disabled.");
            }
            if (!this.DispatchClientsUpdate)
            {
                AppLogger.Message("   DispatchClientsUpdate is disabled.");
            }
            BuildClientURL(SinkProtocolType.LTSF_TCP);
        }
Exemple #29
0
        public DVRtoDVR(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest) : base(sourceConfig, openGraphRequest)
        {
            AppLogger.Message("In DVRtoDVR - CurrentProfile is " + CurrentProfile.Name);

            InitializeSink();

            _captureFilter = DVRGraphHelper.GetAndConfigureDVRSourceForSink(_graphBuilder, sourceConfig);

            _demux                          = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD MPEG2 Transport Demultiplexer");
            _demuxControl                   = (ILMMpgDmx)_demux;
            _demuxControl.AutoLive          = true;
            _demuxControl.AutoLiveTolerance = .5;

//            _currentVideoSettings = new VideoSettings();
//            _currentVideoSettings.CodecType = CurrentProfile.Video.CodecType;

            ConnectFilters(_captureFilter, "Output", _demux, "Input 01");

            if (CurrentProfile.Video != null)
            {
                VideoSettings settings = CurrentProfile.Video;
                _videoDecoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Decoder (3.0)");
                _videoEncoder = AddFilterByName(FilterCategory.LegacyAmFilterCategory, "LEAD H264 Encoder (4.0)");
                ConnectFilters(_demux, "H.264 Video", _videoDecoder, "XForm In");
                ConnectFilters(_videoDecoder, "XForm Out", _videoEncoder, "XForm In");
                LMH264EncoderLib.ILMH264Encoder encoderConfig = (LMH264EncoderLib.ILMH264Encoder)_videoEncoder;
                encoderConfig.EnableRateControl = true;
                encoderConfig.BitRate           = settings.ConstantBitRate * 1024;
                ConnectFilterToMux(_videoEncoder, "XForm Out", "Input 01");
            }
            else
            {
                ConnectFilterToMux(_demux, "H.264 Video", "Input 01");
            }
            ConnectMuxToSink();
        }
Exemple #30
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);
                 }
             }
         }
     }
 }