virtual public BaseAppProtocolHandler GetProtocolHandler(string scheme) { BaseAppProtocolHandler pResult = null; if (false) { } #if HAS_PROTOCOL_RTMP else if (scheme.StartsWith("rtmp")) { pResult = GetProtocolHandler(ProtocolTypes.PT_INBOUND_RTMP) ?? GetProtocolHandler(ProtocolTypes.PT_OUTBOUND_RTMP); } /* HAS_PROTOCOL_RTMP */ #endif #if HAS_PROTOCOL_RTP else if (scheme == "rtsp") { pResult = GetProtocolHandler(ProtocolTypes.PT_RTSP); } /* HAS_PROTOCOL_RTP */ #endif #if HAS_PROTOCOL_MMS else if (scheme == "mms") { pResult = GetProtocolHandler(PT_OUTBOUND_MMS); } /* HAS_PROTOCOL_MMS */ #endif else { Logger.WARN("scheme {0} not recognized", scheme); } return(pResult); }
public void RegisterAppProtocolHandler(ulong protocolType, BaseAppProtocolHandler pAppProtocolHandler) { if (_protocolsHandlers.ContainsKey(protocolType)) { Logger.ASSERT("Invalid protocol handler type. Already registered"); } _protocolsHandlers[protocolType] = pAppProtocolHandler; pAppProtocolHandler.Application = this; }
virtual public bool PushLocalStream(Variant streamConfig) { //1. Minimal verification if (streamConfig["targetUri"] == null) { Logger.FATAL("Invalid uri"); return(false); } if (streamConfig["localStreamName"] == null) { Logger.FATAL("Invalid local stream name"); return(false); } var streamName = (string)streamConfig["localStreamName"]; streamName = streamName.Trim(); if (streamName == "") { Logger.FATAL("Invalid local stream name"); return(false); } streamConfig["localStreamName"] = streamName; //2. Split the URI Uri uri = new Uri((string)streamConfig["targetUri"]); //3. Depending on the scheme name, get the curresponding protocol handler ///TODO: integrate this into protocol factory manager via protocol factories string scheme = uri.Scheme; BaseAppProtocolHandler pProtocolHandler = GetProtocolHandler(scheme); if (pProtocolHandler == null) { Logger.WARN("Unable to find protocol handler for scheme {0} in application {1}", scheme, Name); return(false); } //4. Initiate the stream pulling sequence return(pProtocolHandler.PushLocalStream(streamConfig)); }