internal static DirectShowEncoder TryCreate(Dictionary <string, string> parameters) { DSCodec codecEnum; if (Enum.TryParse <DSCodec>(parameters["codec"], true, out codecEnum)) { DirectShowEncoder encoder = new DirectShowEncoder(); encoder.codec = codecEnum; encoder.parameters = parameters; return(encoder); } return(null); }
public static EncoderBuilder GetEncoder(Dictionary <string, string> parameters) { EncoderBuilder encoder; if ((encoder = DirectShowEncoder.TryCreate(parameters)) != null || (encoder = MediaFoundationEncoder.TryCreate(parameters)) != null || (encoder = GDIEncoder.TryCreate(parameters)) != null) { if (parameters.ContainsKey("video")) { encoder.video = uint.Parse(parameters["video"]); } if (parameters.ContainsKey("audio")) { encoder.audio = uint.Parse(parameters["audio"]); } if (parameters.ContainsKey("width")) { encoder.width = uint.Parse(parameters["width"]); } if (parameters.ContainsKey("height")) { encoder.height = uint.Parse(parameters["height"]); } if (parameters.ContainsKey("vidbitrate")) { encoder.vidBitrate = uint.Parse(parameters["vidbitrate"]); } if (parameters.ContainsKey("audbitrate")) { encoder.audBitrate = uint.Parse(parameters["audbitrate"]); } return(encoder); } throw new MediaCenterException("Unknown codec"); }