public bool AddIfNotExists(string Address, OysterEncoder.Connection value) { if (this.Contains(Address)) return false; this.Add(Address,value); return true; }
/// <summary> /// initializes the encoder. /// </summary> public bool StartupEncoder(OysterEncoder.VideoSignalType eVideoSignal) { log.Context = "OysterEncoder.Encoder.StartupEncoder"; log.Context = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name; string sWMEFile ; switch (eVideoSignal) { case OysterEncoder.VideoSignalType.composite: sWMEFile = m_sProfileDirectory + "\\" + "CompositeChannel" + m_iChannel + ".wme"; break; case OysterEncoder.VideoSignalType.svideo: sWMEFile = m_sProfileDirectory + "\\" + "SVideoChannel" + m_iChannel + ".wme"; break; default: log.WriteLog("SignalType must be a valid OysterEncoder.VideoSignalType"); return false; } m_sWMEFilename = sWMEFile; m_bIsEncoderStreaming = false; // verify that the WMEFilename is exists if (!System.IO.File.Exists(sWMEFile)) { log.WriteLog(sWMEFile + " does not exist."); return false; } // initialize the Winnov capture card on the specified channel // by setting the source index for both audio and video // initialize the WMEncoder // load the WMEFilename into the WMEncoder m_encoder.Load(sWMEFile); // prepare the WMEncoder m_encoder.EnableAutoArchive = false; // synch the start of encoding to the device in case the device is not yet ready m_encoder.SynchronizeOperation = true; m_encoder.PrepareToEncode(true); // start the WMEncoder streaming m_encoder.Start(); WMEncoderLib.IWMEncBroadcast broadcast = (WMEncoderLib.IWMEncBroadcast)m_encoder.Broadcast; log.WriteLog("Broadcasting on port: " + broadcast.get_PortNumber(WMEncoderLib.WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP)); m_bIsEncoderStreaming = true; // end routine return true; }
internal OysterEncoder.Command SendCommandWaitForResponse(OysterEncoder.Command cmd) { //log.Context = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name; OysterEncoder.Command retcmd = null; string sLastErrorMessage = ""; try { cmd.Write(m_TCPClient.GetStream()); } catch (System.IO.IOException ioex) { if (null != ioex.InnerException) { if (ioex.InnerException is System.Net.Sockets.SocketException) { int iErrorCode = ((System.Net.Sockets.SocketException)ioex.InnerException).ErrorCode; string sErrorMessage = ((System.Net.Sockets.SocketException)ioex.InnerException).Message; sLastErrorMessage = "SendCommand: Error Code = " + iErrorCode.ToString() + " Description = " + sErrorMessage; } else { sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ioex.Message; } } m_bDone = true; m_bConnected = false; } catch (System.Exception ex) { sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ex.Message; m_bDone = true; m_bConnected = false; } if(!this.Connected) { log.WriteLog(sLastErrorMessage); OnConnectionErrorReceived(this,sLastErrorMessage); } #if DEBUG if (m_EventMessageAvailable.WaitOne(25000,false)) #else if (m_EventMessageAvailable.WaitOne(3000,false)) #endif { lock (m_qCommands.SyncRoot) { if (m_qCommands.Count > 0) { retcmd = (OysterEncoder.Command)m_qCommands.Dequeue(); } } } else { log.WriteLog("WaitOne timed out waiting for a return message."); } return retcmd; }
internal void SendCommand(OysterEncoder.Command cmd) { string sLastErrorMessage = ""; try { cmd.Write(m_TCPClient.GetStream()); } catch (System.IO.IOException ioex) { if (null != ioex.InnerException) { if (ioex.InnerException is System.Net.Sockets.SocketException) { int iErrorCode = ((System.Net.Sockets.SocketException)ioex.InnerException).ErrorCode; string sErrorMessage = ((System.Net.Sockets.SocketException)ioex.InnerException).Message; sLastErrorMessage = "SendCommand: Error Code = " + iErrorCode.ToString() + " Description = " + sErrorMessage; } else { sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ioex.Message; } } m_bDone = true; m_bConnected = false; } catch (System.Exception ex) { sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ex.Message; m_bDone = true; m_bConnected = false; } if(!m_bConnected) { log.WriteLog(sLastErrorMessage); OnConnectionErrorReceived(this,sLastErrorMessage); } }
internal virtual void OnMessageReceived(OysterEncoder.CommandEventArgs e) { if (MessageReceived != null) MessageReceived(this,e); }
public void Add(string Address, OysterEncoder.Connection value) { this.BaseAdd(Address,value); }
internal RequestCompleteEventArgs(OysterEncoder.eRequestVerbs requestverbs, string [] saParams) { m_eRequestVerb = requestverbs; m_saParams = saParams; }
internal static bool IsValidCommand(OysterEncoder.Command cmd) { switch (cmd.VerbString) { case "LST": return true; case "UPL": if (2 != cmd.Params.GetLength(0)) return false; return true; case "DNL": if (1 != cmd.Params.GetLength(0)) return false; return true; case "ISR": return true; case "REC": if (1 != cmd.Params.GetLength(0)) return false; return true; case "STP": return true; case "SET": if (2 != cmd.Params.GetLength(0)) return false; return true; case "GET": if (1 != cmd.Params.GetLength(0)) return false; return true; case "DEL": if (1 != cmd.Params.GetLength(0)) return false; return true; case "PULSECHECK": return true; default: return false; } }
// start threads and initialize encoder. returns false on errors internal bool Start(ref OysterEncoder.Encoder oEncoder) { log.Context = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name; bool bReturn = true; if (m_bStarted) { throw new System.ApplicationException("Connection.Start already called. Call Connection.Stop first."); } log.WriteLog("Starting Connection ..."); m_Encoder = oEncoder; m_bDone = false; m_bConnected = true; m_ThreadDequeAndExecute.Start(); m_ThreadReceiveDataAndEnqueue.Start(); //m_ThreadIsConnectionAlive.Start(); m_bStarted = true; return bReturn; }