예제 #1
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::CreateReader()
        // Desc: Creates a reader and opens the source file using this reader.
        //------------------------------------------------------------------------------
        protected void CreateReader(string pwszInputFile)
        {
            Console.WriteLine("Creating the Reader...");

            //
            // Create a reader
            //
            WMUtils.WMCreateReader(IntPtr.Zero, 0, out m_pReader);

            //
            // Get the IWMReaderAdvanced interface
            //
            m_pReaderAdvanced = m_pReader as IWMReaderAdvanced;

            //
            // Get the IWMHeaderInfo interface of the reader
            //
            m_pReaderHeaderInfo = m_pReader as IWMHeaderInfo;

            //
            // Open the reader; use "this" as the callback interface.
            //
            m_pReader.Open(pwszInputFile, this, IntPtr.Zero);

            //
            // Wait until WMT_OPENED status message is received in OnStatus()
            //
            WaitForCompletion();

            //
            // Get the duration of the source file
            //
            short        wStreamNumber = 0;
            AttrDataType enumType;
            short        cbLength = 8; // sizeof(m_qwDuration);

            byte[] b = new byte[cbLength];

            m_pReaderHeaderInfo.GetAttributeByName(ref wStreamNumber,
                                                   Constants.g_wszWMDuration,
                                                   out enumType,
                                                   b,
                                                   ref cbLength);

            m_qwDuration = BitConverter.ToInt64(b, 0);

            if (m_qwDuration == 0)
            {
                throw new COMException("Duration is zero", E_InvalidArgument);
            }

            //
            // Turn on the user clock
            //
            m_pReaderAdvanced.SetUserProvidedClock(true);

            //
            // Turn on manual stream selection, so we get all streams.
            //
            m_pReaderAdvanced.SetManualStreamSelection(true);
        }
예제 #2
0
 private void Config()
 {
     WMUtils.WMCreateReader(IntPtr.Zero, 0, out m_read);
 }