public void Clean(NameValueCollection collection, IXssConfigurationHandler configuration, EncoderType encoderType = EncoderType.AutoDetect) { if (string.IsNullOrWhiteSpace(configuration.ControlRegex)) { _xssDetectRegex = new Regex(_regexProcessor.XssPattern, RegexOptions.IgnoreCase); } else { try { _xssDetectRegex = new Regex(HttpUtility.HtmlDecode(configuration.ControlRegex),RegexOptions.IgnoreCase); } catch { _xssDetectRegex = new Regex(_regexProcessor.XssPattern,RegexOptions.IgnoreCase); } } PropertyInfo readonlyProperty = _reflector.MakeWritable(collection); for (int i = 0; i < collection.Count; i++) { if (string.IsNullOrWhiteSpace(collection[i])) { continue; } IterateCleanUp(encoderType, collection, i); } readonlyProperty.SetValue(collection, true, null); }
public static Context Create(int id = 0, EncoderType encoderType = EncoderType.Hardware) { if (encoderType == EncoderType.Hardware && !NativeMethods.GetHardwareEncoderSupport()) { throw new ArgumentException("Hardware encoder is not supported"); } var ptr = NativeMethods.ContextCreate(id, encoderType); return(new Context(ptr, id)); }
public static void Initialize(EncoderType type = EncoderType.Hardware) { NativeMethods.RegisterDebugLog(DebugLog); s_context = Context.Create(encoderType: type); NativeMethods.SetCurrentContext(s_context.self); s_syncContext = SynchronizationContext.Current; var flipShader = Resources.Load <Shader>("Flip"); if (flipShader != null) { flipMat = new Material(flipShader); } }
public IActionResult Update([FromBody] EncoderView encoder) { using (var db = new AllInOneContext.AllInOneContext()) { try { if (encoder == null) { return(BadRequest()); } Encoder en = db.Encoder.Include(t => t.DeviceInfo).FirstOrDefault(t => t.EncoderId.Equals(encoder.EncoderId)); if (en == null) { return(NotFound()); } if (encoder.EncoderType > 0) { EncoderType ent = db.Set <EncoderType>().FirstOrDefault(t => t.EncoderCode == encoder.EncoderType); if (ent == null) { return(BadRequest(new ApplicationException() { ErrorCode = "Unknown", ErrorMessage = "错误的编码器类型" })); } en.EncoderTypeId = ent.EncoderTypeId; } if (encoder.EndPoints != null && encoder.EndPoints.Count > 0) { en.DeviceInfo.EndPoints = encoder.EndPoints; } db.Encoder.Update(en); db.SaveChanges(); return(Ok()); } catch (DbUpdateException dbEx) { _logger.LogError("修改编码器异常:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (System.Exception ex) { _logger.LogError("修改编码器异常:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } } }
///<summary>Инициализирует экземпляр класса EncoderData, считывая данные из потока.</summary> ///<param name="s">Поток, из которого будет производится чтение.</param> ///<param name="depth">Глубина сети.</param> public EncoderData(Stream s, EncoderType depth) { var br = new BinaryReader(s); if ((depth == EncoderType.Conv1) || (depth == EncoderType.Conv2) || (depth == EncoderType.Conv3) || (depth == EncoderType.Conv4) || (depth == EncoderType.Conv5)) { this.Conv0_Weights = LoadWeights(3, 3, 1, 1, br); this.Conv0_Biases = LoadBiases(3, br); this.Conv1_1_Weights = LoadWeights(64, 3, 3, 3, br); this.Conv1_1_Biases = LoadBiases(64, br); } if ((depth == EncoderType.Conv2) || (depth == EncoderType.Conv3) || (depth == EncoderType.Conv4) || (depth == EncoderType.Conv5)) { this.Conv1_2_Weights = LoadWeights(64, 64, 3, 3, br); this.Conv1_2_Biases = LoadBiases(64, br); this.Conv2_1_Weights = LoadWeights(128, 64, 3, 3, br); this.Conv2_1_Biases = LoadBiases(128, br); } if ((depth == EncoderType.Conv3) || (depth == EncoderType.Conv4) || (depth == EncoderType.Conv5)) { this.Conv2_2_Weights = LoadWeights(128, 128, 3, 3, br); this.Conv2_2_Biases = LoadBiases(128, br); this.Conv3_1_Weights = LoadWeights(256, 128, 3, 3, br); this.Conv3_1_Biases = LoadBiases(256, br); } if ((depth == EncoderType.Conv4) || (depth == EncoderType.Conv5)) { this.Conv3_2_Weights = LoadWeights(256, 256, 3, 3, br); this.Conv3_2_Biases = LoadBiases(256, br); this.Conv3_3_Weights = LoadWeights(256, 256, 3, 3, br); this.Conv3_3_Biases = LoadBiases(256, br); this.Conv3_4_Weights = LoadWeights(256, 256, 3, 3, br); this.Conv3_4_Biases = LoadBiases(256, br); this.Conv4_1_Weights = LoadWeights(512, 256, 3, 3, br); this.Conv4_1_Biases = LoadBiases(512, br); } if (depth == EncoderType.Conv5) { this.Conv4_2_Weights = LoadWeights(512, 512, 3, 3, br); this.Conv4_2_Biases = LoadBiases(512, br); this.Conv4_3_Weights = LoadWeights(512, 512, 3, 3, br); this.Conv4_3_Biases = LoadBiases(512, br); this.Conv4_4_Weights = LoadWeights(512, 512, 3, 3, br); this.Conv4_4_Biases = LoadBiases(512, br); this.Conv5_1_Weights = LoadWeights(512, 512, 3, 3, br); this.Conv5_1_Biases = LoadBiases(512, br); } br.Close(); }
public void DecodeNewLineCharacterCorrectly(EncoderType encoderType) { var decoder = new IMessageDecode[] { Encoders.InternationalSystem, Encoders.JapaneseEvent, Encoders.JapaneseSystem, Encoders.TurkishSystem }[(int)encoderType]; var models = decoder.Decode(new byte[] { 0x35, 0x32, 0x02, 0x39, 0x39, 0x3C }); Assert.Single(models); Assert.Equal("HE\nLLO", models[0].Text); }
private void ExecuteCleaner(HttpRequest request, EncoderType encoderType) { if (request.QueryString.Count > 0) { _requestSanitizer.Clean(request.QueryString, _configuration, encoderType); } if (request.HttpMethod == "POST") { if (request.Form.Count > 0) { _requestSanitizer.Clean(request.Form, _configuration, encoderType); } } }
private void ExecuteCleaner(HttpRequest request, EncoderType encoderType) { if (request.QueryString.Count > 0) { _requestCleaner.Clean(request.QueryString, _configuration, encoderType); } if (request.HttpMethod == "POST") { if (request.Form.Count > 0) { _requestCleaner.Clean(request.Form, _configuration, encoderType); } } }
/// <summary> /// Takes a Unity environment and model-specific hyper-parameters and returns the /// appropriate PPO agent model for the environment. /// </summary> /// <param name="brain">BrainInfo used to generate specific network graph.</param> /// <param name="lr">Learning rate.</param> /// <param name="lr_schedule">Learning rate decay schedule.</param> /// <param name="h_size">Size of hidden layers</param> /// <param name="epsilon">Value for policy-divergence threshold.</param> /// <param name="beta">Strength of entropy regularization.</param> /// <param name="max_step">Total number of training steps.</param> /// <param name="normalize">Whether to normalize vector observation input.</param> /// <param name="use_recurrent">Whether to use an LSTM layer in the network.</param> /// <param name="num_layers">Number of hidden layers between encoded input and policy & value layers</param> /// <param name="m_size">Size of brain memory.</param> /// <param name="seed">Seed to use for initialization of model.</param> /// <param name="stream_names">List of names of value streams. Usually, a list of the Reward Signals being used.</param> /// <param name="vis_encode_type"></param> public PPOModel(BrainParameters brain, float lr = 0.0001f, LearningRateSchedule lr_schedule = LearningRateSchedule.LINEAR, int h_size = 128, float epsilon = 0.2f, float beta = 0.001f, float max_step = 5e6f, bool normalize = false, bool use_recurrent = false, int num_layers = 2, int?m_size = null, int seed = 0, List <string> stream_names = null, EncoderType vis_encode_type = EncoderType.SIMPLE) : base(m_size: m_size, normalize: normalize, use_recurrent: use_recurrent, brain: brain, seed: seed, stream_names: stream_names) { // optimizer: Optional[tf.train.AdamOptimizer] = null; // update_batch: Optional[tf.Operation] = null; if (num_layers < 1) { num_layers = 1; } if (brain.vector_action_space_type == "continuous") { throw new NotImplementedException("brain.vector_action_space_type"); // create_cc_actor_critic(h_size, num_layers, vis_encode_type); // entropy = tf.ones_like(tf.reshape(value, [-1])) * entropy; } else { create_dc_actor_critic(h_size, num_layers, vis_encode_type); } learning_rate = create_learning_rate(lr_schedule, lr, global_step, max_step); create_losses( log_probs, old_log_probs, value_heads, entropy, beta, epsilon, lr, max_step); }
public static bool CheckVideoSendRecvCodecSupport(EncoderType encoderType) { WebRTC.Initialize(encoderType); var capabilitiesSenderCodec = RTCRtpSender.GetCapabilities(TrackKind.Video) .codecs .Select(x => x.mimeType) .Except(excludeCodecMimeType); var capabilitiesReceiverCodec = RTCRtpReceiver.GetCapabilities(TrackKind.Video) .codecs .Select(x => x.mimeType) .Except(excludeCodecMimeType); var isSupported = capabilitiesSenderCodec.Any(x => capabilitiesReceiverCodec.Contains(x)); WebRTC.Dispose(); return(isSupported); }
public static string GetEncoderTypeDescription(EncoderType type) { switch (type) { case EncoderType.Standard: return("pełny kod Gray'a"); case EncoderType.Half_1_2: return("1/2 kodu Gray'a"); case EncoderType.Quarter_1_4: return("1/4 kodu Gray'a"); default: return("Nieznany typ enkodera."); } }
/// <summary> /// Gets a new <see cref="ISequenceEncoder"/> instance of the <paramref name="encoderType"/>. /// </summary> /// <param name="encoderType">This <see cref="EncoderType"/>.</param> /// <returns>A new <see cref="ISequenceEncoder"/> instance of the <paramref name="encoderType"/>.</returns> public static ISequenceEncoder Get(this EncoderType encoderType) { switch (encoderType) { case EncoderType.Suffix: return(new TrimSuffixEncoder()); case EncoderType.Prefix: return(new TrimPrefixAndSuffixEncoder()); case EncoderType.Infix: return(new TrimInfixAndSuffixEncoder()); default: return(new NoEncoder()); } }
public ITagger Build(EncoderType encoderType) { switch (encoderType) { case EncoderType.Fhgaacenc: case EncoderType.Lame: case EncoderType.Nero: case EncoderType.Qaac: case EncoderType.Qaac64: return(new SimpleTagger(_cueSheet, _coverFilePath)); case EncoderType.OggVorbis: return(new OggVorbisTagger(_cueSheet, _coverFilePath)); default: throw new Exception(string.Format("No tagger is associated with '{0}'", encoderType)); } }
public static void Initialize(EncoderType type = EncoderType.Hardware, bool limitTextureSize = true) { // todo(kazuki): Add this event to avoid crash caused by hot-reload. // Dispose of all before reloading assembly. #if UNITY_EDITOR UnityEditor.AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; #endif // OpenGL APIs on windows/osx are not supported if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) { if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLCore || SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES2 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3) { Debug.LogError($"Not Support OpenGL API on {Application.platform}."); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; return; #else throw new NotSupportedException($"Not Support OpenGL API on {Application.platform} in Unity WebRTC."); #endif } } NativeMethods.RegisterDebugLog(DebugLog); #if UNITY_IOS && !UNITY_EDITOR NativeMethods.RegisterRenderingWebRTCPlugin(); #endif s_context = Context.Create(encoderType: type); NativeMethods.SetCurrentContext(s_context.self); s_syncContext = SynchronizationContext.Current; var flipShader = Resources.Load <Shader>("Flip"); if (flipShader != null) { flipMat = new Material(flipShader); } s_limitTextureSize = limitTextureSize; }
public void EncodeNewLineCharacterCorrectly(EncoderType encoderType) { var encoder = new IMessageEncode[] { Encoders.InternationalSystem, Encoders.JapaneseEvent, Encoders.JapaneseSystem, Encoders.TurkishSystem }[(int)encoderType]; var encoded = encoder.Encode(new List <MessageCommandModel> { new MessageCommandModel { Command = MessageCommand.PrintText, Text = "HE\nLLO", } }); Assert.Equal(new byte[] { 0x35, 0x32, 0x02, 0x39, 0x39, 0x3C }, encoded); }
private void IterateCleanUp(EncoderType encoderType, NameValueCollection collection, int index) { switch (encoderType) { case EncoderType.Javascript: { collection[collection.Keys[index]] = Encoder.JavaScriptEncode(collection[index]); break; } case EncoderType.HtmlFragment: { collection[collection.Keys[index]] = _regexHelper.IsNumber(collection[index]) ? collection[index] : Sanitizer.GetSafeHtmlFragment(collection[index]); break; } case EncoderType.Html: { collection[collection.Keys[index]] = Encoder.HtmlEncode(collection[index]); } break; case EncoderType.HtmlAttribute: { collection[collection.Keys[index]] = Encoder.HtmlAttributeEncode(collection[index]); } break; case EncoderType.AutoDetect: { if (_regexHelper.ExecFor(_xssDetectRegex, collection[index])) { collection[collection.Keys[index]] = Encoder.JavaScriptEncode(collection[index]); } break; } } }
public static bool CheckVideoSendRecvCodecSupport(EncoderType encoderType) { // hardware encoder is not supported if (encoderType == EncoderType.Hardware && !NativeMethods.GetHardwareEncoderSupport()) { return(false); } WebRTC.Initialize(encoderType); var capabilitiesSenderCodec = RTCRtpSender.GetCapabilities(TrackKind.Video) .codecs .Select(x => x.mimeType) .Except(excludeCodecMimeType); var capabilitiesReceiverCodec = RTCRtpReceiver.GetCapabilities(TrackKind.Video) .codecs .Select(x => x.mimeType) .Except(excludeCodecMimeType); var isSupported = capabilitiesSenderCodec.Any(x => capabilitiesReceiverCodec.Contains(x)); WebRTC.Dispose(); return(isSupported); }
public static IAlphabetEncoder CreateEncoder(EncoderType encoding) { switch (encoding) { case EncoderType.Caesar: return(new CaesarEncoder()); case EncoderType.Trithemius: return(new TrithemiusEncoder()); case EncoderType.Stierlitz: return(new StierlitzEncoder()); case EncoderType.Vigenere: return(new VigenereEncoder()); case EncoderType.DiffiHelman: return(new DiffiHelmanEncoder()); case EncoderType.SHA1: return(new SHA1Encoder()); case EncoderType.MD5: return(new MD5Encoder()); case EncoderType.DSA: return(new DSAEncoder()); case EncoderType.Elgamal: return(new ElgamalEncoder()); case EncoderType.RSA: return(new RSAEncoder()); } throw new Exception("Not implemented encoding."); }
private void IterateCleanUp(EncoderType encoderType, NameValueCollection collection, int index) { switch (encoderType) { case EncoderType.Javascript: { collection[collection.Keys[index]] = Encoder.JavaScriptEncode(collection[index]); break; } case EncoderType.HtmlFragment: { collection[collection.Keys[index]] = _regexProcessor.IsNumber(collection[index]) ? collection[index] : Sanitizer.GetSafeHtmlFragment(collection[index]); break; } case EncoderType.Html: { collection[collection.Keys[index]] = Encoder.HtmlEncode(collection[index]); } break; case EncoderType.HtmlAttribute: { collection[collection.Keys[index]] = Encoder.HtmlAttributeEncode(collection[index]); } break; case EncoderType.AutoDetect: { if (_regexProcessor.ExecFor(_xssDetectRegex, collection[index])) { collection[collection.Keys[index]] = Encoder.JavaScriptEncode(collection[index]); } break; } } }
public void GetAnotherTest() { EncoderType enc = EncodingTypes.GetEncodingType(comboBoxEncoding.SelectedItem.ToString()); _currentquestionByTesting = QuestionByTestingHolder.GetQuestionByTestings(enc) .FirstOrDefault(p => p.AnswerType == AnswerType.Defoult); //if (_currentquestionByTesting == null) //{ // return; //} if (_testingCach != null) { tabPage3.Controls.Clear(); tabPage3.Controls.Add(_testingCach); } if (_currentquestionByTesting == null) { return; } lbDescription.Text = _currentquestionByTesting.Description; _testingCount = QuestionByTestingHolder.GetQuestionByTestings(enc).Count; lbAllQuestions.Text = _testingCount.ToString(); _currentTask = 0; lbCurrentTask.Text = _currentTask.ToString(); cLB.Items.Clear(); foreach (var s in _currentquestionByTesting.Questions) { cLB.Items.Add($"{s.Key}-{s.Value}"); } }
public void Validate() { if (string.IsNullOrWhiteSpace(EncoderString)) { throw new OptionException("Missing encoder type.", "e"); } EncoderType encoderType; if (!Enum.TryParse(EncoderString, true, out encoderType)) { throw new OptionException(string.Format("Encoder '{0}' is not recognized.", EncoderString), "e"); } EncoderType = encoderType; if (string.IsNullOrWhiteSpace(CueFilePath)) { throw new OptionException("Missing cue file path arg.", "i"); } if (!File.Exists(CueFilePath)) { throw new Exception(string.Format("Cue file at '{0}' not found.", CueFilePath)); } if (string.IsNullOrWhiteSpace(OutputPath)) { throw new OptionException("Missing output path arg.", "o"); } if (!string.IsNullOrWhiteSpace(CoverPath) && !File.Exists(CoverPath)) { throw new Exception(string.Format("Cover file at '{0}' not found.", CoverPath)); } }
public static extern IntPtr ContextCreate(int uid, EncoderType encoderType);
/// <summary> /// Decodifica una cadena /// </summary> public static string Decode(EncoderType intEncoder, string strCharSet, string strSource, bool blnSubject) { return GetEncoder(intEncoder).Decode(strCharSet, strSource, blnSubject); }
public static Context Create(int id = 0, EncoderType encoderType = EncoderType.Hardware) { var ptr = NativeMethods.ContextCreate(id, encoderType); return(new Context(ptr, id)); }
/// <summary> /// Decodifica una cadena sobre un archivo /// </summary> public static void DecodeToFile(EncoderType intEncoder, string strCharSet, string strSource, string strFileName) { Encoders.Tools.FileHelper.Save(GetEncoder(intEncoder).DecodeToBytes(strCharSet, strSource, false), strFileName); }
/// <summary> /// Decodifica una cadena sobre un archivo /// </summary> public static void DecodeToFile(EncoderType intEncoder, string strSource, string strFileName) { DecodeToFile(intEncoder, null, strSource, strFileName); }
/// <summary> /// Obtiene el codificador /// </summary> public static Encoders.IEncoder GetEncoder(EncoderType intEncoder) { switch (intEncoder) { case EncoderType.Base64: return new Encoders.Base64Encoder(); case EncoderType.Bit7: return new Encoders.Bit7Encoder(); case EncoderType.Bit8: return new Encoders.Bit8Encoder(); case EncoderType.Dummy: return new Encoders.DummyEncoder(); case EncoderType.QuotedPrintable: return new Encoders.QuotedPrintableEncoder(); default: throw new NotImplementedException(); } }
/// <summary> /// Codifica una cadena /// </summary> public static string Encode(EncoderType intEncoder, string strSource, bool blnSubject) { return GetEncoder(intEncoder).Encode(null, strSource, blnSubject); }
private static extern int EasyScreenLive_StartCapture(IntPtr pusherHandle, SOURCE_TYPE eSourceType, string szURL, int nCamId, int nAudioId, IntPtr hCapWnd, EncoderType encodeType, int nVideoWidth = 1280, int nVideoHeight = 720, int nFps = 30, int nBitRate = 1024, string szDataType = "RGB24", //VIDEO PARAM int nSampleRate = 44100, int nChannel = 2, bool bTransCode = false, ENCODE_MODE encodeMode = 0);
/// <summary> /// Codifica una cadena /// </summary> public static string Encode(EncoderType intEncoder, string strSource) { return Encode(intEncoder, strSource, false); }
/// <summary> /// Create an instance from an attribute dictionary. /// </summary> /// <param name="attrs">A set of <see cref="DictionaryAttribute"/> keys and their associated values.</param> /// <seealso cref="DictionaryMetadataBuilder"/> public DictionaryMetadata(IDictionary <DictionaryAttribute, string> attrs) { this.boolAttributes = new Dictionary <DictionaryAttribute, bool>(); this.attributes = new Dictionary <DictionaryAttribute, string>(); IDictionary <DictionaryAttribute, string> attributeMap = new Dictionary <DictionaryAttribute, string>(DefaultAttributes); foreach (var attr in attrs) { attributes[attr.Key] = attr.Value; attributeMap[attr.Key] = attr.Value; } // Convert some attrs from the map to local fields for performance reasons. ISet <DictionaryAttribute> requiredAttributes = new HashSet <DictionaryAttribute>(RequiredAttributes); foreach (var e in attributeMap) { requiredAttributes.Remove(e.Key); // Run validation and conversion on all of them. object value = e.Key.FromString(e.Value); switch (e.Key) { case DictionaryAttribute.Encoding: this.encoding = e.Value; this.charset = (Encoding)value; break; case DictionaryAttribute.Separator: this.separatorChar = (char)value; break; case DictionaryAttribute.Culture: this.locale = (CultureInfo)value; break; case DictionaryAttribute.Encoder: this.encoderType = (EncoderType)value; break; case DictionaryAttribute.InputConversion: { IDictionary <string, string> gvalue = (IDictionary <string, string>)value; this.inputConversion = gvalue; } break; case DictionaryAttribute.OutputConversion: { IDictionary <string, string> gvalue = (IDictionary <string, string>)value; this.outputConversion = gvalue; } break; case DictionaryAttribute.ReplacementPairs: { IDictionary <string, IList <string> > gvalue = (IDictionary <string, IList <string> >)value; this.replacementPairs = gvalue; } break; case DictionaryAttribute.EquivalentChars: { IDictionary <char, IList <char> > gvalue = (IDictionary <char, IList <char> >)value; this.equivalentChars = gvalue; } break; case DictionaryAttribute.IgnorePunctuation: case DictionaryAttribute.IgnoreNumbers: case DictionaryAttribute.IgnoreCamelCase: case DictionaryAttribute.IgnoreAllUpperCase: case DictionaryAttribute.IgnoreDiacritics: case DictionaryAttribute.ConvertCase: case DictionaryAttribute.RunOnWords: case DictionaryAttribute.FrequencyIncluded: this.boolAttributes[e.Key] = (bool)value; break; case DictionaryAttribute.Author: case DictionaryAttribute.License: case DictionaryAttribute.CreationDate: // Just run validation. e.Key.FromString(e.Value); break; default: throw new Exception("Unexpected code path (attribute should be handled but is not): " + e.Key); } } if (requiredAttributes.Any()) { throw new ArgumentException(string.Format(StringFormatter.CurrentCulture, "At least one the required attributes was not provided: {0}", requiredAttributes)); } // Sanity check. Encoding encoder = Encoder; var encoded = encoder.GetBytes(new char[] { separatorChar }); if (encoded.Length > 1) { throw new ArgumentException("Separator character is not a single byte in encoding " + encoding + ": " + separatorChar); } this.separator = encoded[0]; }
/// <summary> /// 開始音視頻數據捕捉 /// 返回1正常 /// </summary> /// <param name="pusherHandle">EasyPusher_Create返回值</param> /// <param name="eSourceType">推送數據源</param> /// <param name="hCapWnd">預覽句柄</param> /// <param name="encodeType">编码类型</param> /// <param name="szDataType">推送數據類型</param> /// <param name="nBitRate">比特率</param> /// <returns></returns> public static int EasyScreenLive_StartCapture(IntPtr pusherHandle, SOURCE_TYPE eSourceType, string szURL, IntPtr hCapWnd, EncoderType encodeType, string szDataType = "RGB24", int nWidth = 1280, int nHeight = 720, int nBitRate = 2048, bool bTranscode = false, ENCODE_MODE encMode = 0) { //注意:第五个参数是音频采集,0:采集,-1:不采集,没有音频输入一定要赋值-1 var ret = EasyScreenLive_StartCapture(pusherHandle, eSourceType, szURL, 0, -1, hCapWnd, encodeType, nVideoWidth: nWidth, nVideoHeight: nHeight, nBitRate: nBitRate, szDataType: szDataType, bTransCode: bTranscode, encodeMode: encMode); return(ret); }
/// <summary> /// 開始音視頻數據捕捉 /// 返回1正常 /// </summary> /// <param name="pusherHandle">EasyPusher_Create返回值</param> /// <param name="eSourceType">推送數據源</param> /// <param name="hCapWnd">預覽句柄</param> /// <param name="encodeType">编码类型</param> /// <param name="szDataType">推送數據類型</param> /// <param name="nBitRate">比特率</param> /// <returns></returns> public static int EasyScreenLive_StartCapture(IntPtr pusherHandle, SOURCE_TYPE eSourceType, string szURL, IntPtr hCapWnd, EncoderType encodeType, string szDataType = "RGB24", int nWidth = 1280, int nHeight = 720, int nBitRate = 2048, bool bTranscode = true) { var ret = EasyScreenLive_StartCapture(pusherHandle, eSourceType, szURL, 0, 0, hCapWnd, encodeType, nVideoWidth: nWidth, nVideoHeight: nHeight, nBitRate: nBitRate, szDataType: szDataType, bTransCode: bTranscode); return(ret); }
public void StartEncode(EncoderType encoderType) { #if MACOSX || IOS int ftype = BaseEnc.COCOA_AUDIOUNIT_ADTS; int atype = BaseEnc.COCOA_AUDIOUNIT_AAC; int bitrate = 128; _encoderHandle = BaseEnc.EncodeStartCA(_mixerChannel.Handle, ftype, atype, BASSEncode.BASS_ENCODE_AUTOFREE, bitrate * 1000, null, IntPtr.Zero); #else //sprintf(com,"lame -r -s 44100 -b %d -",bitrate); // add "-x" for LAME versions pre-3.98 //sprintf(com,"oggenc -r -R 44100 -M %d -m %d -",bitrate,bitrate); var flags = BASSEncode.BASS_ENCODE_NOHEAD | BASSEncode.BASS_ENCODE_AUTOFREE; switch (encoderType) { case EncoderType.OGG: _encoderHandle = BaseEnc.EncodeStart(_mixerChannel.Handle, "oggenc -r -R 44100 -M 128 -m 128 -", flags, null, IntPtr.Zero); break; case EncoderType.MP3: _encoderHandle = BaseEnc.EncodeStart(_mixerChannel.Handle, "lame -r -x -s 44100 -b 128 -", flags, null, IntPtr.Zero); break; default: throw new ArgumentOutOfRangeException("encoderType"); } #endif }
public IEncoder Build(EncoderType encoderType) { int qualityAsInt = (int)decimal.Truncate(_quality); switch (encoderType) { case EncoderType.Fhgaacenc: { return(new AacEncoder( qualityAsInt, (inputFilePath, outputFilePath, quality) => new Builder("fhgaacenc.exe") .AppendDoubleDash( "vbr", qualityAsInt.ToString(), Builder.SeparatorType.Space, Builder.QuoteValue.No) .AppendDoubleDash("quiet") .AppendValue(inputFilePath) .AppendValue(outputFilePath) .ToString())); } case EncoderType.Lame: { return(new Mp3Encoder( qualityAsInt, (inputFilePath, outputFilePath, quality) => new Builder("lame.exe") .AppendDash( "V", qualityAsInt.ToString(), Builder.SeparatorType.None, Builder.QuoteValue.No) .AppendDoubleDash("silent") .AppendValue(inputFilePath) .AppendValue(outputFilePath) .ToString())); } case EncoderType.Nero: { return(new AacEncoder( _quality, (inputFilePath, outputFilePath, quality) => new Builder("neroaacenc.exe") .AppendDash( "q", quality.ToString("0.00"), Builder.SeparatorType.Space, Builder.QuoteValue.No) .AppendDash("if", inputFilePath, Builder.SeparatorType.Space) .AppendDash("of", outputFilePath, Builder.SeparatorType.Space) .ToString())); } case EncoderType.OggVorbis: { return(new OggVorbisEncoder( _quality, (inputFilePath, outputFilePath, quality) => new Builder("oggenc2.exe") .AppendDash( "q", quality.ToString("0.00"), Builder.SeparatorType.Space, Builder.QuoteValue.No) .AppendDash("o", outputFilePath, Builder.SeparatorType.Space) .AppendValue(inputFilePath) .ToString())); } case EncoderType.Qaac: case EncoderType.Qaac64: { return(new AacEncoder( qualityAsInt, (inputFilePath, outputFilePath, quality) => new Builder((encoderType == EncoderType.Qaac) ? "qaac.exe" : "qaac64.exe") .AppendDoubleDash("silent") .AppendDoubleDash( "tvbr", ((int)decimal.Truncate(quality)).ToString(), Builder.SeparatorType.Space, Builder.QuoteValue.No) .AppendDash("o", outputFilePath, Builder.SeparatorType.Space) .AppendValue(inputFilePath) .ToString())); } default: { throw new Exception(string.Format("No encoder is associated with '{0}'", encoderType)); } } }
public void OneTimeInit() { encoderType = EncoderType.Software; }
public static string GetName(EncoderType type) => _data[type];
/// <summary> /// Decodifica una cadena /// </summary> public static string Decode(EncoderType intEncoder, string strSource, bool blnSubject) { return Decode(intEncoder, null, strSource, blnSubject); }
public DataResult <TheoryEntity> GetTheory(EncoderType encodingType) { DataResult <TheoryEntity> methodResult = new DataResult <TheoryEntity>(); DataResult <TheorysByCript> dataResult = _jsonParser.TheorysByCript(); if (!dataResult.Success) { methodResult.Message = dataResult.Message; return(methodResult); } foreach (var theor in dataResult.Data.TheoryEntitys) { if (theor.EncodingType != encodingType) { continue; } if (theor.Title != null) { if (theor.Title.FontSize < 2) { theor.Title.FontSize = TheotyStandartConfig.TitleFontSize; } if (theor.Title.Color == null) { theor.Title.Color = TheotyStandartConfig.Color; } } if (theor.TheoryTextByImages != null && theor.TheoryTextByImages.Any()) { foreach (var textByImage in theor.TheoryTextByImages) { if (textByImage.TheoryTextEntity != null) { if (textByImage.TheoryTextEntity.FontSize < 2) { textByImage.TheoryTextEntity.FontSize = TheotyStandartConfig.TitleFontSize; } if (theor.Title.Color == null) { textByImage.TheoryTextEntity.Color = TheotyStandartConfig.Color; } } if (textByImage.TheoryImageEntity != null) { if (!File.Exists(textByImage.TheoryImageEntity.Path)) { textByImage.TheoryImageEntity = null; if (textByImage.TheoryTextEntity != null) { textByImage.TheoryTextEntity.HorisontalAligment = Enum.HorisontalAligment.Center; } } else { if (textByImage.TheoryImageEntity.Size == null) { textByImage.TheoryImageEntity.Size = TheotyStandartConfig.ImageSize; } if ( textByImage.TheoryImageEntity.HorisontalAligment == Enum.HorisontalAligment.Center && textByImage.TheoryTextEntity != null) { textByImage.TheoryImageEntity.HorisontalAligment = Enum.HorisontalAligment.Left; textByImage.TheoryTextEntity.HorisontalAligment = Enum.HorisontalAligment.Right; } if (textByImage.TheoryTextEntity != null && textByImage.TheoryTextEntity.HorisontalAligment == textByImage.TheoryImageEntity.HorisontalAligment) { textByImage.TheoryImageEntity.HorisontalAligment = Enum.HorisontalAligment.Left; textByImage.TheoryTextEntity.HorisontalAligment = Enum.HorisontalAligment.Right; } } } } } methodResult.Success = true; methodResult.Data = theor; return(methodResult); } return(methodResult); }
/// <summary> /// 发送语音数据. /// </summary> /// <param name="request"> /// CreateTranscriberRequest所建立的request对象. /// </param> /// <param name="data"> /// 语音数据. /// </param> /// <param name="dataSize"> /// 语音数据长度(建议每次100ms左右数据). /// </param> /// <param name="type"> /// ENCODER_NONE 表示原始音频进行传递, 建议每次100ms音频数据,支持16K和8K; /// ENCODER_OPU 表示以定制OPUS压缩后进行传递, 只支持20ms 16K16b1c; /// ENCODER_OPUS 表示以OPUS压缩后进行传递, 只支持20ms, 支持16K16b1c和8K16b1c. /// </param> /// <returns> /// 成功则返回0, 失败返回-1. /// 由于音频格式不确定, 传入音频字节数和传出音频字节数, 无法通过比较判断成功与否, 故成功返回0. /// </returns> public int SendAudio(SpeechTranscriberRequest request, byte[] data, UInt64 dataSize, EncoderType type) { return(NativeMethods.STsendAudio(request.native_request, data, dataSize, (int)type)); }
public static ErrorCode SetSensorType(void *handle, EncoderType sensorType) { return(driver.c_SparkMax_SetSensorType(handle, sensorType)); }