/// <summary> /// Wird aufgerufen, wenn eine neue Speicherverwaltung im Graphen aktiv ist. /// </summary> /// <param name="allocator">Die neue Speicherverwaltung.</param> protected override void OnAllocatorChanged(NoMarshalComObjects.MemoryAllocator allocator) { // Base first base.OnAllocatorChanged(allocator); // Forward to pin if (null != m_Pin) { m_Pin.SetMemAllocator((allocator == null) ? IntPtr.Zero : allocator.ComInterface); } }
/// <summary> /// Nimmt Rohdaten zur Übermittelung in den Direct Show Graphen entgegen. /// </summary> /// <param name="buffer">Ein Rohdatenblock - ist dieser Parameter <i>null</i>, /// so wird das Ende des Rohdatenstroms angezeigt und die Direct Show /// Speicherverwaltungsinstanz freigegeben.</param> /// <param name="offset">Erstes zu verwendendes Byte im Rohdatenblock.</param> /// <param name="length">Anzahl der Bytes, die dem Rohdatenblock zu entnehmen sind.</param> /// <param name="sync">Gesetzt, wenn die Rohdaten einen Synchronisationspunkt im /// Datenstrom bezeichnen.</param> /// <param name="time">Gesetzt auf eine <i>Stream Time</i>, wenn die Rohdaten /// einen PTS getragen haben.</param> public void Inject(byte[] buffer, int offset, int length, bool sync, long?time) { // Force shutdown of allocator if (null == buffer) { // Release allocator if (null != m_Allocator) { // Release memory m_Allocator.Decommit(); // Release m_Allocator.Dispose(); // Back to CLR m_Allocator = null; // Report OnAllocatorChanged(null); } // Done return; } // Count m_BytesReceived += length; // Discard when not running if (!m_Running) { // Get rid of the rest Flush(); // Done return; } // Create allocator once if (null == m_Allocator) { // Create allocator m_Allocator = new NoMarshalComObjects.MemoryAllocator(); // Properties AllocatorProperties props = new AllocatorProperties(); // Configure props.cbAlign = 8; props.cBuffers = m_Count; props.cbBuffer = m_Buffer.Length; // Store m_Allocator.SetProperties(props); m_Allocator.Commit(); // Forward OnAllocatorChanged(m_Allocator); } // Flush if (sync || time.HasValue) { // Get rid of buffer Flush(); // We are now doing a sync m_SyncWaiting = sync; m_SyncTime = time; } // All of it while (length > 0) { // Check for fill up int fill = Math.Min(m_Buffer.Length - m_Index, length); // Copy over Array.Copy(buffer, offset, m_Buffer, m_Index, fill); // Adjust buffer m_Index += fill; // Adjust input offset += fill; length -= fill; // See if we should send if (m_Index >= m_Buffer.Length) { Flush(); } } }
/// <summary> /// Nimmt Rohdaten zur Übermittelung in den Direct Show Graphen entgegen. /// </summary> /// <param name="buffer">Ein Rohdatenblock - ist dieser Parameter <i>null</i>, /// so wird das Ende des Rohdatenstroms angezeigt und die Direct Show /// Speicherverwaltungsinstanz freigegeben.</param> /// <param name="offset">Erstes zu verwendendes Byte im Rohdatenblock.</param> /// <param name="length">Anzahl der Bytes, die dem Rohdatenblock zu entnehmen sind.</param> /// <param name="sync">Gesetzt, wenn die Rohdaten einen Synchronisationspunkt im /// Datenstrom bezeichnen.</param> /// <param name="time">Gesetzt auf eine <i>Stream Time</i>, wenn die Rohdaten /// einen PTS getragen haben.</param> public void Inject( byte[] buffer, int offset, int length, bool sync, long? time ) { // Force shutdown of allocator if (null == buffer) { // Release allocator if (null != m_Allocator) { // Release memory m_Allocator.Decommit(); // Release m_Allocator.Dispose(); // Back to CLR m_Allocator = null; // Report OnAllocatorChanged( null ); } // Done return; } // Count m_BytesReceived += length; // Discard when not running if (!m_Running) { // Get rid of the rest Flush(); // Done return; } // Create allocator once if (null == m_Allocator) { // Create allocator m_Allocator = new NoMarshalComObjects.MemoryAllocator(); // Properties AllocatorProperties props = new AllocatorProperties(); // Configure props.cbAlign = 8; props.cBuffers = m_Count; props.cbBuffer = m_Buffer.Length; // Store m_Allocator.SetProperties( props ); m_Allocator.Commit(); // Forward OnAllocatorChanged( m_Allocator ); } // Flush if (sync || time.HasValue) { // Get rid of buffer Flush(); // We are now doing a sync m_SyncWaiting = sync; m_SyncTime = time; } // All of it while (length > 0) { // Check for fill up int fill = Math.Min( m_Buffer.Length - m_Index, length ); // Copy over Array.Copy( buffer, offset, m_Buffer, m_Index, fill ); // Adjust buffer m_Index += fill; // Adjust input offset += fill; length -= fill; // See if we should send if (m_Index >= m_Buffer.Length) Flush(); } }
/// <summary> /// Wird aufgerufen, wenn sich die Direct Show Speicherverwaltungsinstanz geändert hat. /// </summary> /// <param name="allocator">Neue Speicherverwaltungsinstanz.</param> protected virtual void OnAllocatorChanged(NoMarshalComObjects.MemoryAllocator allocator) { }