public void OnHeader([In, MarshalAs(UnmanagedType.Interface)] INSSBuffer pHeader) { byte[] buffer; uint Length; if (pHeader is ManBuffer) { buffer = ((ManBuffer)pHeader).Buffer; Length = ((ManBuffer)pHeader).UsedLength; } else { NSSBuffer b = new NSSBuffer(pHeader); Length = b.Length; buffer = new byte[Length]; b.Read(buffer, 0, (int)Length); } if (!m_HeaderWrote) { if (BaseStream.CanSeek) { m_HeaderPosition = BaseStream.Position; m_HeaderLength = Length; } m_HeaderWrote = true; base.Write(buffer, 0, (int)Length); } else if (BaseStream.CanSeek && (Length == m_HeaderLength)) { long pos = BaseStream.Position; BaseStream.Position = m_HeaderPosition; BaseStream.Write(buffer, 0, (int)Length); BaseStream.Position = pos; } }
public void OnDataUnit([In, MarshalAs(UnmanagedType.Interface)] INSSBuffer pDataUnit) { byte[] buffer; int Length; if (pDataUnit is ManBuffer) { buffer = ((ManBuffer)pDataUnit).Buffer; Length = (int)((ManBuffer)pDataUnit).UsedLength; } else { NSSBuffer b = new NSSBuffer(pDataUnit); Length = (int)b.Length; buffer = new byte[Length]; b.Read(buffer, 0, Length); } base.Write(buffer, 0, Length); }
public void OnDataUnit( [In, MarshalAs(UnmanagedType.Interface)] INSSBuffer pDataUnit ) { byte[] buffer; int Length; if (pDataUnit is ManBuffer) { buffer = ((ManBuffer)pDataUnit).Buffer; Length = (int)((ManBuffer)pDataUnit).UsedLength; } else { NSSBuffer b = new NSSBuffer(pDataUnit); Length = (int)b.Length; buffer = new byte[Length]; b.Read(buffer, 0, Length); } base.Write(buffer, 0, Length); }
public void OnHeader( [In, MarshalAs(UnmanagedType.Interface)] INSSBuffer pHeader ) { byte[] buffer; uint Length; if ( pHeader is ManBuffer) { buffer = ((ManBuffer)pHeader).Buffer; Length = ((ManBuffer)pHeader).UsedLength; } else { NSSBuffer b = new NSSBuffer(pHeader); Length = b.Length; buffer = new byte[Length]; b.Read(buffer, 0, (int)Length); } if ( !m_HeaderWrote ) { if (BaseStream.CanSeek) { m_HeaderPosition = BaseStream.Position; m_HeaderLength = Length; } m_HeaderWrote = true; base.Write(buffer, 0, (int)Length); } else if (BaseStream.CanSeek && (Length == m_HeaderLength) ) { long pos = BaseStream.Position; BaseStream.Position = m_HeaderPosition; BaseStream.Write(buffer, 0, (int)Length); BaseStream.Position = pos; } }
public override int Read(byte[] buffer, int offset, int count) { if (m_Reader != null) { int read = 0; if ((m_Length > 0) && ((m_Length - m_Position) < count)) { count = (int)(m_Length - m_Position); } if (m_BufferReader != null) { while ((m_BufferReader.Position < m_BufferReader.Length) && (read < count)) { read += m_BufferReader.Read(buffer, offset, count); } } while (read < count) { INSSBuffer sample = null; ulong SampleTime = 0; ulong Duration = 0; uint Flags = 0; try { m_Reader.GetNextSample(m_OuputStream, out sample, out SampleTime, out Duration, out Flags, out m_OutputNumber, out m_OuputStream); } catch (COMException e) { if (e.ErrorCode == WM.NS_E_NO_MORE_SAMPLES) { //No more samples if (m_OutputFormat.wBitsPerSample == 8) { while (read < count) { buffer[offset + read] = 0x80; read++; } } else { Array.Clear(buffer, offset + read, count - read); read = count; } break; } else { throw(e); } } m_BufferReader = new NSSBuffer(sample); read += m_BufferReader.Read(buffer, offset + read, count - read); } if ((m_BufferReader != null) && (m_BufferReader.Position >= m_BufferReader.Length)) { m_BufferReader = null; } m_Position += read; return(read); } else { throw new ObjectDisposedException(this.ToString()); } }
public override int Read(byte[] buffer, int offset, int count) { if (m_Reader != null) { int read = 0; if ( (m_Length > 0) && ( (m_Length-m_Position) < count) ) { count = (int)(m_Length-m_Position); } if (m_BufferReader != null) { while ( (m_BufferReader.Position < m_BufferReader.Length) && (read < count) ) { read += m_BufferReader.Read(buffer, offset, count); } } while (read < count) { INSSBuffer sample = null; ulong SampleTime = 0; ulong Duration = 0; uint Flags = 0; try { m_Reader.GetNextSample(m_OuputStream, out sample, out SampleTime, out Duration, out Flags, out m_OutputNumber, out m_OuputStream); } catch (COMException e) { if (e.ErrorCode == WM.NS_E_NO_MORE_SAMPLES) { //No more samples if (m_OutputFormat.wBitsPerSample == 8) { while ( read < count ) { buffer[offset+read] = 0x80; read++; } } else { Array.Clear(buffer, offset+read, count-read); read = count; } break; } else { throw (e); } } m_BufferReader = new NSSBuffer(sample); read += m_BufferReader.Read(buffer, offset+read, count-read); } if ( (m_BufferReader != null) && (m_BufferReader.Position >= m_BufferReader.Length) ) { m_BufferReader = null; } m_Position += read; return read; } else { throw new ObjectDisposedException(this.ToString()); } }