Esempio n. 1
0
        /// <summary>
        /// 收到音频数据的回调
        /// </summary>
        /// <param name="val">音频数据指针</param>
        private unsafe void OnDataReady(IntPtr val)
        {
            if (FramePrivate == null)
            {
                return;
            }
            void **ptrs = (void **)val.ToPointer();
            byte * data = (byte *)*ptrs;

            ++ptrs;
            int bits_per_sample = *(int *)*ptrs;

            ++ptrs;
            int sample_rate = *(int *)*ptrs;

            ++ptrs;
            int number_of_channels = *(int *)*ptrs;

            ++ptrs;
            int number_of_frames = *(int *)*ptrs;

            ++ptrs;
            FramePrivate.Invoke(new AudioFrame
            {
                Data          = new IntPtr(data),
                BitsPerSample = bits_per_sample,
                Channels      = number_of_channels,
                Frames        = number_of_frames,
                SampleRate    = sample_rate
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 处理收到的视频帧
        /// </summary>
        /// <param name="val">视频帧指针</param>
        private unsafe void OnDataReady(IntPtr val)
        {
            if (FramePrivate == null)
            {
                return;
            }
            void **ptrs  = (void **)val.ToPointer();
            byte * datay = (byte *)*ptrs;

            ++ptrs;
            byte *datau = (byte *)*ptrs;

            ++ptrs;
            byte *datav = (byte *)*ptrs;

            ++ptrs;
            byte *dataa = (byte *)*ptrs;

            ++ptrs;
            int stridey = *(int *)*ptrs;

            ++ptrs;
            int strideu = *(int *)*ptrs;

            ++ptrs;
            int stridev = *(int *)*ptrs;

            ++ptrs;
            int stridea = *(int *)*ptrs;

            ++ptrs;
            int width = *(int *)*ptrs;

            ++ptrs;
            int height = *(int *)*ptrs;

            ++ptrs;
            int rotation = *(int *)*ptrs;

            ++ptrs;
            long time = *(long *)*ptrs;

            ++ptrs;
            FramePrivate.Invoke(new VideoFrame
            {
                DataY     = new IntPtr(datay),
                DataU     = new IntPtr(datau),
                DataV     = new IntPtr(datav),
                DataA     = new IntPtr(dataa),
                StrideY   = stridey,
                StrideU   = strideu,
                StrideV   = stridev,
                StrideA   = stridea,
                Width     = width,
                Height    = height,
                Rotation  = rotation,
                Timestamp = time
            });
        }