本文整理汇总了C#中IMediaSample.SetSyncPoint方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSample.SetSyncPoint方法的具体用法?C# IMediaSample.SetSyncPoint怎么用?C# IMediaSample.SetSyncPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaSample
的用法示例。
在下文中一共展示了IMediaSample.SetSyncPoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopySample
public static void CopySample(IMediaSample src, IMediaSample dest, bool copySamples)
{
var sourceSize = src.GetActualDataLength();
if (copySamples)
{
IntPtr sourceBuffer;
src.GetPointer(out sourceBuffer);
IntPtr destBuffer;
dest.GetPointer(out destBuffer);
CopyMemory(destBuffer, sourceBuffer, sourceSize);
}
// Copy the sample times
long start, end;
if (src.GetTime(out start, out end) == S_OK)
{
dest.SetTime(start, end);
}
if (src.GetMediaTime(out start, out end) == S_OK)
{
dest.SetMediaTime(start, end);
}
// Copy the media type
AMMediaType mediaType;
src.GetMediaType(out mediaType);
dest.SetMediaType(mediaType);
DsUtils.FreeAMMediaType(mediaType);
dest.SetSyncPoint(src.IsSyncPoint() == S_OK);
dest.SetPreroll(src.IsPreroll() == S_OK);
dest.SetDiscontinuity(src.IsDiscontinuity() == S_OK);
// Copy the actual data length
dest.SetActualDataLength(sourceSize);
}
示例2: 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;
}
示例3: SetTimeStamps
/// <summary>
/// Calculate and populate the timestamps
/// </summary>
/// <param name="pSample">The IMediaSample to set the timestamps on</param>
/// <returns>HRESULT</returns>
public override int SetTimeStamps(IMediaSample pSample)
{
// Time per frame
int tpf = (UNIT / m_Fps);
DsLong rtStart = new DsLong(m_rtSampleTime);
m_rtSampleTime += tpf;
DsLong rtStop = new DsLong(m_rtSampleTime);
// Set the times into the sample
int hr = pSample.SetTime(rtStart, rtStop);
// Set TRUE on every sample for uncompressed frames
if (hr >= 0)
{
hr = pSample.SetSyncPoint(true);
}
return hr;
}
示例4: MediaSampleCB
/// <summary>
/// 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 int MediaSampleCB(IMediaSample pSample)
{
int hr;
try
{
IntPtr pData;
hr = pSample.GetPointer(out pData);
if (hr >= 0)
{
hr = pSample.SetSyncPoint(true);
if (hr >= 0)
{
var len = Source.Read(pData, Constants.DShowNumberOfPacketsTS);
if (len != 0)
{
hr = 0;
pSample.SetActualDataLength(len);
}
else
{
//hr = 1;
hr = 0;
}
}
}
}
catch(Exception ex)
{
Log.ErrorException("Error in Sample handler.", ex);
hr = -1;
}
finally
{
Marshal.ReleaseComObject(pSample);
}
return hr;
}