示例#1
0
        /// <summary>Initializes the editor.</summary>
        /// <param name="filepath">The path to the file.</param>
        public DvrmsMetadataEditor(string filepath) : base()
        {
            IFileSourceFilter sourceFilter = (IFileSourceFilter)ClassId.CoCreateInstance(ClassId.RecordingAttributes);

            sourceFilter.Load(filepath, null);
            _editor = (IStreamBufferRecordingAttribute)sourceFilter;
        }
示例#2
0
        /// <summary>Do the conversion from DVR-MS to WAV.</summary>
        /// <returns>Null; ignored.</returns>
        protected override object DoWork()
        {
            // Get the filter graph
            object filterGraph = ClassId.CoCreateInstance(ClassId.FilterGraph);

            DisposalCleanup.Add(filterGraph);
            IGraphBuilder graph = (IGraphBuilder)filterGraph;

            // Add the ASF writer and set the output name
            IBaseFilter asfWriterFilter = (IBaseFilter)ClassId.CoCreateInstance(ClassId.WMAsfWriter);

            DisposalCleanup.Add(asfWriterFilter);
            graph.AddFilter(asfWriterFilter, null);
            IFileSinkFilter sinkFilter = (IFileSinkFilter)asfWriterFilter;

            sinkFilter.SetFileName(OutputFilePath, null);

            // Set the profile to be used for conversion
            if (_profilePath != null && _profilePath.Trim().Length > 0)
            {
                // Load the profile XML contents
                string profileData;
                using (StreamReader reader = new StreamReader(File.OpenRead(_profilePath)))
                {
                    profileData = reader.ReadToEnd();
                }

                // Create an appropriate IWMProfile from the data
                IWMProfileManager profileManager = ProfileManager.CreateInstance();
                DisposalCleanup.Add(profileManager);
                IntPtr wmProfile = profileManager.LoadProfileByData(profileData);
                DisposalCleanup.Add(wmProfile);

                // Set the profile on the writer
                IConfigAsfWriter2 configWriter = (IConfigAsfWriter2)asfWriterFilter;
                configWriter.ConfigureFilterUsingProfile(wmProfile);
            }

            // Add the source filter; should connect automatically through the appropriate transform filters
            graph.RenderFile(InputFilePath, null);

            // Run the graph to completion
            RunGraph(graph, asfWriterFilter);

            return(null);
        }
示例#3
0
        /// <summary>Do the conversion from DVR-MS to WAV.</summary>
        /// <returns>Null; ignored.</returns>
        protected override object DoWork()
        {
            // Get the filter graph
            object filterGraph = ClassId.CoCreateInstance(ClassId.FilterGraph);

            DisposalCleanup.Add(filterGraph);
            IGraphBuilder graph = (IGraphBuilder)filterGraph;

            // Add the source filter for the dvr-ms file
            IBaseFilter DvrmsSourceFilter = graph.AddSourceFilter(InputFilePath, null);

            DisposalCleanup.Add(DvrmsSourceFilter);

            // Add the file writer to the graph
            IBaseFilter wavFilter = (IBaseFilter)ClassId.CoCreateInstance(ClassId.FileWriter);

            DisposalCleanup.Add(wavFilter);
            graph.AddFilter(wavFilter, null);
            IFileSinkFilter sinkFilter = (IFileSinkFilter)wavFilter;

            sinkFilter.SetFileName(OutputFilePath, null);

            // Add the Wav Dest filter to the graph
            IBaseFilter wavDest = (IBaseFilter)ClassId.CoCreateInstance(ClassId.WavDest);

            DisposalCleanup.Add(wavDest);
            graph.AddFilter(wavDest, null);

            // Add the decrypter node to the graph
            IBaseFilter decrypter = (IBaseFilter)ClassId.CoCreateInstance(ClassId.DecryptTag);

            DisposalCleanup.Add(decrypter);
            graph.AddFilter(decrypter, null);

            // Connect the dvr-ms source to the decrypter, the decrypter to the wav dest,
            // and the wav dest to the file writer
            Connect(graph, DvrmsSourceFilter, "DVR Out - 1", decrypter, "In(Enc/Tag)");
            Connect(graph, decrypter, "Out", wavDest, "In");
            Connect(graph, wavDest, "Out", wavFilter, "in");

            // Run the graph to convert the audio to wav
            RunGraph(graph);

            return(null);
        }
示例#4
0
        /// <summary>Splices together all of the spans.</summary>
        /// <returns></returns>
        protected override object DoWork()
        {
            IStreamBufferRecComp recComp = null;
            Timer timer = null;

            try
            {
                // Timer used for updating progress
                timer = new Timer(new TimerCallback(HandleProgressUpdate), null, PollFrequency, PollFrequency);

                // Create the RecComp and initialize it
                recComp = (IStreamBufferRecComp)ClassId.CoCreateInstance(ClassId.RecComp);
                if (File.Exists(_target.FullName))
                {
                    File.Delete(_target.FullName);
                }
                recComp.Initialize(_target.FullName, _spans[0].File.FullName);
                _recComp = recComp;                 // only valid during this call

                // Add each span to the output file
                FileInfo dvrTarget = _target;
                for (int i = 0; i < _spans.Count; i++)
                {
                    // If the user has requested cancellation, stop processing
                    if (CancellationPending)
                    {
                        break;
                    }

                    // Do the append
                    VideoSpan span  = _spans[i];
                    ulong     start = VideoSpan.SecondsToHundredNanoseconds(span.StartPosition);
                    ulong     stop  = VideoSpan.SecondsToHundredNanoseconds(span.StopPosition);
                    recComp.AppendEx(span.File.FullName, start, stop);
                }
            }
            finally
            {
                // Clean up after the RecComp object and the timer
                if (timer != null)
                {
                    timer.Dispose();
                }
                if (recComp != null)
                {
                    recComp.Close();
                }
                while (Marshal.ReleaseComObject(recComp) > 0)
                {
                    ;
                }
            }

            // Copy the metadata if requested... use that from the first span.
            if (_copyMetadata)
            {
                using (MetadataEditor sourceEditor = new DvrmsMetadataEditor(_spans[0].File.FullName))
                {
                    using (MetadataEditor destEditor = new AsfMetadataEditor(_target.FullName))
                    {
                        MetadataEditor.MigrateMetadata(sourceEditor, destEditor);
                    }
                }
            }

            // Notify that we're done
            OnProgressChanged(100);
            return(null);
        }