/// <summary> /// This object is a managed wrapper around the SBE's RecComp object /// </summary> /// <param name="srcFile">The source file to be cutted</param> /// <param name="destFile">The resulting file. Delet</param> /// <remarks>Warning, if destFile already exists, the constructor delete it</remarks> /// <exception cref="System.IO.FileNotFoundException">Thrown if srcFile doesn't exists</exception> /// <exception cref="System.Runtime.InteropServices.COMException">Thrown if someting wrong append during the destination initialization</exception> public SBECutter2(string srcFile, string destFile) { if (!File.Exists(srcFile)) { throw new FileNotFoundException(); } if (File.Exists(destFile)) { File.Delete(destFile); } sbeRecComp = (IStreamBufferRecComp) new StreamBufferComposeRecording(); source = srcFile; destionation = destFile; int hr = sbeRecComp.Initialize(destionation, source); DsError.ThrowExceptionForHR(hr); }
public SBECutter() { // Create this object recComp = (IStreamBufferRecComp) new StreamBufferComposeRecording(); }
/// <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; }
public SBECutter() { // Create this object recComp = (IStreamBufferRecComp) new StreamBufferComposeRecording(); }
private void Configure() { m_sbrc = (IStreamBufferRecComp) new StreamBufferComposeRecording(); }
/// <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); }