Example #1
0
        /// <summary>
        /// Loads DVRSettings from a specified file.
        /// </summary>
        /// <param name="fileName">The filename to load. If you are trying to load multiple distinct files, set bypassCache to true.</param>
        /// Set to true to always read from the disk and return a distinct copy
        /// Set to false to use the cached copy if available.
        /// </param>
        /// <returns>the RTSPServer from the indicated file</returns>
        public static DVRSettings LoadFromFile(string fileName)
        {
            DVRSettings result = null;
            FileStream  file   = null;

            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(DVRSettings));
                file   = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                result = (DVRSettings)xmlSerializer.Deserialize(file);
            }
            catch (Exception e)
            {
                Debug.WriteLine(String.Format("DVRSettings was not loaded -- the configuration file {0} could not be loaded", PersistFileName));
                Debug.WriteLine(e.Message);
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                    file.Dispose();
                }
            }
            return(result);
        }
Example #2
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();
        }
Example #3
0
        /// <summary>
        /// Add the LEAD DVR Source filter to a graph (builder) and
        /// load the fileSource using the associated input graph's
        /// source name (from sourceConfig).  For example, if the output
        /// graph source name was "Vid1-RTSP" then the input graph
        /// source name will have a name of "Vid1".
        /// <DVRSourceName> --> <LeftOfSinkSourceName>
        /// Vid1-RTSP (the output graph source name) --> Vid1 (the input graph source name)
        /// </summary>
        public static IBaseFilter GetAndConfigureDVRSourceForSink(IGraphBuilder builder, StreamSourceInfo sourceConfig)
        {
            IBaseFilter result = FilterGraphTools.AddFilterByName(builder, FilterCategory.LegacyAmFilterCategory, "LEAD DVR Source");

            if (result == null)
            {
                throw new Exception("The LEADTOOLS DVR Source filter is not registered");
            }
            IFileSourceFilter fileSource = (IFileSourceFilter)result;

            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)result;

            sourceControl.ResetToDefaultsEx(LMDVRSource_APILEVEL.LMDVRSource_APILEVEL_1);
            return(result);
        }