public void SetSource(MjpegInputStream source) { mIn = source; mInUrl = null; StartPlayback(); }
public void SetSource(String url) { mInUrl = url; mIn = null; StartPlayback(); }
public void Run() { start = Convert.ToInt64(DateTime.Now.Subtract(DateTime.Today).TotalMilliseconds); Log.Debug("MjpegView", "playback thread started! time:" + start); var mode = new PorterDuffXfermode(PorterDuff.Mode.DstOver); Bitmap bm; int width; int height; Rect destRect; Canvas c = null; var p = new Paint(); var fps = ""; while (mRun) { if (surfaceDone) { try { if (false) { Log.Debug("MjpegView", "thread run once++++"); } c = mSurfaceHolder.LockCanvas(); //synchronized(mSurfaceHolder) { try { if (mIn == null && mInUrl != null) { mIn = MjpegInputStream.Read(mInUrl); } bm = mIn.ReadMjpegFrame(); if (mtakePic) { Log.Debug("MjpegView", "thread run start to take picture"); var fName = GenerateFileName(); Log.Debug("MjpegView", "mtakePic " + fName); var res = SaveBitmapToFile(bm, fName); BroardCastResult(res, fName); mFileName = fName; mtakePic = false; } destRect = DestRect(mScreenWidth, mScreenHeight); c.DrawColor(Color.Black); c.DrawBitmap(bm, null, destRect, p); if (showFps) { p.SetXfermode(mode); if (ovl != null) { height = ((ovlPos & 1) == 1) ? destRect.Top : destRect.Bottom - ovl.Height; width = ((ovlPos & 8) == 8) ? destRect.Left : destRect.Right - ovl.Width; c.DrawBitmap(ovl, width, height, null); } p.SetXfermode(null); frameCounter++; if (Convert.ToInt64(DateTime.Now.Subtract(DateTime.Today).TotalMilliseconds) - start >= 1000) { fps = $"{frameCounter} fps"; frameCounter = 0; start = Convert.ToInt64(DateTime.Now.Subtract(DateTime.Today).TotalMilliseconds); ovl = MakeFpsOverlay(overlayPaint, fps); } } } catch (Java.Lang.Exception) { } catch (System.Exception) { } //} } finally { if (c != null) { mSurfaceHolder.UnlockCanvasAndPost(c); } } } } }