Пример #1
0
        void TestPreroll()
        {
            int hr;
            int s1, s2;

            // Read the value
            s1 = m_ims.IsPreroll();

            // Change the value
            hr = m_ims.SetPreroll(s1 != 0);
            Marshal.ThrowExceptionForHR(hr);

            // Re-read the value
            s2 = m_ims.IsPreroll();

            // Check to see if the change took
            Debug.Assert(s1 != s2, "Get/Set Preroll");

            // put the original value back
            hr = m_ims.SetPreroll(s1 == 0);
            Marshal.ThrowExceptionForHR(hr);

            // Re-read the value
            s2 = m_ims.IsPreroll();

            // Check to see if the change took
            Debug.Assert(s1 == s2, "Get/Set Preroll2");
        }
Пример #2
0
 public MediaSample(IMediaSample sample)
 {
     m_Size             = sample.GetSize();
     m_ActualDataLength = sample.GetActualDataLength();
     m_IsSyncPoint      = sample.IsSyncPoint() == 0;
     m_IsPreroll        = sample.IsPreroll() == 0;
     m_IsDiscontinuity  = sample.IsDiscontinuity() == 0;
     sample.GetTime(out m_TimeStart, out m_TimeEnd);
     sample.GetMediaTime(out m_MediaTimeStart, out m_MediaTimeEnd);
     m_Buffer = Marshal.AllocCoTaskMem(m_Size);
 }
Пример #3
0
        public int SampleCB(double SampleTime, IMediaSample pSample)
        {
            DateTime dt = DateTime.Now;

            lock (this)
            {
                sb.AppendFormat("{0:T}.{1:D3}: ", dt, dt.Millisecond);
                sb.AppendFormat("SampleTime={0:G4}, ", SampleTime);
                if (pSample != null)
                {
                    long start = 0, end = 0;
                    pSample.GetTime(out start, out end);
                    sb.AppendFormat("Time(start={0}, end={1}), ", start, end);
                    pSample.GetMediaTime(out start, out end);
                    sb.AppendFormat("MediaTime(start={0}, end={1}), ", start, end);
                    int len = pSample.GetActualDataLength();
                    sb.AppendFormat("data length={0}, ", len);
                    bool syncpoint = pSample.IsSyncPoint() == 0;
                    sb.AppendFormat("keyframe={0}", syncpoint);
                    if (pSample.IsDiscontinuity() == 0)
                    {
                        sb.Append(", Discontinuity");
                    }
                    if (pSample.IsPreroll() == 0)
                    {
                        sb.Append(", Preroll");
                    }
                    int    n = Math.Min(len, 8);
                    IntPtr pbuf;
                    if (pSample.GetPointer(out pbuf) == 0)
                    {
                        byte[] buf = new byte[n];
                        Marshal.Copy(pbuf, buf, 0, n);
                        sb.Append(", Data=");
                        for (int i = 0; i < n; i++)
                        {
                            sb.AppendFormat("{0:X2}", buf[i]);
                        }
                        sb.Append("...");
                    }
                }
                else
                {
                    sb.Append("pSample==NULL!");
                }
                sb.Append(Environment.NewLine);
            }
            Marshal.ReleaseComObject(pSample);
            return(0);
        }
Пример #4
0
        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);
        }
Пример #5
0
        public MediaSample(IMediaSample sample)
        {
            m_Size             = sample.GetSize();
            m_ActualDataLength = sample.GetActualDataLength();
            m_IsSyncPoint      = sample.IsSyncPoint() == 0;
            m_IsPreroll        = sample.IsPreroll() == 0;
            m_IsDiscontinuity  = sample.IsDiscontinuity() == 0;
            m_HasTime          = sample.GetTime(out m_TimeStart, out m_TimeEnd) == 0;
            m_HasMediaTime     = sample.GetMediaTime(out m_MediaTimeStart, out m_MediaTimeEnd) == 0;
            m_Buffer           = Marshal.AllocCoTaskMem(m_Size);
            // Copy the media type
            AMMediaType mediaType;

            if (sample.GetMediaType(out mediaType) == 0)
            {
                m_MediaType = mediaType;
            }
        }
Пример #6
0
        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);
        }