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


C# IMediaSample.GetPointer方法代码示例

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


在下文中一共展示了IMediaSample.GetPointer方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:16,代码来源:SampleGrabberCallback.cs

示例2: Exception

        /// <summary> sample callback, NOT USED. </summary>
        int ISampleGrabberCB.SampleCB(double SampleTime, IMediaSample pSample)
        {
            if (!m_bGotOne)
            {
                // Set bGotOne to prevent further calls until we
                // request a new bitmap.
                m_bGotOne = true;
                IntPtr pBuffer;

                pSample.GetPointer(out pBuffer);
                int iBufferLen = pSample.GetSize();

                if (pSample.GetSize() > m_stride*m_videoHeight)
                {
                    throw new Exception("Buffer is wrong size");
                }

                NativeMethods.CopyMemory(m_handle, pBuffer, m_stride*m_videoHeight);

                // Picture is ready.
                m_PictureReady.Set();
            }

            Marshal.ReleaseComObject(pSample);
            return 0;
        }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:27,代码来源:OSDVideo.cs

示例3: AMMediaType

        int ISampleGrabberCB.SampleCB(double sampleTime, IMediaSample pSample)
        {
            var mediaType = new AMMediaType();

            /* We query for the media type the sample grabber is using */
            int hr = m_sampleGrabber.GetConnectedMediaType(mediaType);

            var videoInfo = new VideoInfoHeader();

            /* 'Cast' the pointer to our managed struct */
            Marshal.PtrToStructure(mediaType.formatPtr, videoInfo);

            /* The stride is "How many bytes across for each pixel line (0 to width)" */
            int stride = Math.Abs(videoInfo.BmiHeader.Width * (videoInfo.BmiHeader.BitCount / 8 /* eight bits per byte */));
            int width = videoInfo.BmiHeader.Width;
            int height = videoInfo.BmiHeader.Height;

            if (m_videoFrame == null)
                InitializeBitmapFrame(width, height);

            if (m_videoFrame == null)
                return 0;

            BitmapData bmpData = m_videoFrame.LockBits(new Rectangle(0, 0, width, height),
                                                       ImageLockMode.ReadWrite,
                                                       PixelFormat.Format24bppRgb);

            /* Get the pointer to the pixels */
            IntPtr pBmp = bmpData.Scan0;

            IntPtr samplePtr;

            /* Get the native pointer to the sample */
            pSample.GetPointer(out samplePtr);

            int pSize = stride * height;

            /* Copy the memory from the sample pointer to our bitmap pixel pointer */
            CopyMemory(pBmp, samplePtr, pSize);

            m_videoFrame.UnlockBits(bmpData);

            InvokeNewVideoSample(new VideoSampleArgs { VideoFrame = m_videoFrame });

            DsUtils.FreeAMMediaType(mediaType);

            /* Dereference the sample COM object */
            Marshal.ReleaseComObject(pSample);
            return 0;
        }
开发者ID:JayBeavers,项目名称:WPF-MediaKit,代码行数:50,代码来源:VideoCapturePlayer.cs

示例4: SampleCallback

        /// <summary>
        /// The callback from the GSSF to populate the sample.  This class isn't intended
        /// to be overridden.  Child classes should instead implement PopulateSample,
        /// which this method calls.
        /// </summary>
        /// <param name="pSample">The sample to populate</param>
        /// <returns>HRESULT</returns>
        public int SampleCallback(IMediaSample pSample)
        {
            int hr;
            IntPtr pData;

            try
            {
                // Get the buffer into which we will copy the data
                hr = pSample.GetPointer(out pData);
                if (hr >= 0)
                {
                    // Find out the amount of space in the buffer
                    int cbData = pSample.GetSize();

                    lock (this)
                    {
                        hr = SetTimeStamps(pSample);
                        if (hr >= 0)
                        {
                            int iRead;

                            // Populate the sample
                            hr = PopulateSample(pData, cbData, out iRead);
                            if (hr >= 0)
                            {
                                if (hr == S_Ok) // 1 == End of stream
                                {
                                    // increment the frame number for next time
                                    m_iFrameNumber++;
                                }
                                else
                                {
                                    m_iFrameNumber = 0;
                                }

                                pSample.SetActualDataLength(iRead);
                            }
                        }
                    }
                }
            }
            finally
            {
                // Release our pointer the the media sample.  THIS IS ESSENTIAL!  If
                // you don't do this, the graph will stop after about 2 samples.
                Marshal.ReleaseComObject(pSample);
            }

            return hr;
        }
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:57,代码来源:Overlay.cs

示例5: 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

示例6: CxSampleGrabberEventArgs

 /// <summary>
 /// �R���X�g���N�^ (�����l�w��)
 /// </summary>
 /// <param name="sample_time">�T���v���^�C��</param>
 /// <param name="sample_data">�T���v���f�[�^</param>
 public CxSampleGrabberEventArgs(double sample_time, IMediaSample sample_data)
 {
     SampleTime = sample_time;
     SampleData = sample_data;
     if (sample_data != null)
     {
         sample_data.GetPointer(ref m_Address);
         m_Length = sample_data.GetSize();
     }
 }
