void TestTime() { int hr; long TimeStart1, TimeEnd1; long TimeStart2, TimeEnd2; // Read the value hr = m_ims.GetTime(out TimeStart1, out TimeEnd1); Marshal.ThrowExceptionForHR(hr); // Change the value hr = m_ims.SetTime(new DsLong(TimeStart1 + 1), new DsLong(TimeEnd1 - 1)); Marshal.ThrowExceptionForHR(hr); // Re-read the value hr = m_ims.GetTime(out TimeStart2, out TimeEnd2); Marshal.ThrowExceptionForHR(hr); // Check to see if the change took Debug.Assert(TimeStart1 + 1 == TimeStart2, "Get/Set time start"); Debug.Assert(TimeEnd1 - 1 == TimeEnd2, "Get/Set time End"); // Try using nulls hr = m_ims.SetTime(null, null); Marshal.ThrowExceptionForHR(hr); // Read the time, should fail (because of the nulls) hr = m_ims.GetTime(out TimeStart1, out TimeEnd1); Debug.Assert(hr == DsResults.E_SampleTimeNotSet, "Get/Set time null"); // Put it back to where it started hr = m_ims.SetTime(new DsLong(TimeStart1), new DsLong(TimeEnd1)); Marshal.ThrowExceptionForHR(hr); }
override public int SetTimeStamps(IMediaSample pSample) { DsLong rtStart = new DsLong(m_iFrameNumber * _fps); DsLong rtStop = new DsLong(rtStart + _fps); int hr = pSample.SetTime(rtStart, rtStop); return(hr); }
override public int SetTimeStamps(IMediaSample pSample, int iFrameNumber) { reader.ReadTimeStamps(iFrameNumber, out startFrameTime, out endFrameTime); DsLong rtStart = new DsLong(startFrameTime); DsLong rtStop = new DsLong(endFrameTime); int hr = pSample.SetTime(rtStart, rtStop); return(hr); }
// Calculate the timestamps based on the frame number and the frames per second override public int SetTimeStamps(IMediaSample pSample) { // Calculate the start/end times based on the current frame number // and frame rate DsLong rtStart = new DsLong(m_iFrameNumber * m_FPS); DsLong rtStop = new DsLong(rtStart + m_FPS); // Set the times into the sample int hr = pSample.SetTime(rtStart, rtStop); return(hr); }
/// <summary> /// Calculate the timestamps based on the frame number and the frames per second. /// </summary> /// <param name="sample">The <see cref="IMediaSample"/> to be timed.</param> /// <returns>0 = success, negative values for errors</returns> public override int SetTimeStamps(IMediaSample sample) { // Calculate the start/end times based on the current frame number // and frame rate DsLong start = new DsLong(this.FrameNumber * this.framesPerSecond); DsLong stop = new DsLong(start + this.framesPerSecond); // Set the times into the sample int hr = sample.SetTime(start, stop); return(hr); }
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; var changed = src.GetMediaType(out mediaType) == 0; if (changed) { 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); }
/// <summary> /// Calculate and populate the timestamps /// </summary> /// <param name="pSample">The IMediaSample to set the timestamps on</param> /// <returns>HRESULT</returns> override public 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); }
// Set the timestamps override public 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); }
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); }
/// <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; }
// Calculate the timestamps based on the frame number and the frames per second public override int SetTimeStamps(IMediaSample pSample) { // Calculate the start/end times based on the current frame number // and frame rate DsLong rtStart = new DsLong(m_iFrameNumber * m_FPS); DsLong rtStop = new DsLong(rtStart + m_FPS); // Set the times into the sample int hr = pSample.SetTime(rtStart, rtStop); return hr; }
// 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; }
/// <summary> /// Calculate the timestamps based on the frame number and the frames per second. /// </summary> /// <param name="sample">The <see cref="IMediaSample"/> to be timed.</param> /// <returns>0 = success, negative values for errors</returns> public override int SetTimeStamps(IMediaSample sample) { // Calculate the start/end times based on the current frame number // and frame rate DsLong start = new DsLong(this.FrameNumber * this.framesPerSecond); DsLong stop = new DsLong(start + this.framesPerSecond); // Set the times into the sample int hr = sample.SetTime(start, stop); return hr; }