예제 #1
0
 public ChaseHokan(numTaskInfo nti, int lastSegmentNo, string[] name,
                   string lvid, RecordingManager rm, Html5Recorder h5r)
 {
     this.nti           = nti;
     this.lastSegmentNo = lastSegmentNo;
     this.name          = name;
     this.lvid          = lvid;
     this.rm            = rm;
     this.h5r           = h5r;
 }
예제 #2
0
        public bool start(numTaskInfo nti)
        {
            try {
                this.nti = nti;
                Thread.Sleep(3000);
                var subL = rfu.subGotNumTaskInfo;
                rec.addDebugBuf("drop segment process s.dt " + nti.dt.ToString() + " lastwrote " + lastWroteSegmentDt.ToString() + " now " + DateTime.Now.ToString() + " nti.no " + nti.no + " nti.originNo " + nti.originNo + " lastsegmentno " + lastSegmentNo);
                if (rfu.subGotNumTaskInfo != null)
                {
                    rec.addDebugBuf("drop segment process start count " + subL.Count);
                    if (rfu.subGotNumTaskInfo.Count > 0)
                    {
                        rec.addDebugBuf("drop segment process subList min " + subL[0].dt + " " + subL[0].no + " max " + subL[subL.Count - 1].dt + " " + subL[subL.Count - 1].no);
                    }
                }
                var fName = writeNukeSegment();
                rec.addDebugBuf("drop fname " + (fName == null ? "" : (fName[0] + " " + fName[1])));
                var    dropTime = (nti.no - lastSegmentNo - 1) * nti.second;
                var    msg      = lastWroteSegmentDt.ToString() + "ぐらいから" + nti.dt.ToString() + "ぐらいまでの動画データが取得できませんでした。(" + dropTime + "秒)";
                string hokanMsg = (fName == null) ? "補完設定がされていませんでした。" :
                                  //	((fName == "") ? "補完用データがありませんでした。" : ("補完を試みました。" + fName));
                                  ("補完を試みます。");
                if (rm.cfg.get("IsSegmentNukeInfo") == "true")
                {
                    writeNukeInfo(msg, null, nti.no, hokanMsg);
                }
                else
                {
                    rec.addDebugBuf("write nuke info no");
                }

                rm.form.addLogText(msg);
                rm.form.addLogText(hokanMsg, true);

                if (fName != null)
                {
                    rec.addDebugBuf("drop hokan chase  nti.no " + nti.no + " nti.second " + nti.second);
                    chaseHokan = new ChaseHokan(nti, lastSegmentNo, fName, rfu.lvid, rm, h5r);
                    Task.Run(() => {
                        chaseHokan.start();
                        chaseHokan = null;
                        rec.dsp    = null;
                    });
                }
                else
                {
                    return(false);
                }
            } catch (Exception e) {
                rec.addDebugBuf("drop exception " + e.Message + e.Source + e.StackTrace + e.TargetSite);
            }
            return(true);
        }
예제 #3
0
        private void rtmpdumpReadFFmpegWriteProcess(
            Process rtmpdumpP, Process ffmpegP)
        {
            util.debugWriteLine("rtmpdumpReadFFmpegWriteProcess start");
            Stream o;

            try {
                Thread.Sleep(500);
                o = rtmpdumpP.StandardOutput.BaseStream;
            } catch (Exception e) {
                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                return;
            }
//			var _is = ffmpegP.StandardInput.BaseStream;
            var b = new byte[100000000];

            while (!rtmpdumpP.HasExited && rfu == rm.rfu)
            {
                try {
                    var i = o.Read(b, 0, b.Length);
//					if (isFirst)
//					Debug.WriteLine("rtmpdump " + i);
//					if (rm.isPlayOnlyMode) continue;

                    if (i == 0)
                    {
                        util.debugWriteLine("rtmpdump read i " + (" get 0"));
                    }

                    var bb = b.CloneRange(0, i);
                    if (rfu.firstFlvData == null && bb.Length > 0)
                    {
                        rfu.firstFlvData = bb;
                        util.debugWriteLine("rtmp set firstData len " + bb.Length);
                    }
                    var nti = new numTaskInfo(subNtiGroupNum, null, 1, null, 0, 0);
                    nti.res = bb;
                    rfu.subGotNumTaskInfo.Add(nti);
                } catch (Exception ee) {
                    Debug.WriteLine("rtmpdump read exception " + ee.Message + ee.Source + ee.StackTrace + ee.TargetSite);
                }
            }
            subNtiGroupNum++;
            util.debugWriteLine("rtmpdumpReadFFmpegWriteProcess end");
        }
예제 #4
0
        private void ffmpegReadProcess(Process ffmpegP)
        {
            util.debugWriteLine("ffmpegReadProcess start");
            Stream _os;

            try {
                _os = ffmpegP.StandardOutput.BaseStream;
            } catch (Exception e) {
                util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite);
                return;
            }

            var resBuf = new List <byte>();
            var b      = new byte[100000000];

            while (!ffmpegP.HasExited)
            {
                try {
                    var i = _os.Read(b, 0, b.Length);
//					if (isFirst)
//					Debug.WriteLine("ff " + i);
                    var bb = b.CloneRange(0, i);

                    var nti = new numTaskInfo(0, null, 1, null, 0, 0);
                    nti.res = bb;
//					util.debugWriteLine("ffmpeg " + nti.res.Length + util.getMainSubStr(isSub, true));

//					if (DateTime.Now - nti.dt > TimeSpan.FromSeconds(2)) {
                    rfu.subGotNumTaskInfo.Add(nti);
//					}
                } catch (Exception ee) {
                    Debug.WriteLine(ee.Message + ee.Source + ee.StackTrace + ee.TargetSite);
                }
            }
            util.debugWriteLine("ffmpegReadProcess end");
        }