本文整理汇总了C#中IMediaSample.GetTime方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSample.GetTime方法的具体用法?C# IMediaSample.GetTime怎么用?C# IMediaSample.GetTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaSample
的用法示例。
在下文中一共展示了IMediaSample.GetTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例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: 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;
}