protected override void OnCommonUpdate() { base.OnCommonUpdate(); if (this.LocalUser.UserID == "U-guillefix") { UniLog.Log("Update"); if (record_skeleton) { foreach (var item in joint_slots) { User user = item.Key; List <Slot> slots = item.Value; Slot root_slot = slots[0]; float3 root_global_position = root_slot.GlobalPosition; floatQ root_global_rotation = root_slot.GlobalRotation; output_file.Write(root_global_position.ToString() + "," + root_global_rotation.ToString()); for (int i = 1; i < slots.Count; i++) { Slot slot = slots[i]; float3 global_position = slot.GlobalPosition; floatQ global_rotation = slot.GlobalRotation; float3 relative_position = root_slot.GlobalPointToLocal(global_position); floatQ relative_rotation = root_slot.GlobalRotationToLocal(global_rotation); output_file.Write("," + relative_position.ToString() + "," + relative_rotation.ToString()); } output_file.Write("\n"); } } } }
public override object CreateInstance(Type neosType) { Data.OverloadSetting typeOverloadSetting = GetOverload(neosType); if (typeOverloadSetting is null) { UniLog.Log($"Missing Component overload for {neosType.FullName}"); return(null); } Component instance = InstanceSlot.AttachComponent(typeOverloadSetting.OverloadType ?? neosType.FullName); if (typeOverloadSetting.Initializer != null) { try { //Create a new environment each time LuaTable environment = LuaInstance.CreateEnvironment(); environment.DefineFunction("FindType", new Func <string, Type>(luaFindType)); //Set "Instance" to point to the component we want to modify environment.SetMemberValue("Instance", instance); //Compile and run the initializer script LuaInstance.CompileChunk(typeOverloadSetting.Initializer, "Init.lua", new LuaCompileOptions() { ClrEnabled = false }).Run(environment); } catch (Exception ex) { UniLog.Log($"Unable to run initializer on {typeOverloadSetting.OverloadType}: {ex}"); return(null); } } return(instance); }
public void Save() { // Encode and save to file. string fileName = DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss") + ".bvh"; string filePath = Path.Combine(Path.GetTempPath(), fileName); UniLog.Log("Recording Name: " + fileName); UniLog.Log("Temp Path: " + Path.GetTempPath()); UniLog.Log("Recording File Path: " + filePath); FileStream fs = File.Create(filePath); Encoder.EncodeAnimationSet(RecordingCache, fs); fs.Close(); // Load the new asset into Neos DB. Uri uri = Engine.LocalDB.ImportLocalAsset(filePath, LocalDB.ImportLocation.Move); Binary binary = new Binary(); binary.SetURL(uri); UniLog.Log("Recording URL: " + uri.ToString()); // Spawn into world. Output.Target.URL.Value = uri; }
public void StartRecording() { World currentWorld = metagen_comp.World; current_users_ids = new List <string>(); currentWorld.RunSynchronously(() => { foreach (var item in metagen_comp.userMetaData) { User user = item.Key; UserMetadata metadata = item.Value; if (!metadata.isRecording || (metagen_comp.LocalUser == user && !metagen_comp.record_local_user)) { continue; } RefID user_id = user.ReferenceID; current_users_ids.Add(user_id.ToString()); Slot localSlot = user.Root.HeadSlot.AddLocalSlot("vision recorder camera"); FrooxEngine.Camera camera = localSlot.AttachComponent <FrooxEngine.Camera>(); camera.GetRenderSettings(camera_resolution); camera.NearClipping.Value = 0.15f; cameras[user_id] = camera; int fps = 30; visual_recorders[user_id] = new VideoRecorder(Path.Combine(saving_folder, user_id.ToString() + "_vision_tmp.avi"), camera_resolution.x, camera_resolution.y, fps, metagen_comp); } UniLog.Log("Made visual recorder"); isRecording = true; }); }
/// <summary> /// Calculates a new CompatabilityHash based on the specified networkVersion and /// the list of loaded plugins /// </summary> /// <param name="engine">FrooxEngine reference</param> /// <param name="networkVersion">the current network version from which to base the CompatabilityHash. -1 Means the value is determined automatically</param> /// <param name="loadedPlugins">additionally loaded assemblies, to factor into the CompatabilityHash</param> public static void OverrideHash(Engine engine, int networkVersion = -1, string versionString = null, Dictionary <string, string> loadedPlugins = null) { MD5CryptoServiceProvider csp = new MD5CryptoServiceProvider(); ConcatenatedStream hashStream = new ConcatenatedStream(); if (networkVersion == -1) { networkVersion = GetCurrentVersion(); } hashStream.EnqueueStream(new MemoryStream(BitConverter.GetBytes(networkVersion))); if (loadedPlugins != null) { string PluginsBase = PathUtility.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Plugins\\"; foreach (string assemblyPath in loadedPlugins.Keys) { try { FileStream fileStream = File.OpenRead(PluginsBase + assemblyPath); fileStream.Seek(375L, SeekOrigin.Current); hashStream.EnqueueStream(fileStream); } catch { UniLog.Log("Failed to load assembly for hashing: " + PluginsBase + assemblyPath); } } } AssemblyName currentAssemblyName = Assembly.GetExecutingAssembly().GetName(); SetHash(Convert.ToBase64String(csp.ComputeHash(hashStream)), versionString ?? (currentAssemblyName.Name + "-" + currentAssemblyName.Version), engine); }
public void StartInteracting() { UniLog.Log("Start Text interaction"); UniLog.Log("Attaching component"); client = metagen_comp.interaction_slot.GetComponent <WebsocketClient>(); if (client == null) { client = metagen_comp.interaction_slot.AttachComponent <WebsocketClient>(); } //client = metagen_comp.Slot.AttachComponent<WebsocketClient>(); UniLog.Log("Attached component"); //client.Connected += AddEventHandlers; client.TextMessageReceived += OnTextMessageReceived; client.BinaryMessageReceived += OnBinaryMessageReceived; //client.HandlingUser.Target = metagen_comp.LocalUser; client.HandlingUser.Target = FrooxEngine.Engine.Current.WorldManager.FocusedWorld.LocalUser; client.URL.Value = new Uri("ws://localhost:8765"); //client.URL.Value = new Uri("ws://localhost:8765"); //client.TextMessageReceived += OnTextMessageReceived; //client.BinaryMessageReceived += OnBinaryMessageReceived; bool could_read_output_field = metagen_comp.interaction_space.TryReadValue <Sync <string> >("output field", out output_field); bool could_read_input_field = metagen_comp.interaction_space.TryReadValue <Sync <string> >("input field", out input_field); if (input_field != null) { input_field.OnValueChange += new SyncFieldEvent <string>(OnInputFieldChanged); } isInteracting = true; }
public void StartRecording() { UniLog.Log("Start recording"); SetUpConfigSlot(); if (!dataManager.have_started_recording_session) { dataManager.StartRecordingSession(); } if (!recording) { dataManager.StartSection(); } recording = true; recording_state = OutputState.Starting; recording_frame_index = 0; //Set the recordings time to now utcNow = DateTime.UtcNow; recordingBeginTime = DateTime.UtcNow; if (!metaRecorder.isRecording) { metaRecorder.StartRecording(); } recording_state = OutputState.Started; }
public void StopRecording() { UniLog.Log("Stop recording"); metaDataManager.WriteUserMetaData(); if (recording) { foreach (var item in userMetaData) { User user = item.Key; UserMetadata metadata = item.Value; if (metadata.isRecording) { dataBase.UpdateRecordedTime(user.UserID, recording_time / 1000, metadata.isPublic); //in seconds } } } recording = false; recording_state = OutputState.Stopping; if (metaRecorder.isRecording) { metaRecorder.StopRecording(); } }
public void StartRecording() { current_users_ids = new List <string>(); saving_folder = metagen_comp.dataManager.saving_folder; foreach (var item in metagen_comp.userMetaData) { User user = item.Key; UserMetadata metadata = item.Value; if (!metadata.isRecording || (metagen_comp.LocalUser == user && !metagen_comp.record_local_user)) { continue; } RefID user_id = user.ReferenceID; current_users_ids.Add(user_id.ToString()); AvatarAudioOutputManager comp = user.Root.Slot.GetComponentInChildren <AvatarAudioOutputManager>(); AudioOutput audio_output = comp.AudioOutput.Target; audio_outputs[user_id] = audio_output; if (audio_outputs[user_id] == null) { UniLog.Log("OwO: Audio output for user " + user_id.ToString() + " is null!"); } else { UniLog.Log("Sample rate"); UniLog.Log(metagen_comp.Engine.AudioSystem.Connector.SampleRate.ToString()); audio_recorders[user_id] = new AudioRecorder(saving_folder + "/" + user_id.ToString() + "_voice_tmp", metagen_comp.Engine.AudioSystem.BufferSize, 1, metagen_comp.Engine.AudioSystem.SampleRate, 1); audio_recorders[user_id].StartWriting(); } } isRecording = true; }
public void StopRecording() { isRecording = false; foreach (var item in audio_recorders) { item.Value.WriteHeader(); } string saving_folder_inner = saving_folder; var current_users_ids_inner = current_users_ids; Task task1 = Task.Run(() => { foreach (string user_id in current_users_ids_inner) { UniLog.Log("Moving " + Path.Combine(saving_folder_inner, user_id + "_voice_tmp.wav")); //File.Move(saving_folder_inner + "/" + user_id + "_voice_tmp.wav", saving_folder_inner + "/" + user_id + "_voice.wav"); File.Move(Path.Combine(saving_folder_inner, user_id + "_voice_tmp.wav"), Path.Combine(saving_folder_inner, user_id + "_voice.wav")); } //current_users_ids = new List<string>(); }); task1.Wait(); audio_outputs = new Dictionary <RefID, AudioOutput>(); audio_recorders = new Dictionary <RefID, AudioRecorder>(); }
public void StartInteracting() { foreach (var item in metagen_comp.userMetaData) { User user = item.Key; UserMetadata metadata = item.Value; if (!(metadata.isRecording || metagen_comp.record_everyone)) { continue; } UniLog.Log("Starting voice interaction for user " + user.UserName); RefID user_id = user.ReferenceID; current_users_ids.Add(user_id.ToString()); AvatarAudioOutputManager comp = user.Root.Slot.GetComponentInChildren <AvatarAudioOutputManager>(); AudioOutput audio_output = comp.AudioOutput.Target; audio_outputs[user_id] = audio_output; isRecording[user_id] = false; if (audio_outputs[user_id] == null) { UniLog.Log("OwO: Audio output for user " + user_id.ToString() + " is null!"); } else { UniLog.Log("Sample rate"); UniLog.Log(metagen_comp.Engine.AudioSystem.Connector.SampleRate.ToString()); } } isInteracting = true; }
public void StartPlaying(int recording_index = 0, Slot avatar_template = null) { UniLog.Log("Start playing"); SetUpConfigSlot(); //playing = true; playing_state = OutputState.Started; playingBeginTime = DateTime.UtcNow; playing_frame_index = 0; if (use_grpc_player) { grpcStreamPlayer.generateAnimation = generate_animation_play; grpcStreamPlayer.generateBvh = recording_bvh; if (!grpcStreamPlayer.isPlaying) { grpcStreamPlayer.StartPlaying(avatar_template); } } else { streamPlayer.generateAnimation = generate_animation_play; streamPlayer.generateBvh = recording_bvh; if (!streamPlayer.isPlaying) { streamPlayer.StartPlaying(recording_index, avatar_template); } } }
public void StopInteracting() { UniLog.Log("Stop Text interaction"); client.URL.Value = null; client.TextMessageReceived -= OnTextMessageReceived; client.BinaryMessageReceived -= OnBinaryMessageReceived; isInteracting = false; }
public void RecordFrame(float deltaT) { bool streams_ok = (streamRecorder == null ? false : streamRecorder.isRecording) || !metagen_comp.recording_streams; bool eye_streams_ok = (eyeRecorder == null ? false : eyeRecorder.isRecording) || !metagen_comp.recording_faces; bool mouth_streams_ok = (mouthRecorder == null ? false : mouthRecorder.isRecording) || !metagen_comp.recording_faces; bool controller_streams_ok = (controllerRecorder == null ? false : controllerRecorder.isRecording) || !metagen_comp.recording_controllers; bool vision_ok = (visionRecorder == null ? false : visionRecorder.isRecording) || !metagen_comp.recording_vision; bool hearing_ok = (metagen_comp.hearingRecorder == null ? false : metagen_comp.hearingRecorder.isRecording) || !metagen_comp.recording_hearing; bool voice_ok = (voiceRecorder == null ? false : (voiceRecorder.isRecording && voiceRecorder.audio_sources_ready)) || !metagen_comp.recording_voice; bool all_ready = voice_ok && streams_ok && controller_streams_ok && eye_streams_ok && mouth_streams_ok && vision_ok && hearing_ok; //bool all_ready = hearing_ok; if (all_ready && streamRecorder == null? false : streamRecorder.isRecording) { UniLog.Log("recording pose streams"); streamRecorder.RecordStreams(deltaT); } if (all_ready && controllerRecorder == null? false : controllerRecorder.isRecording) { UniLog.Log("recording controller streams"); controllerRecorder.RecordStreams(deltaT); } if (all_ready && eyeRecorder == null? false : eyeRecorder.isRecording) { //UniLog.Log("recording streams"); eyeRecorder.RecordStreams(deltaT); } if (all_ready && mouthRecorder == null? false : mouthRecorder.isRecording) { //UniLog.Log("recording streams"); mouthRecorder.RecordStreams(deltaT); } if (all_ready && visionRecorder == null? false : visionRecorder.isRecording) { //UniLog.Log("recording vision"); //if (frame_index == 30) // hearingRecorder.videoStartedRecording = true; visionRecorder.RecordVision(); } if (all_ready && animationRecorder == null? false : animationRecorder.isRecording) { animationRecorder.RecordFrame(); } if (all_ready && bvhRecorder == null? false : bvhRecorder.isRecording) { bvhRecorder.RecordFrame(); } //if (recording && all_ready && recording_hearing_user != null && hearingRecorder==null? false : hearingRecorder.isRecording) //{ //} }
private void RemoveWorld(World world) { UniLog.Log("remove world " + world.RawName); //current_session_id = FrooxEngine.Engine.Current.WorldManager.FocusedWorld.SessionId; if (world.SessionId != null && metagens.ContainsKey(world.SessionId)) { metagens.Remove(world.SessionId); } }
/// <summary> /// Searches the MSIL in FrooxEngine.Initialize for the current network version /// </summary> /// <returns>Neos' current network version</returns> public static int GetCurrentVersion() { try { /* * Get AsyncStateMachine attribute for FrooxEngine.Initialize, since it is an Async method * This allows us to get the state machine's class from AsyncStateMachineAttribute.StateMachineType */ var asyncAttribute = typeof(FrooxEngine.Engine).GetMethod("Initialize", BindingFlags.Public | BindingFlags.Instance)?.GetCustomAttribute <AsyncStateMachineAttribute>(); if (asyncAttribute != null && asyncAttribute.StateMachineType != null) { //Get the .MoveNext method from our custom IAsyncStateMachine var asyncTargetMethodInfo = asyncAttribute.StateMachineType.GetMethod("MoveNext", BindingFlags.NonPublic | BindingFlags.Instance); if (asyncTargetMethodInfo != null) { //Read the MSIL from the MoveNext method var ops = HarmonyLib.PatchProcessor.GetOriginalInstructions(asyncTargetMethodInfo); /* * Store the method's local variable corresponding to a usage of ConcatenatedStream * which occurs near the target value. We can begin searching from here. */ var targetLocal = asyncTargetMethodInfo.GetMethodBody().LocalVariables.SingleOrDefault(l => l.LocalType == typeof(ConcatenatedStream)); for (int opIndex = 0; opIndex < ops.Count(); opIndex++) { var opcode = ops.ElementAt(opIndex); //Check if this opcode corresponds to the previously defined local if (opcode.IsLdloc(targetLocal as LocalBuilder)) { //If so, check the opcode 2 places ahead to see if it's a call to BitConverter.GetBytes(int) opcode = ops.ElementAt(opIndex + 2); if (opcode.Is(OpCodes.Call, typeof(BitConverter).GetMethod("GetBytes", new Type[] { typeof(int) }))) { //If so, check that the opcode 1 place ahead is a constant opcode = ops.ElementAt(opIndex + 1); if (opcode != null && opcode.LoadsConstant()) { //If it is a constant, then it's *probably* the correct constant for our purposes. if (opcode.operand is int version) { //Check if it's an int, and if so, assign it to NetworkVersion for use in OverrideHash below. return(version); } } } } } } } } catch (Exception ex) { UniLog.Log("Unable to determine Neos network version: " + ex); throw; } throw new Exception("Unable to determine neos version"); }
public override object CreateInstance(Type neosType) { Data.OverloadSetting typeOverloadSetting = GetOverload(neosType); if (typeOverloadSetting is null || typeOverloadSetting.OverloadType is null) { UniLog.Log($"Missing LogiX overload for {neosType.FullName}"); return(null); } return(InstanceSlot.AttachComponent(typeOverloadSetting.OverloadType)); }
//private void AddEventHandlers(WebsocketClient client) //{ // UniLog.Log("Websocket connected"); // client.TextMessageReceived += OnTextMessageReceived; // client.BinaryMessageReceived += OnBinaryMessageReceived; //} private void OnTextMessageReceived(WebsocketClient client, string msg) { //UniLog.Log("hi"); UniLog.Log(msg); UniLog.Log(output_field.Value); metagen_comp.World.RunSynchronously(() => { output_field.Value = msg; }); }
public void MaybeResetHearingUserOnJoin(User joined_user) { World world = FrooxEngine.Engine.Current.WorldManager.FocusedWorld; UniLog.Log("hi " + recording_hearing_user.UserID); if (recording_hearing_user.UserID == world.LocalUser.UserID) { UniLog.Log("h0"); ResetHearingUser(); } }
//protected override void OnPaste() protected void Setup() { //base.OnPaste(); //UniLog.Log("Transferred to userspace"); UniLog.Log("Setup"); //Remember that onPasting this component is reinitialized //so that changes made in the previous OnAttach won't be saved! //This records the audio from an audiolistener. Unfortunately we can only have one audiolistener in an Unity scene:/ //It starts/stops recording upon pressing the key R. //TODO: make below work in VR mode too //TODO: sync between audios and videos is not right!! UniLog.Log("Adding Audio Listener"); GameObject gameObject = GameObject.Find("AudioListener"); //default_record_local_user = true; if (!(LocalUser.HeadDevice == HeadOutputDevice.Screen)) //must be on VR mode { UniLog.Log("VR mode!"); //gameObject = GameObject.Find("Camera (ears)"); default_record_local_user = true; is_in_VR_mode = true; } //GameObject[] rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); //GameObject gameObject = rootObjects[0]; //for (int i = 0; i < rootObjects.Length; i++) //{ // AudioListener audioListener = rootObjects[i].GetComponentInChildren<UnityEngine.AudioListener>(); // if (audioListener != null) { // gameObject = audioListener.gameObject; // break; // } //} hearingRecorder = gameObject.AddComponent <UnityNeos.AudioRecorderNeos>(); //dataManager = new DataManager(); World currentWorld = FrooxEngine.Engine.Current.WorldManager.FocusedWorld; current_session_id = currentWorld.SessionId; //AddWorld(currentWorld); FrooxEngine.Engine.Current.WorldManager.WorldRemoved += RemoveWorld; //FrooxEngine.Engine.Current.WorldManager.WorldAdded += AddWorld; FrooxEngine.Engine.Current.WorldManager.WorldFocused += FocusedWorld; if (!is_in_VR_mode) { FrooxEngine.Engine.Current.Cloud.Messages.OnMessageReceived += ProcessMessage; } //FrooxEngine.Engine.Current.Cloud.Friends.FriendRequestCountChanged += ProcessFriendRequest; FrooxEngine.Engine.Current.Cloud.Friends.FriendAdded += ProcessFriendRequest; FrooxEngine.Engine.Current.Cloud.Friends.FriendRequestCountChanged += ProcessFriendRequest2; FrooxEngine.Engine.Current.Cloud.Friends.FriendRemoved += ProcessFriendRemoved; dataBase = new DataBase(); }
public void StopInteracting() { UniLog.Log("Stop interacting"); interacting = false; interacting_state = OutputState.Stopping; if (metaInteraction.isInteracting) { metaInteraction.StopInteracting(); } interacting_state = OutputState.Stopped; }
private void Elog(System.Object e) { try { string es; xlasterror = (string)e; } finally { UniLog.Log(e); } }
static private void DeleteFile(string fileName) { try { UniLog.Log("DELETING " + fileName); File.Delete(fileName); } catch (Exception e) { UniLog.Log("OwO: " + e.Message); Console.WriteLine(e.StackTrace); } }
public void StopPlaying() { UniLog.Log("Stop playing"); //playing = false; if (grpcStreamPlayer.isPlaying) { grpcStreamPlayer.StopPlaying(); } if (streamPlayer.isPlaying) { streamPlayer.StopPlaying(); } playing_state = OutputState.Stopped; }
protected void BuildWorkerSyncMembers(StringBuilder infoboxBuilder, Worker target, int indexOffset = 0) { try { for (int index = indexOffset; index < target.SyncMemberCount; ++index) { if (target.GetSyncMemberFieldInfo(index).GetCustomAttribute <HideInInspectorAttribute>() == null) { Type memberType = target.GetSyncMemberFieldInfo(index).FieldType; if (memberType.IsGenericType && memberType.GenericTypeArguments.Length > 0) { Type t = GetNeosWriteNodeOverload(memberType); if (t != null) { if (t.IsGenericType) { infoboxBuilder.AppendLine($"|{target.GetSyncMemberName(index)}|{t.Name.UppercaseFirst()}|TypeString{index - indexOffset}={t.GetNiceName().UppercaseFirst()}|"); } else { infoboxBuilder.AppendLine($"|{target.GetSyncMemberName(index)}|{t.GetNiceName().UppercaseFirst()}|"); } } else { UniLog.Log($"Missing WriteNode overload for {memberType.GetNiceName()}"); infoboxBuilder.AppendLine($"|{target.GetSyncMemberName(index)}|{memberType.Name.UppercaseFirst()}|TypeString{index - indexOffset}={memberType.GetNiceName().UppercaseFirst()}|"); } } else { if (target.GetSyncMember(index) is SyncObject syncField) { BuildWorkerSyncMembers(infoboxBuilder, syncField); } else { infoboxBuilder.AppendLine($"|{target.GetSyncMemberName(index)}|{memberType.GetNiceName().UppercaseFirst()}| "); } } } } } catch (Exception ex) { UniLog.Log(ex.Message); } }
private void SetUpDatabase() { if (!File.Exists(temp_database_file)) { UniLog.Log("Creating database file"); File.Create(temp_database_file); } using (var reader = new StreamReader(temp_database_file)) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { foreach (MetaGenUser item in csv.GetRecords <MetaGenUser>()) { _userData[item.userId] = item; } } }
public void InteractPoseStreams(float deltaT) { if (channel.State != ChannelState.Ready) { return; } try { //UniLog.Log("InteractPoseStreams"); foreach (var item in pose_writers) { RefID refID = item.Key; BinaryWriter writer = item.Value; //read heading bytes from GRPC //byte[] bs = null; ByteString bs1 = client.GetFrameBytes(new RefIDMessage { RefId = refID.ToString() }).Data; //writer.Write(bs1.ToByteArray()); //writer.BaseStream.Write(bs1.ToByteArray(),(int) writer.BaseStream.Position, bs1.Length); UniLog.Log(writer.BaseStream.Position); writer.Write(bs1.ToByteArray()); UniLog.Log(writer.BaseStream.Position); UniLog.Log(bs1.Length); writer.BaseStream.Position -= bs1.Length; //writer.Write(frame_bs); } metagen_comp.streamPlayer.PlayStreams(); metagen_comp.metaRecorder.streamRecorder.RecordStreams(deltaT); foreach (var item in pose_readers) { RefID refID = item.Key; BinaryReaderX reader = item.Value; //send heading bytes to GRPC byte[] byteArray = reader.ReadBytes((int)reader.BaseStream.Length); Google.Protobuf.ByteString byteString = Google.Protobuf.ByteString.CopyFrom(byteArray, 0, byteArray.Length); client.SendFrameBytes(new Frame { RefId = refID.ToString(), Data = byteString }); } } catch (Exception e) { UniLog.Log("OwO: " + e.Message); } }
private void FocusedWorld(World world) { if (currentWorld != null && !is_in_VR_mode) { try { if (currentWorld.IsAuthority) { Userspace.LeaveSession(currentWorld); } else { Userspace.EndSession(currentWorld); } } catch (Exception e) { UniLog.Log("Exception when leaving/ending session: " + e.Message); } } bool is_there_metagen_in_world = false; foreach (var item in metagens) { try { MetaGen metagen = item.Value; metagen.StopPlaying(); metagen.StopRecording(); //metagen.Destroy(); if (metagen.World == world) { is_there_metagen_in_world = true; } } catch (Exception e) { UniLog.Log("owo Exception when stopping the metagens when focusing a new world"); UniLog.Log("This could be because someone invited the bot while it was playing"); } } current_session_id = world.SessionId; currentWorld = world; if (!is_there_metagen_in_world) { AddWorld(world); } }
public VideoRecorder(String fileName, int width, int height, int frameRate, MetaGen component) { metagen_comp = component; this.width = width; this.height = height; this.frameRate = frameRate; this.fileName = fileName; framesQueue = new ConcurrentQueue <byte[]>(); UniLog.Log("Starting writerloop"); //writtingTask = metagen_comp.StartTask(async ()=>await Task.Run(FileWriterLoop)); //writtingTask = Task.Run(FileWriterLoop); writtingThread = new Thread(FileWriterLoop); writtingThread.IsBackground = true; writtingThread.Priority = ThreadPriority.AboveNormal; writtingThread.Name = "Video frame writting thread"; writtingThread.Start(); }
public void StartInteracting() { UniLog.Log("Start interacting"); SetUpConfigSlot(); interacting = true; //TODO: need to add these if we are gonna have interaction with a certain fps? interacting_state = OutputState.Starting; interacting_frame_index = 0; //Set the recordings time to now utcNow = DateTime.UtcNow; interactingBeginTime = DateTime.UtcNow; if (!metaInteraction.isInteracting) { metaInteraction.StartInteracting(); } interacting_state = OutputState.Started; }