/// <summary> /// Get the current status of the streaming and recording outputs /// </summary> /// <returns>An <see cref="OutputStatus"/> object describing the current outputs states</returns> public OutputStatus GetStreamingStatus() { JObject response = SendRequest("GetStreamingStatus"); var outputStatus = new OutputStatus(response); return(outputStatus); }
public void Refresh() { if (websocket.IsConnected) { MidiObserver.Display(EMidiOBSItemType.ReloadOBSData, EMidiOBSOutputType.Off, -1, -1, true); var studiomode = websocket.StudioModeEnabled(); Mode = studiomode ? 2 : 1; OutputStatus = websocket.GetStreamingStatus(); CurrentTransition = websocket.GetCurrentTransition(); LoadSources(); LoadScenesAndSources(); LoadTransitions(); if (studiomode) { ActivePScene = -1; var pscene = websocket.GetPreviewScene(); ActivePSceneName = pscene.Name; for (int i = 0; i < Scenes.Count(); i++) { if (Scenes[i].Name == ActivePSceneName) { ActivePScene = i; } } } MidiObserver.Display(EMidiOBSItemType.ReloadOBSData, EMidiOBSOutputType.On, -1, -1, true); MidiObserver.RenderSurface(); } }
public void StartRecording() { Policy .Handle <Exception>() .WaitAndRetry(retryCount: 5, sleepDurationProvider: (retryAttempt) => TimeSpan.FromSeconds(1)) .Execute(() => { try { if (settings.OBS.RecordingEnabled) { obs.Connect(settings.OBS.WebSocketEndpoint, password: null); OutputStatus status = obs.GetStreamingStatus(); if (!status.IsRecording) { obs.StartRecording(); } obs.Disconnect(); } } catch (Exception e) { logger.LogError(e, $"There was an setting the game scene"); } }); }
public OutputData(string rootKeyId, string keyId, uint nChild, ulong value, OutputStatus status, ulong height, ulong lockHeight, bool isCoinbase) { RootKeyId = rootKeyId; KeyId = keyId; NChild = nChild; Value = value; Status = status; Height = height; LockHeight = lockHeight; IsCoinbase = isCoinbase; }
/// <summary> /// Send a sound file to play /// </summary> /// <param name="soundUri"></param> /// <returns></returns> public bool SendSound(string soundUri) { OutputStatus outputFormat = new OutputStatus { SoundToPlay = soundUri }; Send(Utility.SerializationUtility.Serialize(outputFormat)); return(true); }
public void OBSOutputStatus_BuildFromJSON() { var data = new JObject(); data.Add("streaming", true); data.Add("recording", true); var outputState = new OutputStatus(data); Assert.IsTrue(outputState.IsStreaming); Assert.IsTrue(outputState.IsRecording); }
public void OpenFile(string destPath, Parameters parameters, CodecToken videoCodecToken) { this.parameters = parameters; this.currVideoCodecToken = videoCodecToken; //TODO - try creating the file once first before we let vfw botch it up? //open the avi output file handle if (File.Exists(destPath)) { File.Delete(destPath); } if (Win32.FAILED(Win32.AVIFileOpenW(ref pAviFile, destPath, Win32.OpenFileStyle.OF_CREATE | Win32.OpenFileStyle.OF_WRITE, 0))) { throw new InvalidOperationException("Couldnt open dest path for avi file: " + destPath); } //initialize the video stream Win32.AVISTREAMINFOW vidstream_header = new Win32.AVISTREAMINFOW(); Win32.BITMAPINFOHEADER bmih = new Win32.BITMAPINFOHEADER(); parameters.PopulateBITMAPINFOHEADER24(ref bmih); vidstream_header.fccType = Win32.mmioFOURCC("vids"); vidstream_header.dwRate = parameters.fps; vidstream_header.dwScale = parameters.fps_scale; vidstream_header.dwSuggestedBufferSize = (int)bmih.biSizeImage; if (Win32.FAILED(Win32.AVIFileCreateStreamW(pAviFile, out pAviRawVideoStream, ref vidstream_header))) { CloseFile(); throw new InvalidOperationException("Failed opening raw video stream. Not sure how this could happen"); } //initialize audio stream Win32.AVISTREAMINFOW audstream_header = new Win32.AVISTREAMINFOW(); Win32.WAVEFORMATEX wfex = new Win32.WAVEFORMATEX(); parameters.PopulateWAVEFORMATEX(ref wfex); audstream_header.fccType = Win32.mmioFOURCC("auds"); audstream_header.dwQuality = -1; audstream_header.dwScale = wfex.nBlockAlign; audstream_header.dwRate = (int)wfex.nAvgBytesPerSec; audstream_header.dwSampleSize = wfex.nBlockAlign; audstream_header.dwInitialFrames = 1; // ??? optimal value? if (Win32.FAILED(Win32.AVIFileCreateStreamW(pAviFile, out pAviRawAudioStream, ref audstream_header))) { CloseFile(); throw new InvalidOperationException("Failed opening raw audio stream. Not sure how this could happen"); } outStatus = new OutputStatus(); IsOpen = true; }
public static void CheckStream() { streamStatus = obs.GetStreamingStatus(); if (startStream && !streamStatus.IsStreaming) { PhatOBS.StartStream(obs); startStream = false; } if (stopStream && streamStatus.IsStreaming) { PhatOBS.StopStream(obs); stopStream = false; } }
public async Task StartStopStream() { await this.OBSCommandTimeoutWrapper(() => { OutputStatus status = this.OBSWebsocket.GetStreamingStatus(); if (status.IsStreaming) { this.OBSWebsocket.StopStreaming(); } else { this.OBSWebsocket.StartStreaming(); } return(true); }); }
public Task StartStopStream() { try { OutputStatus status = this.OBSWebsocket.GetStreamingStatus(); if (status.IsStreaming) { this.OBSWebsocket.StopStreaming(); } else { this.OBSWebsocket.StartStreaming(); } } catch (Exception ex) { Logger.Log(ex); } return(Task.FromResult(0)); }
/// <summary> /// Devuelve una instancia de <see cref="AccessoryDecoderOperationCommand"/>. /// </summary> /// <param name="block">El bloque con las propiedades que debe tomar físicamente.</param> public AccessoryDecoderOperationCommand(BlockBase block) { _block = block; _address = block.DigitalAddress; // Determina la salida a activar if (block.Connection == OTCBlockConnection.S1StarightS2Turned && block.Status == OTCBlockStatus.Red_Straight) { _out = AccessoryDecoderOperationCommand.Outputs.Output1; } else { _out = AccessoryDecoderOperationCommand.Outputs.Output2; } _status = OutputStatus.Activated; }
private void runADBShell(string shellcommand) { CmdStatus = OutputStatus.Busy; OutputData = string.Empty; bytesOutputfixed = null; timer.Start(); bytesOutputfixed = Fix0d0d0a(RunAdbProcess(shellcommand)); timer.Stop(); OutputData = System.Text.Encoding.ASCII.GetString(bytesOutputfixed).Replace((char)0x0a, ' '); if (shellcommand.Contains("shell screencap -p") || shellcommand.Contains("shell dumpsys window")) { //System.IO.File.WriteAllBytes(@"D:\1fix.png", bytesOutputfixed); OutputText = shellcommand + " (received " + bytesOutputfixed.Length.ToString() + ") "; } else { if (string.IsNullOrEmpty(OutputData)) { OutputText = shellcommand + " "; } else { OutputText = OutputData.Replace("\r", ""); } } if (shellcommand.Contains("getprop") && string.IsNullOrEmpty(OutputData)) { OutputText = "no devices"; } if (Output != null) { Output(null, new EventArgsOutput() { Output = OutputText + "--> " + timer.Duration.ToString() + "\r\n" }); } CmdStatus = OutputStatus.Success; }
private SOBSStreamingState _translateStreamingStatus(OutputStatus input) { var state = new SOBSStreamingState(); if (input.IsRecording) { state.Record = EOBSStreamingState.Started; } else { state.Record = EOBSStreamingState.Stopped; } if (input.IsStreaming) { state.Stream = EOBSStreamingState.Started; } else { state.Stream = EOBSStreamingState.Stopped; } return(state); }
public void OpenFile(string destPath, Parameters parameters, CodecToken videoCodecToken) { this.parameters = parameters; this.currVideoCodecToken = videoCodecToken; //TODO - try creating the file once first before we let vfw botch it up? //open the avi output file handle if (File.Exists(destPath)) File.Delete(destPath); if (Win32.FAILED(Win32.AVIFileOpenW(ref pAviFile, destPath, Win32.OpenFileStyle.OF_CREATE | Win32.OpenFileStyle.OF_WRITE, 0))) throw new InvalidOperationException("Couldnt open dest path for avi file: " + destPath); //initialize the video stream Win32.AVISTREAMINFOW vidstream_header = new Win32.AVISTREAMINFOW(); Win32.BITMAPINFOHEADER bmih = new Win32.BITMAPINFOHEADER(); parameters.PopulateBITMAPINFOHEADER24(ref bmih); vidstream_header.fccType = Win32.mmioFOURCC("vids"); vidstream_header.dwRate = parameters.fps; vidstream_header.dwScale = parameters.fps_scale; vidstream_header.dwSuggestedBufferSize = (int)bmih.biSizeImage; if (Win32.FAILED(Win32.AVIFileCreateStreamW(pAviFile, out pAviRawVideoStream, ref vidstream_header))) { CloseFile(); throw new InvalidOperationException("Failed opening raw video stream. Not sure how this could happen"); } //initialize audio stream Win32.AVISTREAMINFOW audstream_header = new Win32.AVISTREAMINFOW(); Win32.WAVEFORMATEX wfex = new Win32.WAVEFORMATEX(); parameters.PopulateWAVEFORMATEX(ref wfex); audstream_header.fccType = Win32.mmioFOURCC("auds"); audstream_header.dwQuality = -1; audstream_header.dwScale = wfex.nBlockAlign; audstream_header.dwRate = (int)wfex.nAvgBytesPerSec; audstream_header.dwSampleSize = wfex.nBlockAlign; audstream_header.dwInitialFrames = 1; // ??? optimal value? if (Win32.FAILED(Win32.AVIFileCreateStreamW(pAviFile, out pAviRawAudioStream, ref audstream_header))) { CloseFile(); throw new InvalidOperationException("Failed opening raw audio stream. Not sure how this could happen"); } outStatus = new OutputStatus(); IsOpen = true; }
public OutputStatusReportReplyEventArgs(Guid connectionId, byte address, OutputStatus outputStatus) { ConnectionId = connectionId; Address = address; OutputStatus = outputStatus; }
/// <summary> /// Wraps sending messages to the connected descriptor /// </summary> /// <param name="strings">the output</param> /// <returns>success status</returns> public bool SendOutput(IEnumerable <string> strings) { //TODO: Stop hardcoding this but we have literally no sense of injury/self status yet SelfStatus self = new SelfStatus { Body = new BodyStatus { Health = _currentPlayer.CurrentHealth == 0 ? 100 : 100 / (2M * _currentPlayer.CurrentHealth), Stamina = _currentPlayer.CurrentStamina, Overall = OverallStatus.Excellent, Anatomy = new AnatomicalPart[] { new AnatomicalPart { Name = "Arm", Overall = OverallStatus.Good, Wounds = new string[] { "Light scrape" } }, new AnatomicalPart { Name = "Leg", Overall = OverallStatus.Excellent, Wounds = new string[] { } } } }, CurrentActivity = _currentPlayer.CurrentAction, Balance = _currentPlayer.Balance.ToString(), CurrentArt = _currentPlayer.LastAttack?.Name ?? "", CurrentCombo = _currentPlayer.LastCombo?.Name ?? "", CurrentTarget = _currentPlayer.GetTarget() == null ? "" : _currentPlayer.GetTarget() == _currentPlayer ? "Your shadow" : _currentPlayer.GetTarget().GetDescribableName(_currentPlayer), CurrentTargetHealth = _currentPlayer.GetTarget() == null || _currentPlayer.GetTarget() == _currentPlayer ? double.PositiveInfinity : _currentPlayer.GetTarget().CurrentHealth == 0 ? 100 : 100 / (2 * _currentPlayer.CurrentHealth), Position = _currentPlayer.StancePosition.ToString(), Stance = _currentPlayer.Stance, Stagger = _currentPlayer.Stagger.ToString(), Qualities = string.Join("", _currentPlayer.Qualities.Where(quality => quality.Visible).Select(quality => string.Format("<div class='qualityRow'><span>{0}</span><span>{1}</span></div>", quality.Name, quality.Value))), CurrentTargetQualities = _currentPlayer.GetTarget() == null || _currentPlayer.GetTarget() == _currentPlayer ? "" : string.Join("", _currentPlayer.GetTarget().Qualities.Where(quality => quality.Visible).Select(quality => string.Format("<div class='qualityRow'><span>{0}</span><span>{1}</span></div>", quality.Name, quality.Value))), Mind = new MindStatus { Overall = OverallStatus.Excellent, States = new string[] { "Fearful" } } }; IGlobalPosition currentLocation = _currentPlayer.CurrentLocation; IContains currentContainer = currentLocation.CurrentLocation(); IZone currentZone = currentContainer.CurrentLocation.CurrentZone; ILocale currentLocale = currentLocation.CurrentLocale; IRoom currentRoom = currentLocation.CurrentRoom; IGaia currentWorld = currentZone.GetWorld(); IEnumerable <string> pathways = Enumerable.Empty <string>(); IEnumerable <string> inventory = Enumerable.Empty <string>(); IEnumerable <string> populace = Enumerable.Empty <string>(); string locationDescription = string.Empty; LexicalContext lexicalContext = new LexicalContext(_currentPlayer) { Language = _currentPlayer.Template <IPlayerTemplate>().Account.Config.UILanguage, Perspective = NarrativePerspective.SecondPerson, Position = LexicalPosition.Near }; Message toCluster = new Message(currentContainer.RenderToVisible(_currentPlayer)); if (currentContainer != null) { pathways = ((ILocation)currentContainer).GetPathways().Select(data => data.GetDescribableName(_currentPlayer)); inventory = currentContainer.GetContents <IInanimate>().Select(data => data.GetDescribableName(_currentPlayer)); populace = currentContainer.GetContents <IMobile>().Where(player => !player.Equals(_currentPlayer)).Select(data => data.GetDescribableName(_currentPlayer)); locationDescription = toCluster.Unpack(TargetEntity.Actor, lexicalContext); } LocalStatus local = new LocalStatus { ZoneName = currentZone?.TemplateName, LocaleName = currentLocale?.TemplateName, RoomName = currentRoom?.TemplateName, Inventory = inventory.ToArray(), Populace = populace.ToArray(), Exits = pathways.ToArray(), LocationDescriptive = locationDescription }; //The next two are mostly hard coded, TODO, also fix how we get the map as that's an admin thing ExtendedStatus extended = new ExtendedStatus { Horizon = new string[] { "A hillside", "A dense forest" }, VisibleMap = currentLocation.CurrentRoom == null ? string.Empty : currentLocation.CurrentRoom.RenderCenteredMap(3, true) }; string timeOfDayString = string.Format("The hour of {0} in the day of {1} in {2} in the year of {3}", currentWorld.CurrentTimeOfDay.Hour , currentWorld.CurrentTimeOfDay.Day , currentWorld.CurrentTimeOfDay.MonthName() , currentWorld.CurrentTimeOfDay.Year); string sun = "0"; string moon = "0"; string visibilityString = "5"; Tuple <string, string, string[]> weatherTuple = new Tuple <string, string, string[]>("", "", new string[] { }); if (currentZone != null) { Tuple <PrecipitationAmount, PrecipitationType, HashSet <WeatherType> > forecast = currentZone.CurrentForecast(); weatherTuple = new Tuple <string, string, string[]>(forecast.Item1.ToString(), forecast.Item2.ToString(), forecast.Item3.Select(wt => wt.ToString()).ToArray()); visibilityString = currentZone.GetCurrentLuminosity().ToString(); if (currentWorld != null) { IEnumerable <ICelestial> bodies = currentZone.GetVisibileCelestials(_currentPlayer); ICelestial theSun = bodies.FirstOrDefault(cest => cest.Name.Equals("sun", StringComparison.InvariantCultureIgnoreCase)); ICelestial theMoon = bodies.FirstOrDefault(cest => cest.Name.Equals("moon", StringComparison.InvariantCultureIgnoreCase)); if (theSun != null) { ICelestialPosition celestialPosition = currentWorld.CelestialPositions.FirstOrDefault(celest => celest.CelestialObject == theSun); sun = AstronomicalUtilities.GetCelestialLuminosityModifier(celestialPosition.CelestialObject, celestialPosition.Position, currentWorld.PlanetaryRotation , currentWorld.OrbitalPosition, currentZone.Template <IZoneTemplate>().Hemisphere, currentWorld.Template <IGaiaTemplate>().RotationalAngle).ToString(); } if (theMoon != null) { ICelestialPosition celestialPosition = currentWorld.CelestialPositions.FirstOrDefault(celest => celest.CelestialObject == theMoon); moon = AstronomicalUtilities.GetCelestialLuminosityModifier(celestialPosition.CelestialObject, celestialPosition.Position, currentWorld.PlanetaryRotation , currentWorld.OrbitalPosition, currentZone.Template <IZoneTemplate>().Hemisphere, currentWorld.Template <IGaiaTemplate>().RotationalAngle).ToString(); } } } EnvironmentStatus environment = new EnvironmentStatus { Sun = sun, Moon = moon, Visibility = visibilityString, Weather = weatherTuple, Temperature = currentZone.EffectiveTemperature().ToString(), Humidity = currentZone.EffectiveHumidity().ToString(), TimeOfDay = timeOfDayString }; OutputStatus outputFormat = new OutputStatus { Occurrence = EncapsulateOutput(strings), Self = self, Local = local, Extended = extended, Environment = environment }; Send(Utility.SerializationUtility.Serialize(outputFormat)); return(true); }
private static void Obs_Connected(object sender, EventArgs e) { streamStatus = obs.GetStreamingStatus(); }