Example #1
0
        public bool StartTimeShift(UInt32 reserveID)
        {
            try
            {
                if (Settings.Instance.TvTestExe.Length == 0)
                {
                    MessageBox.Show("TVTest.exeのパスが設定されていません");
                    return(false);
                }
                if (CommonManager.Instance.NWMode == false)
                {
                    if (IniFileHandler.GetPrivateProfileInt("SET", "EnableTCPSrv", 0, SettingPath.TimerSrvIniPath) == 0)
                    {
                        MessageBox.Show("追っかけ再生を行うには、動作設定でネットワーク接続を許可する必要があります。");
                        return(false);
                    }
                }
                NWPlayTimeShiftInfo playInfo = new NWPlayTimeShiftInfo();
                UInt32 err = cmd.SendNwTimeShiftOpen(reserveID, ref playInfo);
                if (err == 205)
                {
                    MessageBox.Show("サーバーに接続できませんでした");
                    return(false);
                }
                else if (err != 1)
                {
                    MessageBox.Show("まだ録画が開始されていません");
                    return(false);
                }

                if (IsOpenTVTest() == false)
                {
                    processID = FindTVTestProcess();
                    if (processID == -1)
                    {
                        Process process;
                        process   = System.Diagnostics.Process.Start(Settings.Instance.TvTestExe, Settings.Instance.TvTestCmd);
                        processID = process.Id;
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                cmdTvTest.SetPipeSetting("Global\\TvTest_Ctrl_BonConnect_" + processID.ToString(), "\\\\.\\pipe\\TvTest_Ctrl_BonPipe_" + processID.ToString());
                cmdTvTest.SetConnectTimeOut(1000);

                TVTestStreamingInfo sendInfo = new TVTestStreamingInfo();
                sendInfo.enableMode = 1;
                sendInfo.ctrlID     = playInfo.ctrlID;
                if (CommonManager.Instance.NWMode == false)
                {
                    sendInfo.serverIP = 0x7F000001;

                    string      hostname = Dns.GetHostName();
                    IPAddress[] adrList  = Dns.GetHostAddresses(hostname);
                    foreach (IPAddress address in adrList)
                    {
                        if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            UInt32 ip    = 0;
                            Int32  shift = 24;
                            foreach (string word in address.ToString().Split('.'))
                            {
                                ip    |= Convert.ToUInt32(word) << shift;
                                shift -= 8;
                            }
                            sendInfo.serverIP = ip;
                            break;
                        }
                    }

                    sendInfo.serverPort = (UInt32)IniFileHandler.GetPrivateProfileInt("SET", "TCPPort", 4510, SettingPath.TimerSrvIniPath);
                }
                else
                {
                    UInt32 ip    = 0;
                    Int32  shift = 24;
                    String srvIP = CommonManager.Instance.NW.ConnectedIP;
                    foreach (IPAddress address in Dns.GetHostAddresses(CommonManager.Instance.NW.ConnectedIP))
                    {
                        srvIP = address.ToString();
                    }
                    foreach (string word in srvIP.Split('.'))
                    {
                        ip    |= Convert.ToUInt32(word) << shift;
                        shift -= 8;
                    }
                    sendInfo.serverIP   = ip;
                    sendInfo.serverPort = CommonManager.Instance.NW.ConnectedPort;
                }
                sendInfo.filePath = playInfo.filePath;
                if (Settings.Instance.NwTvModeUDP == true)
                {
                    sendInfo.udpSend = 1;
                }
                if (Settings.Instance.NwTvModeTCP == true)
                {
                    sendInfo.tcpSend = 1;
                }
                if (cmdTvTest.SendViewSetStreamingInfo(sendInfo) != 1)
                {
                    System.Threading.Thread.Sleep(5 * 1000);
                    cmdTvTest.SendViewSetStreamingInfo(sendInfo);
                }

                WakeupWindow(processID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
            return(true);
        }
Example #2
0
        public bool StartTimeShift(UInt32 reserveID)
        {
            try
            {
                if (Settings.Instance.TvTestExe.Length == 0)
                {
                    MessageBox.Show("TVTest.exeのパスが設定されていません");
                    return(false);
                }
                if (CommonManager.Instance.NWMode == false)
                {
                    if (IniFileHandler.GetPrivateProfileInt("SET", "EnableTCPSrv", 0, SettingPath.TimerSrvIniPath) == 0)
                    {
                        MessageBox.Show("追っかけ再生を行うには、動作設定でネットワーク接続を許可する必要があります。");
                        return(false);
                    }
                }
                NWPlayTimeShiftInfo playInfo = new NWPlayTimeShiftInfo();
                ErrCode             err      = cmd.SendNwTimeShiftOpen(reserveID, ref playInfo);
                if (err == ErrCode.CMD_ERR_CONNECT)
                {
                    MessageBox.Show("サーバーに接続できませんでした");
                    return(false);
                }
                else if (err != ErrCode.CMD_SUCCESS)
                {
                    MessageBox.Show("まだ録画が開始されていません");
                    return(false);
                }

                OpenTVTest(1000, "TvTest");
                var cmdTvTest = new CtrlCmdUtil();
                cmdTvTest.SetPipeSetting("Global\\TvTest_Ctrl_BonConnect_" + process.Id, "\\\\.\\pipe\\TvTest_Ctrl_BonPipe_" + process.Id);
                cmdTvTest.SetConnectTimeOut(1000);

                TVTestStreamingInfo sendInfo = new TVTestStreamingInfo();
                sendInfo.enableMode = 1;
                sendInfo.ctrlID     = playInfo.ctrlID;
                if (CommonManager.Instance.NWMode == false)
                {
                    sendInfo.serverIP = 0x7F000001;
                    // 原作はここで自ホスト名を取得して解決したアドレスを格納している。(ないとは思うが)不具合があれば戻すこと
                    sendInfo.serverPort = (UInt32)IniFileHandler.GetPrivateProfileInt("SET", "TCPPort", 4510, SettingPath.TimerSrvIniPath);
                }
                else
                {
                    sendInfo.serverIP = 0x7F000001;
                    IPAddress srvIP = CommonManager.Instance.NW.ConnectedIP;
                    if (srvIP != null && srvIP.GetAddressBytes().Length == 4)
                    {
                        byte[] oct = srvIP.GetAddressBytes();
                        sendInfo.serverIP = (uint)oct[0] << 24 | (uint)oct[1] << 16 | (uint)oct[2] << 8 | oct[3];
                    }
                    sendInfo.serverPort = CommonManager.Instance.NW.ConnectedPort;
                }
                sendInfo.filePath = playInfo.filePath;
                if (Settings.Instance.NwTvModeUDP == true)
                {
                    sendInfo.udpSend = 1;
                }
                if (Settings.Instance.NwTvModeTCP == true)
                {
                    sendInfo.tcpSend = 1;
                }
                for (int i = 0; i < 10 && cmdTvTest.SendViewSetStreamingInfo(sendInfo) != ErrCode.CMD_SUCCESS; i++)
                {
                    System.Threading.Thread.Sleep(1000);
                }

                WakeupWindow(process.MainWindowHandle);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
            return(true);
        }