/// <summary>
        /// Gibt alle internen Strukturen frei.
        /// </summary>
        private void DestroyGraph()
        {
            // Get rid of clock
            DisposeClock();

            // Try stop and delete all filters
            if (null != m_Graph)
            {
                try
                {
                    // Stop self
                    GraphAsFilter.Stop();
                }
                catch
                {
                }
            }

            // Filters first
            foreach (var filter in m_Filters.Values)
            {
                filter.Dispose();
            }

            // Clear list
            m_Filters.Clear();

            // Forward
            using (m_Register)
                m_Register = null;

            // Must cleanup COM references
            BDAEnvironment.Release(ref m_Graph);

            // Must cleanup file
            using (m_LogFile)
                m_LogFile = null;

            // Clear helpers and reset flags
            m_VideoWindowCreated = false;
            m_VideoPID           = 0;
            m_AudioPID           = 0;

            // TS Filter
            using (InjectorFilter)
                InjectorFilter = null;
        }
        /// <summary>
        /// Initialisiert die Filterstruktur.
        /// </summary>
        public void CreateGraph()
        {
            // Cleanup
            DestroyGraph();

            // Check log
            var logFile = BDASettings.BDALogPath;

            if (logFile != null)
            {
                m_LogFile = new FileStream(logFile.FullName, FileMode.Create, FileAccess.Write, FileShare.Read);
            }

            // Create new graph builder
            m_Graph = (IGraphBuilder)Activator.CreateInstance(Type.GetTypeFromCLSID(BDAEnvironment.GraphBuilderClassIdentifier));

            // Enable logging
            if (m_LogFile != null)
            {
                m_Graph.SetLogFile(m_LogFile.SafeFileHandle);
            }

            // See if we should register the graph
            m_Register = BDASettings.RegisterBDAGRaph(DirectShowObject, false);

            // Create filter
            InjectorFilter = new TSFilter(this);
            try
            {
                // Check for statistics
                InjectorFilter.EnableStatistics = BDASettings.GenerateTSStatistics;

                // Register in graph
                AddFilter(Filter_Injector, InjectorFilter);
            }
            catch
            {
                // Cleanup
                InjectorFilter.Dispose();

                // Forward
                throw;
            }
        }