Commit fa0cb6f4 authored by nextime's avatar nextime

Add obs thread, basic main program logic thread

parent b9d880fa
...@@ -60,6 +60,8 @@ builtins.TEMPLATE_DIR=os.path.join(os.path.dirname(__file__), 'templates') ...@@ -60,6 +60,8 @@ builtins.TEMPLATE_DIR=os.path.join(os.path.dirname(__file__), 'templates')
from shmcs import run_command, check_port_available, create_daemon from shmcs import run_command, check_port_available, create_daemon
from shmcs.webpanel import run_flask_app from shmcs.webpanel import run_flask_app
from shmcs.panel import create_panel_gui from shmcs.panel import create_panel_gui
from shmcs.studio import run_camstudio
from shmcs.obs import run_obs_controller
def main(): def main():
# Setup argument parser # Setup argument parser
...@@ -75,10 +77,6 @@ def main(): ...@@ -75,10 +77,6 @@ def main():
args = parser.parse_args() args = parser.parse_args()
try: try:
# Daemon mode for web interface
if args.nogui or args.daemon:
run_flask_app(port=args.port, daemon_mode=args.daemon)
else:
# Start web interface in a background thread # Start web interface in a background thread
web_thread = threading.Thread( web_thread = threading.Thread(
target=run_flask_app, target=run_flask_app,
...@@ -87,6 +85,25 @@ def main(): ...@@ -87,6 +85,25 @@ def main():
) )
web_thread.start() web_thread.start()
obs_thread = threading.Thread(
target=run_obs_controller,
kwargs={},
daemon=True
)
obs_thread.start()
# Daemon mode for web interface
if args.nogui or args.daemon:
run_camstudio(args.daemon)
else:
core_thread = threading.Thread(
target=run_camstudio,
kwargs={},
daemon=True
)
core_thread.start()
# Launch Tkinter GUI # Launch Tkinter GUI
window = create_panel_gui() window = create_panel_gui()
window.mainloop() window.mainloop()
......
# Copyright (C) 2023 Stefy Lanza <stefy@nexlab.net> and SexHack.me
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import obsws_python as obs
import time
def on_scene_item_enable_state_changed(data):
print("scscene_item_enable_state_changed")
print(data.attrs())
print(data.scene_item_enabled, data.scene_item_id, data.scene_name, data.scene_uuid)
def run_obs_controller():
cl = obs.EventClient(host='192.168.42.115', port=4455, password='motorol4')
cr = obs.ReqClient(host='192.168.42.115', port=4455, password='motorol4')
cl.callback.register(on_scene_item_enable_state_changed)
print(cl.callback.get())
#cl.callback.deregister(on_input_mute_state_changed)
now=time.time()-30
while True:
if (time.time() - now) > 30:
now = time.time()
cr.broadcast_custom_event({'eventData': {'eventType': 'Ping', 'time': time.time()}})
time.sleep(.01)
# Copyright (C) 2023 Stefy Lanza <stefy@nexlab.net> and SexHack.me
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import time
import sys
from utils import create_daemon
def camstudio():
while True:
time.sleep(.001)
def run_camstudio(daemon=False):
if daemon and sys.platform != 'win32':
create_daemon()
camstudio()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment