private void TestStart() { IWMReader read = m_read as IWMReader; read.Pause(); TimeCodeExtensionData tce1 = new TimeCodeExtensionData(); TimeCodeExtensionData tce2 = new TimeCodeExtensionData(); RA3Union l1 = new RA3Union(0L); RA3Union l2 = new RA3Union(123456789L); RA3Union l3 = new RA3Union(0); RA3Union l4 = new RA3Union(1234567); RA3Union l5 = new RA3Union(tce1); RA3Union l6 = new RA3Union(tce2); m_read.StartAtPosition(1, l1, l2, OffsetFormat.HundredNS, 1.0f, IntPtr.Zero); m_read.StartAtPosition(1, l3, l4, OffsetFormat.PlaylistOffset, 1.0f, IntPtr.Zero); // apparently SMPTE functionality is broken in WMF. Apparently the indices aren't // created correctly. // m_read.StartAtPosition(1, l5, l6, OffsetFormat.Timecode, 1.0f, IntPtr.Zero); }
/// <summary> /// Wraps the WMWMCreateReader function /// </summary> /// <param name="Rights">Indicates the desired operation. See WMF SDK documentation</param> /// <returns>The reader object</returns> public static IWMReader CreateReader(WMT_RIGHTS Rights) { IWMReader res = null; Marshal.ThrowExceptionForHR(WMCreateReader(IntPtr.Zero, Rights, out res)); return(res); }
private void DoStart(IWMReader read) { read.Start(0, 0, 1.0f, IntPtr.Zero); m_CallbackCalled = false; while (!m_CallbackCalled) { System.Threading.Thread.Sleep(0); } }
private void DoOpen(IWMReader read) { m_Opened = false; read.Open(sFileName, this, new IntPtr(123)); while (!m_Opened) { System.Threading.Thread.Sleep(0); } }
private void TestStream() { m_br = new BinaryReader(new FileStream(sFileName, FileMode.Open, FileAccess.Read)); IWMReader read = m_read as IWMReader; read.Close(); m_read.OpenStream(this, this, IntPtr.Zero); m_br.Close(); }
private void ChangeProps(IWMReader read) { IWMOutputMediaProps pProps; read.GetOutputProps(0, out pProps); int iLen = 0; AMMediaType pType = null; pProps.GetMediaType(pType, ref iLen); pType = new AMMediaType(); pType.formatSize = iLen; pProps.GetMediaType(pType, ref iLen); pType.temporalCompression = true; pType.formatSize = 20; //pType.subType = MediaSubType.WAVE; pProps.SetMediaType(pType); read.SetOutputProps(0, pProps); }
public void Dispose() { try { Close(); } catch { } if (!IsDisposed()) { Marshal.ReleaseComObject(m_pReader); m_pReader = null; m_pHeaderInfo = null; } if (IntPtr.Zero != m_hWaveOut) { waveOut.Close(m_hWaveOut); // Ignore return m_hWaveOut = IntPtr.Zero; } if (IntPtr.Zero != m_hMixer) { Mixer.Close(m_hMixer); m_hMixer = IntPtr.Zero; } if (null != m_hAsyncEvent) { m_hAsyncEvent.Close(); m_hAsyncEvent = null; } m_pWfx = null; #if SUPPORT_DRM objDRM.Dispose(); m_pwszURL = null; #endif }
/// <summary> /// Create the player /// </summary> /// <param name="iDevice">Zero based index of the playback device. See GetDevs for a list of devices.</param> public CAudioPlay(int iDevice, Form fForm) { m_DeviceIndex = iDevice; m_fForm = fForm; WaveOutCaps woc = new WaveOutCaps(); int mmr = waveOut.GetDevCaps(iDevice, woc, Marshal.SizeOf(woc)); waveOut.ThrowExceptionForError(mmr); m_WaveCaps = woc.dwSupport; m_bIsSeekable = false; m_bIsBroadcast = false; m_dwAudioOutputNum = -1; m_hrAsync = 0; m_hWaveOut = IntPtr.Zero; m_hMixer = IntPtr.Zero; m_pReader = null; m_pHeaderInfo = null; m_cnsFileDuration = 0; m_pWfx = null; m_MaxSampleSize = -1; m_OldTime = -1; m_UseNext = 0; m_InsBuf = new INSBuf[MAXBUFFERS]; // Create an event for asynchronous calls. // When code in this class makes a call to an asynchronous // method, it will wait for the event to be set to resume // processing. m_hAsyncEvent = new AutoResetEvent(false); // Create a reader object, requesting only playback rights. WMUtils.WMCreateReader(IntPtr.Zero, Rights.Playback, out m_pReader); }
private static extern int WMCreateReader(IntPtr pUnkReserved, WMT_RIGHTS dwRights, [Out, MarshalAs(UnmanagedType.Interface)] out IWMReader ppReader);
public static extern uint WMCreateReader( [In, MarshalAs(UnmanagedType.Interface)] object pUnkReserved, // Always null. [In] uint dwRights, [Out, MarshalAs(UnmanagedType.Interface)] out IWMReader ppReader);
public static extern int WMCreateReader( IntPtr pUnkCert, Rights dwRights, out IWMReader ppReader );
//------------------------------------------------------------------------------ // Name: CWMVCopy::Copy() // Desc: Copies the input file to the output file. The script stream is moved // to the header if fMoveScriptStream is true. //------------------------------------------------------------------------------ public void Copy( string pwszInputFile, string pwszOutputFile, long qwMaxDuration, bool fMoveScriptStream) { // // Initialize the pointers // m_hEvent = null; m_pReader = null; m_pReaderAdvanced = null; m_pReaderHeaderInfo = null; m_pReaderProfile = null; m_pWriter = null; m_pWriterAdvanced = null; m_pWriterHeaderInfo = null; m_dwStreamCount = 0; m_pguidStreamType = null; m_pwStreamNumber = null; if (null == pwszInputFile || null == pwszOutputFile) { throw new COMException("Missing input or output file", E_InvalidArgument); } m_fMoveScriptStream = fMoveScriptStream; m_qwMaxDuration = qwMaxDuration; // // Event for the asynchronous calls // m_hEvent = new AutoResetEvent(false); // // Create the Reader // CreateReader(pwszInputFile); // // Get profile information // GetProfileInfo(); // // Create the Writer // CreateWriter(pwszOutputFile); // // Copy all attributes // CopyAttribute(); // // Copy codec info // CopyCodecInfo(); // // Copy all scripts in the header // CopyScriptInHeader(); // // Process samples: read from the reader, and write to the writer // try { Process(); } catch (Exception e) { int hr = Marshal.GetHRForException(e); // // Output some common error messages. // if (NSResults.E_VIDEO_CODEC_NOT_INSTALLED == hr) { Console.WriteLine("Processing samples failed: Video codec not installed"); } if (NSResults.E_AUDIO_CODEC_NOT_INSTALLED == hr) { Console.WriteLine("Processing samples failed: Audio codec not installed"); } else if (NSResults.E_INVALID_OUTPUT_FORMAT == hr) { Console.WriteLine("Processing samples failed: Invalid output format "); } else if (NSResults.E_VIDEO_CODEC_ERROR == hr) { Console.WriteLine("Processing samples failed: An unexpected error occurred with the video codec "); } else if (NSResults.E_AUDIO_CODEC_ERROR == hr) { Console.WriteLine("Processing samples failed: An unexpected error occurred with the audio codec "); } else { Console.WriteLine(string.Format("Processing samples failed: Error (hr=0x{0:x})", hr)); } throw; } // // Copy all scripts in m_ScriptList // CopyScriptInList(pwszOutputFile); // // Copy marker information // CopyMarker(pwszOutputFile); Console.WriteLine("Copy finished."); // // Note: The output file is indexed automatically. // You can use IWMWriterFileSink3::SetAutoIndexing(false) to disable // auto indexing. // Dispose(); }