public override void SetupSignalTracing(CpuNode cpuNode, Register register, ChannelMode channelMode) { // Make sure the CpuNode is present in our dictionary if (DebugChannels.ContainsKey(cpuNode)) { if (!this.DebugChannels[cpuNode].ContainsValue(register) && channelMode != ChannelMode.Off) { for (byte i = 0; i < 255; i++) { if (!register.CpuNode.DebugChannels.ContainsKey(i)) { this.DebugChannels[cpuNode].Add(i, register); break; } } } if (this.DebugChannels[cpuNode].ContainsValue(register)) { Version protocolVersion = cpuNode.ProtocolVersion; ConfigChannelMessage msg = new ConfigChannelMessage() { ChannelId = this.DebugChannels[cpuNode].First(x => x.Value.Id == register.Id).Key, Mode = channelMode, Offset = register.Offset, Control = MessageCodec.GetControlByte(protocolVersion, register.ReadWrite, register.Source, register.DerefDepth), Size = register.Size, }; SendMessage(cpuNode.Id, msg); if (this.DebugChannels[cpuNode].ContainsValue(register) && channelMode == ChannelMode.Off) { this.DebugChannels[cpuNode].Remove(this.DebugChannels[cpuNode].First(x => x.Value.Id == register.Id).Key); } } } }
public void AddMode(ChannelMode mode) { if (!Modes.Contains(mode)) { Modes.Add(mode); } }
public void RemoveMode(ChannelMode mode) { if (Modes.Contains(mode)) { Modes.Remove(mode); } }
public override void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas) { base.LoadFromXML(xmlElement, canvas); _channelType = ChannelType.Unicast; try { _channelType = (ChannelType)int.Parse(xmlElement.GetAttribute(TAG_PRO_CHANNEL_TYPE)); } catch { } _channelMode = ChannelMode.Normal; try { _channelMode = (ChannelMode)int.Parse(xmlElement.GetAttribute(TAG_PRO_CHANNEL_MODE)); } catch { } _id = xmlElement.GetAttribute(TAG_PRO_CHANNEL_ID); if (_id != null && _id.Length == 0) { _id = null; } //Hashtable _pros = TransitionCondition; //WSNUtil.LoadPNTranProperties(xmlElement, ref _pros); }
public bool UpdateChannelMode(Register register, ChannelMode channelMode) { bool result = false; if (!register.CpuNode.DebugChannels.ContainsValue(register)) { for (byte i = 0; i < register.CpuNode.MaxNumberOfDebugChannels; i++) { if (!register.CpuNode.DebugChannels.ContainsKey(i)) { register.CpuNode.DebugChannels.Add(i, register); this.modelManager.DebugProtocol.ConfigChannel(register.CpuID, i, channelMode, register); result = true; break; } } } else { int channelId = register.CpuNode.DebugChannels.FirstOrDefault(x => x.Value == register).Key; this.modelManager.DebugProtocol.ConfigChannel(register.CpuID, (byte)channelId, channelMode, register); if (channelMode == ChannelMode.Off) { this.modelManager.DebugChannels.Remove((byte)channelId); } } return(result); }
protected Channel CreateChannel(string path, ChannelMode mode) { Channel channel = new Channel(); bindChannel(channel); channel.Connect(URL + "/" + path, mode); return channel; }
internal PCANChannel(PCANAdapter adapter) { m_parent = adapter; m_mode = ChannelMode.Extended; m_handle = adapter.Handle; m_receivers = new List <IReceiveEntity>(); m_receivers.Add(m_noQueueReceived); }
public static string ChannelMode(string channel, ChannelMode mode, ChannelAction action) { string actionName = $"{(char)action}"; string modeName = $"{(char)mode}"; string command = $"MODE {channel} {actionName}{modeName}"; return(command); }
private void Client_MessageReceived(object sender, MessageReceivedEventArgs e) { var ircMessage = new IrcMessage(e.Message); switch (ircMessage.Command) { case "001": OnLoggedIn(); break; case "JOIN": { string userName = ircMessage.GetUserName(); string channel = ircMessage.GetChannel(); if (UserName.Equals(userName)) { OnChannelJoined(channel); } else { OnUserJoined(userName, channel); } break; } case "PART": { string userName = ircMessage.GetUserName(); string channel = ircMessage.GetChannel(); if (UserName.Equals(userName)) { OnChannelParted(channel); } else { OnUserParted(userName, channel); } break; } case "PING": string serverAddress = ircMessage.GetParameterByIndex(0); OnPingReceived(serverAddress); break; case "MODE": var channelMode = new ChannelMode(ircMessage); OnChannelModeReceived(channelMode); break; default: OnUnprocessedIrcMessageReceived(ircMessage); break; } OnIrcMessageReceived(ircMessage); }
public static int XingHeaderOffset(TagLib.Mpeg.Version version, ChannelMode channelMode) { bool flag = channelMode == ChannelMode.SingleChannel; if (version == TagLib.Mpeg.Version.Version1) { return (!flag ? 0x24 : 0x15); } return (!flag ? 0x15 : 13); }
public static string ChannelMode(string channel, ChannelMode mode, ChannelAction action, List <string> modeParams) { string param = $" {string.Join(" ", modeParams)}"; string actionName = $"{(char)action}"; string modeName = $"{(char)mode}"; string command = $"MODE {channel} {actionName}{modeName}{param}"; return(command); }
private void SetMode(bool set, string channel, ChannelMode mode, string nickname) { ChannelModeInfo modeInfo = new ChannelModeInfo(); modeInfo.Mode = mode; modeInfo.Parameter = nickname; modeInfo.Set = set; Bot.IRC.Command.SendMode(channel, modeInfo); }
private void method_7(string string_1, int int_0, byte[] byte_0, int int_1, ChannelMode channelMode_0, int int_2) { if ((byte_0 != null) && (byte_0.Length != 0)) { if (int_1 <= 0) { throw new ArgumentException("Value of fragmentSize must be greater than 0."); } if (string_1 == null) { string_1 = "_0"; } int num3 = Interlocked.Increment(ref this.eycfKeykKx); int num2 = byte_0.Length / int_1; if ((byte_0.Length % int_1) > 0) { num2++; } for (int i = 0; i < num2; i++) { if (!(this.interface31_0.Connected.Value || (channelMode_0 == ChannelMode.ByP2PChannel))) { throw new Exception("The connection to server is interrupted !"); } byte[] dst = null; if (i < (num2 - 1)) { dst = new byte[int_1]; } else { dst = new byte[byte_0.Length - (i * int_1)]; } Buffer.BlockCopy(byte_0, i * int_1, dst, 0, dst.Length); BlobFragmentContract body = new BlobFragmentContract(num3, int_0, i, dst, i == (num2 - 1)); IMessageHandler interface2 = this.interface9_0.imethod_4 <BlobFragmentContract>(this.string_0, int_2, body, string_1); bool flag = true; if ((string_1 == "_0") || (channelMode_0 == ChannelMode.TransferByServer)) { flag = this.interface31_0.imethod_0(interface2, false, ActionTypeOnChannelIsBusy.Continue); } else if (channelMode_0 == ChannelMode.P2PChannelFirst) { flag = this.interface31_0.Send(interface2, false, ActionTypeOnChannelIsBusy.Continue); } else { flag = this.interface31_0.SendByP2PChannel(interface2, ActionTypeOnNoP2PChannel.Discard, false, string_1, ActionTypeOnChannelIsBusy.Continue); } if (!flag) { throw new Exception("The connection is interrupted !"); } } } }
public Channel MakeChannel(ChannelMode mode) { var idx = NativeMethods.wirefox_peer_make_channel(m_handle, mode); var channel = new Channel { Index = idx, Mode = mode }; return(channel); }
public void OnChannelList( string channel, ChannelMode mode, string item, UserInfo who, long when, bool last ) { Assertion.AssertEquals("OnChannelList: channel", "#sharktest", channel ); Assertion.AssertEquals("OnChannelList: mode", ChannelMode.Ban, mode ); Assertion.AssertEquals("OnChannelList: item", "jocko!*@*", item ); Assertion.AssertEquals("OnChannelList: who", "Scurvy", who.Nick ); Assertion.Assert("OnChannelList: when", 120192129 == when ); Assertion.Assert( "OnChannelList: last", !last ); Console.WriteLine("OnChannelList"); }
protected string GetPNId(ChannelType type, ChannelMode mode) { string id = null; if (type >= 0 && mode >= 0) { id = type.ToString() + "_" + mode.ToString(); } return(id); }
public AudioCodecSettings() { downmixMode = ChannelMode.KeepOriginal; bitrateMode = BitrateManagementMode.CBR; bitrate = 128; delay = 0; delayEnabled = false; autoGain = true; forceDirectShow = false; improveAccuracy = true; }
/// <summary> /// Gets the offset at which a Xing header would appear in an /// MPEG audio packet based on the version and channel mode. /// </summary> /// <param name="version"> /// A <see cref="Version" /> value specifying the version of /// the MPEG audio packet. /// </param> /// <param name="channelMode"> /// A <see cref="ChannelMode" /> value specifying the channel /// mode of the MPEG audio packet. /// </param> /// <returns> /// A <see cref="int" /> value indicating the offset in an /// MPEG audio packet at which the Xing header would appear. /// </returns> public static int XingHeaderOffset(Version version, ChannelMode channelMode) { var single_channel = channelMode == ChannelMode.SingleChannel; if (version == Version.Version1) { return(single_channel ? 0x15 : 0x24); } return(single_channel ? 0x0D : 0x15); }
public override void Encode(string sourceFilePath, string destinationFilePath, int minBitrate, int maxBitrate, int sampleRate, ChannelMode channelMode) { var lameProcess = new Process(); lameProcess.StartInfo.FileName = GetLameExePath(); lameProcess.StartInfo.Arguments = GetLameExeArguments(sourceFilePath, destinationFilePath, minBitrate, maxBitrate, sampleRate, channelMode); lameProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; lameProcess.Start(); lameProcess.WaitForExit(); if (lameProcess.ExitCode != 0) throw new Exception(string.Format("lame.exe was terminated with an exit code of {0}.", lameProcess.ExitCode)); }
/// <summary> /// We only care about how to set mode in this channel /// we do not need to care about if the user is legal /// because MODEHandler will check for us /// </summary> /// <param name="changer"></param> /// <param name="cmd"></param> public void SetProperties(ChatChannelUser changer, MODERequest cmd) { switch (cmd.RequestType) { case ModeRequestType.AddChannelUserLimits: AddChannelUserLimits(cmd); break; case ModeRequestType.RemoveChannelUserLimits: RemoveChannelUserLimits(cmd); break; case ModeRequestType.AddBanOnUser: AddBanOnUser(cmd); break; case ModeRequestType.RemoveBanOnUser: RemoveBanOnUser(cmd); break; case ModeRequestType.AddChannelPassword: AddChannelPassword(cmd); break; case ModeRequestType.RemoveChannelPassword: RemoveChannelPassword(cmd); break; case ModeRequestType.AddChannelOperator: AddChannelOperator(cmd); break; case ModeRequestType.RemoveChannelOperator: RemoveChannelOperator(cmd); break; case ModeRequestType.EnableUserVoicePermission: EnableUserVoicePermission(cmd); break; case ModeRequestType.DisableUserVoicePermission: DisableUserVoicePermission(cmd); break; case ModeRequestType.SetChannelModesWithUserLimit: AddChannelUserLimits(cmd); goto default; default: ChannelMode.ChangeModes(cmd); break; } }
private void cbMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cbMode.SelectedIndex > -1) { mode = (ChannelMode)(cbMode.SelectedIndex); if (modeChanged != null) { modeChanged(channel, mode); } } }
private void ModifyChannelModes(Command curCommand, CommandMessage command) { string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; bool allowedMode = true; bool allowedCommand = Bot.CheckChannelAccess(channel, command.Nick.Nickname, curCommand.AllowedAccess); if (allowedCommand) { List <ChannelModeInfo> modeList = new List <ChannelModeInfo>(); if (command.Arguments.ContainsKey("Parameters")) { modeList = Bot.IRC.ParseChannelModeString(command.Arguments["Modes"], command.Arguments["Parameters"]); } else { modeList = Bot.IRC.ParseChannelModeString(command.Arguments["Modes"], string.Empty); } ChannelMode mode = ChannelMode.q; for (int i = 0; i < modeList.Count; i++) { switch (modeList[i].Mode) { case ChannelMode.v: case ChannelMode.h: case ChannelMode.o: case ChannelMode.a: case ChannelMode.q: allowedMode = Bot.CheckChannelAccess(channel, command.Nick.Nickname, Bot.ChannelModeMapping[modeList[i].Mode]); if (!allowedMode) { mode = modeList[i].Mode; } break; } } if (allowedMode) { Bot.IRC.Command.SendMode(channel, modeList); } else { string noAccessMessage = string.Format("You do not have access to set mode \u0002+{0}\u000F on \u0002{1}\u000F.", mode, channel); SendResponse(command.MessageType, command.Location, command.Nick.Nickname, noAccessMessage, true); } } else { string noAccessMessage = string.Format("You do not have access to use \u0002{0}\u000F on \u0002{1}\u000F.", command.Command, channel); SendResponse(command.MessageType, command.Location, command.Nick.Nickname, noAccessMessage, true); } }
private static string GetLameExeArguments(string sourceFilePath, string destinationFilePath, int minBitrate, int maxBitrate, int sampleRate, ChannelMode channelMode) { string arguments; if (minBitrate == maxBitrate) arguments = string.Format("-b {0}", minBitrate / 1000); else arguments = string.Format("-v -b {0} -B {1}", minBitrate / 1000, maxBitrate / 1000); arguments += string.Format(" --resample {0} -m {1} \"{2}\" \"{3}\"", sampleRate / 1000, channelMode.ToString().Substring(0, 1).ToLower(), sourceFilePath, destinationFilePath); return arguments; }
/// <summary> /// Construct a new ADS1115 /// </summary> /// <param name="i2c">The i2C port this ADC is attached to</param> /// <param name="channelMode">Whether this ADC is single-ended or differential</param> /// <param name="addr">The address pin of this module</param> /// <param name="refVoltage">The supply (reference) voltage of this module</param> /// <param name="speed">The speed to use when communicating with this module, in kHz</param> public Ads1115(I2C i2c, ChannelMode channelMode = ChannelMode.SingleEnded, bool addr = false, double refVoltage = 3.3, int speed = 400) { dev = new SMBusDevice((byte)(0x48 | (addr ? 1 : 0)), i2c, speed); Mode = channelMode; dev.WriteBufferDataAsync(0x01, new byte[] { 0x01, 0x83 }).Wait(); for (var i = 0; i < (channelMode == ChannelMode.SingleEnded ? 4 : 2); i++) { Pins.Add(new AdsPin(this)); } }
private void ModifyUserPrivilege(bool set, CommandMessage command, ChannelMode mode) { string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, Bot.ChannelModeMapping[mode])) { SetMode(set, channel, mode, command.Arguments["Nickname"]); } else { string noAccessMessage = string.Format("You do not have access to set mode \u0002+{0}\u000F for \u0002{1}\u000F on \u0002{2}\u000F.", mode, command.Arguments["Nickname"], channel); SendResponse(command.MessageType, command.Location, command.Nick.Nickname, noAccessMessage, true); } }
public AudioCodecSettings(string id, AudioCodec codec, AudioEncoderType encoder, int bitrate, BitrateManagementMode mode) { this.id = id; audioCodec = codec; audioEncoderType = encoder; downmixMode = ChannelMode.KeepOriginal; bitrateMode = mode; this.bitrate = bitrate; delay = 0; delayEnabled = false; autoGain = true; forceDirectShow = false; improveAccuracy = true; }
private void SetMode(bool set, string channel, ChannelMode mode, List <string> nicknames) { List <ChannelModeInfo> modeInfos = new List <ChannelModeInfo>(); foreach (var nickname in nicknames) { ChannelModeInfo modeInfo = new ChannelModeInfo(); modeInfo.Mode = mode; modeInfo.Parameter = nickname; modeInfo.Set = set; modeInfos.Add(modeInfo); } Bot.IRC.Command.SendMode(channel, modeInfos); }
public void SetDebugChannel(int nodeID, int registerID, ChannelMode mode) { if (!mm.Nodes.Any(x => x.Id == nodeID)) { return; } CpuNode node = mm.Nodes.First(x => x.Id == nodeID); if (!node.Registers.Any(x => x.Id == registerID)) { return; } node.Registers.First(x => x.Id == registerID).ChannelMode = mode; }
/// <summary> /// Initializes a new instance of the <see cref="ChannelModel" /> class. /// Creates a new Channel data model /// </summary> /// <param name="identity"> /// Name of the channel (or character, for Pms) /// </param> /// <param name="kind"> /// Type of the channel /// </param> /// <param name="mode"> /// The rules associated with the channel (only Ads, only posts, or both) /// </param> protected ChannelModel(string identity, ChannelType kind, ChannelMode mode = ChannelMode.Both) { try { Id = identity.ThrowIfNull("identity"); Type = kind; Mode = mode; LastReadCount = 0; } catch (Exception ex) { ex.Source = "Channel Model, init"; Exceptions.HandleException(ex); } }
public AudioCodecSettings(string id, AudioCodec codec, AudioEncoderType encoder, int bitrate, BitrateManagementMode mode) { this.id = id; audioCodec = codec; audioEncoderType = encoder; downmixMode = ChannelMode.KeepOriginal; bitrateMode = mode; this.bitrate = bitrate; autoGain = false; applyDRC = false; normalize = 100; preferredDecoder = AudioDecodingEngine.NicAudio; timeModification = TimeModificationMode.KeepOriginal; sampleRate = SampleRateMode.KeepOriginal; }
public void Setup([Implicit] ICallContext context, Baudrate baudrate, ChannelMode mode) { if (context != null && context.LoggingEnabled) { context.Logger.Log("Setup", $"( {baudrate}, {mode} )"); } m_baudrate = baudrate; m_mode = mode; if (m_open && m_receiverThread == null) { m_receiverThread = new Thread(new ThreadStart(this.ReceiveThreadHandler)); m_receiverThread.Start(); //Core.Main.ServiceManager.Get<> } }
/// <summary> /// Initializes a new instance of the <see cref="ChannelModel" /> class. /// Creates a new Channel data model /// </summary> /// <param name="identity"> /// Name of the channel (or character, for Pms) /// </param> /// <param name="kind"> /// Type of the channel /// </param> /// <param name="mode"> /// The rules associated with the channel (only Ads, only posts, or both) /// </param> protected ChannelModel(string identity, ChannelType kind, ChannelMode mode = ChannelMode.Both) { try { this.identity = identity.ThrowIfNull("identity"); Type = kind; Mode = mode; LastReadCount = 0; } catch (Exception ex) { ex.Source = "Channel Model, init"; Exceptions.HandleException(ex); } }
public Waveform(AudioFormat format, AudioStreamDelegate sampleGenerator, ChannelMode channelMode = ChannelMode.Stereo, int frequency = 44100) { _internalCallback = AudioCallback; SampleGenerator = sampleGenerator; ChannelMode = channelMode; Frequency = frequency; Handle = SDL2_nmix.NMIX_NewSource( format.SdlFormat, (byte)ChannelMode, Frequency, _internalCallback, IntPtr.Zero ); }
private void SetupTransport(string uri, ChannelMode mode) { graph = new ChannelGraph(); node = graph.ChannelFor<ChannelSettings>(x => x.Upstream); node.Mode = mode; node.Uri = new Uri(uri); node.Incoming = true; var delayedCache = new DelayedMessageCache<MessageId>(); queues = new PersistentQueues(new RecordingLogger()); queues.ClearAll(); transport = new LightningQueuesTransport(queues, new LightningQueueSettings()); transport.OpenChannels(graph); }
protected override void OnChannelModeReceived(ChannelMode channelMode) { if (channelMode.Modes.Contains("o")) { switch (channelMode.Action) { case ChannelModeActionType.Add: OnModeratorJoined(channelMode.ModeParams, channelMode.Channel); break; case ChannelModeActionType.Remove: OnModeratorParted(channelMode.ModeParams, channelMode.Channel); break; } } base.OnChannelModeReceived(channelMode); }
private void SetupTransport(string uri, ChannelMode mode) { graph = new ChannelGraph(); node = graph.ChannelFor <ChannelSettings>(x => x.Upstream); node.Mode = mode; node.Uri = new Uri(uri); node.Incoming = true; var delayedCache = new DelayedMessageCache <MessageId>(); queues = new PersistentQueues(new RecordingLogger()); queues.ClearAll(); transport = new LightningQueuesTransport(queues, new LightningQueueSettings()); transport.OpenChannels(graph); }
public GeneralChannelModel( string channelName, ChannelType type, int users = 0, ChannelMode mode = ChannelMode.Both) : base(channelName, type, mode) { try { if (users < 0) { throw new ArgumentOutOfRangeException(nameof(users), "Users cannot be a negative number"); } UserCount = users; CharacterManager = new ChannelCharacterManager(); Settings = new ChannelSettingsModel(); // the message count now faces the user, so when we reset it it now requires a UI update Messages.CollectionChanged += (s, e) => { if (e.Action != NotifyCollectionChangedAction.Reset) { return; } LastReadCount = Messages.Count; UpdateBindings(); }; Ads.CollectionChanged += (s, e) => { if (e.Action != NotifyCollectionChangedAction.Reset) { return; } LastReadAdCount = Ads.Count; UpdateBindings(); }; } catch (Exception ex) { ex.Source = "General Channel Model, init"; Exceptions.HandleException(ex); } }
public GeneralChannelModel( string channelName, ChannelType type, int users = 0, ChannelMode mode = ChannelMode.Both) : base(channelName, type, mode) { try { if (users < 0) throw new ArgumentOutOfRangeException("users", "Users cannot be a negative number"); UserCount = users; CharacterManager = new ChannelCharacterManager(); Settings = new ChannelSettingsModel(); // the message count now faces the user, so when we reset it it now requires a UI update Messages.CollectionChanged += (s, e) => { if (e.Action != NotifyCollectionChangedAction.Reset) return; LastReadCount = Messages.Count; UpdateBindings(); }; Ads.CollectionChanged += (s, e) => { if (e.Action != NotifyCollectionChangedAction.Reset) return; LastReadAdCount = Ads.Count; UpdateBindings(); }; } catch (Exception ex) { ex.Source = "General Channel Model, init"; Exceptions.HandleException(ex); } }
internal static Frame Create(uint ptr, ChannelMode mode) { return Create(ptr, mode, ContentType.Utf, null); }
public override bool CanChangeChannelMode(ChannelMode mode) { return false; }
internal static Frame Create(uint ptr, ChannelMode mode, ContentType ctype, byte[] payload) { return new Frame(ptr, OpCode.Open, (byte)mode, ctype, payload); }
public abstract bool CanChangeChannelMode(ChannelMode mode);
/// <summary> /// Converts a ChannelMode into its RFC2812 character. /// </summary> /// <param name="mode">The mode enum.</param> /// <returns>The corresponding char.</returns> public static char ChannelModeToChar( ChannelMode mode ) { return Convert.ToChar( (byte) mode, CultureInfo.InvariantCulture ) ; }
/// <summary> /// Change a channel's mode. /// </summary> /// <remarks> /// Possible Errors /// <list type="bullet"> /// <item><description>ERR_NEEDMOREPARAMS</description></item> /// <item><description>ERR_KEYSET</description></item> /// <item><description>ERR_NOCHANMODES</description></item> /// <item><description>ERR_CHANOPRIVSNEEDED</description></item> /// <item><description>ERR_USERNOTINCHANNEL</description></item> /// <item><description>ERR_UNKNOWNMODE</description></item> /// </list> /// </remarks> /// <param name="channel">The target channel.</param> /// <param name="action">Add or remove.</param> /// <param name="mode">The target mode.</param> /// <param name="param">An optional parameter for certain modes. If the mode /// does not require one this should be null.</param> /// <example><code> /// //Give 'nick' the ability to talk on a moderated channel, i.e. add Voice /// connection.Sender.ChangeChannelMode("#thresher", ModeAction.Add, ChannelMode.Voice,"nick" ); /// //Make a channel private /// connection.Sender.ChangeChannelMode( "#thresher", ModeAction.Add, ChannelMode.Private, null ); /// </code></example> /// <exception cref="ArgumentException">If the channel name is invalid.</exception> /// <seealso cref="Listener.OnChannelModeChange"/> public void ChangeChannelMode( string channel, ModeAction action, ChannelMode mode, string param ) { lock( this ) { if (!Rfc2812Util.IsValidChannelName(channel)) { ClearBuffer(); throw new ArgumentException(channel + " is not a valid channel."); } Buffer.Append("MODE"); Buffer.Append(SPACE); Buffer.Append( channel ); Buffer.Append(SPACE); Buffer.Append( Rfc2812Util.ModeActionToChar( action ) ); Buffer.Append( Rfc2812Util.ChannelModeToChar( mode ) ); if( !IsEmpty( param ) ) { Buffer.Append(SPACE); Buffer.Append( param ); } Connection.SendCommand( Buffer ); } }
internal void PushCommand(Command cmd) { if (cmd.Source == CommandSource.Client) return; switch (cmd.Token) { case "JCH": { var jch = cmd as Server_JCH_ChannelJoin; var character = Connection.GetOrCreateCharacter(jch.Character.Identity); if (!_Characters.Contains(character)) _Characters.Add(character); if (!string.IsNullOrEmpty(jch.Title)) { _Title = jch.Title; Joined = true; } else OnUserJoin?.Invoke(this, new ChannelUserEntryEventArgs(this, character, jch)); } return; case "LCH": { var lch = cmd as Server_LCH_ChannelLeave; var character = GetCharacter(lch.Character); _Characters.Remove(character); if (character.Name == Connection.LocalCharacter.Name) Dispose(); else OnUserLeave?.Invoke(this, new ChannelUserEntryEventArgs(this, character, lch)); } return; case "ICH": { var ich = cmd as Server_ICH_ChannelInitialData; _ChannelMode = ich.Mode; Joined = true; foreach (var user in ich.Users) { var ch = GetCharacter(user.Identity); if (!_Characters.Contains(ch)) _Characters.Add(ch); } } return; case "COL": { var col = cmd as Server_COL_ChannelGetOPs; foreach (var op in col.OPs) if (!string.IsNullOrWhiteSpace(op)) _OPs.Add(GetCharacter(op)); } return; case "CDS": { var cds = cmd as Server_CDS_ChannelChangeDescription; OnDescriptionChange?.Invoke(this, new ChannelEntryEventArgs<string>(this, cds.Description, cds)); _Description = cds.Description; } return; case "RMO": { var rmo = cmd as Server_RMO_ChannelSetMode; OnModeChange?.Invoke(this, new ChannelEntryEventArgs<ChannelMode>(this, rmo.Mode, rmo)); _ChannelMode = rmo.Mode; } return; case "CSO": { var cso = cmd as Server_CSO_ChannelSetOwner; OnOwnerChange?.Invoke(this, new ChannelEntryEventArgs<Character>(this, GetCharacter(cso.Character), cso)); _OwnerName = cso.Character; } return; case "RST": { var rst = cmd as Server_RST_ChannelSetStatus; OnStatusChange?.Invoke(this, new ChannelEntryEventArgs<ChannelStatus>(this, rst.Status, rst)); _Status = rst.Status; } return; case "COA": { var coa = cmd as Server_COA_ChannelMakeOP; var character = GetCharacter(coa.Character); _OPs.Add(character); OnOPAdded?.Invoke(this, new ChannelUserEntryEventArgs(this, character, coa)); } return; case "COR": { var cor = cmd as Server_COR_ChannelRemoveOP; var character = GetCharacter(cor.Character); _OPs.Remove(character); OnOPRemoved?.Invoke(this, new ChannelUserEntryEventArgs(this, character, cor)); } return; case "CKU": { var cku = cmd as Server_CKU_ChannelKickCharacter; var character = GetCharacter(cku.Character); _Characters.Remove(character); OnUserKicked?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cku.OP), cku)); } return; case "CBU": { var cbu = cmd as Server_CBU_ChannelBanCharacter; var character = GetCharacter(cbu.Character); _Characters.Remove(character); _Banlist.Add(character); OnUserBanned?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cbu.OP), cbu)); } return; case "CUB": { var cub = cmd as Server_CUB_ChannelUnbanCharacter; var character = GetCharacter(cub.Character); _Banlist.Remove(character); OnUserUnbanned?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cub.OP), cub)); } return; case "CTU": { var ctu = cmd as Server_CTU_ChannelTimeoutCharacter; var character = GetCharacter(ctu.Character); _Characters.Remove(character); OnUserTimedout?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(ctu.OP), ctu)); } return; case "MSG": { var msg = cmd as Server_MSG_ChannelChatMessage; OnChatMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(msg.Character), msg.Message, msg)); } return; case "LRP": { var lrp = cmd as Server_LRP_ChannelLFRPMessage; OnLFRPMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(lrp.Character), lrp.AD, lrp)); } return; case "RLL": { var rll = cmd as Server_RLL_ChannelRollMessage; OnRollMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(rll.Character), rll.Message, rll)); } return; case "SYS": { var sys = cmd as Server_SYS_ChatSYSMessage; OnSYSMessage?.Invoke(this, new ChannelEntryEventArgs<string>(this, sys.Message, sys)); } return; } }
public override bool CanChangeChannelMode(ChannelMode mode) => true;
public AudioCodecSettings(string id, AudioCodec codec, AudioEncoderType encoder, int bitrate, BitrateManagementMode mode) { this.id = id; audioCodec = codec; audioEncoderType = encoder; downmixMode = ChannelMode.KeepOriginal; bitrateMode = mode; this.bitrate = bitrate; delay = 0; delayEnabled = false; autoGain = true; forceDirectShow = false; applyDRC = false; sampleRateType = 0; normalize = 100; }
/// <summary>checks if the four bytes represent a valid header, /// if they are, will parse the values into local properties /// </summary> private bool IsValidHeader(byte[] headerBytes) { if ((headerBytes[0] == 0xFF) && ((headerBytes[1] & 0xE0) == 0xE0)) { // TODO: could do with a bitstream class here mpegVersion = (MpegVersion)((headerBytes[1] & 0x18) >> 3); if (mpegVersion == MpegVersion.Reserved) { //throw new FormatException("Unsupported MPEG Version"); return false; } layer = (MpegLayer)((headerBytes[1] & 0x06) >> 1); if (layer == MpegLayer.Reserved) { return false; } int layerIndex = this.layer == MpegLayer.Layer1 ? 0 : this.layer == MpegLayer.Layer2 ? 1: 2; crcPresent = (headerBytes[1] & 0x01) == 0x00; int bitRateIndex = (headerBytes[2] & 0xF0) >> 4; if (bitRateIndex == 15) { // invalid index return false; } int versionIndex = this.mpegVersion == Wave.MpegVersion.Version1 ? 0 : 1; this.bitRate = bitRates[versionIndex, layerIndex, bitRateIndex] * 1000; if (bitRate == 0) { return false; } int sampleFrequencyIndex = (headerBytes[2] & 0x0C) >> 2; if (sampleFrequencyIndex == 3) { return false; } if (mpegVersion == MpegVersion.Version1) sampleRate = sampleRatesVersion1[sampleFrequencyIndex]; else if (mpegVersion == MpegVersion.Version2) sampleRate = sampleRatesVersion2[sampleFrequencyIndex]; else // mpegVersion == MpegVersion.Version25 sampleRate = sampleRatesVersion25[sampleFrequencyIndex]; bool padding = (headerBytes[2] & 0x02) == 0x02; bool privateBit = (headerBytes[2] & 0x01) == 0x01; channelMode = (ChannelMode)((headerBytes[3] & 0xC0) >> 6); int channelExtension = (headerBytes[3] & 0x30) >> 4; bool copyright = (headerBytes[3] & 0x08) == 0x08; bool original = (headerBytes[3] & 0x04) == 0x04; int emphasis = (headerBytes[3] & 0x03); int nPadding = padding ? 1 : 0; this.samplesInFrame = samplesPerFrame[versionIndex, layerIndex]; int coefficient = this.samplesInFrame / 8; if (this.layer == MpegLayer.Layer1) { this.frameLengthInBytes = (coefficient * bitRate / sampleRate + nPadding) * 4; } else { frameLengthInBytes = (coefficient * bitRate) / sampleRate + nPadding; } if (this.frameLengthInBytes > MaxFrameLength) { return false; } return true; } return false; }
public static int GetNumberOfChannels( ChannelMode mode ) { return mode == ChannelMode.SingleChannel ? 1 : 2; }
protected Channel CreateRandomChannel(ChannelMode mode, bool secure) { Channel channel = new Channel(); bindChannel(channel); channel.Connect((secure ? "https://" : "") + UniqueUrl(), mode); return channel; }
public override bool CanChangeChannelMode(ChannelMode mode) => false;
protected Channel CreateRandomChannel(ChannelMode mode) { return CreateRandomChannel(mode, false); }
public abstract void Encode(string sourceFilePath, string destinationFilePath, int minBitrate, int maxBitrate, int sampleRate, ChannelMode channelMode);
/// <summary>Reads an MP3Frame from a stream</summary> /// <remarks>http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm /// has some good info</remarks> public Mp3Frame(Stream input) { BinaryReader reader = new BinaryReader(input); // try for a header long headerStartPosition = input.Position; byte[] headerBytes = reader.ReadBytes(4); // Added -jam to play wrapped mp3 files via RIFF headerBytes = CheckForRiff(input, reader, headerBytes); if ((headerBytes[0] == 0xFF) && ((headerBytes[1] & 0xE0) == 0xE0)) { // TODO: could do with a bitstream class here mpegVersion = (MpegVersion)((headerBytes[1] & 0x18) >> 3); if (mpegVersion == MpegVersion.Reserved) { throw new FormatException("Unsupported MPEG Version"); } layer = (MpegLayer)((headerBytes[1] & 0x06) >> 1); if (layer != MpegLayer.Layer3) { throw new FormatException("Not an MP3"); } crcPresent = (headerBytes[1] & 0x01) == 0x00; int bitRateIndex = (headerBytes[2] & 0xF0) >> 4; bitRate = (mpegVersion == MpegVersion.Version1) ? bitRatesLayer3Version1[bitRateIndex] : bitRatesLayer3Version2[bitRateIndex]; int sampleFrequencyIndex = (headerBytes[2] & 0x0C) >> 2; if (mpegVersion == MpegVersion.Version1) sampleRate = sampleRatesVersion1[sampleFrequencyIndex]; else if (mpegVersion == MpegVersion.Version2) sampleRate = sampleRatesVersion2[sampleFrequencyIndex]; else // mpegVersion == MpegVersion.Version25 sampleRate = sampleRatesVersion25[sampleFrequencyIndex]; bool padding = (headerBytes[2] & 0x02) == 0x02; bool privateBit = (headerBytes[2] & 0x01) == 0x01; channelMode = (ChannelMode) ((headerBytes[3] & 0xC0) >> 6); int channelExtension = (headerBytes[3] & 0x30) >> 4; bool copyright = (headerBytes[3] & 0x08) == 0x80; bool original = (headerBytes[3] & 0x04) == 0x80; int emphasis = (headerBytes[3] & 0x03); frameLengthInBytes = (144 * 1000 * bitRate) / sampleRate + ((padding) ? 1 : 0); } else { input.Position = headerStartPosition; throw new FormatException("Not a recognised MP3 block"); } if (crcPresent) crc = reader.ReadInt16(); long dataStartPosition = input.Position; input.Position = headerStartPosition; rawData = reader.ReadBytes(frameLengthInBytes); }
public ServerChannelDetails(ChannelMode mode, int port) { Mode = mode; Port = port; }
/// <summary> /// Gets the offset at which a Xing header would appear in an /// MPEG audio packet based on the version and channel mode. /// </summary> /// <param name="version"> /// A <see cref="Version" /> value specifying the version of /// the MPEG audio packet. /// </param> /// <param name="channelMode"> /// A <see cref="ChannelMode" /> value specifying the channel /// mode of the MPEG audio packet. /// </param> /// <returns> /// A <see cref="int" /> value indicating the offset in an /// MPEG audio packet at which the Xing header would appear. /// </returns> public static int XingHeaderOffset(Version version, ChannelMode channelMode) { bool single_channel = channelMode == ChannelMode.SingleChannel; if (version == Version.Version1) return single_channel ? 0x15 : 0x24; else return single_channel ? 0x0D : 0x15; }
/// <summary> /// Connect to a remote server at specified <c>uri</c>, in specified /// <c>mode</c>. /// </summary> /// <param name="uri">The <c>uri</c> to server</param> /// <param name="mode">The <c>mode</c> to open channel in.</param> public void Connect (Uri uri, ChannelMode mode) { if (_state != ChannelState.Closed) { throw new Exception("Channel is already connecting/connected"); } if (uri == null) { throw new ArgumentNullException("uri", "Expected an Uri"); } if (uri.Scheme != "http" && uri.Scheme != "https") { throw new ArgumentException("uri", "Unsupported Scheme"); } if (uri.Scheme == "https" && Connection.hasTlsSupport == false) { throw new ArgumentException("uri", "TLS is not supported"); } if (uri.Query != null && uri.Query.Length > 0) { token = Encoding.UTF8.GetBytes(uri.Query.Substring(1)); } _mode = mode; _uri = uri; try { _connection = Connection.create(this, uri); } catch (Exception ex) { token = null; _mode = ChannelMode.Listen; throw ex; } _state = ChannelState.Connecting; }
/// <summary> /// Request the list of users that a channel keeps for the given mode.. /// </summary> /// <remarks> /// Each channel maintains a list of those banned, those excepted from a ban, /// those on automatic invite, and the channel creator. Use this method to retreieve one /// of those lists. /// </remarks> /// <param name="channel">The taregt channel.</param> /// <param name="mode">Must be one of: /// Ban, Exception, Invitation, or ChannelCreator. /// </param> /// <example><code> /// //Request the channel's banned list /// connection.Sender.RequestChannelList("#thresher", ChannelMode.Ban ); /// </code></example> /// <exception cref="ArgumentException">If the channel is invalid or the ChannelMode is /// not one of the 4 allowed types.</exception> /// <seealso cref="Listener.OnChannelList"/> public void RequestChannelList( string channel, ChannelMode mode ) { lock( this ) { if (!Rfc2812Util.IsValidChannelName(channel)) { ClearBuffer(); throw new ArgumentException(channel + " is not a valid channel."); } if( mode != ChannelMode.Ban && mode != ChannelMode.Exception && mode != ChannelMode.Invitation && mode != ChannelMode.ChannelCreator ) { ClearBuffer(); throw new ArgumentException( Enum.GetName( typeof(ChannelMode), mode ) + " is not a valid channel mode for this request."); } Buffer.Append("MODE"); Buffer.Append(SPACE); Buffer.Append( channel ); Buffer.Append(SPACE); Buffer.Append( Rfc2812Util.ChannelModeToChar( mode ) ); Connection.SendCommand( Buffer ); } }
/// <summary> /// Connect to a remote server at specified <c>url</c>, in specified /// <c>mode</c>. /// </summary> /// <param name="url">The <c>url</c> (e.g. public.hydna.net)</param> /// <param name="mode">The <c>mode</c> to open channel in.</param> public void Connect (string url, ChannelMode mode) { Uri uri; if (url == null) { throw new ArgumentNullException("url", "Expected an Url"); } if (url.Contains("://") == false) { UriBuilder builder = new UriBuilder("http://" + url); uri = builder.Uri; } else { uri = new Uri(url); } Connect(uri, mode); }