Esempio n. 1
0
 public void Stop()
 {
     CurThr.Abort();
     Paused = true;
     VideoIn.stopVideo(vid);
     int res = VideoIn.stopAudio(vid);
 }
Esempio n. 2
0
        public void Thr_Decode()
        {
            while (true)
            {
                if (!Paused)
                {
                    if (gotAudioTime == false)
                    {
                        if (VideoIn.audioHasBegun() == 1)
                        {
                            gotAudioTime   = true;
                            audioStartTime = Environment.TickCount;
                        }
                    }
                    else
                    {
                        long curTime = Environment.TickCount;

                        long timed = curTime - audioStartTime;
                        AUDIOCLOCK = ((double)(timed) / 1000.0);
                    }

                    FrameMutex.WaitOne();

                    while (true)
                    {
                        if (Frames.Count == 0)
                        {
                            break;
                        }
                        var frm = Frames.Peek();
                        if (frm.DPTS < AUDIOCLOCK)
                        {
                            Frames.Dequeue();
                        }
                        else
                        {
                            break;
                        }
                    }
                    FrameMutex.ReleaseMutex();
                    if (Frames.Count > 0)
                    {
                        double ft = Frames.Peek().DPTS;

                        TimeDelta = ft - AUDIOCLOCK;
                    }

                    FrameMutex.WaitOne();
                    if (Frames.Count < 8)
                    {
                        DecodeNextFrame();
                    }
                    FrameMutex.ReleaseMutex();
                }
                //  GC.Collect();
                //  T//hread.Sleep(2);
            }
        }
Esempio n. 3
0
        public void DecodeNextFrame()
        {
            Profiler.Profile.BeginBlock("DecodeFrame");
            VideoIn.decodeNextFrame(vid);

            int fw = VideoIn.getFrameWidth(vid);
            int fh = VideoIn.getFrameHeight(vid);

            if (fw < 0 || fw > 10000)
            {
                Profiler.Profile.EndBlock("DecodeFrame");
                return;
            }

            Width  = fw;
            Height = fh;

            // if (Data == null)
            // {
            //   Data = new byte[Width * Height * 3];w
            //}

            VideoIn.genFrameData(vid);

            //  var tex = new Texture.Texture2D(Width, Height, Data, false);

            VideoFrame frame = new VideoFrame();

            // frame.Data = buf;

            frame.W = Width;

            frame.H    = Height;
            frame.DPTS = VideoIn.getDPTS(vid);
            if (frame.DPTS < CLOCK - 0.1f)
            {
                return;
            }

            byte[] buf = new byte[Width * Height * 3];

            VideoIn.getFrameData(vid, buf);
            frame.Data   = buf;
            frame.DDELAY = VideoIn.getDDelay(vid);
            frame.Pict   = VideoIn.getPict(vid);

            FrameMutex.WaitOne();
            Frames.Enqueue(frame);
            FrameMutex.ReleaseMutex();

            Profiler.Profile.EndBlock("DecodeFrame");
        }
Esempio n. 4
0
        public VideoPlayer(string path)
        {
            Profiler.Profile.BeginBlock("InitVideo");

            if (AudioUp == false)
            {
                int res = VideoIn.initAudio();
                AudioUp = true;
            }

            //Console.WriteLine("VideoInit:" + VideoIn
            var rt = Marshal.StringToHGlobalAnsi(path);

            vid = VideoIn.initVideoNative(rt);

            TimeStart = Environment.TickCount;

            var decode_thread = new Thread(new ThreadStart(Thr_Decode));

            decode_thread.Start();
            CurThr          = decode_thread;
            CurThr.Priority = ThreadPriority.AboveNormal;
            Profiler.Profile.EndBlock("InitVideo");
        }
Esempio n. 5
0
 public void StopAudio()
 {
     CurThr.Abort();
     int res = VideoIn.stopAudio(vid);
     //   VideoIn.stopVideo(vid);
 }