当前位置: 首页>>代码示例>>C#>>正文


C# IMediaSample.SetTime方法代码示例

本文整理汇总了C#中IMediaSample.SetTime方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSample.SetTime方法的具体用法?C# IMediaSample.SetTime怎么用?C# IMediaSample.SetTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMediaSample的用法示例。


在下文中一共展示了IMediaSample.SetTime方法的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);
        }
开发者ID:Xuno,项目名称:MPDN_Extensions,代码行数:41,代码来源:AudioHelpers.cs

示例2: 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;
        }
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:26,代码来源:Overlay.cs

示例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;
        }
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:23,代码来源:BuildGraph.cs

示例4: SetTimeStamps

    /// <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;
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:17,代码来源:ImageFromVectorGraphics.cs


注:本文中的IMediaSample.SetTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。