Exemple #1
0
    def update(self):
        global globSettings

        self.selection['menu'].delete(0, 'end')
        for choice in self.scenes:
            self.selection['menu'].add_command(label=choice,
                                               command=tk._setit(
                                                   self.scene, choice))
        stored = obs.obs_data_get_string(globSettings, "scene")
        if stored in self.scenes:
            self.scene.set(stored)
        else:
            self.scene.set(self.scenes[0])

        self.list.delete(0, self.list.index('end'))

        self.duration.set(obs.obs_data_get_int(globSettings, "duration"))

        templates = obs.obs_data_get_array(globSettings,
                                           "templates" + self.scene.get())
        if templates == None:
            template = obs.obs_data_array_create()
            obs.obs_data_set_array(globSettings,
                                   "templates" + self.scene.get(), template)
        length = obs.obs_data_array_count(templates)
        for i in range(length):
            item = obs.obs_data_array_item(templates, i)
            self.list.insert(
                'end',
                obs.obs_data_get_string(item, "id") + ". " +
                obs.obs_data_get_string(item, "name"))
            obs.obs_data_release(item)

        obs.obs_data_array_release(templates)
Exemple #2
0
 def switch(self):
     global globSettings
     selection = self.list.curselection()
     if selection != "":
         templates = obs.obs_data_get_array(globSettings,
                                            "templates" + self.scene.get())
         item = obs.obs_data_array_item(templates, selection[0])
         loc = obs.obs_data_get_string(item, "loc")
         obs.obs_data_release(item)
         obs.obs_data_array_release(templates)
         start_animation(loc)
Exemple #3
0
 def remove(self):
     global globSettings
     selection = self.list.curselection()
     if selection != "":
         templates = obs.obs_data_get_array(globSettings,
                                            "templates" + self.scene.get())
         obs.obs_data_array_erase(templates, selection[0])
         length = obs.obs_data_array_count(templates)
         for i in range(selection[0], length):
             item = obs.obs_data_array_item(templates, i)
             obs.obs_data_set_string(item, "id", str(i + 1))
             obs.obs_data_release(item)
         obs.obs_data_array_release(templates)
     self.update()
def script_update(settings):
    """
    Applies any changes made to the MQTT settings in the OBS Scripts GUI then
    reconnects the MQTT client.
    """
    # Apply the new settings
    global MQTT_HOST
    global MQTT_PORT
    global MQTT_CHANNEL
    global INTERVAL
    global TALLY_STATUS

    TALLY_STATUS = {}
    data_array = obs.obs_data_get_array(settings, "tally_sources")
    try:
        for i in range(obs.obs_data_array_count(data_array)):
            item = obs.obs_data_array_item(data_array, i)
            TALLY_STATUS[obs.obs_data_get_string(item, 'value')] = "000000"
    finally:
        obs.obs_data_array_release(data_array)

    mqtt_host = obs.obs_data_get_string(settings, "mqtt_host")
    if mqtt_host != MQTT_HOST:
        MQTT_HOST = mqtt_host
    mqtt_channel = obs.obs_data_get_string(settings, "mqtt_channel")
    if mqtt_channel != MQTT_CHANNEL:
        MQTT_CHANNEL = mqtt_channel
    mqtt_port = obs.obs_data_get_int(settings, "mqtt_port")
    if mqtt_port != MQTT_PORT:
        MQTT_PORT = mqtt_port
    INTERVAL = obs.obs_data_get_int(settings, "interval")

    # Disconnect (if connected) and reconnect the MQTT client
    CLIENT.disconnect()
    try:
        CLIENT.connect_async(MQTT_HOST, MQTT_PORT, 60)
        # Publish our initial state
        CLIENT.publish(MQTT_CHANNEL, json.dumps(STATUS))
    except (socket.gaierror, ConnectionRefusedError) as e:
        print("NOTE: Got a socket issue: %s" % e)
        pass  # Ignore it for now

    # Remove and replace the timer that publishes our status information
    obs.timer_remove(update_status)
    obs.timer_add(update_status, INTERVAL * 1000)
    CLIENT.loop_start()  # So we can know if we connected successfully
Exemple #5
0
    def find_obs_device_pipeline(self):
        gst_raw_list = obs.obs_data_get_array(self.plugin_settings, "list")
        num_gst_raw = obs.obs_data_array_count(gst_raw_list)

        self.devices = {}
        for i in range(num_gst_raw):  # Convert C array to Python list
            gst_raw_object = obs.obs_data_array_item(gst_raw_list, i)
            device_id,pipeline = obs.obs_data_get_string(gst_raw_object, "value").split("~")
            self.devices[device_id]=pipeline

        for device_id,pipeline in self.devices.items():
                print("{device_id}: {pipeline}".format(device_id=device_id,pipeline=pipeline))
        if self.device_supplied_id in  self.devices:
            obs.script_log(obs.LOG_INFO,"Device entry found for {device_id}".format(device_id=self.device_supplied_id))
            self.pipeline = self.devices[self.device_supplied_id] +" matroskamux name=mux ! queue ! tcpclientsink host={obs_ip_address} port={port}".format(port=self.video_port,obs_ip_address=self.obs_ip_address)
        else:
            obs.script_log(obs.LOG_INFO,"No device entry for {device_id}".format(device_id=self.device_supplied_id))
        return
Exemple #6
0
def monitor_source(source):
    ignored = obs.obs_data_get_array(settings, 'ignored')

    for idx in range(obs.obs_data_array_count(ignored)):
        ignored_source_data = obs.obs_data_array_item(ignored, idx)
        ignored_source = str(
            obs.obs_data_get_string(ignored_source_data, 'value'))
        obs.obs_data_release(ignored_source_data)

        if ignored_source.strip() == obs.obs_source_get_name(source).strip():
            print(f'Ignoring "{obs.obs_source_get_name(source)}"')
            break
    else:
        print(f'Monitoring "{obs.obs_source_get_name(source)}"')
        obs.obs_source_set_monitoring_type(
            source, obs.OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT)

    obs.obs_data_array_release(ignored)
def script_update(settings):
    twitch.channel = obs.obs_data_get_string(settings, "channel").lower()
    twitch.nickname = obs.obs_data_get_string(settings, "user").lower()

    new_oauth = obs.obs_data_get_string(settings, "oauth").lower()
    if new_oauth != twitch.password:
        twitch.disconnect()  # Disconnect old oauth connection, if it exists
        twitch.password = new_oauth

    obs_messages = obs.obs_data_get_array(settings, "messages")
    num_messages = obs.obs_data_array_count(obs_messages)

    messages = []
    for i in range(num_messages):  # Convert C array to Python list
        message_object = obs.obs_data_array_item(obs_messages, i)
        messages.append(obs.obs_data_get_string(message_object, "value"))

    ChatMessage.check_messages(messages, settings)
    obs.obs_data_array_release(obs_messages)