本文整理汇总了C#中IMediaSample.GetSize方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSample.GetSize方法的具体用法?C# IMediaSample.GetSize怎么用?C# IMediaSample.GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaSample
的用法示例。
在下文中一共展示了IMediaSample.GetSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SampleCallback
/// <summary>
/// The callback from the GSSF to populate the sample. This class isn't intended
/// to be overridden. Child classes should instead implement PopulateSample,
/// which this method calls.
/// </summary>
/// <param name="pSample">The sample to populate</param>
/// <returns>HRESULT</returns>
public int SampleCallback(IMediaSample pSample)
{
int hr;
IntPtr pData;
try
{
// Get the buffer into which we will copy the data
hr = pSample.GetPointer(out pData);
if (hr >= 0)
{
// Find out the amount of space in the buffer
int cbData = pSample.GetSize();
lock (this)
{
hr = SetTimeStamps(pSample);
if (hr >= 0)
{
int iRead;
// Populate the sample
hr = PopulateSample(pData, cbData, out iRead);
if (hr >= 0)
{
if (hr == S_Ok) // 1 == End of stream
{
// increment the frame number for next time
m_iFrameNumber++;
}
else
{
m_iFrameNumber = 0;
}
pSample.SetActualDataLength(iRead);
}
}
}
}
}
finally
{
// Release our pointer the the media sample. THIS IS ESSENTIAL! If
// you don't do this, the graph will stop after about 2 samples.
Marshal.ReleaseComObject(pSample);
}
return hr;
}
示例2: Exception
/// <summary> sample callback, NOT USED. </summary>
int ISampleGrabberCB.SampleCB(double SampleTime, IMediaSample pSample)
{
if (!m_bGotOne)
{
// Set bGotOne to prevent further calls until we
// request a new bitmap.
m_bGotOne = true;
IntPtr pBuffer;
pSample.GetPointer(out pBuffer);
int iBufferLen = pSample.GetSize();
if (pSample.GetSize() > m_stride*m_videoHeight)
{
throw new Exception("Buffer is wrong size");
}
NativeMethods.CopyMemory(m_handle, pBuffer, m_stride*m_videoHeight);
// Picture is ready.
m_PictureReady.Set();
}
Marshal.ReleaseComObject(pSample);
return 0;
}
示例3: CxSampleGrabberEventArgs
/// <summary>
/// �R���X�g���N�^ (�����l�w��)
/// </summary>
/// <param name="sample_time">�T���v���^�C��</param>
/// <param name="sample_data">�T���v���f�[�^</param>
public CxSampleGrabberEventArgs(double sample_time, IMediaSample sample_data)
{
SampleTime = sample_time;
SampleData = sample_data;
if (sample_data != null)
{
sample_data.GetPointer(ref m_Address);
m_Length = sample_data.GetSize();
}
}
示例4: SampleCallback
/// <summary>
/// Called by the GenericSampleSourceFilter. This routine populates the MediaSample.
/// </summary>
/// <param name="pSample">Pointer to a sample</param>
/// <returns>0 = success, 1 = end of stream, negative values for errors</returns>
public virtual int SampleCallback(IMediaSample pSample)
{
int hr;
IntPtr pData;
try
{
// Get the buffer into which we will copy the data
hr = pSample.GetPointer(out pData);
if (hr >= 0)
{
// Set TRUE on every sample for uncompressed frames
hr = pSample.SetSyncPoint(true);
if (hr >= 0)
{
// Find out the amount of space in the buffer
int cbData = pSample.GetSize();
hr = SetTimeStamps(pSample);
if (hr >= 0)
{
int iRead;
// Get copy the data into the sample
hr = GetImage(m_iFrameNumber, pData, cbData, out iRead);
if (hr == 0) // 1 == End of stream
{
pSample.SetActualDataLength(iRead);
// increment the frame number for next time
m_iFrameNumber++;
}
}
}
}
}
finally
{
// Release our pointer the the media sample. THIS IS ESSENTIAL! If
// you don't do this, the graph will stop after about 2 samples.
Marshal.ReleaseComObject(pSample);
}
return hr;
}
示例5: Analyze
/// <summary>
/// Implementation of ISampleGrabberCB.
/// </summary>
int ISampleGrabberCB.SampleCB(double sampleTime, IMediaSample pSample)
{
IntPtr pBuffer;
int hr = pSample.GetPointer(out pBuffer);
DsError.ThrowExceptionForHR(hr);
Analyze(sampleTime, pBuffer, pSample.GetSize());
Marshal.ReleaseComObject(pSample);
return 0;
}
示例6: SyncReadAligned
public int SyncReadAligned(IMediaSample pSample)
{
Monitor.Enter(this);
long start, end;
long mediaStart, mediaEnd;
int size;
int offset;
int hr;
int ans = S_OK;
IntPtr ptr = new IntPtr();
hr = pSample.GetPointer(out ptr);
hr = pSample.GetTime(out start, out end);
hr = pSample.GetMediaTime(out mediaStart, out mediaEnd);
size = pSample.GetSize();
int rescale = DS_RESCALE_FACTOR; // (int)((end - start) / size);
//start += startTime;
offset = (int)(start / rescale);
if ((offset + size) > reader.BufferSize)
{
Memory.Set(ptr, offset, size);
log.InfoFormat("SyncReadAligned went off the end ({0}, {1}, {2})", offset, (offset + size), reader.BufferSize);
size = (int)(reader.BufferSize - offset);
ans = S_FALSE;
}
if ((offset + size) > reader.BufferEnd)
{
log.InfoFormat("SyncReadAligned wait for buffer ({0}, {1}, {2})", offset, (offset + size), reader.BufferEnd);
BufferData(offset + size);
}
log.InfoFormat("SyncReadAligned ({0} / {1} ({2}), {3} / {4}) - {5}, {6}", start, mediaStart, offset, end, mediaEnd, size, rescale);
byte[] buffer = reader.GetBuffer();
Marshal.Copy(buffer, offset, ptr, size);
reader.ReleaseBuffer();
Monitor.Exit(this);
return ans;
}
示例7: Request
public int Request(IMediaSample pSample, IntPtr dwUser)
{
// queues up a request for a new sample
Monitor.Enter(this);
long start, end;
pSample.GetTime(out start, out end);
log.InfoFormat("Request ({0}, {1} - {2})", start, end, pSample.GetSize());
sampleList.Add(pSample);
samplePtrList.Add(dwUser);
Monitor.Exit(this);
return S_OK;
}
示例8: Exception
int ISampleGrabberCB.SampleCB(double SampleTime, IMediaSample pSample)
{
if (!gotOne)
{
gotOne = true;
IntPtr pBuffer;
pSample.GetPointer(out pBuffer);
pSample.GetSize();
if (pSample.GetSize() > Stride*Height)
throw new Exception("Buffer is wrong size");
Kernel32.CopyMemory(handle, pBuffer, Stride * Height);
pictureReady.Set();
}
Marshal.ReleaseComObject(pSample);
return 0;
}
示例9: Exception
int ISampleGrabberCB.SampleCB(double sampleTime, IMediaSample sample)
{
if (!_gotPicture)
{
// Set bGotOne to prevent further calls until we
// request a new bitmap.
_gotPicture = true;
IntPtr pBuffer;
sample.GetPointer(out pBuffer);
if (sample.GetSize() > _stride * _height)
{
throw new Exception("Buffer is wrong size");
}
CopyMemory(_handle, pBuffer, _stride * _height);
_pictureReadyResetEvent.Set();
}
Marshal.ReleaseComObject(sample);
return 0;
}