コード例 #1
0
 /// <summary>Initializes the editor.</summary>
 /// <param name="filepath">The path to the file.</param>
 public MCRecMetadataEditor(string filepath)
   : base(filepath)
 {
   _editor = (IStreamBufferRecordingAttribute)new StreamBufferRecordingAttributes();//ClassId.CoCreateInstance(ClassId.RecordingAttributes);
   IFileSourceFilter sourceFilter = (IFileSourceFilter)_editor;
   sourceFilter.Load(filepath, null);
 }
コード例 #2
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;
        }
コード例 #3
0
        private static KeyValuePair <string, object> GetAttributeByIndex(IStreamBufferRecordingAttribute editor, short index)
        {
            StreamBufferAttrDataType attributeType;
            short attributeNameLength  = 0;
            short attributeValueLength = 0;

            // Get the lengths of the name and the value, then use them to create buffers to receive them
            editor.GetAttributeByIndex(index, 0, null, ref attributeNameLength,
                                       out attributeType, IntPtr.Zero, ref attributeValueLength);

            string attributeName  = null;
            object attributeValue = null;

            IntPtr attributeValuePtr = IntPtr.Zero;

            try
            {
                StringBuilder attributeNameBuilder = new StringBuilder(attributeNameLength);
                attributeValuePtr = Marshal.AllocCoTaskMem(attributeValueLength);

                editor.GetAttributeByIndex(index, 0, attributeNameBuilder, ref attributeNameLength,
                                           out attributeType, attributeValuePtr, ref attributeValueLength);

                attributeName  = attributeNameBuilder.ToString().Trim('\0');
                attributeValue = ConvertAttributeValue(attributeType, attributeValuePtr, attributeValueLength);
            }
            finally
            {
                Marshal.FreeCoTaskMem(attributeValuePtr);
            }
            return(new KeyValuePair <string, object>(attributeName, attributeValue));
        }
コード例 #4
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;
 }
コード例 #5
0
        /// <summary>Initializes the editor.</summary>
        /// <param name="filepath">The path to the file.</param>
        public MCRecMetadataEditor(string filepath)
            : base(filepath)
        {
            _editor = (IStreamBufferRecordingAttribute) new StreamBufferRecordingAttributes();//ClassId.CoCreateInstance(ClassId.RecordingAttributes);
            IFileSourceFilter sourceFilter = (IFileSourceFilter)_editor;

            sourceFilter.Load(filepath, null);
        }
コード例 #6
0
        /// <summary>Get all of the attributes on a file.</summary>
        /// <returns>A collection of the attributes from the file.</returns>
        public static IDictionary <string, object> GetAttributes(string path)
        {
            IFileSourceFilter sourceFilter = (IFileSourceFilter)Activator.CreateInstance <StreamBufferRecordingAttributes>();

            sourceFilter.Load(path, null);

            IStreamBufferRecordingAttribute editor = (IStreamBufferRecordingAttribute)sourceFilter;

            return(GetAttributes(editor));
        }
コード例 #7
0
        private void Configure()
        {
            // In order to lock a profile, you have to have at least one stream
            // connected to the sink. I connect a video thru the DVVideoEnc into
            // the StreamBufferSink.
            const string FileName = "delme.out";

            int         hr;
            IBaseFilter pFilter;
            object      o;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
            StreamBufferSink      sbk  = new StreamBufferSink();

            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            DsROTEntry ds = new DsROTEntry(m_FilterGraph);

            hr = icgb.SetFiltergraph(m_FilterGraph);
            DsError.ThrowExceptionForHR(hr);

            hr = m_FilterGraph.AddFilter((IBaseFilter)sbk, "StreamBufferSink");
            DsError.ThrowExceptionForHR(hr);

            DsDevice [] devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
            hr = m_FilterGraph.AddSourceFilterForMoniker(devs[0].Mon, null, devs[0].Name, out pFilter);
            DsError.ThrowExceptionForHR(hr);

            DVVideoEnc  dve         = new DVVideoEnc();
            IBaseFilter ibfVideoEnc = (IBaseFilter)dve;

            hr = m_FilterGraph.AddFilter(ibfVideoEnc, "dvenc");
            DsError.ThrowExceptionForHR(hr);

            hr = icgb.RenderStream(null, null, pFilter, ibfVideoEnc, (IBaseFilter)sbk);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(pFilter);
            Marshal.ReleaseComObject(icgb);

            IStreamBufferSink isbc = (IStreamBufferSink)sbk;

            hr = isbc.LockProfile("delme.prf");
            DsError.ThrowExceptionForHR(hr);

            File.Delete(FileName);

            hr = isbc.CreateRecorder("delme.out", RecordingType.Content, out o);
            DsError.ThrowExceptionForHR(hr);

            // Make sure we really got a recorder object
            IStreamBufferRecordingAttribute sbra = (IStreamBufferRecordingAttribute)o;

            hr = sbra.EnumAttributes(out m_sbra);
            DsError.ThrowExceptionForHR(hr);
        }
コード例 #8
0
 /// <summary>Release all resources.</summary>
 /// <param name="disposing">Whether this is being called from IDisposable.Dispose.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && _editor != null)
     {
         while (Marshal.ReleaseComObject(_editor) > 0)
         {
             ;
         }
         _editor = null;
     }
 }
コード例 #9
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposeManagedObjs"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 void Dispose(bool disposeManagedObjs)
 {
     if (disposeManagedObjs && _editor != null)
     {
         while (Marshal.ReleaseComObject(_editor) > 0)
         {
             ;
         }
         _editor = null;
     }
 }
コード例 #10
0
        /// <summary>Get all of the attributes for a stream buffer.</summary>
        /// <returns>A collection of the attributes from the stream buffer.</returns>
        private static IDictionary <string, object> GetAttributes(IStreamBufferRecordingAttribute editor)
        {
            var result = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase);

            editor.GetAttributeCount(0, out short attributeCount);

            for (short i = 0; i < attributeCount; i++)
            {
                var attribute = GetAttributeByIndex(editor, i);
                if (string.IsNullOrWhiteSpace(attribute.Key) == false)
                {
                    result.Add(attribute.Key, attribute.Value);
                }
            }
            return(result);
        }
コード例 #11
0
        private void TestRecorder()
        {
            const string FileName = "delme.out";
            int          hr;
            object       o;
            short        c;

            File.Delete(FileName);

            hr = m_isbc.CreateRecorder("delme.out", RecordingType.Content, out o);
            DsError.ThrowExceptionForHR(hr);

            // Make sure we really got a recorder object
            IStreamBufferRecordingAttribute i = o as IStreamBufferRecordingAttribute;

            hr = i.GetAttributeCount(0, out c);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(c != 0, "CreateRecorder");
        }
コード例 #12
0
 public MCRecMetadataEditor(object editor)
     : base("blank")
 {
     _editor = (IStreamBufferRecordingAttribute)editor;
 }
コード例 #13
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposeManagedObjs"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 void Dispose(bool disposeManagedObjs)
 {
     if (disposeManagedObjs && _editor != null)
     {
         while(Marshal.ReleaseComObject(_editor) > 0);
         _editor = null;
     }
 }
コード例 #14
0
 /// <summary>Release all resources.</summary>
 /// <param name="disposing">Whether this is being called from IDisposable.Dispose.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && _editor != null)
     {
         while(Marshal.ReleaseComObject(_editor) > 0);
         _editor = null;
     }
 }
コード例 #15
0
 public MCRecMetadataEditor(object editor)
   : base("blank")
 {
   _editor = (IStreamBufferRecordingAttribute)editor;
 }