private void Config() { WMUtils.WMCreateWriter(IntPtr.Zero, out m_Writer); m_Writer.SetProfileByID(g); m_Writer.SetOutputFilename(sFileName); m_wa3 = m_Writer as IWMWriterAdvanced3; }
private void Config() { IWMWriter pWMWriter; IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; INSSBuffer pSample; // Profile id for "Windows Media Video 8 for Dial-up Modem (No audio, 56 Kbps)" Guid guidProfileID = new Guid(0x6E2A6955, 0x81DF, 0x4943, 0xBA, 0x50, 0x68, 0xA9, 0x86, 0xA7, 0x08, 0xF6); WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.LoadProfileByID(guidProfileID, out pWMProfile); WMUtils.WMCreateWriter(IntPtr.Zero, out pWMWriter); pWMWriter.SetProfile(pWMProfile); pWMWriter.SetOutputFilename("foo.out"); Marshal.ReleaseComObject(pWMProfile); Marshal.ReleaseComObject(pWMProfileManager); pWMWriter.BeginWriting(); pWMWriter.AllocateSample(MAXLENGTH, out pSample); m_pSample = (INSSBuffer3)pSample; }
private void Config() { IWMWriter pWriter; WMUtils.WMCreateWriter(IntPtr.Zero, out pWriter); m_Writer = pWriter as IWMWriterPostView; pWriter.SetProfileByID(g); }
private void Config() { IWMWriter m_Writer; WMUtils.WMCreateWriter(IntPtr.Zero, out m_Writer); m_Writer.SetProfileByID(g); m_Writer.GetInputProps(0, out m_Props); }
private void Config() { IWMWriter pWriter; WMUtils.WMCreateWriter(IntPtr.Zero, out pWriter); m_Writer = pWriter as IWMWriterAdvanced; }
private void Config() { IWMWriter writer; WMUtils.WMCreateWriter(IntPtr.Zero, out writer); writer.SetProfileByID(g); m_Writer = writer as IWMWriterAdvanced2; }
private void Config() { WMUtils.WMCreateWriter(IntPtr.Zero, out m_pWriter); m_pWriter.SetProfileByID(g); m_pWriter.BeginWriting(); m_preproc = m_pWriter as IWMWriterPreprocess; }
private void Config() { IWMWriter m_Writer; IWMInputMediaProps pProps; WMUtils.WMCreateWriter(IntPtr.Zero, out m_Writer); m_Writer.SetProfileByID(g); m_Writer.GetInputProps(0, out pProps); m_Props = pProps as IWMMediaProps; }
private void Config() { m_OnHeader = m_IsRealTime = m_AllocateDataUnit = m_OnDataUnit = m_OnEndWriting = false; IWMWriterAdvanced pWriterA; WMUtils.WMCreateWriter(IntPtr.Zero, out m_Writer); pWriterA = m_Writer as IWMWriterAdvanced; m_Writer.SetProfileByID(g); pWriterA.AddSink(this); }
private void Config() { IWMWriter pWriter; IWMWriterAdvanced pWriterA; WMUtils.WMCreateWriter(IntPtr.Zero, out pWriter); pWriterA = pWriter as IWMWriterAdvanced; WMUtils.WMCreateWriterFileSink(out m_pSink); pWriterA.AddSink(m_pSink); m_rcb = m_pSink as IWMRegisterCallback; }
private void Config() { IWMWriterFileSink pSink; WMUtils.WMCreateWriter(IntPtr.Zero, out m_Writer); m_Writer.SetProfileByID(g); WMUtils.WMCreateWriterFileSink(out pSink); IWMWriterAdvanced pWriterA; pWriterA = m_Writer as IWMWriterAdvanced; pWriterA.AddSink(pSink); m_fs3 = pSink as IWMWriterFileSink3; }
private void TestOpen() { IWMWriterAdvanced wa; IWMWriter pw; WMUtils.WMCreateWriter(IntPtr.Zero, out pw); wa = pw as IWMWriterAdvanced; wa.AddSink(m_pSink); m_pSink.Open(sFileName); pw.SetProfileByID(g); pw.BeginWriting(); }
//------------------------------------------------------------------------------ // Name: CWMVCopy::CreateWriter() // Desc: Creates a writer and sets the profile and output of this writer. //------------------------------------------------------------------------------ protected void CreateWriter(string pwszOutputFile) { int dwInputCount = 0; Console.WriteLine("Creating the Writer..."); // // Create a writer // WMUtils.WMCreateWriter(IntPtr.Zero, out m_pWriter); // // Get the IWMWriterAdvanced interface of the writer // m_pWriterAdvanced = m_pWriter as IWMWriterAdvanced; // // Get the IWMHeaderInfo interface of the writer // m_pWriterHeaderInfo = m_pWriter as IWMHeaderInfo; // // Set the profile of the writer to the reader's profile // m_pWriter.SetProfile(m_pReaderProfile); m_pWriter.GetInputCount(out dwInputCount); // // Set the input property to null so the SDK knows we're going to // send compressed samples to the inputs of the writer. // for (int i = 0; i < dwInputCount; i++) { m_pWriter.SetInputProps(i, null); } // // Set the output file of the writer // m_pWriter.SetOutputFilename(pwszOutputFile); }
private void Config() { WMUtils.WMCreateWriter(IntPtr.Zero, out writer); writer.SetProfileByID(g); WMUtils.WMCreateWriterNetworkSink(out sink); m_clientConns = (IWMClientConnections)sink; IWMWriterAdvanced advWriter = (IWMWriterAdvanced)writer; advWriter.AddSink(sink); sink.Open(ref port); int urlLen = 0; sink.GetHostURL(null, ref urlLen); sbUrl = new StringBuilder(urlLen); sink.GetHostURL(sbUrl, ref urlLen); writer.BeginWriting(); WMUtils.WMCreateReader(IntPtr.Zero, Rights.Playback, out reader); reader.Open(sbUrl.ToString(), this, new IntPtr(123)); lock (m_openLock) { Monitor.Wait(m_openLock); } reader.Start(0, 0, 1.0f, new IntPtr(321)); lock (m_openLock) { Monitor.Wait(m_openLock); } }
public IWMWriter GetWriter() { IWMProfileManager pProfileManager = null; try { WMUtils.WMCreateProfileManager(out pProfileManager); var pCodecInfo3 = pProfileManager as IWMCodecInfo3; // We have to use the same pProfileManager for enumeration, // because it calls SetCodecEnumerationSetting, so chosenFormat.format // would not point to the same format for a pProfileManager // with different (default) settings, and GetCodecFormat // would return the wrong stream config. var formats = GetFormats(pProfileManager); if (this.EncoderMode != "") { formats.RemoveAll(fmt => fmt.modeName != this.EncoderMode); } if (formats.Count < 1) { throw new NotSupportedException("codec/format not found"); } if (formats.Count > 1) { throw new NotSupportedException("codec/format ambiguous"); } var chosenFormat = formats[0]; IWMStreamConfig pStreamConfig1; pCodecInfo3.GetCodecFormat(MediaType.Audio, chosenFormat.codec, chosenFormat.format, out pStreamConfig1); try { pStreamConfig1.SetStreamNumber(1); IWMProfile pProfile; pProfileManager.CreateEmptyProfile(WMVersion.V9_0, out pProfile); try { pProfile.AddStream(pStreamConfig1); IWMWriter pWriter; WMUtils.WMCreateWriter(IntPtr.Zero, out pWriter); try { pWriter.SetProfile(pProfile); } catch (Exception ex) { Marshal.ReleaseComObject(pWriter); throw ex; } return(pWriter); } finally { Marshal.ReleaseComObject(pProfile); } } finally { Marshal.ReleaseComObject(pStreamConfig1); } } finally { Marshal.ReleaseComObject(pProfileManager); } }
private void Config() { WMUtils.WMCreateWriter(IntPtr.Zero, out m_Writer); }
/// <summary> /// Create filename from specified profile using specified framerate /// </summary> /// <param name="lpszFileName">File name to create</param> /// <param name="guidProfileID">WM Profile to use for compression</param> /// <param name="iFrameRate">Frames Per Second</param> public CwmvFile(string lpszFileName, ref Guid guidProfileID, int iFrameRate) { Guid guidInputType; int dwInputCount; IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; // Initialize all member variables m_iFrameRate = iFrameRate; m_dwVideoInput = -1; m_dwCurrentVideoSample = 0; m_msVideoTime = 0; m_pWMWriter = null; m_pInputProps = null; m_Init = false; try { // Open the profile manager WMUtils.WMCreateProfileManager(out pWMProfileManager); // Convert pWMProfileManager to a IWMProfileManager2 IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; // Specify the version number of the profiles to use pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); // Load the profile specified by the caller pProfileManager2.LoadProfileByID(guidProfileID, out pWMProfile); // Create a writer. This is the interface we actually write with WMUtils.WMCreateWriter(IntPtr.Zero, out m_pWMWriter); // Set the profile we got into the writer. This controls compression, video // size, # of video channels, # of audio channels, etc m_pWMWriter.SetProfile(pWMProfile); // Find out how many inputs are in the current profile m_pWMWriter.GetInputCount(out dwInputCount); // Assume we won't find any video pins m_dwVideoInput = -1; // Find the first video input on the writer for (int i = 0; i < dwInputCount; i++) { // Get the properties of channel #i m_pWMWriter.GetInputProps(i, out m_pInputProps); // Read the type of the channel m_pInputProps.GetType(out guidInputType); // If it is video, we are done if (guidInputType == MediaType.Video) { m_dwVideoInput = i; break; } } // Didn't find a video channel if (m_dwVideoInput == -1) { throw new Exception("Profile does not accept video input"); } // Specify the file name for the output m_pWMWriter.SetOutputFilename(lpszFileName); } catch { Close(); throw; } finally { // Release the locals if (pWMProfile != null) { Marshal.ReleaseComObject(pWMProfile); pWMProfile = null; } if (pWMProfileManager != null) { Marshal.ReleaseComObject(pWMProfileManager); pWMProfileManager = null; } } }
private bool Initialize(string destinationFileName, VideoQuality videoQuality) { IWMProfileManager profileManagerTemp = null; IWMProfile profile = null; int inputCount = 0; Guid inputTypeId; bool success = false; try { #region Initialize Properties CurrentSampleIndex = 0; CurrentSampleTimeStamp = 0; VideoChannelIndex = -1; MediaWriterConfigured = false; MediaWriterIsWriting = false; #endregion #region Create ProfileManager WMUtils.WMCreateProfileManager(out profileManagerTemp); IWMProfileManager2 profileManager = (IWMProfileManager2)profileManagerTemp; #endregion #region Configure ProfileManager profileManager.SetSystemProfileVersion(WMVersion.V8_0); #endregion #region Load Profile switch (videoQuality) { case VideoQuality.Kbps128: profileManager.LoadProfileByData(Wilke.Interactive.Drone.Control.Properties.Resources.VideoProfile128kbps, out profile); break; case VideoQuality.Kbps256: profileManager.LoadProfileByData(Wilke.Interactive.Drone.Control.Properties.Resources.VideoProfile256kbps, out profile); break; } #endregion #region Create Writer WMUtils.WMCreateWriter(IntPtr.Zero, out mediaWriter); #endregion #region Configure Writer MediaWriter.SetProfile(profile); MediaWriter.GetInputCount(out inputCount); // Find the first video input on the writer for (int index = 0; index < inputCount; index++) { // Get the properties of channel #index MediaWriter.GetInputProps(index, out mediaProperties); // Read the type of the channel MediaProperties.GetType(out inputTypeId); // If it is video, we are done if (inputTypeId == MediaType.Video) { VideoChannelIndex = index; break; } } // Didn't find a video channel if (VideoChannelIndex == -1) { throw new Exception("Profile does not accept video input"); } MediaWriter.SetOutputFilename(destinationFileName); #endregion success = true; } catch { throw; } return(success); }