本文整理汇总了C#中IMediaSample.GetActualDataLength方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSample.GetActualDataLength方法的具体用法?C# IMediaSample.GetActualDataLength怎么用?C# IMediaSample.GetActualDataLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaSample
的用法示例。
在下文中一共展示了IMediaSample.GetActualDataLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SampleCB
public int SampleCB(double SampleTime, IMediaSample pSample)
{
// Console.WriteLine("**********************55555555555555555555555**********************");
if (pSample == null) return -1;
int len = pSample.GetActualDataLength();
IntPtr pbuf;
if (pSample.GetPointer(out pbuf) == 0 && len > 0)
{
byte[] buf = new byte[len];
Marshal.Copy(pbuf, buf, 0, len);
for (int i = 0; i < len; i += 2)
buf[i] = (byte)(255 - buf[i]);
Marshal.Copy(buf, 0, pbuf, len);
}
return 0;
}
示例2: 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);
}
示例3: SetTimeStamps
// Set the timestamps
public override int SetTimeStamps(IMediaSample pSample)
{
int hr;
int iRead = pSample.GetActualDataLength();
long SampleTime = GetTimeFromBytes(iRead);
long TimeStart = m_FSampleTime;
m_FSampleTime = m_FSampleTime + SampleTime;
long TimeStop = m_FSampleTime;
hr = pSample.SetTime(TimeStart, TimeStop);
if (hr >= 0)
{
TimeStart = m_FMediaTime;
m_FMediaTime = m_FMediaTime + SampleTime;
TimeStop = m_FMediaTime;
hr = pSample.SetMediaTime(TimeStart, TimeStop);
DsError.ThrowExceptionForHR(hr);
}
return hr;
}