开发者ID:cogorou,项目名称:DSLab,代码行数:15,代码来源:CxSampleGrabberCB.cs

示例7: SampleCallback

        /// <summary>
        /// Called by the GenericSampleSourceFilter.  This routine populates the MediaSample.
        /// </summary>
        /// <param name="pSample">Pointer to a sample</param>
        /// <returns>0 = success, 1 = end of stream, negative values for errors</returns>
        public virtual int SampleCallback(IMediaSample pSample)
        {
            int hr;
            IntPtr pData;

            try
            {
                // Get the buffer into which we will copy the data
                hr = pSample.GetPointer(out pData);
                if (hr >= 0)
                {
                    // Set TRUE on every sample for uncompressed frames
                    hr = pSample.SetSyncPoint(true);
                    if (hr >= 0)
                    {
                        // Find out the amount of space in the buffer
                        int cbData = pSample.GetSize();

                        hr = SetTimeStamps(pSample);
                        if (hr >= 0)
                        {
                            int iRead;

                            // Get copy the data into the sample
                            hr = GetImage(m_iFrameNumber, pData, cbData, out iRead);
                            if (hr == 0) // 1 == End of stream
                            {
                                pSample.SetActualDataLength(iRead);

                                // increment the frame number for next time
                                m_iFrameNumber++;
                            }
                        }
                    }
                }
            }
            finally
            {
                // Release our pointer the the media sample.  THIS IS ESSENTIAL!  If
                // you don't do this, the graph will stop after about 2 samples.
                Marshal.ReleaseComObject(pSample);
            }

            return hr;
        }
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:50,代码来源:BuildGraph.cs

示例8: Analyze

        /// <summary>
        /// Implementation of ISampleGrabberCB.
        /// </summary>
        int ISampleGrabberCB.SampleCB(double sampleTime, IMediaSample pSample)
        {
            IntPtr pBuffer;
            int hr = pSample.GetPointer(out pBuffer);
            DsError.ThrowExceptionForHR(hr);

            Analyze(sampleTime, pBuffer, pSample.GetSize());

            Marshal.ReleaseComObject(pSample);
            return 0;
        }
开发者ID:nuukcillo,项目名称:PerrySub,代码行数:14,代码来源:SceneDetector.cs

示例9: 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;
 }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:36,代码来源:DirectShowCodec.cs

示例10: Exception

        int ISampleGrabberCB.SampleCB(double SampleTime, IMediaSample pSample)
        {
            if (!gotOne)
            {
                gotOne = true;
                IntPtr pBuffer;

                pSample.GetPointer(out pBuffer);
                pSample.GetSize();

                if (pSample.GetSize() > Stride*Height)
                    throw new Exception("Buffer is wrong size");

                Kernel32.CopyMemory(handle, pBuffer, Stride * Height);
                pictureReady.Set();
            }

            Marshal.ReleaseComObject(pSample);
            return 0;
        }
开发者ID:pingmeaschandru,项目名称:LiveMeeting,代码行数:20,代码来源:VideoCapture.cs

示例11: Exception

        int ISampleGrabberCB.SampleCB(double sampleTime, IMediaSample sample)
        {
            if (!_gotPicture)
            {
                // Set bGotOne to prevent further calls until we
                // request a new bitmap.
                _gotPicture = true;
                IntPtr pBuffer;

                sample.GetPointer(out pBuffer);

                if (sample.GetSize() > _stride * _height)
                {
                    throw new Exception("Buffer is wrong size");
                }

                CopyMemory(_handle, pBuffer, _stride * _height);

                _pictureReadyResetEvent.Set();
            }

            Marshal.ReleaseComObject(sample);
            return 0;
        }
开发者ID:WildGenie,项目名称:ipcamemu,代码行数:24,代码来源:IvdDataAdapter.cs

示例12: MediaSampleCB

        /// <summary>
        /// This routine populates the MediaSample.
        /// </summary>
        /// <param name="pSample">Pointer to a sample</param>
        /// <returns>0 = success, 1 = end of stream, negative values for errors</returns>
        public int MediaSampleCB(IMediaSample pSample)
        {
            int hr;

            try
            {
                IntPtr pData;

                hr = pSample.GetPointer(out pData);
                if (hr >= 0)
                {
                    hr = pSample.SetSyncPoint(true);
                    if (hr >= 0)
                    {
                        var len = Source.Read(pData, Constants.DShowNumberOfPacketsTS);
                        if (len != 0)
                        {
                            hr = 0;
                            pSample.SetActualDataLength(len);
                        }
                        else
                        {
                            //hr = 1;
                            hr = 0;
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                Log.ErrorException("Error in Sample handler.", ex);
                hr = -1;
            }
            finally
            {
                Marshal.ReleaseComObject(pSample);
            }

            return hr;
        }
开发者ID:markTwen,项目名称:TStreamSource,代码行数:45,代码来源:TSampleHandler.cs


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