diff --git a/.gitignore b/.gitignore index 49c8dfe..85dd609 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ coverage # Dependency directory node_modules bower_components +.pnpm-store # Editors .idea @@ -44,9 +45,18 @@ yalc.lock # Ignore output folder backend/out -backend/bin -backend/obj -libs +# Make sure to ignore any instance of the loader's decky_plugin.py +decky_plugin.py + +# Ignore decky CLI for building plugins +out +out/* +cli/ +cli/* +cli/decky + + bin -/.pnpm-store \ No newline at end of file +obj +.run \ No newline at end of file diff --git a/.vscode/build.sh b/.vscode/build.sh new file mode 100644 index 0000000..7fc5a93 --- /dev/null +++ b/.vscode/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +CLI_LOCATION="$(pwd)/cli" +echo "Building plugin in $(pwd)" +printf "Please input sudo password to proceed.\n" + +# read -s sudopass + +# printf "\n" + +echo $sudopass | sudo $CLI_LOCATION/decky plugin build $(pwd) diff --git a/.vscode/defsettings.json b/.vscode/defsettings.json index 7360735..9734ed5 100644 --- a/.vscode/defsettings.json +++ b/.vscode/defsettings.json @@ -1,7 +1,12 @@ { - "deckip" : "0.0.0.0", + "deckip" : "steamdeck.local", "deckport" : "22", + "deckuser" : "deck", "deckpass" : "ssap", "deckkey" : "-i ${env:HOME}/.ssh/id_rsa", - "deckdir" : "/home/deck" -} \ No newline at end of file + "deckdir" : "/home/deck", + "pluginname": "Example Plugin", + "python.analysis.extraPaths": [ + "./py_modules" + ] +} diff --git a/.vscode/setup.sh b/.vscode/setup.sh new file mode 100644 index 0000000..90701ff --- /dev/null +++ b/.vscode/setup.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +PNPM_INSTALLED="$(which pnpm)" +DOCKER_INSTALLED="$(which docker)" +CLI_INSTALLED="$(pwd)/cli/decky" + +# echo "$PNPM_INSTALLED" +# echo "$DOCKER_INSTALLED" +# echo "$CLI_INSTALLED" + +echo "If you are using alpine linux, do not expect any support." +if [[ "$PNPM_INSTALLED" =~ "which" ]]; then + echo "pnpm is not currently installed, you can install it via your distro's package managment system or via a script that will attempt to do a manual install based on your system. If you wish to proceed with installing via the script then answer "no" (capitals do not matter) and proceed with the rest of the script. Otherwise, just hit enter to proceed and use the script." + read run_pnpm_script + if [[ "$run_pnpm_script" =~ "n" ]]; then + echo "You have chose to install pnpm via npm or your distros package manager. Please make sure to do so before attempting to build your plugin." + else + CURL_INSTALLED="$(which curl)" + WGET_INSTALLED="$(which wget)" + if [[ "$CURL_INSTALLED" =~ "which" ]]; then + printf "curl not found, attempting with wget.\n" + if [[ "$WGET_INSTALLED" =~ "which" ]]; then + printf "wget not found, please install wget or curl.\n" + printf "Could not install pnpm as curl and wget were not found.\n" + else + wget -qO- https://get.pnpm.io/install.sh | sh - + fi + else + curl -fsSL https://get.pnpm.io/install.sh | sh - + fi + fi +fi + +if [[ "$DOCKER_INSTALLED" =~ "which" ]]; then + echo "Docker is not currently installed, in order build plugins with a backend you will need to have Docker installed. Please install Docker via the preferred method for your distribution." +fi + +if ! test -f "$CLI_INSTALLED"; then + echo "The Decky CLI tool (binary file is just called "decky") is used to build your plugin as a zip file which you can then install on your Steam Deck to perform testing. We highly recommend you install it. Hitting enter now will run the script to install Decky CLI and extract it to a folder called cli in the current plugin directory. You can also type 'no' and hit enter to skip this but keep in mind you will not have a usable plugin without building it." + read run_cli_script + if [[ "$run_cli_script" =~ "n" ]]; then + echo "You have chosen to not install the Decky CLI tool to build your plugins. Please install this tool to build and test your plugin before submitting it to the Plugin Database." + else + mkdir $(pwd)/cli + curl -L -o $(pwd)/cli/decky "https://github.com/SteamDeckHomebrew/cli/releases/latest/download/decky" + chmod +x $(pwd)/cli/decky + echo "Decky CLI tool is now installed and you can build plugins into easy zip files using the "Build Zip" Task in vscodium." + fi +fi diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 78025a5..027b4e4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,105 +1,148 @@ { "version": "2.0.0", "tasks": [ - // OTHER + //PRELIMINARY SETUP TASKS + //Dependency setup task { - "label": "checkforsettings", + "label": "depsetup", "type": "shell", "group": "none", - "detail": "Check that settings.json has been created", - "command": "bash -c ${workspaceFolder}/.vscode/config.sh", + "detail": "Install depedencies for basic setup", + "linux": { + "command": "${workspaceFolder}/.vscode/setup.sh", + }, + // // placeholder for windows scripts, not currently planned + // "windows": { + // "command": "call -c ${workspaceFolder}\\.vscode\\setup.bat", + // }, "problemMatcher": [] }, - // BUILD + //pnpm setup task to grab all needed modules { "label": "pnpmsetup", "type": "shell", - "group": "build", + "group": "none", "detail": "Setup pnpm", - "command": "pnpm i", + "command": "which pnpm && pnpm i", "problemMatcher": [] }, + //Preliminary "All-in-one" setup task { - "label": "updatefrontendlib", + "label": "setup", + "detail": "Set up depedencies, pnpm and update Decky Frontend Library.", + "dependsOrder": "sequence", + "dependsOn": [ + "depsetup", + "pnpmsetup", + "updatefrontendlib" + ], + "problemMatcher": [] + }, + //Preliminary Deploy Config Setup + { + "label": "settingscheck", "type": "shell", - "group": "build", - "detail": "Update deck-frontend-lib", - "command": "pnpm update decky-frontend-lib --latest", + "group": "none", + "detail": "Check that settings.json has been created", + "linux": { + "command": "${workspaceFolder}/.vscode/config.sh", + }, + // // placeholder for windows scripts, not currently planned + // "windows": { + // "command": "call ${workspaceFolder}\\.vscode\\config.bat", + // }, "problemMatcher": [] }, + //BUILD TASKS { - "label": "build", - "type": "npm", + "label": "cli-build", "group": "build", - "detail": "rollup -c", - "script": "build", - "path": "", + "detail": "Build plugin with CLI", + "linux": { + "command": "${workspaceFolder}/.vscode/build.sh", + }, + // // placeholder for windows logic, not currently planned + // "windows": { + // "command": "call ${workspaceFolder}\\.vscode\\build.bat", + // }, "problemMatcher": [] }, + //"All-in-one" build task { - "label": "buildall", + "label": "build", "group": "build", "detail": "Build decky-plugin-template", "dependsOrder": "sequence", "dependsOn": [ - "pnpmsetup", - "build" + "setup", + "settingscheck", + "cli-build", ], "problemMatcher": [] }, - // DEPLOY + //DEPLOY TASKS + //Copies the zip file of the built plugin to the plugins folder { - "label": "createfolders", - "detail": "Create plugins folder in expected directory", + "label": "copyzip", + "detail": "Deploy plugin zip to deck", "type": "shell", "group": "none", "dependsOn": [ - "checkforsettings" + "chmodplugins" ], - "command": "ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'mkdir -p ${config:deckdir}/homebrew/pluginloader && mkdir -p ${config:deckdir}/homebrew/plugins'", + "command": "rsync -azp --chmod=D0755,F0755 --rsh='ssh -p ${config:deckport} ${config:deckkey}' out/ ${config:deckuser}@${config:deckip}:${config:deckdir}/homebrew/plugins", "problemMatcher": [] }, + // { - "label": "deploy", - "detail": "Deploy dev plugin to deck", + "label": "extractzip", + "detail": "", "type": "shell", "group": "none", - "dependsOn": [ - "createfolders", - "chmodfolders" - ], - "command": "rsync -azp --delete --chmod=D0755,F0755 --rsh='ssh -p ${config:deckport} ${config:deckkey}' --exclude='.git/' --exclude='.github/' --exclude='.vscode/' --exclude='node_modules/' --exclude='src/' --exclude='*.log' --exclude='.gitignore' . deck@${config:deckip}:${config:deckdir}/homebrew/plugins/${workspaceFolderBasename}", + "command": "echo '${config:deckdir}/homebrew/plugins/${config:pluginname}.zip' && ssh ${config:deckuser}@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo ${config:deckpass} | sudo -S mkdir 755 -p \"$(echo \"${config:deckdir}/homebrew/plugins/${config:pluginname}\" | sed \"s| |-|\")\" && echo ${config:deckpass} | sudo -S chown ${config:deckuser}:${config:deckuser} \"$(echo \"${config:deckdir}/homebrew/plugins/${config:pluginname}\" | sed \"s| |-|\")\" && echo ${config:deckpass} | sudo -S bsdtar -xzpf \"${config:deckdir}/homebrew/plugins/${config:pluginname}.zip\" -C \"$(echo \"${config:deckdir}/homebrew/plugins/${config:pluginname}\" | sed \"s| |-|g\")\" --strip-components=1 --fflags '", "problemMatcher": [] }, + //"All-in-one" deploy task { - "label": "chmodfolders", - "detail": "chmods folders to prevent perms issues", - "type": "shell", + "label": "deploy", + "dependsOrder": "sequence", "group": "none", - "command": "ssh deck@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo '${config:deckpass}' | sudo -S chmod -R ug+rw ${config:deckdir}/homebrew/'", + "dependsOn": [ + "copyzip", + "extractzip" + ], "problemMatcher": [] }, + //"All-in-on" build & deploy task { - "label": "deployall", + "label": "builddeploy", + "detail": "Builds plugin and deploys to deck", "dependsOrder": "sequence", "group": "none", "dependsOn": [ - "deploy", - "chmodfolders" + "build", + "deploy" ], "problemMatcher": [] }, - // ALL-IN-ONE + //GENERAL TASKS + //Update Decky Frontend Library, aka DFL { - "label": "allinone", - "detail": "Build and deploy", - "dependsOrder": "sequence", - "group": "test", - "dependsOn": [ - "buildall", - "deployall" - ], + "label": "updatefrontendlib", + "type": "shell", + "group": "build", + "detail": "Update deck-frontend-lib aka DFL", + "command": "pnpm update decky-frontend-lib --latest", "problemMatcher": [] - } + }, + //Used chmod plugins folder to allow copy-over of files + { + "label": "chmodplugins", + "detail": "chmods plugins folder to prevent perms issues", + "type": "shell", + "group": "none", + "command": "ssh ${config:deckuser}@${config:deckip} -p ${config:deckport} ${config:deckkey} 'echo '${config:deckpass}' | sudo -S chmod -R ug+rw ${config:deckdir}/homebrew/plugins/'", + "problemMatcher": [] + }, ] } diff --git a/LICENSE b/LICENSE index 6955850..3e139d0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,675 +1,55 @@ -### GNU GENERAL PUBLIC LICENSE +MIT License -Version 3, 29 June 2007 +Copyright (c) 2023 Kieran Coldron +(LibObs.NET Code) Copyright (c) 2022 Jimmy Quach -Copyright (C) 2007 Free Software Foundation, Inc. - +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -### Preamble +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. -The GNU General Public License is a free, copyleft license for -software and other kinds of works. -The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom -to share and change all versions of a program--to make sure it remains -free software for all its users. We, the Free Software Foundation, use -the GNU General Public License for most of our software; it applies -also to any other work released this way by its authors. You can apply -it to your programs, too. +DECKY FRONTEND TEMPLATE: +BSD 3-Clause License -When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. +Original Copyright (c) 2022-2023, Steam Deck Homebrew -To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you -have certain responsibilities if you distribute copies of the -software, or if you modify it: responsibilities to respect the freedom -of others. +All rights reserved. -For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. -Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the -manufacturer can do so. This is fundamentally incompatible with the -aim of protecting users' freedom to change the software. The -systematic pattern of such abuse occurs in the area of products for -individuals to use, which is precisely where it is most unacceptable. -Therefore, we have designed this version of the GPL to prohibit the -practice for those products. If such problems arise substantially in -other domains, we stand ready to extend this provision to those -domains in future versions of the GPL, as needed to protect the -freedom of users. +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish -to avoid the special danger that patents applied to a free program -could make it effectively proprietary. To prevent this, the GPL -assures that patents cannot be used to render the program non-free. - -The precise terms and conditions for copying, distribution and -modification follow. - -### TERMS AND CONDITIONS - -#### 0. Definitions. - -"This License" refers to version 3 of the GNU General Public License. - -"Copyright" also means copyright-like laws that apply to other kinds -of works, such as semiconductor masks. - -"The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - -To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of -an exact copy. The resulting work is called a "modified version" of -the earlier work or a work "based on" the earlier work. - -A "covered work" means either the unmodified Program or a work based -on the Program. - -To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - -To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user -through a computer network, with no transfer of a copy, is not -conveying. - -An interactive user interface displays "Appropriate Legal Notices" to -the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - -#### 1. Source Code. - -The "source code" for a work means the preferred form of the work for -making modifications to it. "Object code" means any non-source form of -a work. - -A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - -The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - -The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - -The Corresponding Source need not include anything that users can -regenerate automatically from other parts of the Corresponding Source. - -The Corresponding Source for a work in source code form is that same -work. - -#### 2. Basic Permissions. - -All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - -You may make, run and propagate covered works that you do not convey, -without conditions so long as your license otherwise remains in force. -You may convey covered works to others for the sole purpose of having -them make modifications exclusively for you, or provide you with -facilities for running those works, provided that you comply with the -terms of this License in conveying all material for which you do not -control copyright. Those thus making or running the covered works for -you must do so exclusively on your behalf, under your direction and -control, on terms that prohibit them from making any copies of your -copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the -conditions stated below. Sublicensing is not allowed; section 10 makes -it unnecessary. - -#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - -No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - -When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such -circumvention is effected by exercising rights under this License with -respect to the covered work, and you disclaim any intention to limit -operation or modification of the work as a means of enforcing, against -the work's users, your or third parties' legal rights to forbid -circumvention of technological measures. - -#### 4. Conveying Verbatim Copies. - -You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - -#### 5. Conveying Modified Source Versions. - -You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these -conditions: - -- a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under - section 7. This requirement modifies the requirement in section 4 - to "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent - works, which are not by their nature extensions of the covered work, - and which are not combined with it such as to form a larger program, - in or on a volume of a storage or distribution medium, is called an - "aggregate" if the compilation and its resulting copyright are not - used to limit the access or legal rights of the compilation's users - beyond what the individual works permit. Inclusion of a covered work - in an aggregate does not cause this License to apply to the other - parts of the aggregate. - - #### 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms of - sections 4 and 5, provided that you also convey the machine-readable - Corresponding Source under the terms of this License, in one of these - ways: - - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the Corresponding - Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, - provided you inform other peers where the object code and - Corresponding Source of the work are being offered to the general - public at no charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded - from the Corresponding Source as a System Library, need not be - included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any - tangible personal property which is normally used for personal, - family, or household purposes, or (2) anything designed or sold for - incorporation into a dwelling. In determining whether a product is a - consumer product, doubtful cases shall be resolved in favor of - coverage. For a particular product received by a particular user, - "normally used" refers to a typical or common use of that class of - product, regardless of the status of the particular user or of the way - in which the particular user actually uses, or expects or is expected - to use, the product. A product is a consumer product regardless of - whether the product has substantial commercial, industrial or - non-consumer uses, unless such uses represent the only significant - mode of use of the product. - - "Installation Information" for a User Product means any methods, - procedures, authorization keys, or other information required to - install and execute modified versions of a covered work in that User - Product from a modified version of its Corresponding Source. The - information must suffice to ensure that the continued functioning of - the modified object code is in no case prevented or interfered with - solely because modification has been made. - - If you convey an object code work under this section in, or with, or - specifically for use in, a User Product, and the conveying occurs as - part of a transaction in which the right of possession and use of the - User Product is transferred to the recipient in perpetuity or for a - fixed term (regardless of how the transaction is characterized), the - Corresponding Source conveyed under this section must be accompanied - by the Installation Information. But this requirement does not apply - if neither you nor any third party retains the ability to install - modified object code on the User Product (for example, the work has - been installed in ROM). - - The requirement to provide Installation Information does not include a - requirement to continue to provide support service, warranty, or - updates for a work that has been modified or installed by the - recipient, or for the User Product in which it has been modified or - installed. Access to a network may be denied when the modification - itself materially and adversely affects the operation of the network - or violates the rules and protocols for communication across the - network. - - Corresponding Source conveyed, and Installation Information provided, - in accord with this section must be in a format that is publicly - documented (and with an implementation available to the public in - source code form), and must require no special password or key for - unpacking, reading or copying. - - #### 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this - License by making exceptions from one or more of its conditions. - Additional permissions that are applicable to the entire Program shall - be treated as though they were included in this License, to the extent - that they are valid under applicable law. If additional permissions - apply only to part of the Program, that part may be used separately - under those permissions, but the entire Program remains governed by - this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option - remove any additional permissions from that copy, or from any part of - it. (Additional permissions may be written to require their own - removal in certain cases when you modify the work.) You may place - additional permissions on material, added by you to a covered work, - for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you - add to a covered work, you may (if authorized by the copyright holders - of that material) supplement the terms of this License with terms: - - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, - or requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors - or authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions - of it) with contractual assumptions of liability to the recipient, - for any liability that these contractual assumptions directly - impose on those licensors and authors. - - All other non-permissive additional terms are considered "further - restrictions" within the meaning of section 10. If the Program as you - received it, or any part of it, contains a notice stating that it is - governed by this License along with a term that is a further - restriction, you may remove that term. If a license document contains - a further restriction but permits relicensing or conveying under this - License, you may add to a covered work material governed by the terms - of that license document, provided that the further restriction does - not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you - must place, in the relevant source files, a statement of the - additional terms that apply to those files, or a notice indicating - where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the - form of a separately written license, or stated as exceptions; the - above requirements apply either way. - - #### 8. Termination. - - You may not propagate or modify a covered work except as expressly - provided under this License. Any attempt otherwise to propagate or - modify it is void, and will automatically terminate your rights under - this License (including any patent licenses granted under the third - paragraph of section 11). - - However, if you cease all violation of this License, then your license - from a particular copyright holder is reinstated (a) provisionally, - unless and until the copyright holder explicitly and finally - terminates your license, and (b) permanently, if the copyright holder - fails to notify you of the violation by some reasonable means prior to - 60 days after the cessation. - - Moreover, your license from a particular copyright holder is - reinstated permanently if the copyright holder notifies you of the - violation by some reasonable means, this is the first time you have - received notice of violation of this License (for any work) from that - copyright holder, and you cure the violation prior to 30 days after - your receipt of the notice. - - Termination of your rights under this section does not terminate the - licenses of parties who have received copies or rights from you under - this License. If your rights have been terminated and not permanently - reinstated, you do not qualify to receive new licenses for the same - material under section 10. - - #### 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or run - a copy of the Program. Ancillary propagation of a covered work - occurring solely as a consequence of using peer-to-peer transmission - to receive a copy likewise does not require acceptance. However, - nothing other than this License grants you permission to propagate or - modify any covered work. These actions infringe copyright if you do - not accept this License. Therefore, by modifying or propagating a - covered work, you indicate your acceptance of this License to do so. - - #### 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically - receives a license from the original licensors, to run, modify and - propagate that work, subject to this License. You are not responsible - for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an - organization, or substantially all assets of one, or subdividing an - organization, or merging organizations. If propagation of a covered - work results from an entity transaction, each party to that - transaction who receives a copy of the work also receives whatever - licenses to the work the party's predecessor in interest had or could - give under the previous paragraph, plus a right to possession of the - Corresponding Source of the work from the predecessor in interest, if - the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the - rights granted or affirmed under this License. For example, you may - not impose a license fee, royalty, or other charge for exercise of - rights granted under this License, and you may not initiate litigation - (including a cross-claim or counterclaim in a lawsuit) alleging that - any patent claim is infringed by making, using, selling, offering for - sale, or importing the Program or any portion of it. - - #### 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this - License of the Program or a work on which the Program is based. The - work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims owned - or controlled by the contributor, whether already acquired or - hereafter acquired, that would be infringed by some manner, permitted - by this License, of making, using, or selling its contributor version, - but do not include claims that would be infringed only as a - consequence of further modification of the contributor version. For - purposes of this definition, "control" includes the right to grant - patent sublicenses in a manner consistent with the requirements of - this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free - patent license under the contributor's essential patent claims, to - make, use, sell, offer for sale, import and otherwise run, modify and - propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express - agreement or commitment, however denominated, not to enforce a patent - (such as an express permission to practice a patent or covenant not to - sue for patent infringement). To "grant" such a patent license to a - party means to make such an agreement or commitment not to enforce a - patent against the party. - - If you convey a covered work, knowingly relying on a patent license, - and the Corresponding Source of the work is not available for anyone - to copy, free of charge and under the terms of this License, through a - publicly available network server or other readily accessible means, - then you must either (1) cause the Corresponding Source to be so - available, or (2) arrange to deprive yourself of the benefit of the - patent license for this particular work, or (3) arrange, in a manner - consistent with the requirements of this License, to extend the patent - license to downstream recipients. "Knowingly relying" means you have - actual knowledge that, but for the patent license, your conveying the - covered work in a country, or your recipient's use of the covered work - in a country, would infringe one or more identifiable patents in that - country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or - arrangement, you convey, or propagate by procuring conveyance of, a - covered work, and grant a patent license to some of the parties - receiving the covered work authorizing them to use, propagate, modify - or convey a specific copy of the covered work, then the patent license - you grant is automatically extended to all recipients of the covered - work and works based on it. - - A patent license is "discriminatory" if it does not include within the - scope of its coverage, prohibits the exercise of, or is conditioned on - the non-exercise of one or more of the rights that are specifically - granted under this License. You may not convey a covered work if you - are a party to an arrangement with a third party that is in the - business of distributing software, under which you make payment to the - third party based on the extent of your activity of conveying the - work, and under which the third party grants, to any of the parties - who would receive the covered work from you, a discriminatory patent - license (a) in connection with copies of the covered work conveyed by - you (or copies made from those copies), or (b) primarily for and in - connection with specific products or compilations that contain the - covered work, unless you entered into that arrangement, or that patent - license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting - any implied license or other defenses to infringement that may - otherwise be available to you under applicable patent law. - - #### 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot convey a - covered work so as to satisfy simultaneously your obligations under - this License and any other pertinent obligations, then as a - consequence you may not convey it at all. For example, if you agree to - terms that obligate you to collect a royalty for further conveying - from those to whom you convey the Program, the only way you could - satisfy both those terms and this License would be to refrain entirely - from conveying the Program. - - #### 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have - permission to link or combine any covered work with a work licensed - under version 3 of the GNU Affero General Public License into a single - combined work, and to convey the resulting work. The terms of this - License will continue to apply to the part which is the covered work, - but the special requirements of the GNU Affero General Public License, - section 13, concerning interaction through a network will apply to the - combination as such. - - #### 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions - of the GNU General Public License from time to time. Such new versions - will be similar in spirit to the present version, but may differ in - detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the Program - specifies that a certain numbered version of the GNU General Public - License "or any later version" applies to it, you have the option of - following the terms and conditions either of that numbered version or - of any later version published by the Free Software Foundation. If the - Program does not specify a version number of the GNU General Public - License, you may choose any version ever published by the Free - Software Foundation. - - If the Program specifies that a proxy can decide which future versions - of the GNU General Public License can be used, that proxy's public - statement of acceptance of a version permanently authorizes you to - choose that version for the Program. - - Later license versions may give you additional or different - permissions. However, no additional obligations are imposed on any - author or copyright holder as a result of your choosing to follow a - later version. - - #### 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY - APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT - HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT - WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND - PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE - DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR - CORRECTION. - - #### 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING - WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR - CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, - INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES - ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT - NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR - LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM - TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER - PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - #### 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided - above cannot be given local legal effect according to their terms, - reviewing courts shall apply local law that most closely approximates - an absolute waiver of all civil liability in connection with the - Program, unless a warranty or assumption of liability accompanies a - copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - ### How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest - possible use to the public, the best way to achieve this is to make it - free software which everyone can redistribute and change under these - terms. - - To do so, attach the following notices to the program. It is safest to - attach them to the start of each source file to most effectively state - the exclusion of warranty; and each file should have at least the - "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - - Also add information on how to contact you by electronic and paper - mail. - - If the program does terminal interaction, make it output a short - notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - - The hypothetical commands \`show w' and \`show c' should show the - appropriate parts of the General Public License. Of course, your - program's commands might be different; for a GUI interface, you would - use an "about box". - - You should also get your employer (if you work as a programmer) or - school, if any, to sign a "copyright disclaimer" for the program, if - necessary. For more information on this, and how to apply and follow - the GNU GPL, see . - - The GNU General Public License does not permit incorporating your - program into proprietary programs. If your program is a subroutine - library, you may consider it more useful to permit linking proprietary - applications with the library. If this is what you want to do, use the - GNU Lesser General Public License instead of this License. But first, - please read . +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 873c9b6..5f29879 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,54 @@ -# DeckyStream -Basic Decky plugin to allow recording and streaming (via NDI) from the steamdeck. +# OpenDeckStream -## Development -//TODO +![OpenDeckStream banner](banner.png) -## Thanks +OpenDeckStream is a Decky plugin specially designed for the SteamDeck. Utilizing `libobs` for recording, OpenDeckStream aims to provide you with an exceptional experience of recording your SteamDeck gameplay with a seamless, integrated, and easy-to-use interface. -Thanks to @AAGaming for Deckorder of which this plugin uses UI code from https://git.catvibers.me/aa/Deckorder +In the future, we plan on implementing streaming capabilities to bring live casts of your gameplay directly from your SteamDeck to your favorite platforms. -@avery for Recapture which I used as a reference for gstreamer https://git.sr.ht/~avery/recapture -and the rest of the Decky team for being helpful in Discord and providing the awesome plugin loader. +## Features + +* Easy-to-Use Interface +* Quick and High-Quality Recording with low performance hit +* Seamless Integration with SteamDeck +* Always recording replay buffer +* Planned Future Support for Streaming + +## Installation +Ensure you have git, docker and decky-cli installed + +1. Clone the repository +```sh +git clone https://github.com/epictek/OpenDeckStream.git +``` +1. Navigate to the project directory +```sh +cd OpenDeckStream +``` + +1. Build the project +```sh +decky plugin build -b +``` + +## Usage + +Once OpenDeckStream is installed on your SteamDeck, you can access it under your Decky plugins. + +1. Open Quick Access Menu. +2. Navigate to the plugins section. +3. Choose OpenDeckStream from the list. +4. Start/Stop recording at your convenience. + +To save the replay buffer + +## Acknowledgments +A special thank you to the following teams for their incredible contributions: + +lulzsun/RePlays for creating the LibObs.Net C# wrapper that made this project possible. +The OBS Studio Team for crafting libobs, the wonderful library that's the heart of this plugin. +The Decky Team for the exceptional Decky plugin manager that aids seamless integration of plugins into the SteamDeck. + +--- + +Thanks for checking out OpenDeckStream, happy gaming and recording! diff --git a/backend/.run/Publish Debug.run.xml b/backend/.run/Publish Debug.run.xml deleted file mode 100644 index 8086774..0000000 --- a/backend/.run/Publish Debug.run.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/backend/.run/Publish Release.run.xml b/backend/.run/Publish Release.run.xml deleted file mode 100644 index 3b6e194..0000000 --- a/backend/.run/Publish Release.run.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/backend/DeckyStreamConfig.cs b/backend/DeckyStreamConfig.cs deleted file mode 100644 index 9aa73c5..0000000 --- a/backend/DeckyStreamConfig.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.IO; -using System.Text; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace deckystream; - - -public enum StreamType -{ - ndi, - rtmp -} - -public record DeckyStreamConfig() -{ - public StreamType StreamingMode { get; set; } - public string? RtmpEndpoint { get; set; } - public bool ShadowEnabled { get; set; } - - public bool MicEnabled { get; set; } - public int ReplayBuffer { get; set; } -} - -public class SettingsService -{ - ILogger _logger; - - public SettingsService(ILogger logger) - { - _logger = logger; - } - - internal async Task Initialise() - { - Directory.CreateDirectory(DirectoryHelper.SETTINGS_DIR); - - Current = await Load(); - } - - - private static readonly JsonSerializerOptions JsonSerializerOptions = new () { Converters = { new JsonStringEnumConverter() }, PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true }; - private DeckyStreamConfig DefaultConfig = new() - { - StreamingMode = StreamType.ndi, - MicEnabled = false, - RtmpEndpoint = null, - ReplayBuffer = 30, - ShadowEnabled = false - }; - - private static string CONFIG_PATH = $"{DirectoryHelper.SETTINGS_DIR}/deckystream.json"; - - public EventHandler SettingChanged; - public DeckyStreamConfig Current; - public async Task Load() - { - if (!File.Exists(CONFIG_PATH)) return DefaultConfig; - try - { - - var cfg = await File.ReadAllTextAsync(CONFIG_PATH); - var serialised = JsonSerializer.Deserialize(cfg, JsonSerializerOptions); - if (serialised != null) return serialised; - _logger.LogError("Error loading settings file, null object, using defaults"); - - } - catch (Exception ex) - { - _logger.LogError(ex, "Error loading settings file, using defaults"); - } - - return DefaultConfig; - } - - public Task Save(DeckyStreamConfig config) - { - return File.WriteAllTextAsync(CONFIG_PATH, JsonSerializer.Serialize(config, JsonSerializerOptions), Encoding.UTF8); - } -} \ No newline at end of file diff --git a/backend/DirectoryHelper.cs b/backend/DirectoryHelper.cs deleted file mode 100644 index 239f04b..0000000 --- a/backend/DirectoryHelper.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace deckystream; - -public static class DirectoryHelper -{ - public static string HOMEBREW_DIR = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../"); - public static string LOG_DIR = $"{HOMEBREW_DIR}/logs/deckystream"; - public static string SETTINGS_DIR = $"{HOMEBREW_DIR}/settings/deckystream/"; - public static string CLIPS_DIR = "/home/deck/Videos/DeckyStream"; - - public static string REPLAY_CLIPS_DIR = CLIPS_DIR + "/ReplayClips"; - - - - public static void CreateDirs() - { - Directory.CreateDirectory(CLIPS_DIR); - Directory.CreateDirectory(REPLAY_CLIPS_DIR); - } -} \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index 233e578..1a89e9a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,8 +1,23 @@ -FROM ghcr.io/steamdeckhomebrew/holo-base:latest -#RUN sed -r -i 's/\[(jupiter|core|extra|community|multilib|holo)\]/\[\1-rel\]/g' /etc/pacman.conf -#RUN pacman -Sy --noconfirm archlinux-keyring -RUN pacman -Sy --noconfirm gcc glibc gcc-libs wget -RUN pacman -Sy --noconfirm rustup git && rustup install stable -RUN pacman -Sy --noconfirm dotnet-sdk gstreamer gst-plugins-base gst-plugins-bad-libs gst-plugins-good gst-plugin-pipewire gstreamer-vaapi - -ENTRYPOINT [ "/backend/entrypoint.sh" ] \ No newline at end of file +FROM holo-toolchain-dotnet:latest + +RUN pacman -Sy --noconfirm wget zlib clang && \ + wget https://dot.net/v1/dotnet-install.sh && \ + chmod +x dotnet-install.sh && \ + ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 8.0 && \ + rm dotnet-install.sh + +RUN pacman -S --noconfirm asio cmake git libfdk-aac libxcomposite x264 vlc swig luajit nlohmann-json python wayland pipewire xdg-desktop-portal ffmpeg git jansson libxinerama libxkbcommon-x11 curl speexdsp pciutils \ + && rm -rf /var/cache/pacman/pkg/* + +RUN git clone https://github.com/Joshua-Ashton/obs-studio \ + && cd obs-studio \ + && git checkout gamescope-capture \ + && git submodule update --init --recursive \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_VLC=OFF -DENABLE_PIPEWIRE=ON -DENABLE_BROWSER=OFF -DENABLE_NEW_MPEGTS_OUTPUT=OFF -DENABLE_DECKLINK=OFF -DENABLE_UI=OFF -DENABLE_AJA=0 -DENABLE_WEBRTC=0 -DLINUX_PORTABLE=ON -DENABLE_VST=OFF -DENABLE_QSV11=OFF -DENABLE_HEVC=ON -DCMAKE_INSTALL_PREFIX="/obs-portable" ../ \ + && make \ + && make install + + +ENTRYPOINT [ "/backend/entrypoint.sh" ] diff --git a/backend/GstreamerService.cs b/backend/GstreamerService.cs deleted file mode 100644 index 04438e3..0000000 --- a/backend/GstreamerService.cs +++ /dev/null @@ -1,617 +0,0 @@ -using System; -using System.IO; -using System.IO.Pipelines; -using Gst; -using System.Net; -using System.Runtime.InteropServices.ComTypes; -using System.Threading; -using deckystream; -using Microsoft.AspNetCore.SignalR; -using Microsoft.Extensions.Logging; -using StreamType = Gst.StreamType; -using Task = System.Threading.Tasks.Task; -using Value = GLib.Value; - -public class GstreamerService : IDisposable -{ - const string micSrcSink = @"alsa_input.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__source"; - const string audioSrcSink = @"alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_1__sink.monitor"; - - GLib.MainLoop _mainLoop; - // GLib.MainLoop _ndiMicLoop; - - Gst.Pipeline? _pipeline; - Gst.Pipeline? _ndiMicPipeline; - - readonly ILogger _logger; - - private bool isRecording; - - public bool IsRecording - { - get => isRecording; - set - { - isRecording = value; - try - { - _streamHubContext.Clients.All.RecordingStatusChange(isRecording); - } - catch (Exception ex) - { - _logger.LogError(ex, "SignalR StreamingStatusChange"); - } - - } - } - - - private bool isStreaming; - - public bool IsStreaming - { - get => isStreaming; - set - { - isStreaming = value; - try - { - _streamHubContext.Clients.All.StreamingStatusChange(isStreaming); - } - catch (Exception ex) - { - _logger.LogError(ex, "SignalR StreamingStatusChange"); - } - - } - } - private readonly IHubContext _streamHubContext; - private readonly SettingsService _settingsService; - - public GstreamerService(ILogger logger, IHubContext streamHubContext, SettingsService settingsService) - { - _logger = logger; - _streamHubContext = streamHubContext; - _settingsService = settingsService; - try - { - Application.Init(); - } - catch (Exception ex) - { - _logger.LogCritical(ex, "error"); - } - - _mainLoop = new GLib.MainLoop(); - } - - public bool GetIsRecording() - { - return IsRecording; - } - - public bool GetIsStreaming() - { - return IsStreaming; - } - - - private Element audioqueue; - private Element audioMixer; - private Element micAudio; - private Element desktopAudio; - private Element audioEnc; - private Element audioconv; - private Pad queueSrc; - private ulong blockProbeId; - - - void AddAudioPipeline(Element outMux) - { - audioqueue = Gst.ElementFactory.Make("multiqueue", "audioqueue"); - - audioMixer = Gst.ElementFactory.Make("audiomixer", "audiomixer"); - - desktopAudio = Gst.ElementFactory.Make("pulsesrc", "desktop_audio"); - desktopAudio.SetProperty("device", new Value(audioSrcSink)); - - - audioconv = Gst.ElementFactory.Make("audioconvert"); - - audioEnc = ElementFactory.Make("lamemp3enc"); - audioEnc.SetProperty("target", new Value(1)); - audioEnc.SetProperty("bitrate", new Value(128)); - audioEnc.SetProperty("cbr", new Value(true)); - - _pipeline.Add(audioMixer); - _pipeline.Add(audioqueue); - _pipeline.Add(desktopAudio); - _pipeline.Add(audioEnc); - _pipeline.Add(audioconv); - - desktopAudio.Link(audioqueue); - audioqueue.Link(audioMixer); - audioMixer.Link(audioconv); - audioconv.Link(audioEnc); - audioEnc.Link(outMux); - - - _logger.LogInformation("Mic enabled {MicEnabled}", _settingsService.Current.MicEnabled); - if (_settingsService.Current.MicEnabled) - { - AddMic(); - } - } - - - private Element fileSink; - - - public async Task Start() - { - if (IsRecording || IsStreaming) return false; - await _streamHubContext.Clients.All.GstreamerStateChange(GstreamerState.Starting); - - IsRecording = true; - - string videoDir = Path.Join(DirectoryHelper.CLIPS_DIR, System.DateTime.Now.ToString("yyyy-M-dd")); - Directory.CreateDirectory(videoDir); - - var outFile = videoDir + "/" + System.DateTime.Now.ToString("HH-mm-ss") + ".mp4"; - _logger.LogInformation("Writing to: " + outFile); - - _pipeline = new Pipeline(); - _pipeline.ElementAdded += PipelineOnElementAdded; - _pipeline.ElementRemoved += PipelineOnElementRemoved; - var sink = Gst.ElementFactory.Make("filesink"); - sink.SetProperty("location", new Value(outFile)); - var videosrc = Gst.ElementFactory.Make("pipewiresrc"); - videosrc.SetProperty("do-timestamp", new Value(true)); - - - var videopostproc = Gst.ElementFactory.Make("vaapipostproc"); - var queue1 = Gst.ElementFactory.Make("queue"); - - var videoenc = Gst.ElementFactory.Make("vaapih264enc"); - var h264parse = Gst.ElementFactory.Make("h264parse"); - var mux = Gst.ElementFactory.Make("mp4mux", "mux"); - - _pipeline.Add(videosrc, queue1, videopostproc, videoenc, h264parse, mux, sink); - - _pipeline.Link(videosrc); - videosrc.Link(videopostproc); - videopostproc.Link(queue1); - queue1.Link(videoenc); - videoenc.Link(h264parse); - h264parse.Link(mux); - mux.Link(sink); - - AddAudioPipeline(mux); - - _pipeline.Bus.AddSignalWatch(); - _pipeline.Bus.EnableSyncMessageEmission(); - _pipeline.Bus.Message += OnMessage; - - - var ret = _pipeline.SetState(State.Playing); - - if (ret == StateChangeReturn.Failure) - { - _logger.LogCritical("Unable to set the pipeline to the playing state."); - IsRecording = false; - IsStreaming = false; - - return false; - } - - StartMainLoop(); - return true; - } - - private void PipelineOnElementRemoved(object o, ElementRemovedArgs args) - { - _logger.LogInformation("Removed element {ElementName} from pipeline", args.Element.Name); - } - - private void PipelineOnElementAdded(object o, ElementAddedArgs args) - { - _logger.LogInformation("Added element {ElementName} to pipeline", args.Element.Name); - } - - void StartMainLoop() - { - ThreadPool.QueueUserWorkItem(x => _mainLoop.Run()); - } - - public async Task StartStream() - { - if (IsRecording || IsStreaming) return false; - IsStreaming = true; - - - _pipeline = new Pipeline(); - if (_settingsService.Current.StreamingMode == deckystream.StreamType.ndi) - { - if (_settingsService.Current.MicEnabled || true) - { - GenerateNdiMicPipeline(); - - _ndiMicPipeline.Bus.AddSignalWatch(); - _ndiMicPipeline.Bus.EnableSyncMessageEmission(); - _ndiMicPipeline.Bus.Message += OnNdiMicMessage; - var micState = _ndiMicPipeline.SetState(State.Playing); - - if (micState == StateChangeReturn.Failure) - { - _logger.LogCritical("Unable to set the microphone pipeline to the playing state."); - IsRecording = false; - IsStreaming = false; - - return false; - } - - } - GenerateNdiPipeline(); - - } - else - { - if (_settingsService.Current.RtmpEndpoint != null && !_settingsService.Current.RtmpEndpoint.StartsWith("rtmp://")) return false; - } - - - - - _pipeline.Bus.AddSignalWatch(); - _pipeline.Bus.EnableSyncMessageEmission(); - _pipeline.Bus.Message += OnMessage; - var ret = _pipeline.SetState(State.Playing); - - if (ret == StateChangeReturn.Failure) - { - _logger.LogCritical("Unable to set the pipeline to the playing state."); - IsRecording = false; - IsStreaming = false; - - return false; - } - - StartMainLoop(); - return true; - } - - - private void GenerateNdiMicPipeline() - { - _ndiMicPipeline = new Pipeline("ndi_mic_pipeline"); - - var ndisink = ElementFactory.Make("ndisink"); - ndisink.SetProperty("ndi-name", new Value(Dns.GetHostName() + "-mic")); - - var micAudio = ElementFactory.Make("pulsesrc", "desktop_audio"); - micAudio.SetProperty("device", new Value(micSrcSink)); - - _ndiMicPipeline.Add(micAudio); - _ndiMicPipeline.Add(ndisink); - - micAudio.Link(ndisink); - } - - - private void GenerateNdiPipeline() - { - var ndisinkcombiner = Gst.ElementFactory.Make("ndisinkcombiner"); - var ndisink = Gst.ElementFactory.Make("ndisink"); - ndisink.SetProperty("ndi-name", new Value(Dns.GetHostName())); - - var videosrc = Gst.ElementFactory.Make("pipewiresrc"); - videosrc.SetProperty("do-timestamp", new Value(true)); - - var videopostproc = Gst.ElementFactory.Make("vaapipostproc"); - var queue1 = Gst.ElementFactory.Make("queue"); - - // var audioqueue = Gst.ElementFactory.Make("queue", "audioqueue"); - - - desktopAudio = Gst.ElementFactory.Make("pulsesrc", "desktop_audio"); - desktopAudio.SetProperty("device", new Value(audioSrcSink)); - - - _pipeline.Add(videopostproc); - _pipeline.Add(queue1); - _pipeline.Add(desktopAudio); - // _pipeline.Add(audioqueue); - - _pipeline.Add(videosrc); - _pipeline.Add(ndisinkcombiner); - _pipeline.Add(ndisink); - - _pipeline.Link(videosrc); - videosrc.Link(videopostproc); - videopostproc.Link(queue1); - queue1.Link(ndisinkcombiner); - ndisinkcombiner.Link(ndisink); - - desktopAudio.Link(ndisinkcombiner); - } - - - private void GenerateRtmpPipeline(DeckyStreamConfig config) - { - var flvmux = Gst.ElementFactory.Make("flvmux"); - flvmux.SetProperty("streamable", new Value(true)); - - var rtmpsink = Gst.ElementFactory.Make("rtmpsink"); - rtmpsink.SetProperty("location", new Value(config.RtmpEndpoint)); - - var videosrc = Gst.ElementFactory.Make("pipewiresrc"); - videosrc.SetProperty("do-timestamp", new Value(true)); - - var videopostproc = Gst.ElementFactory.Make("vaapipostproc"); - var queue1 = Gst.ElementFactory.Make("queue"); - - var videoenc = Gst.ElementFactory.Make("vaapih264enc"); - var h264parse = Gst.ElementFactory.Make("h264parse"); - - - var audioconv = ElementFactory.Make("audioconvert"); - - - var audioEnc = ElementFactory.Make("lamemp3enc"); - audioEnc.SetProperty("target", new Value("bitrate")); - audioEnc.SetProperty("bitrate", new Value("128")); - audioEnc.SetProperty("cbr", new Value(true)); - - - var audioMixer = Gst.ElementFactory.Make("audiomixer", "audiomixer"); - - var desktopAudio = Gst.ElementFactory.Make("pulsesrc", "desktop_audio"); - desktopAudio.SetProperty("device", new Value(audioSrcSink)); - - var micAudio = Gst.ElementFactory.Make("pulsesrc", "mic_audio"); - micAudio.SetProperty("device", new Value(micSrcSink)); - - _pipeline.Add(videopostproc); - _pipeline.Add(queue1); - _pipeline.Add(audioMixer); - _pipeline.Add(desktopAudio); - _pipeline.Add(micAudio); - _pipeline.Add(videosrc); - _pipeline.Add(flvmux); - _pipeline.Add(rtmpsink); - _pipeline.Add(audioEnc); - _pipeline.Add(audioconv); - _pipeline.Add(h264parse); - _pipeline.Add(videoenc); - - _pipeline.Link(videosrc); - videosrc.Link(videopostproc); - videopostproc.Link(queue1); - queue1.Link(videoenc); - videoenc.Link(h264parse); - h264parse.Link(flvmux); - - - audioMixer.Link(audioconv); - audioconv.Link(audioEnc); - audioEnc.Link(flvmux); - - desktopAudio.Link(audioMixer); - micAudio.Link(audioMixer); - } - - public bool Stop() - { - _logger.LogInformation("Stopping pipeline"); - if (!IsRecording && !IsStreaming) return true; - - if (_ndiMicPipeline != null) - { - var evt = _ndiMicPipeline.SendEvent(Event.NewEos()); - - } - if (_pipeline != null) - { - - var evt = _pipeline.SendEvent(Event.NewEos()); - if (evt) - { - IsRecording = false; - IsStreaming = false; - } - - return evt; - } - - return false; - } - - - public void AddMic() - { - if (_pipeline != null) - { - micAudio = Gst.ElementFactory.Make("pulsesrc", "mic_audio"); - micAudio.SetProperty("device", new Value(micSrcSink)); - - _pipeline.Add(micAudio); - micAudio.Link(audioqueue); - - } - } - - public void RemoveMic() - { - if (_pipeline != null) - { - micAudio.Unlink(audioqueue); - _pipeline.Remove(micAudio); - } - } - public string GetDotDebug() - { - return Gst.Debug.BinToDotData(_pipeline, DebugGraphDetails.All); - } - - public void Dispose() - { - _pipeline.SendEvent(Event.NewEos()); - Thread.Sleep(1000); - - _pipeline.Dispose(); - } - - - async void OnNdiMicMessage(object e, MessageArgs args) - { - - switch (args.Message.Type) - { - case MessageType.StateChanged: - State oldstate, newstate, pendingstate; - args.Message.ParseStateChanged(out oldstate, out newstate, out pendingstate); - if (newstate == State.Playing) - { - if (IsRecording) await _streamHubContext.Clients.All.GstreamerStateChange(GstreamerState.StartedRecording); - if (IsStreaming) await _streamHubContext.Clients.All.GstreamerStateChange(GstreamerState.StartedStreaming); - - } - _logger.LogInformation($"[StateChange] From {oldstate} to {newstate} pending at {pendingstate}"); - break; - case MessageType.StreamStatus: - Element owner; - StreamStatusType type; - args.Message.ParseStreamStatus(out type, out owner); - _logger.LogInformation($"[StreamStatus] Type {type} from {owner}"); - break; - case MessageType.DurationChanged: - long duration; - _pipeline.QueryDuration(Format.Time, out duration); - _logger.LogInformation($"[DurationChanged] New duration is {(duration / Gst.Constants.SECOND)} seconds"); - break; - case MessageType.ResetTime: - ulong runningtime = args.Message.ParseResetTime(); - _logger.LogInformation($"[ResetTime] Running time is {runningtime}"); - break; - case MessageType.AsyncDone: - ulong desiredrunningtime = args.Message.ParseAsyncDone(); - _logger.LogInformation($"[AsyncDone] Running time is {desiredrunningtime}"); - break; - case MessageType.NewClock: - Clock clock = args.Message.ParseNewClock(); - _logger.LogInformation($"[NewClock] {clock}"); - break; - case MessageType.Buffering: - int percent = args.Message.ParseBuffering(); - _logger.LogInformation($"[Buffering] {percent}% done"); - break; - case MessageType.Tag: - TagList list = args.Message.ParseTag(); - _logger.LogInformation($"[Tag] Information in scope {list.Scope} is {list.ToString()}"); - break; - case MessageType.Error: - GLib.GException gerror; - string debug; - args.Message.ParseError(out gerror, out debug); - _logger.LogError($"[Error] {gerror.Message}, debug information {debug}."); - _mainLoop.Quit(); - break; - case MessageType.Warning: - IntPtr warningPtr; - string warning; - args.Message.ParseWarning(out warningPtr, out warning); - _logger.LogInformation($"[Warning] {warning}."); - break; - case MessageType.Eos: - _logger.LogInformation("[Eos] Playback has ended. Exiting!"); - IsRecording = false; - IsStreaming = false; - _ndiMicPipeline.SetState(State.Null); - _pipeline.Unref(); - _mainLoop.Quit(); - break; - default: - _logger.LogInformation($"[Recv] {args.Message.Type} {args.Message}"); - break; - } - } - - - async void OnMessage(object e, MessageArgs args) - { - switch (args.Message.Type) - { - case MessageType.StateChanged: - State oldstate, newstate, pendingstate; - args.Message.ParseStateChanged(out oldstate, out newstate, out pendingstate); - if (newstate == State.Playing) - { - if (IsRecording) await _streamHubContext.Clients.All.GstreamerStateChange(GstreamerState.StartedRecording); - if (IsStreaming) await _streamHubContext.Clients.All.GstreamerStateChange(GstreamerState.StartedStreaming); - - } - _logger.LogInformation($"[StateChange] From {oldstate} to {newstate} pending at {pendingstate}"); - break; - case MessageType.StreamStatus: - Element owner; - StreamStatusType type; - args.Message.ParseStreamStatus(out type, out owner); - _logger.LogInformation($"[StreamStatus] Type {type} from {owner}"); - break; - case MessageType.DurationChanged: - long duration; - _pipeline.QueryDuration(Format.Time, out duration); - _logger.LogInformation($"[DurationChanged] New duration is {(duration / Gst.Constants.SECOND)} seconds"); - break; - case MessageType.ResetTime: - ulong runningtime = args.Message.ParseResetTime(); - _logger.LogInformation($"[ResetTime] Running time is {runningtime}"); - break; - case MessageType.AsyncDone: - ulong desiredrunningtime = args.Message.ParseAsyncDone(); - _logger.LogInformation($"[AsyncDone] Running time is {desiredrunningtime}"); - break; - case MessageType.NewClock: - Clock clock = args.Message.ParseNewClock(); - _logger.LogInformation($"[NewClock] {clock}"); - break; - case MessageType.Buffering: - int percent = args.Message.ParseBuffering(); - _logger.LogInformation($"[Buffering] {percent}% done"); - break; - case MessageType.Tag: - TagList list = args.Message.ParseTag(); - _logger.LogInformation($"[Tag] Information in scope {list.Scope} is {list.ToString()}"); - break; - case MessageType.Error: - GLib.GException gerror; - string debug; - args.Message.ParseError(out gerror, out debug); - _logger.LogError($"[Error] {gerror.Message}, debug information {debug}."); - _mainLoop.Quit(); - break; - case MessageType.Warning: - IntPtr warningPtr; - string warning; - args.Message.ParseWarning(out warningPtr, out warning); - _logger.LogInformation($"[Warning] {warning}."); - break; - case MessageType.Eos: - _ = _streamHubContext.Clients.All.GstreamerStateChange(GstreamerState.Stopped, ""); - - _logger.LogInformation("[Eos] Playback has ended. Exiting!"); - IsRecording = false; - IsStreaming = false; - _pipeline.SetState(State.Null); - _pipeline.Unref(); - _mainLoop.Quit(); - break; - default: - _logger.LogInformation($"[Recv] {args.Message.Type} {args.Message}"); - break; - } - } - - -} - diff --git a/backend/GstreamerServiceShadow.cs b/backend/GstreamerServiceShadow.cs deleted file mode 100644 index 4e90daa..0000000 --- a/backend/GstreamerServiceShadow.cs +++ /dev/null @@ -1,369 +0,0 @@ -using System; -using System.IO; -using System.IO.Pipelines; -using Gst; -using System.Net; -using System.Runtime; -using System.Runtime.InteropServices.ComTypes; -using System.Threading; -using deckystream; -using GLib; -using Microsoft.AspNetCore.SignalR; -using Microsoft.Extensions.Logging; -using Application = Gst.Application; -using DateTime = Gst.DateTime; -using StreamType = Gst.StreamType; -using Task = System.Threading.Tasks.Task; -using Value = GLib.Value; - -public class GstreamerServiceShadow : IDisposable -{ - const string micSrcSink = @"alsa_input.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__source"; - const string audioSrcSink = @"alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_1__sink.monitor"; - int buffer_count = 0; - - GLib.MainLoop _mainLoop; - - Gst.Pipeline? pipeline; - - readonly ILogger _logger; - - private readonly IHubContext _streamHubContext; - private readonly SettingsService _settingsService; - private System.DateTime PipelineStartTime; - - public GstreamerServiceShadow(ILogger logger, IHubContext streamHubContext, SettingsService settingsService) - { - _logger = logger; - _streamHubContext = streamHubContext; - _settingsService = settingsService; - try - { - Application.Init(); - } - catch (Exception ex) - { - _logger.LogCritical(ex, "error"); - } - - _mainLoop = new GLib.MainLoop(); - } - - public string GetDotDebug() - { - return Gst.Debug.BinToDotData(pipeline, DebugGraphDetails.All); - } - - private Element muxer; - private Element vrecq; - private Element filesink; - private Pad vrecq_src; - private ulong vrecq_src_probe_id; - - public async Task StopPipeline() - { - - pipeline.SendEvent(Event.NewEos()); - - pipeline.Unref(); - } - - private Element venc; - private Element parse; - private Element videosrc; - private Element postproc; - - public async Task StartPipeline() - { - PipelineStartTime = System.DateTime.UtcNow; - try - { - - var videoSrc = "pipewiresrc name=videosrc do-timestamp=true ! vaapipostproc name=postproc ! queue name=vrecq ! vaapih264enc name=venc ! h264parse name=parse "; - //var videoSrc = "videotestsrc ! video/x-raw,width=1920,height=1080,format=I420 ! clockoverlay ! x264enc tune=zerolatency bitrate=8000"; - - pipeline = (Gst.Parse.Launch($@"{videoSrc} ! mp4mux name=muxer ! filesink async=false name=filesink") as Pipeline)!; - - var buffer = _settingsService.Current.ReplayBuffer; - //todo: workout sane values for the buffer - if (buffer is < 5 or > 600) - { - _logger.LogError("Invalid buffer length: {buffer}", buffer); - return; - } - - - venc = pipeline.GetByName("venc"); - parse = pipeline.GetByName("parse"); - videosrc = pipeline.GetByName("videosrc"); - postproc = pipeline.GetByName("postproc"); - - - vrecq = pipeline.GetByName("vrecq"); - vrecq.SetProperty("max-size-time", new Value(buffer * Constants.SECOND)); - vrecq.SetProperty("max-size-bytes", new Value(0)); - vrecq.SetProperty("max-size-buffers", new Value(0)); - - //sets the queue to dispose of old buffer frames - vrecq.SetProperty("leaky", new Value(2)); - - vrecq_src = vrecq.GetStaticPad("src"); - vrecq_src_probe_id = vrecq_src.AddProbe(PadProbeType.Block | PadProbeType.Buffer, block_probe_cb); - - filesink = pipeline.GetByName("filesink"); - UpdateFileSinkLocation(); - - - muxer = pipeline.GetByName("muxer"); - - pipeline.SetState(State.Playing); - - pipeline.Bus.AddSignalWatch(); - pipeline.Bus.EnableSyncMessageEmission(); - pipeline.Bus.Message += OnMessage; - - _mainLoop.Run(); - - pipeline.SetState(State.Null); - - pipeline.Unref(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error starting pipeline"); - } - } - - void push_eos_thread() - { - try - { - vrecq_src = vrecq.GetStaticPad("src"); - _logger.LogInformation(vrecq_src.ToString()); - var peer = vrecq_src.Peer; - _logger.LogInformation(peer?.ToString()); - - if (peer == null) - { - _logger.LogError("peer is null"); - return; - } - - _logger.LogInformation($"pushing EOS event on pad ({peer.Name})"); - - /* tell pipeline to forward EOS message from filesink immediately and not - * hold it back until it also got an EOS message from the video sink */ - pipeline.MessageForward = true; - peer.SendEvent(Event.NewEos()); - peer.Unref(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error sending EOS"); - } - - isSaving = false; - } - - - void UpdateFileSinkLocation() - { - var outFile = Path.Join(DirectoryHelper.REPLAY_CLIPS_DIR, System.DateTime.Now.ToString("HH-mm-ss") + ".mp4"); - _logger.LogInformation("Changing file to location" + outFile); - filesink.SetProperty("location", new Value(outFile)); - } - - - PadProbeReturn probe_drop_one_cb(Pad pad, PadProbeInfo info) - { - if (buffer_count == 0) - { - buffer_count++; - _logger.LogInformation("Drop one buffer with ts " + info.Buffer.Dts); - return PadProbeReturn.Drop; - } - else - { - bool is_keyframe; - is_keyframe = !info.Buffer.Flags.HasFlag(BufferFlags.DeltaUnit); - - - if (is_keyframe) - { - _logger.LogInformation("Letting buffer through and removing drop probe"); - return PadProbeReturn.Remove; - } - else - { - _logger.LogInformation("Dropping buffer, wait for a keyframe."); - return PadProbeReturn.Drop; - } - } - } - - - private bool isSaving; - - public async Task StartRecording() - { - if (isSaving) return; - isSaving = true; - try - { - _logger.LogInformation("timeout, unblocking pad to start recording"); - - /* need to hook up another probe to drop the initial old buffer stuck - * in the blocking pad probe */ - vrecq_src.AddProbe(PadProbeType.Buffer, probe_drop_one_cb); - - - /* now remove the blocking probe to unblock the pad */ - if (vrecq_src_probe_id != 0) - { - vrecq_src.RemoveProbe(vrecq_src_probe_id); - } - - vrecq_src_probe_id = 0; - - await Task.Delay(5000).ContinueWith((x) => StopRecording()); - - } - catch (Exception ex) - { - _logger.LogError("StartRecording fail"); - } - } - - PadProbeReturn block_probe_cb(Pad pad, PadProbeInfo info) - { - return PadProbeReturn.Ok; - } - - - void StopRecording() - { - try - { - _logger.LogInformation("stop recording"); - vrecq_src_probe_id = vrecq_src.AddProbe(PadProbeType.Block | PadProbeType.Buffer, block_probe_cb); - Task.Run(push_eos_thread); - } - catch (Exception ex) - { - - _logger.LogError("StopRecording fail"); - } - } - - - async void OnMessage(object e, MessageArgs args) - { - try - { - _logger.LogInformation($"[{args.Message.Type}] {args.Message}"); - - switch (args.Message.Type) - { - case MessageType.StateChanged: - State oldstate, newstate, pendingstate; - args.Message.ParseStateChanged(out oldstate, out newstate, out pendingstate); - _logger.LogInformation($"[StateChange] From {oldstate} to {newstate} pending at {pendingstate}"); - Directory.CreateDirectory(Path.Join(DirectoryHelper.LOG_DIR, PipelineStartTime.ToString("yyyy-M-d-hh-mm-ss"))); - var file = File.CreateText(Path.Join(DirectoryHelper.LOG_DIR, PipelineStartTime.ToString("yyyy-M-d-hh-mm-ss"), - $"{System.DateTime.UtcNow.ToString("HHms")}-{oldstate}-{newstate}-{pendingstate}")); - await file.WriteAsync(GetDotDebug()); - break; - case MessageType.Error: - GLib.GException gerror; - string debug; - args.Message.ParseError(out gerror, out debug); - _logger.LogError($"[Error] {gerror.Message}, debug information {debug}."); - _mainLoop.Quit(); - break; - case MessageType.Warning: - IntPtr warningPtr; - string warning; - args.Message.ParseWarning(out warningPtr, out warning); - _logger.LogTrace($"[Warning] {warning}."); - break; - case MessageType.Element: - - if (args.Message.Structure.HasName("GstBinForwarded")) - { - var forwardedMessage = (Message)args.Message.Structure.GetValue("message"); - - if (forwardedMessage.Type == MessageType.Eos) - { - _logger.LogInformation("Forwarded EOS from " + forwardedMessage.Src.NativeType + ":" + forwardedMessage.Src.Name); - - filesink.SetState(State.Null); - muxer.SetState(State.Null); - parse.SetState(State.Null); - venc.SetState(State.Null); - - // videosrc.SetState(State.Null); - // postproc.SetState(State.Null); - - - - // pipeline.Remove(muxer); - // muxer = Gst.ElementFactory.Make("mp4mux", "muxer"); - // pipeline.Add(muxer); - // vrecq.Link(muxer); - // muxer.Link(filesink); - // Gst.Element.Link(vrecq, muxer, filesink); - UpdateFileSinkLocation(); - - - // videosrc.SetState(State.Playing); - // postproc.SetState(State.Playing); - - venc.SetState(State.Playing); - parse.SetState(State.Playing); - muxer.SetState(State.Playing); - - filesink.SetState(State.Playing); - - - } - - forwardedMessage.Dispose(); - } - - break; - case MessageType.Eos: - // filesink.SetState(State.Null); - // muxer.SetState(State.Null); - // venc.SetState(State.Null); - // parse.SetState(State.Null); - // pipeline.SetState(State.Null); - // _mainLoop.Quit(); - break; - case MessageType.StreamStatus: - Element owner; - StreamStatusType type; - args.Message.ParseStreamStatus(out type, out owner); - _logger.LogInformation($"[StreamStatus] Type {type} from {owner}"); - break; - - default: - _logger.LogInformation($"[Recv] {args.Message.Type} {args.Message}"); - break; - } - } - catch (Exception ex) - { - _logger.LogError(ex, "OnMessage fail"); - } - } - - - public void Dispose() - { - pipeline?.Dispose(); - muxer.Dispose(); - vrecq.Dispose(); - filesink.Dispose(); - vrecq_src.Dispose(); - } -} \ No newline at end of file diff --git a/backend/LogHooks/CaptureFilePathHook.cs b/backend/LogHooks/CaptureFilePathHook.cs deleted file mode 100644 index 0850f66..0000000 --- a/backend/LogHooks/CaptureFilePathHook.cs +++ /dev/null @@ -1,15 +0,0 @@ -ļ»æusing System.Text; -using Serilog.Sinks.File; - -namespace deckystream.LogHooks; - -internal class CaptureFilePathHook : FileLifecycleHooks -{ - public string? Path { get; private set; } - - public override Stream OnFileOpened(string path, Stream underlyingStream, Encoding encoding) - { - Path = path; - return base.OnFileOpened(path, underlyingStream, encoding); - } -} \ No newline at end of file diff --git a/backend/Program.cs b/backend/Program.cs deleted file mode 100644 index cb1c8ce..0000000 --- a/backend/Program.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System.IO.Compression; -using System.Text; -using System.Text.Json.Serialization; -using deckystream; -using deckystream.LogHooks; -using Microsoft.Extensions.FileProviders; -using Serilog; -using JsonOptions = Microsoft.AspNetCore.Http.Json.JsonOptions; - -// DirectoryHelper.CreateDirs(); - - -CaptureFilePathHook filePathHook = new CaptureFilePathHook(); - - -Log.Logger = new LoggerConfiguration() - .Enrich.FromLogContext() - .WriteTo.Console() - // .WriteTo.File($"{DirectoryHelper.LOG_DIR}/deckystream.log", rollingInterval: RollingInterval.Day, hooks: filePathHook) - .CreateBootstrapLogger(); - -var builder = WebApplication.CreateBuilder(args); - -#if DEBUG - -builder.Services.AddCors( - options => options.AddPolicy("CorsPolicy", - x => x.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin())); - -#else - -builder.Services.AddCors( - options => options.AddPolicy("CorsPolicy", - x => x.AllowAnyMethod().AllowCredentials().AllowAnyHeader().WithOrigins("https://steamloopback.host"))); -#endif -builder.Host.UseSerilog((context, services, configuration) => configuration - .ReadFrom.Configuration(context.Configuration) - .ReadFrom.Services(services) - .Enrich.FromLogContext() - .WriteTo.Console() - // .WriteTo.File($"{DirectoryHelper.LOG_DIR}/deckystream.log", rollingInterval: RollingInterval.Day, hooks: filePathHook) -); - -builder.Services.Configure(options => { options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); }); - - -builder.Services.AddSignalR(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); - -var app = builder.Build(); -app.UseSerilogRequestLogging(); - -app.UseCors("CorsPolicy"); - -var settings = app.Services.GetRequiredService(); -await settings.Initialise(); - - -app.MapHub("/streamhub"); - -app.MapGet("/start", (GstreamerService gstreamerService) => gstreamerService.Start()); - -app.MapGet("/start-shadow", (GstreamerServiceShadow gstreamerService) => -{ - _ = gstreamerService.StartPipeline(); - return ""; -}); - -app.MapGet("/stop-shadow", (GstreamerServiceShadow gstreamerService) => -{ - _ = gstreamerService.StopPipeline(); - return ""; -}); - -app.MapGet("/save-shadow", (GstreamerServiceShadow gstreamerService) => -{ - _ = gstreamerService.StartRecording(); - return ""; -}); - -app.MapGet("/start-stream", async (GstreamerService gstreamerService) => await gstreamerService.StartStream()); - -app.MapGet("/stop", (GstreamerService gstreamerService) => gstreamerService.Stop()); - - -app.MapGet("/isRecording", (GstreamerService gstreamerService) => gstreamerService.GetIsRecording()); -app.MapGet("/isStreaming", (GstreamerService gstreamerService) => gstreamerService.GetIsStreaming()); - -app.MapDelete("/delete/{*path}", (string path) => -{ - Console.WriteLine(path); - File.Delete($"/home/deck/Videos/DeckyStream/{path}"); -}); - -app.MapGet("/debug/dot", (GstreamerService gstreamerService) => gstreamerService.GetDotDebug()); - -app.MapGet("/debug/shadow/dot", (GstreamerServiceShadow gstreamerService) => gstreamerService.GetDotDebug()); - -app.MapGet("/debug/zip", async (HttpResponse response, GstreamerService gstreamerService, ILogger logger) => -{ - response.ContentType = "application/octet-stream"; - response.Headers.Add("Content-Disposition", "attachment; filename=\"DeckyStreamTroubleshoot.zip\""); - - string? dotText = null; - using var archive = new ZipArchive(response.BodyWriter.AsStream(), ZipArchiveMode.Create); - - try - { - dotText = gstreamerService.GetDotDebug(); - } - catch (Exception ex) - { - logger.LogError(ex, "Failed to get dot graph"); - } - - if (!string.IsNullOrEmpty(dotText)) - { - var entry = archive.CreateEntry("dot"); - await using var entryStream = entry.Open(); - await entryStream.WriteAsync(Encoding.UTF8.GetBytes(dotText)); - - } - - if (!string.IsNullOrEmpty(filePathHook.Path)) - { - var logFile = File.ReadAllBytes(filePathHook.Path); - var logEntry = archive.CreateEntry(Path.GetFileName(filePathHook.Path)); - await using var logEntryStream = logEntry.Open(); - await logEntryStream.WriteAsync(logFile); - } - else - { - logger.LogError("No log file"); - } -}); - - -app.MapGet("/list", () => -{ - return Directory.GetFiles(DirectoryHelper.CLIPS_DIR, "*.mp4", SearchOption.AllDirectories) - .OrderByDescending(d => new FileInfo(d).CreationTime) - .Select((x) => x.Replace(DirectoryHelper.CLIPS_DIR, "")); -}); - -app.MapGet("/list-count", () => Directory.GetFiles(DirectoryHelper.CLIPS_DIR, "*.mp4", SearchOption.AllDirectories).Length); - -app.Run("http://*:6969"); \ No newline at end of file diff --git a/backend/StreamHub.cs b/backend/StreamHub.cs deleted file mode 100644 index 2d3924a..0000000 --- a/backend/StreamHub.cs +++ /dev/null @@ -1,126 +0,0 @@ -using Microsoft.AspNetCore.SignalR; - -namespace deckystream; - -public class StreamHub : Hub -{ - private readonly GstreamerService _gstreamerService; - private readonly GstreamerServiceShadow _gstreamerServiceShadow; - private readonly SettingsService _settingsService; - - public StreamHub(GstreamerService gstreamerService, GstreamerServiceShadow gstreamerServiceShadow, SettingsService settingsService) - { - _gstreamerService = gstreamerService; - _gstreamerServiceShadow = gstreamerServiceShadow; - _settingsService = settingsService; - } - - public async Task StartRecord() - { - return await _gstreamerService.Start(); - } - public async Task StopRecord() - { - return _gstreamerService.Stop(); - } - - public async Task StartStream() - { - return await _gstreamerService.StartStream(); - } - - public async Task StopStream() - { - return _gstreamerService.Stop(); - } - - public async Task GetRecordingStatus() - { - return _gstreamerService.GetIsRecording(); - } - - public async Task GetStreamingStatus() - { - return _gstreamerService.GetIsStreaming(); - } - - public Task StartShadow() - { - _ = _gstreamerServiceShadow.StartPipeline(); - return Task.CompletedTask; - } - - public Task StopShadow() - { - _ = _gstreamerServiceShadow.StopPipeline(); - return Task.CompletedTask; - } - - public Task SaveShadow() - { - _ = _gstreamerServiceShadow.StartRecording(); - return Task.CompletedTask; - } - - public Task SetConfig(DeckyStreamConfig config) - { - return _settingsService.Save(config); - } - - public async Task GetConfig() - { - return _settingsService.Current; - } - - public async Task ToggleMic(bool enabled) - { - if (enabled) - { - _gstreamerService.AddMic(); - return true; - } - - return false; - } - - public async Task ResumeSuspend() - { - if (_settingsService.Current.ShadowEnabled) - { - await _gstreamerServiceShadow.StartPipeline(); - } - } - - - public async Task Suspend() - { - if (_settingsService.Current.ShadowEnabled) - { - await _gstreamerServiceShadow.StopPipeline(); - } - } - - - -} - -public enum GstreamerState -{ - Starting, - StartedRecording, - StartedStreaming, - StoppedError, - Stopped -} - - - -public interface IStreamClient -{ - Task StreamingStatusChange(bool streaming); - - Task RecordingStatusChange(bool recording); - - Task GstreamerStateChange(GstreamerState state, string reason = ""); - -} \ No newline at end of file diff --git a/backend/appsettings.Development.json b/backend/appsettings.Development.json deleted file mode 100644 index 0c208ae..0000000 --- a/backend/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/backend/appsettings.json b/backend/appsettings.json deleted file mode 100644 index 10f68b8..0000000 --- a/backend/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/backend/buildGstreamerNdi.sh b/backend/buildGstreamerNdi.sh deleted file mode 100644 index 01d5d9a..0000000 --- a/backend/buildGstreamerNdi.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs -cd gst-plugins-rs -cargo install cargo-c -cargo cbuild -p gst-plugin-ndi -cp -v target/x86_64-unknown-linux-gnu/debug/libgstndi.so /backend/out/lib/gstreamer/ - -cd ../ -rm -rfv gst-plugins-rs \ No newline at end of file diff --git a/backend/deckystream.csproj b/backend/deckystream.csproj deleted file mode 100644 index d84c2c5..0000000 --- a/backend/deckystream.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net6.0 - enable - enable - exe - true - $(DefaultItemExcludes);out** - - - - - - - - - - - - diff --git a/backend/deckystream.sln b/backend/deckystream.sln deleted file mode 100644 index 4a8f5bd..0000000 --- a/backend/deckystream.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "deckystream", "deckystream.csproj", "{AE90B7E5-F5F3-4A9F-AF42-6401BAE81986}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AE90B7E5-F5F3-4A9F-AF42-6401BAE81986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE90B7E5-F5F3-4A9F-AF42-6401BAE81986}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE90B7E5-F5F3-4A9F-AF42-6401BAE81986}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE90B7E5-F5F3-4A9F-AF42-6401BAE81986}.Release|Any CPU.Build.0 = Release|Any CPU - {DF37EB45-9391-4BBA-A40C-C19B806D250E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DF37EB45-9391-4BBA-A40C-C19B806D250E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DF37EB45-9391-4BBA-A40C-C19B806D250E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DF37EB45-9391-4BBA-A40C-C19B806D250E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/backend/downloadNdi.sh b/backend/downloadNdi.sh deleted file mode 100755 index 879bede..0000000 --- a/backend/downloadNdi.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -echo "Downloading" -mkdir ndi-build -wget https://downloads.ndi.tv/SDK/NDI_SDK_Linux/Install_NDI_SDK_v5_Linux.tar.gz - -#code from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ndi-sdk - -bsdtar -x -f Install_NDI_SDK_v5_Linux.tar.gz -C ndi-build -cd ndi-build -_target_line="$(sed -n '/^__NDI_ARCHIVE_BEGIN__$/=' "Install_NDI_SDK_v5_Linux.sh")" -_target_line="$((_target_line + 1))" - -echo "Extracting" - -tail -n +"$_target_line" "Install_NDI_SDK_v5_Linux.sh" | tar -zxvf - - -echo "Copying libs" - -cp -v "NDI SDK for Linux/lib/x86_64-linux-gnu/libndi.so.5.5.2" /backend/out/lib/libndi.so.5 -# cp -v "NDI SDK for Linux/lib/x86_64-linux-gnu/libndi.so*" /usr/lib/ -# ldconfig -cd .. - -# git clone https://github.com/teltek/gst-plugin-ndi -# cd gst-plugin-ndi -# cargo build -# cp target/release/libgstndi.so ../out/lib/gstreamer/ - -echo "Cleaning up" -rm Install_NDI_SDK_v5_Linux.tar.gz -rm -rfv ndi-build diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index 231b965..5edcb51 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -1,18 +1,25 @@ #!/bin/sh set -e -cd /backend +export DOTNET_ROOT=/usr/share/dotnet +export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools +export DOTNET_CLI_HOME="/tmp/DOTNET_CLI_HOME" +export DOTNET_CLI_TELEMETRY_OPTOUT=1 + mkdir -p /backend/out +cd /backend/src/obs_recorder + +dotnet publish -r linux-x64 -c Release -o /backend/out/ + +mkdir -p /backend/out/obs +mv /obs-portable/* /backend/out/obs/ +mv /backend/out/obs/bin/64bit/obs-ffmpeg-mux /backend/out/ -dotnet publish -p:OutputType=exe -c Debug -r linux-x64 -p:PublishSingleFile=true --self-contained true -p:PublishTrimmed=false -cp -rfv /backend/bin/Release/net6.0/linux-x64/publish/* /backend/out/ -chmod +x /backend/out/deckystream -mkdir -p /backend/out/lib/gstreamer +mkdir -p /backend/out/ffmpeg-libs/ -cp -rv /usr/lib/libgst* /backend/out/lib/ -cp -rv /usr/lib/gstreamer-1.0/libgst* /backend/out/lib/gstreamer/ -/backend/downloadNdi.sh +pacman -Ql ffmpeg | grep '/usr/lib/.*\.so\.[0-9]*$' | awk '{print $2}' | xargs -I{} cp {} /backend/out/ffmpeg-libs/ -/backend/buildGstreamerNdi.sh \ No newline at end of file +cp /usr/lib/libvpx* /backend/out/ffmpeg-libs/ +cp /usr/lib/libvidstab* /backend/out/ffmpeg-libs/ \ No newline at end of file diff --git a/backend/publish.sh b/backend/publish.sh deleted file mode 100644 index 9045e78..0000000 --- a/backend/publish.sh +++ /dev/null @@ -1,3 +0,0 @@ -dotnet publish -p:OutputType=exe -c Release -r linux-x64 -p:PublishSingleFile=true --self-contained true -p:PublishTrimmed=true --output ../bin - -# dotnet publish -p:OutputType=exe -c Debug -r linux-x64 -p:PublishSingleFile=true --self-contained true -p:PublishTrimmed=false --output ../bin \ No newline at end of file diff --git a/backend/src/LICENSE b/backend/src/LICENSE new file mode 100644 index 0000000..87f923f --- /dev/null +++ b/backend/src/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Jimmy Quach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/backend/src/README.md b/backend/src/README.md new file mode 100644 index 0000000..b55672d --- /dev/null +++ b/backend/src/README.md @@ -0,0 +1,51 @@ +# libobs.NET +This is a C# wrapper for libobs. It's intention is to provide straightforward API for building around the libobs library, creating applications on the .NET platform. + +This library is currently built around .NET 5 and LibObs 27.5.32. + +## Development Notes +1. Currently supports only a very limited amount of features mainly for the purpose of recording/encoding. It is mainly built for the use of my personal project, [RePlays](https://github.com/lulzsun/RePlays). + +2. Do not use this unless you understand the consequences of the API being directly exposed, (at the time of writing, there are no safety wrapper methods). You should only use this if you can handle the issues related to this. + +3. For docs, you can reference from [obsproject's documentation](https://obsproject.com/docs/index.html). Naming conventions of methods/classes/etc. are 1:1 with the docs (because of note #2), for ease of use and straightforward library development. + +Missing features that you would like to see? Submit an issue ticket! + +## Install +Build libobs yourself or use this [prebuilt version 27.5.32](https://obsstudios3.streamlabs.com/libobs-windows64-release-27.5.32.7z) provided by Streamlabs. + +If you are using the prebuilt version, this is what the file structure should (roughly) look like after you unzip: +``` +- packed_build + - bin + - 64bit + - obs.dll & ~dependencies/.dlls, etc. files~ + - cmake + - data + - include + - obs-plugins +``` + +Using the `obs_net.example` project as an example, this is how the libobs files should be located under `Debug` folder in order for everything to work correctly when debugging. + +``` +- Debug + - net5.0 + - data + - obs-plugins + - obs.dll & ~dependencies/.dlls, etc. files~ + - obs_net.example.exe +``` + +## TODO +- abstraction +- type safety +- gc / memory management + +## Special thanks to +[GoaLitiuM/libobs-sharp](https://github.com/GoaLitiuM/libobs-sharp) used some snippets and as reference + +[FFFFFFFXXXXXXX/libobs-recorder](https://github.com/FFFFFFFXXXXXXX/libobs-recorder) used as learning reference + +[stream-labs/obs-studio-node](https://github.com/stream-labs/obs-studio-node) used as learning reference diff --git a/backend/src/obs_net.sln b/backend/src/obs_net.sln new file mode 100644 index 0000000..df4b70a --- /dev/null +++ b/backend/src/obs_net.sln @@ -0,0 +1,33 @@ +ļ»æ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32421.90 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "obs_net", "obs_net\obs_net.csproj", "{8CA38250-7107-4EBD-9009-EE57746DF934}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "obs_recorder", "obs_recorder\obs_recorder.csproj", "{D1381669-B5F9-49AE-835D-C58CEBAB20E6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8E85EA2D-0888-41DE-B2EC-16A9F9EBF16B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8CA38250-7107-4EBD-9009-EE57746DF934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CA38250-7107-4EBD-9009-EE57746DF934}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CA38250-7107-4EBD-9009-EE57746DF934}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CA38250-7107-4EBD-9009-EE57746DF934}.Release|Any CPU.Build.0 = Release|Any CPU + {D1381669-B5F9-49AE-835D-C58CEBAB20E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1381669-B5F9-49AE-835D-C58CEBAB20E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1381669-B5F9-49AE-835D-C58CEBAB20E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1381669-B5F9-49AE-835D-C58CEBAB20E6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5B6BB559-6DE0-4082-95A3-53A08B358253} + EndGlobalSection +EndGlobal diff --git a/backend/src/obs_net/Bmem.cs b/backend/src/obs_net/Bmem.cs new file mode 100644 index 0000000..ea31b01 --- /dev/null +++ b/backend/src/obs_net/Bmem.cs @@ -0,0 +1,14 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + public partial class Obs { + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern long bnum_allocs(); + + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void bfree(IntPtr ptr); + + } +} diff --git a/backend/src/obs_net/Data.cs b/backend/src/obs_net/Data.cs new file mode 100644 index 0000000..e0c02e3 --- /dev/null +++ b/backend/src/obs_net/Data.cs @@ -0,0 +1,65 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using obs_data_array_t = IntPtr; + using obs_data_t = IntPtr; + using size_t = UIntPtr; + + public partial class Obs { + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern obs_data_t obs_data_create(); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void obs_data_set_string( + obs_data_t data, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string val); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void obs_data_set_bool( + obs_data_t data, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + bool val); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void obs_data_set_int( + obs_data_t data, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + uint val); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_data_array_t obs_data_get_array( + obs_data_t data, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void obs_data_set_array( + obs_data_t data, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + obs_data_array_t array); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern obs_data_array_t obs_data_array_create(); + + /// + /// https://obsproject.com/docs/reference-settings.html?highlight=obs_data_create#c.obs_data_release + /// Releases a reference to a data object. + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_data_release( + obs_data_t data); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern size_t obs_data_array_push_back( + obs_data_array_t array, + obs_data_t obj); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_data_array_release(obs_data_array_t array); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern string obs_data_get_json(obs_data_t data); + } +} diff --git a/backend/src/obs_net/Display.cs b/backend/src/obs_net/Display.cs new file mode 100644 index 0000000..8cf3ca6 --- /dev/null +++ b/backend/src/obs_net/Display.cs @@ -0,0 +1,30 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + + +namespace obs_net; + +public partial class Obs { + + [DllImport(Obs.importLibrary, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + //public static extern void obs_set_nix_platform([NativeTypeName("enum obs_nix_platform_type")] obs_nix_platform_type platform); + + public static extern void obs_set_nix_platform(obs_nix_platform_type platform); + + [DllImport(Obs.importLibrary, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + //[return: NativeTypeName("enum obs_nix_platform_type")] + public static extern obs_nix_platform_type obs_get_nix_platform(); + + [DllImport(Obs.importLibrary, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void obs_set_nix_platform_display(IntPtr display); + + [DllImport(Obs.importLibrary, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern IntPtr obs_get_nix_platform_display(); + +} + +public enum obs_nix_platform_type { + OBS_NIX_PLATFORM_X11_GLX, + OBS_NIX_PLATFORM_X11_EGL, + OBS_NIX_PLATFORM_WAYLAND +} \ No newline at end of file diff --git a/backend/src/obs_net/Encoder.cs b/backend/src/obs_net/Encoder.cs new file mode 100644 index 0000000..32f26fd --- /dev/null +++ b/backend/src/obs_net/Encoder.cs @@ -0,0 +1,61 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using audio_t = IntPtr; + using obs_data_t = IntPtr; + using obs_encoder_t = IntPtr; + using obs_output_t = IntPtr; + using size_t = UIntPtr; + using video_t = IntPtr; + public partial class Obs { + /// + /// https://obsproject.com/docs/reference-encoders.html?highlight=obs_video_encoder_create#c.obs_video_encoder_create + /// + /// The encoder type string identifier + /// The desired name of the encoder. If this is not unique, it will be made to be unique + /// The settings for the encoder, or NULL if none + /// Saved hotkey data for the encoder, or NULL if none + /// A reference to the newly created encoder, or NULL if failed + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_encoder_t obs_video_encoder_create( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string id, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + obs_data_t settings, obs_data_t hotkey_data); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_encoder_t obs_audio_encoder_create( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string id, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + obs_data_t settings, UIntPtr mixer_idx, obs_data_t hotkey_data); + + /// + /// https://obsproject.com/docs/reference-outputs.html?highlight=obs_output_set_video_encoder#c.obs_output_set_video_encoder + /// + /// + /// The video/audio encoder + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_set_video_encoder(obs_output_t output, obs_encoder_t encoder); + + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_enum_encoder_types(size_t idx, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] ref string id); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_set_audio_encoder(obs_output_t output, obs_encoder_t encoder, UIntPtr idx); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_encoder_set_video(obs_encoder_t encoder, video_t video); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_encoder_set_audio(obs_encoder_t encoder, audio_t audio); + + /// + /// https://obsproject.com/docs/reference-encoders.html?highlight=obs_encoder_release#c.obs_encoder_release + /// Releases a reference to an encoder. When the last reference is released, the encoder is destroyed. + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_encoder_release(obs_encoder_t encoder); + } +} diff --git a/backend/src/obs_net/Helpers.cs b/backend/src/obs_net/Helpers.cs new file mode 100644 index 0000000..104f99e --- /dev/null +++ b/backend/src/obs_net/Helpers.cs @@ -0,0 +1,77 @@ +ļ»æusing System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace obs_net { + class Helpers { + + + } + + /* + * P/Invoke helpers + */ + + /// + /// Marshals strings between unmanaged and managed heaps, and + /// converts them from UTF-8 strings to UTF-16 and vice versa. + /// + [System.Diagnostics.DebuggerStepThrough] + public class UTF8StringMarshaler : ICustomMarshaler { + IntPtr allocatedPtr; + + public static ICustomMarshaler GetInstance(string cookie) { + //return instance; + return new UTF8StringMarshaler(); + } + + public object MarshalNativeToManaged(IntPtr ptr) { + if (ptr == IntPtr.Zero) + return null; + + var bytes = new List(); + int offset = 0; + byte chr = 0; + + do { + if ((chr = Marshal.ReadByte(ptr, offset++)) != 0) + bytes.Add(chr); + } while (chr != 0); + + return System.Text.Encoding.UTF8.GetString(bytes.ToArray()); + } + + public IntPtr MarshalManagedToNative(object obj) { + string str = obj as string; + if (str == null) + return IntPtr.Zero; + + byte[] bytes = new byte[System.Text.Encoding.UTF8.GetByteCount(str) + 1]; + System.Text.Encoding.UTF8.GetBytes(str, 0, str.Length, bytes, 0); + + IntPtr ptr = Marshal.AllocHGlobal(bytes.Length); + Marshal.Copy(bytes, 0, ptr, bytes.Length); + + allocatedPtr = ptr; + return ptr; + } + + public int GetNativeDataSize() { + return -1; + } + + public void CleanUpNativeData(IntPtr ptr) { + // Clean up is called even though no native data were allocated + // by us. Since we always assume the caller itself allocated + // the memory, we don't need to release it. + + if (ptr != IntPtr.Zero && allocatedPtr == ptr) { + Marshal.FreeHGlobal(ptr); + allocatedPtr = IntPtr.Zero; + } + } + + public void CleanUpManagedData(object obj) { + } + } +} diff --git a/backend/src/obs_net/Logger.cs b/backend/src/obs_net/Logger.cs new file mode 100644 index 0000000..5ad5b70 --- /dev/null +++ b/backend/src/obs_net/Logger.cs @@ -0,0 +1,120 @@ +ļ»æusing System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using Microsoft.Extensions.Logging; + +namespace obs_net +{ + public partial class Obs + { + public enum LogErrorLevel { error = 100, warning = 200, info = 300, debug = 400 }; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)] + public delegate void log_handler_t(int lvl, string msg, IntPtr args, IntPtr p); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void base_set_log_handler(log_handler_t handler, IntPtr param); + + static public LogLevel LogErrorLvlToLogLvl(LogErrorLevel logError) + { + switch (logError) + { + case LogErrorLevel.error: + return LogLevel.Error; + case LogErrorLevel.warning: + return LogLevel.Warning; + case LogErrorLevel.info: + return LogLevel.Information; + case LogErrorLevel.debug: + return LogLevel.Debug; + default: + return LogLevel.None; + } + } + } + + public static class va_list + { + [StructLayout(LayoutKind.Sequential, Pack = 4)] + struct VaListLinuxX64 + { + uint gp_offset; + uint fp_offset; + IntPtr overflow_arg_area; + IntPtr reg_save_area; + } + + public static void UseStructurePointer(T structure, Action action) + { + var listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); + try + { + Marshal.StructureToPtr(structure, listPointer, false); + action(listPointer); + } + finally + { + Marshal.FreeHGlobal(listPointer); + } + } + + public static void LinuxX64Callback(string format, IntPtr args, ILogger logger) + { + // The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure. + var listStructure = Marshal.PtrToStructure(args); + int byteLength = 0; + UseStructurePointer(listStructure, listPointer => + { + byteLength = vsnprintf(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1; + }); + var utf8Buffer = Marshal.AllocHGlobal(byteLength); + try + { + UseStructurePointer(listStructure, listPointer => + { + vsprintf(utf8Buffer, format, listPointer); + logger.LogInformation(Utf8ToString(utf8Buffer)); + }); + } + finally + { + Marshal.FreeHGlobal(utf8Buffer); + } + } + + public static string Utf8ToString(IntPtr ptr) + { + if (ptr == IntPtr.Zero) + { + return null; + } + + var length = 0; + + while (Marshal.ReadByte(ptr, length) != 0) + { + length++; + } + + byte[] buffer = new byte[length]; + Marshal.Copy(ptr, buffer, 0, buffer.Length); + return Encoding.UTF8.GetString(buffer); + } + + [DllImport("libc", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern int vsprintf( + IntPtr buffer, + [In][MarshalAs(UnmanagedType.LPStr)] string format, + IntPtr args); + + [DllImport("libc", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] + public static extern int vsnprintf( + IntPtr buffer, + UIntPtr size, + [In][MarshalAs(UnmanagedType.LPStr)] string format, + IntPtr args); + + } +} \ No newline at end of file diff --git a/backend/src/obs_net/Obs.cs b/backend/src/obs_net/Obs.cs new file mode 100644 index 0000000..6a9cf3c --- /dev/null +++ b/backend/src/obs_net/Obs.cs @@ -0,0 +1,320 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net +{ + using audio_t = IntPtr; + using obs_source_t = IntPtr; + using profiler_name_store_t = IntPtr; + using video_t = IntPtr; + public partial class Obs + { + public const string importLibrary = @"libobs.so"; + public const CallingConvention importCall = CallingConvention.Cdecl; + public const CharSet importCharSet = CharSet.Ansi; + + /// + /// https://obsproject.com/docs/reference-core.html#c.obs_startup + /// Initializes the OBS core context. + /// + /// The locale to use for modules (E.G. ā€œen-USā€) + /// Path to module config storage directory (or NULL if none) + /// The profiler name store for OBS to use or NULL + /// false if already initialized or failed to initialize + public static bool obs_startup(string locale, string module_config_path, profiler_name_store_t store) + { + //Directory.SetCurrentDirectory(@"C:\Program Files\obs-studio\bin\64bit\"); + return obs_startup_call(locale, module_config_path, store); + } + [DllImport(importLibrary, EntryPoint = "obs_startup", CallingConvention = importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.I1)] + private static extern bool obs_startup_call( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string locale, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string module_config_path, + profiler_name_store_t store); + + /// + /// https://obsproject.com/docs/reference-core.html#c.obs_get_version_string + /// + /// The current core version string + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] + public static extern string obs_get_version_string(); + + + /// + /// https://obsproject.com/docs/reference-core.html#c.obs_initialized + /// + /// true if the main OBS context has been initialized + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_initialized(); + + /// + /// https://obsproject.com/docs/reference-core.html#c.obs_reset_video + /// Sets base video output base resolution/fps/format. + /// Note: This data cannot be changed if an output is currently active. + /// Note: The graphics module cannot be changed without fully destroying the OBS context. + /// + /// Pointer to an obs_video_info structure containing the specification of the graphics subsystem + /// + /// OBS_VIDEO_SUCCESS - Success + /// OBS_VIDEO_NOT_SUPPORTED - The adapter lacks capabilities + /// OBS_VIDEO_INVALID_PARAM - A parameter is invalid + /// OBS_VIDEO_CURRENTLY_ACTIVE - Video is currently active + /// OBS_VIDEO_MODULE_NOT_FOUND - The graphics module is not found + /// OBS_VIDEO_FAIL - Generic failure + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern int obs_reset_video(ref obs_video_info ovi); + + /// + /// https://obsproject.com/docs/reference-core.html#c.obs_reset_audio + /// Sets base audio output format/channels/samples/etc. + /// Note: Cannot reset base audio if an output is currently active. + /// + /// Pointer to an obs_audio_info structure containing the specification of the audio subsystem + /// true if successful, false otherwise + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_reset_audio(ref obs_audio_info oai); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void obs_add_data_path( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string path + ); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void obs_add_module_path( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string bin, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string data + ); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_log_loaded_modules(); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_load_all_modules(); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_post_load_modules(); + + [StructLayout(LayoutKind.Sequential, CharSet = importCharSet)] + public struct obs_video_info + { + public string graphics_module; //Marshal.PtrToStringAnsi + + public uint fps_num; //Output FPS numerator + public uint fps_den; //Output FPS denominator + + public uint base_width; //Base compositing width + public uint base_height; //Base compositing height + + public uint output_width; //Output width + public uint output_height; //Output height + public video_format output_format; // Output format + + //Video adapter index to use (NOTE: avoid for optimus laptops) + public uint adapter; + + //Use shaders to convert to different color formats + + [MarshalAs(UnmanagedType.I1)] + public bool gpu_conversion; + + public video_colorspace colorspace; //YUV type (if YUV) + public video_range_type range; //YUV range (if YUV) + + public obs_scale_type scale_type; //How to scale if scaling + }; + + public enum obs_scale_type : int + { + OBS_SCALE_DISABLE, + OBS_SCALE_POINT, + OBS_SCALE_BICUBIC, + OBS_SCALE_BILINEAR, + OBS_SCALE_LANCZOS, + }; + + [StructLayout(LayoutKind.Sequential)] + public struct obs_audio_info + { + public uint samples_per_sec; + public speaker_layout speakers; + }; + + public const int MAX_AV_PLANES = 8; + + + [StructLayout(LayoutKind.Sequential)] + public struct AudioData + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_AV_PLANES)] + public IntPtr[] data; + public uint frames; + public ulong timestamp; + } + + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct resample_info + { + private uint samples_per_sec; + private audio_format format; + private speaker_layout speakers; + }; + + [UnmanagedFunctionPointer(importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.I1)] + public delegate bool audio_input_callback_t(obs_source_t param, uint start_ts, uint end_ts, out uint new_ts, uint active_mixers, uint mixes); + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct audio_output_info + { + public string name; + + public uint samples_per_sec; + public audio_format format; + public speaker_layout speakers; + public audio_input_callback_t input_callback; + public void* input_param; + }; + + public enum video_format : int + { + VIDEO_FORMAT_NONE, + + /* planar 4:2:0 formats */ + VIDEO_FORMAT_I420, /* three-plane */ + VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */ + + /* packed 4:2:2 formats */ + VIDEO_FORMAT_YVYU, + VIDEO_FORMAT_YUY2, /* YUYV */ + VIDEO_FORMAT_UYVY, + + /* packed uncompressed formats */ + VIDEO_FORMAT_RGBA, + VIDEO_FORMAT_BGRA, + VIDEO_FORMAT_BGRX, + VIDEO_FORMAT_Y800, /* grayscale */ + + /* planar 4:4:4 */ + VIDEO_FORMAT_I444, + + /* more packed uncompressed formats */ + VIDEO_FORMAT_BGR3, + + /* planar 4:2:2 */ + VIDEO_FORMAT_I422, + + /* planar 4:2:0 with alpha */ + VIDEO_FORMAT_I40A, + + /* planar 4:2:2 with alpha */ + VIDEO_FORMAT_I42A, + + /* planar 4:4:4 with alpha */ + VIDEO_FORMAT_YUVA, + + /* packed 4:4:4 with alpha */ + VIDEO_FORMAT_AYUV, + + /* planar 4:2:0 format, 10 bpp */ + VIDEO_FORMAT_I010, /* three-plane */ + VIDEO_FORMAT_P010, /* two-plane, luma and packed chroma */ + + /* planar 4:2:2 10 bits */ + VIDEO_FORMAT_I210, // Little Endian + + /* planar 4:4:4 12 bits */ + VIDEO_FORMAT_I412, // Little Endian + + /* planar 4:4:4 12 bits with alpha */ + VIDEO_FORMAT_YA2L, // Little Endian + }; + + public enum audio_format : int + { + AUDIO_FORMAT_UNKNOWN, + + AUDIO_FORMAT_U8BIT, + AUDIO_FORMAT_16BIT, + AUDIO_FORMAT_32BIT, + AUDIO_FORMAT_FLOAT, + + AUDIO_FORMAT_U8BIT_PLANAR, + AUDIO_FORMAT_16BIT_PLANAR, + AUDIO_FORMAT_32BIT_PLANAR, + AUDIO_FORMAT_FLOAT_PLANAR, + }; + + public enum speaker_layout : int + { + SPEAKERS_UNKNOWN, + SPEAKERS_MONO, + SPEAKERS_STEREO, + SPEAKERS_2POINT1, + SPEAKERS_QUAD, + SPEAKERS_4POINT1, + SPEAKERS_5POINT1, + SPEAKERS_5POINT1_SURROUND, + SPEAKERS_7POINT1, + SPEAKERS_7POINT1_SURROUND, + SPEAKERS_SURROUND, + }; + + public enum video_colorspace : int + { + VIDEO_CS_DEFAULT, + VIDEO_CS_601, + VIDEO_CS_709, + VIDEO_CS_SRGB, + VIDEO_CS_2100_PQ, + VIDEO_CS_2100_HLG, + }; + + public enum video_range_type : int + { + VIDEO_RANGE_DEFAULT, + VIDEO_RANGE_PARTIAL, + VIDEO_RANGE_FULL + }; + + /// + /// https://obsproject.com/docs/reference-core.html?highlight=obs_set_output_source#c.obs_set_output_source + /// Sets the primary output source for a channel. + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_set_output_source(uint channel, obs_source_t source); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern obs_source_t obs_get_output_source(uint channel); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern audio_t obs_get_audio(); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern video_t obs_get_video(); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_source_set_volume(obs_source_t source, float volume); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern float obs_source_get_volume(obs_source_t source); + + + public enum VideoResetError + { + OBS_VIDEO_SUCCESS = 0, + OBS_VIDEO_FAIL = -1, + OBS_VIDEO_NOT_SUPPORTED = -2, + OBS_VIDEO_INVALID_PARAM = -3, + OBS_VIDEO_CURRENTLY_ACTIVE = -4, + OBS_VIDEO_MODULE_NOT_FOUND = -5 + } + } +} diff --git a/backend/src/obs_net/Output.cs b/backend/src/obs_net/Output.cs new file mode 100644 index 0000000..cdd584d --- /dev/null +++ b/backend/src/obs_net/Output.cs @@ -0,0 +1,96 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using audio_t = IntPtr; + using obs_data_t = IntPtr; + using obs_output_t = IntPtr; + using proc_handler_t = IntPtr; + using signal_handler_t = IntPtr; + using size_t = UIntPtr; + using video_t = IntPtr; + + public partial class Obs { + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_output_t obs_output_create( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string id, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + obs_data_t settings, obs_data_t hotkey_data); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_release(obs_output_t output); + + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_output_active(obs_output_t output); + + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_output_start(obs_output_t output); + + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_output_can_begin_data_capture(obs_output_t output, uint flags); + + [DllImport(importLibrary, CallingConvention = importCall)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool obs_output_initialize_encoders(obs_output_t output, uint flags); + + /// + /// https://obsproject.com/docs/reference-outputs.html?highlight=obs_output_stop#c.obs_output_stop + /// Requests the output to stop. The output will wait until all data is sent up until the time the call was made, then when the output has successfully stopped, it will send the ā€œstopā€ signal. + /// See Output Signals for more information on output signals. + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_stop(obs_output_t output); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern signal_handler_t obs_output_get_signal_handler(obs_output_t output); + + /// + /// https://obsproject.com/docs/reference-outputs.html#c.obs_output_get_last_error + /// + /// Gets the translated error message that is presented to a user in case of disconnection, inability to connect, etc. + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] + public static extern string obs_output_get_last_error(obs_output_t output); + + /// + /// https://obsproject.com/docs/reference-outputs.html?highlight=obs_output_update#c.obs_output_update + /// Updates the settings for this output context. + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_update(obs_output_t output, obs_data_t settings); + + /// + /// https://obsproject.com/docs/reference-outputs.html?highlight=obs_output_update#c.obs_output_set_mixers + /// Sets the current audio mixer for non-encoded outputs. For multi-track outputs, this would be the equivalent of setting the mask only for the specified mixer index. + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_set_mixer(obs_output_t output, size_t mixer_idx); + + /// + /// https://obsproject.com/docs/reference-outputs.html?highlight=obs_output_update#c.obs_output_set_mixers + /// Sets the current audio mixers (via mask) for non-encoded multi-track outputs. + /// If used with single-track outputs, the single-track output will use either the first set mixer track in the bitmask, or the first track if none is set in the bitmask. + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_output_set_mixers(obs_output_t output, size_t mixers); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern video_t obs_output_video(obs_output_t output); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern audio_t obs_output_audio(obs_output_t output); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern proc_handler_t obs_output_get_proc_handler(obs_output_t output); + } +} diff --git a/backend/src/obs_net/Proc.cs b/backend/src/obs_net/Proc.cs new file mode 100644 index 0000000..d8f326c --- /dev/null +++ b/backend/src/obs_net/Proc.cs @@ -0,0 +1,29 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using proc_handler_t = IntPtr; + + public partial class Obs { + [StructLayout(LayoutKind.Sequential)] + public struct calldata_t { + public IntPtr stack; + public UIntPtr size; /* size of the stack, in bytes */ + public UIntPtr capacity; /* capacity of the stack, in bytes */ + public bool fixedSize; /* fixed size (using call stack) */ + }; + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool proc_handler_call(proc_handler_t handler, string name, calldata_t _params); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool calldata_get_string(calldata_t data, string name, out string str); + + public static void calldata_free(calldata_t data){ + bfree(data.stack); + data.stack = IntPtr.Zero; + } + } +} diff --git a/backend/src/obs_net/Properties/launchSettings.json b/backend/src/obs_net/Properties/launchSettings.json new file mode 100644 index 0000000..0d293de --- /dev/null +++ b/backend/src/obs_net/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "obs-net": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/backend/src/obs_net/Scene.cs b/backend/src/obs_net/Scene.cs new file mode 100644 index 0000000..ccbc93b --- /dev/null +++ b/backend/src/obs_net/Scene.cs @@ -0,0 +1,17 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using obs_scene_t = IntPtr; + using obs_sceneitem_t = IntPtr; + using obs_source_t = IntPtr; + + public partial class Obs { + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_scene_t obs_scene_create( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source); + } +} diff --git a/backend/src/obs_net/Signal.cs b/backend/src/obs_net/Signal.cs new file mode 100644 index 0000000..aaa5b40 --- /dev/null +++ b/backend/src/obs_net/Signal.cs @@ -0,0 +1,17 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using signal_handler_t = IntPtr; + + public partial class Obs { + [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)] + public delegate void signal_callback_t(IntPtr data, calldata_t cd); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void signal_handler_connect(signal_handler_t handler, string signal, signal_callback_t callback, IntPtr data); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern void signal_handler_disconnect(signal_handler_t handler, string signal, signal_callback_t callback, IntPtr data); + } +} diff --git a/backend/src/obs_net/Source.cs b/backend/src/obs_net/Source.cs new file mode 100644 index 0000000..0514887 --- /dev/null +++ b/backend/src/obs_net/Source.cs @@ -0,0 +1,90 @@ +ļ»æusing System; +using System.Runtime.InteropServices; + +namespace obs_net { + using obs_data_t = IntPtr; + using obs_source_t = IntPtr; + + public partial class Obs { + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] + public static extern string obs_source_get_display_name( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string id); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_source_t obs_source_create( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string id, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string name, + obs_data_t settings, obs_data_t hotkey_data); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_source_release(obs_source_t source); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_source_remove(obs_source_t source); + + /// + /// https://obsproject.com/docs/reference-sources.html?highlight=audio%20mixer#c.obs_source_set_audio_mixers + /// + /// Sets/gets the audio mixer channels that a source outputs to, depending on what bits are set. + /// Audio mixers allow filtering specific using multiple audio encoders to mix different sources + /// together depending on what mixer channel theyā€™re set to. + /// + /// For example, to output to mixer 1 and 3, you would perform a bitwise OR on bits 0 and 2: (1<<0) | (1<<2), or 0x5. + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_source_set_audio_mixers(obs_source_t source, uint mixers); + + + /// + /// https://obsproject.com/docs/reference-sources.html?highlight=obs_source_get_flags#c.obs_source_get_flags + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern uint obs_source_get_flags(obs_source_t source); + + /// + /// https://obsproject.com/docs/reference-sources.html?highlight=obs_source_get_flags#c.obs_source_set_flags + /// + /// + /// OBS_SOURCE_FLAG_FORCE_MONO Forces audio to mono + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_source_set_flags(obs_source_t source, uint flags); + + /// + /// https://obsproject.com/docs/reference-sources.html#c.obs_source_update + /// + /// Updates the settings for a source and calls the obs_source_info.update callback of the source. + /// If the source is a video source, the obs_source_info.update will be not be called immediately; + /// instead, it will be deferred to the video thread to prevent threading issues. + /// + /// + /// + /// + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern void obs_source_update(obs_source_t source, obs_data_t settings); + + [DllImport(importLibrary, CallingConvention = importCall)] + public static extern obs_data_t obs_source_get_settings(obs_source_t source); + + [DllImport(importLibrary, CallingConvention = importCall, CharSet = importCharSet)] + public static extern obs_data_t obs_get_source_defaults( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8StringMarshaler))] string id); + + [DllImport(importLibrary, CallingConvention = CallingConvention.Cdecl)] + public static extern void obs_source_add_audio_capture_callback(IntPtr source, + AudioCapturedDelegate callback, + IntPtr param); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void AudioCapturedDelegate(IntPtr param, IntPtr source, + ref AudioData audioData, bool muted); + + + + + } +} diff --git a/backend/src/obs_net/obs_net.csproj b/backend/src/obs_net/obs_net.csproj new file mode 100644 index 0000000..57506ee --- /dev/null +++ b/backend/src/obs_net/obs_net.csproj @@ -0,0 +1,24 @@ +ļ»æ + + + net8.0 + latest + obs_net + true + + + + true + + + + true + + + + + + + + + diff --git a/backend/src/obs_recorder/ConfigService.cs b/backend/src/obs_recorder/ConfigService.cs new file mode 100644 index 0000000..fa13763 --- /dev/null +++ b/backend/src/obs_recorder/ConfigService.cs @@ -0,0 +1,55 @@ +using System; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + +public class Config +{ + public string VideoOutputPath { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "ods"); + public bool ReplayBufferEnabled { get; set; } = false; + public int ReplayBufferSeconds { get; set; } = 60; + public string Encoder { get; set; } = "ffmpeg_vaapi"; + public int ReplayBufferSize { get; set; } = 500; +} + +public class ConfigService +{ + private readonly string _configFilePath; + private ILogger Logger { get; } + + public ConfigService(string configFilePath, ILogger logger) + { + Logger = logger; + _configFilePath = configFilePath; + + if (!File.Exists(_configFilePath)) + { + var config = new Config(); + _= SaveConfig(config); + } + } + + + public Config GetConfig() + { + Logger.LogInformation("Loading config"); + if (!File.Exists(_configFilePath)) + { + Logger.LogWarning("Config file not found"); + return new Config(); + } + + var json = File.ReadAllText(_configFilePath); + return JsonSerializer.Deserialize(json); + } + + public async Task SaveConfig(Config config) + { + Logger.LogInformation("Saving config"); + var json = JsonSerializer.Serialize(config); + await File.WriteAllTextAsync(_configFilePath, json); + return config; + } +} diff --git a/backend/src/obs_recorder/ObsRecordingService.cs b/backend/src/obs_recorder/ObsRecordingService.cs new file mode 100644 index 0000000..3ed3b54 --- /dev/null +++ b/backend/src/obs_recorder/ObsRecordingService.cs @@ -0,0 +1,379 @@ +using System; +using System.Threading.Tasks; +using static obs_net.Obs; +using obs_net; +using Microsoft.Extensions.Logging; + +using System.IO; +using System.Reflection; +using ILogger = Microsoft.Extensions.Logging.ILogger; +using System.Runtime.InteropServices; +using System.Linq; + +public class ObsRecordingService : IDisposable +{ + public void Dispose() + { + StopRecording(); + + obs_output_stop(bufferOutput); + obs_output_release(bufferOutput); + + } + + IntPtr bufferOutput; + IntPtr recordOutput; + + IntPtr videoEncoder; + IntPtr audioEncoder; + IntPtr streamOutput; + public EventHandler OnStatusChanged { get; set; } + public EventHandler OnVolumePeakChanged { get; set; } + + bool initialised; + bool Initialized + { + get + { + return initialised; + } + set + { + initialised = value; + OnStatusChanged?.Invoke(this, EventArgs.Empty); + } + } + + bool recording; + bool Recording + { + get + { + return recording; + } + set + { + recording = value; + OnStatusChanged?.Invoke(this, EventArgs.Empty); + } + } + + + readonly ILogger Logger; + readonly ConfigService ConfigService; + + public ObsRecordingService(ILogger logger, ConfigService configService) + { + Logger = logger; + ConfigService = configService; + + ; + } + + public void Init() + { + //need to change directory so obs can find its plugins (this is a massive hack and I hate it but it works) + Directory.SetCurrentDirectory(Path.Combine(System.AppContext.BaseDirectory, "obs")); + Logger.LogError("Current directory: " + Directory.GetCurrentDirectory()); + + if (obs_initialized()) + { + throw new Exception("error: obs already initialized"); + } + + obs_set_nix_platform(obs_nix_platform_type.OBS_NIX_PLATFORM_X11_EGL); + obs_set_nix_platform_display(UnixSysCalls.XOpenDisplay(IntPtr.Zero)); + + + // base_set_log_handler(new log_handler_t((lvl, msg, args, p) => + // { + // va_list.LinuxX64Callback(msg, args, Logger); + // // if (Logger is not null) + // // { + // // Logger.Log(LogErrorLvlToLogLvl((LogErrorLevel)lvl), logMsg); + // // } + // }), IntPtr.Zero); + + Logger.LogInformation("libobs version: " + obs_get_version_string()); + if (!obs_startup("en-US", null, IntPtr.Zero)) + { + throw new Exception("error on libobs startup"); + } + + //var obsPath = "~/obs-portable/"; + var obsPath = "./"; + + obs_add_data_path($"{obsPath}data/libobs/"); + obs_add_module_path($"{obsPath}obs-plugins/64bit/", $"{obsPath}data/obs-plugins/%module%/"); + obs_load_all_modules(); + obs_log_loaded_modules(); + + obs_audio_info avi = new() + { + samples_per_sec = 44100, + speakers = speaker_layout.SPEAKERS_STEREO + }; + bool resetAudioCode = obs_reset_audio(ref avi); + + ResetVideo(); + + obs_post_load_modules(); + Logger.LogInformation("Loaded modules"); + + InitVideoOut(); + InitBufferOutput(); + Initialized = true; + + var config = ConfigService.GetConfig(); + if (config.ReplayBufferEnabled && config.ReplayBufferSeconds > 0) StartBufferOutput(); + } + + private void ResetVideo() + { + // scene rendering resolution + int MainWidth = 1280; + int MainHeight = 800; + + int outputWidth = MainWidth; + int outputHeight = MainHeight; + + obs_video_info ovi = new() + { + adapter = 0, + graphics_module = "libobs-opengl", + fps_num = 60, + fps_den = 1, + base_width = (uint)MainWidth, + base_height = (uint)MainHeight, + output_width = (uint)outputWidth, + output_height = (uint)outputHeight, + output_format = video_format.VIDEO_FORMAT_NV12, + gpu_conversion = true, + colorspace = video_colorspace.VIDEO_CS_DEFAULT, + range = video_range_type.VIDEO_RANGE_DEFAULT, + scale_type = obs_scale_type.OBS_SCALE_BILINEAR + }; + + int resetVideoCode = obs_reset_video(ref ovi); + if (resetVideoCode != 0) + { + throw new Exception("error on libobs reset video: " + ((VideoResetError)resetVideoCode).ToString()); + } + } + + public void StopRecording() + { + Logger.LogInformation("Stopping recording"); + //obs_output_stop(bufferOutput); + obs_output_stop(recordOutput); + + obs_output_release(recordOutput); + //todo release all the things + + Recording = false; + } + + DateTime lastSampleTime = DateTime.MinValue; + + void OnAudioData(IntPtr param, IntPtr source, ref AudioData audioData, bool muted) + { + double elapsed = (DateTime.Now - lastSampleTime).TotalSeconds; + if (elapsed < 0.5) return; + lastSampleTime = DateTime.Now; + + float rms = 0.0f; + + for (int plane = 0; plane < Obs.MAX_AV_PLANES && audioData.data[plane] != IntPtr.Zero; plane++) + { + float[] data = new float[audioData.frames]; + Marshal.Copy(audioData.data[plane], data, 0, (int)audioData.frames); + + float sum = data.Select(x => x * x).Sum(); // Square the sample to get the power + + rms += (float)Math.Sqrt(sum / data.Length); // Root Mean Square (RMS) amplitude per plane + } + + float db = 20.0f * (float)Math.Log10(rms); // Convert amplitude to decibels (dB) + + // Map dB level to a percentage + float minDb = -60.0f; + float maxDb = 0.0f; + float percentage = ((db - minDb) / (maxDb - minDb)) * 100.0f; + + percentage = Math.Min(Math.Max(percentage, 0.0f), 100.0f); + + OnVolumePeakChanged?.Invoke(null, new VolumePeakChangedArg() { Peak = percentage, Channel = 0 }); + } + + + void InitVideoOut() + { + var config = ConfigService.GetConfig(); + + IntPtr videoSource = obs_source_create("pipewire-gamescope-capture-source", "Gamescope Capture Source", IntPtr.Zero, IntPtr.Zero); + + obs_set_output_source(0, videoSource); //0 = VIDEO CHANNEL + + + IntPtr videoEncoderSettings = obs_data_create(); + + obs_data_set_int(videoEncoderSettings, "level", 40); + obs_data_set_int(videoEncoderSettings, "bitrate", 3500); + obs_data_set_int(videoEncoderSettings, "qp", 20); + obs_data_set_int(videoEncoderSettings, "maxrate", 0); + + + videoEncoder = obs_video_encoder_create(config.Encoder, "FFMPEG VAAPI Encoder", videoEncoderSettings, IntPtr.Zero); + + obs_encoder_set_video(videoEncoder, obs_get_video()); + obs_data_release(videoEncoderSettings); + + // SETUP NEW AUDIO SOURCE + IntPtr audioSource = obs_source_create("pulse_output_capture", "Audio Capture Source", IntPtr.Zero, IntPtr.Zero); + obs_set_output_source(1, audioSource); //1 = AUDIO CHANNEL + // SETUP NEW AUDIO ENCODER + + obs_source_add_audio_capture_callback(audioSource, OnAudioData, IntPtr.Zero); + + + audioEncoder = obs_audio_encoder_create("ffmpeg_aac", "simple_aac_recording", IntPtr.Zero, (UIntPtr)0, IntPtr.Zero); + obs_encoder_set_audio(audioEncoder, obs_get_audio()); + + + + // SETUP NEW RECORD OUTPUT + + } + + void InitBufferOutput() + { + var config = ConfigService.GetConfig(); + + var replayDir = Path.Combine(config.VideoOutputPath, "Replays"); + Directory.CreateDirectory(replayDir); + + IntPtr bufferOutputSettings = obs_data_create(); + obs_data_set_string(bufferOutputSettings, "directory", replayDir); + obs_data_set_string(bufferOutputSettings, "format", "%CCYY-%MM-%DD %hh-%mm-%ss"); + obs_data_set_string(bufferOutputSettings, "extension", "mp4"); + //obs_data_set_int(bufferOutputSettings, "duration_sec", 60); + obs_data_set_int(bufferOutputSettings, "max_time_sec", (uint)config.ReplayBufferSeconds); + obs_data_set_int(bufferOutputSettings, "max_size_mb", (uint)config.ReplayBufferSize); + bufferOutput = obs_output_create("replay_buffer", "replay_buffer_output", bufferOutputSettings, IntPtr.Zero); + obs_data_release(bufferOutputSettings); + + obs_output_set_video_encoder(bufferOutput, videoEncoder); + obs_output_set_audio_encoder(bufferOutput, audioEncoder, (UIntPtr)0); + } + + public void UpdateBufferSettings() + { + var config = ConfigService.GetConfig(); + IntPtr bufferOutputSettings = obs_data_create(); + obs_data_set_int(bufferOutputSettings, "max_time_sec", (uint)config.ReplayBufferSeconds); + obs_data_set_int(bufferOutputSettings, "max_size_mb", (uint)config.ReplayBufferSize); + obs_output_update(bufferOutput, bufferOutputSettings); + obs_data_release(bufferOutputSettings); + } + + public void SetupNewRecordOutput() + { + var config = ConfigService.GetConfig(); + var videoDir = config.VideoOutputPath; + Directory.CreateDirectory(videoDir); + + IntPtr recordOutputSettings = obs_data_create(); + + obs_data_set_string(recordOutputSettings, "path", $"{videoDir}/Record-{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.mp4"); + recordOutput = obs_output_create("ffmpeg_muxer", "simple_ffmpeg_output", recordOutputSettings, IntPtr.Zero); + obs_data_release(recordOutputSettings); + + obs_output_set_video_encoder(recordOutput, videoEncoder); + obs_output_set_audio_encoder(recordOutput, audioEncoder, (UIntPtr)0); + + } + + public bool StartBufferOutput() + { + if (!Initialized) + { + Logger.LogWarning("Not initialized yet, skipping start buffer"); + return false; + } + + bool bufferOutputStartSuccess = obs_output_start(bufferOutput); + Logger.LogInformation("buffer output successful start: " + bufferOutputStartSuccess); + if (!bufferOutputStartSuccess) Logger.LogError("buffer output error: '" + obs_output_get_last_error(bufferOutput) + "'"); + + return bufferOutputStartSuccess; + } + + + bool startingRecording = false; + public bool StartRecording() + { + if (startingRecording) + { + Logger.LogWarning("Already starting recording, skipping start recording"); + return false; + } + + if (!Initialized) + { + Logger.LogWarning("Not initialized yet, skipping start recording"); + return false; + } + + if (Recording) + { + Logger.LogWarning("Already recording, skipping start recording"); + return false; + } + + startingRecording = true; + + SetupNewRecordOutput(); + + Logger.LogInformation("Starting recording"); + + // START RECORD OUTPUT + bool recordOutputStartSuccess = obs_output_start(recordOutput); + Logger.LogInformation("record output successful start: " + recordOutputStartSuccess); + if (!recordOutputStartSuccess) Logger.LogError("record output error: '" + obs_output_get_last_error(recordOutput) + "'"); + Recording = recordOutputStartSuccess; + startingRecording = false; + + return recordOutputStartSuccess; + } + + public bool SaveReplayBuffer() + { + calldata_t cd = new(); + var ph = obs_output_get_proc_handler(bufferOutput); + var successful = proc_handler_call(ph, "save", cd); + Logger.LogInformation("buffer output successful save: {successful}", successful); + calldata_free(cd); + + return successful; + } + + public void StopBufferOutput() + { + var config = ConfigService.GetConfig(); + obs_output_stop(bufferOutput); + obs_output_release(bufferOutput); + } + + public (bool Running, bool Recording) GetStatus() + { + return (Initialized, Recording); + } + + +} + +public class VolumePeakChangedArg : EventArgs +{ + public float Peak { get; set; } + public int Channel { get; set; } +} \ No newline at end of file diff --git a/backend/src/obs_recorder/Program.cs b/backend/src/obs_recorder/Program.cs new file mode 100644 index 0000000..d9b6bf6 --- /dev/null +++ b/backend/src/obs_recorder/Program.cs @@ -0,0 +1,73 @@ +ļ»æusing System; +using System.IO; +using System.Text.Json.Serialization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http.Json; +using Microsoft.Extensions.DependencyInjection; +using obs_recorder; + +// using Microsoft.Extensions.Logging; +using Serilog; + +Log.Logger = new LoggerConfiguration() + .WriteTo.Console() + .WriteTo.File( + // System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "logs\\obs-recorder.log"), + Path.Combine(Environment.GetEnvironmentVariable("HOME"), "homebrew", "logs", "decky-obs", "obs-recorder.log"), + rollingInterval: RollingInterval.Day, + fileSizeLimitBytes: 10 * 1024 * 1024, + retainedFileCountLimit: 2, + rollOnFileSizeLimit: true, + shared: true, + flushToDiskInterval: TimeSpan.FromSeconds(1) + ) + .CreateLogger(); + +try { + +var builder = WebApplication.CreateBuilder(args); +// builder.Logging.ClearProviders(); +// builder.Logging.AddConsole(); + +#if DEBUG + +builder.Services.AddCors( + options => options.AddPolicy("CorsPolicy", x => x.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin())); + +#else + +builder.Services.AddCors( + options => options.AddPolicy("CorsPolicy",x => x.AllowAnyMethod().AllowCredentials().AllowAnyHeader().WithOrigins("https://steamloopback.host"))); +#endif + + +builder.Host.UseSerilog(); +builder.Services.Configure(options => { options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); }); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(x => ActivatorUtilities.CreateInstance(x, Environment.GetEnvironmentVariable("DECKY_PLUGIN_SETTINGS_DIR") + "/config.json")); +builder.Services.AddSignalR(); + +var app = builder.Build(); +app.UseSerilogRequestLogging(); +app.UseWebSockets(); + + +app.UseCors("CorsPolicy"); + +app.MapHub("/SignalrHub"); + + +app.MapGet("/", () => "Hello World!"); + +var recorder = app.Services.GetRequiredService(); +recorder.Init(); + + +app.Run("http://0.0.0.0:9988"); +} catch (Exception e) { + + Log.Error(e, "Exception:"); +} +finally { + Log.CloseAndFlush(); +} \ No newline at end of file diff --git a/backend/src/obs_recorder/SignalrService.cs b/backend/src/obs_recorder/SignalrService.cs new file mode 100644 index 0000000..26d2942 --- /dev/null +++ b/backend/src/obs_recorder/SignalrService.cs @@ -0,0 +1,117 @@ +ļ»æusing System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.SignalR; + +namespace obs_recorder; + +public class SignalrHub : Hub, IDisposable +{ + + private readonly ObsRecordingService RecordingService; + private readonly ConfigService ConfigService; + + public SignalrHub(ObsRecordingService recordingService, ConfigService configService) + { + ConfigService = configService; + RecordingService = recordingService; + // RecordingService.OnStatusChanged += OnStatusChanged; + // RecordingService.OnVolumePeakChanged += OnVolumePeakChanged; + } + + public override async Task OnConnectedAsync() + { + await base.OnConnectedAsync(); + + Console.WriteLine("Client connected"); + + + var (Running, Recording) = RecordingService.GetStatus(); + _ = Clients.Caller.OnStatusChanged(Running, Recording); + } + + void OnVolumePeakChanged(object sender, VolumePeakChangedArg e) + { + _ = Clients.Caller.OnVolumePeakChanged(e.Channel, e.Peak); + } + + + void OnStatusChanged(object sender, EventArgs e) + { + var (Running, Recording) = RecordingService.GetStatus(); + _ = Clients.Caller.OnStatusChanged(Running, Recording); + } + + + public override async Task OnDisconnectedAsync(Exception? exception) + { + await base.OnDisconnectedAsync(exception); + } + + + public object GetStatus() + { + var (Running, Recording) = RecordingService.GetStatus(); + //todo add types + return new {Running, Recording}; + } + + public void StartRecording() + { + RecordingService.StartRecording(); + } + + public void StopRecording() + { + RecordingService.StopRecording(); + } + + public bool BufferOutput(bool enabled) + { + var config = ConfigService.GetConfig(); + + if (config.ReplayBufferEnabled == enabled) return true; + + config.ReplayBufferEnabled = enabled; + _ = ConfigService.SaveConfig(config); + + if (config.ReplayBufferEnabled) + { + return RecordingService.StartBufferOutput(); + } else { + RecordingService.StopBufferOutput(); + return true; + } + } + + public void UpdateBufferSettings(){ + RecordingService.UpdateBufferSettings(); + } + + public bool SaveReplayBuffer() + { + return RecordingService.SaveReplayBuffer(); + } + + public Config GetConfig(){ + return ConfigService.GetConfig(); + } + + public Task SaveConfig(Config config){ + return ConfigService.SaveConfig(config); + } + + public new void Dispose() + { + base.Dispose(); + // RecordingService.OnStatusChanged -= OnStatusChanged; + // RecordingService.OnVolumePeakChanged -= OnVolumePeakChanged; + } + +} + +public interface SignalrHubClient +{ + public Task OnStatusChanged(bool running, bool recording); + + public Task OnVolumePeakChanged(int channel, float peak); +} \ No newline at end of file diff --git a/backend/src/obs_recorder/UnixInterop.cs b/backend/src/obs_recorder/UnixInterop.cs new file mode 100644 index 0000000..30aaa7b --- /dev/null +++ b/backend/src/obs_recorder/UnixInterop.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +public static class UnixSysCalls { + +[DllImport("libwayland-client.so")] +public static extern IntPtr wl_display_connect(IntPtr display); + +[DllImport("libX11.so.6")] +public static extern IntPtr XOpenDisplay(IntPtr display); +} \ No newline at end of file diff --git a/backend/src/obs_recorder/obs_recorder.csproj b/backend/src/obs_recorder/obs_recorder.csproj new file mode 100644 index 0000000..24cfc42 --- /dev/null +++ b/backend/src/obs_recorder/obs_recorder.csproj @@ -0,0 +1,17 @@ +ļ»æ + + + Exe + net8.0 + obs_recorder + linux-x64 + true + + + enable + + + + + + diff --git a/build-zip.sh b/build-zip.sh deleted file mode 100755 index 7a326e1..0000000 --- a/build-zip.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env bash - -plugin="deckystream" -docker_name="backend-${plugin,,}" - -dockerfile_exists="false" -entrypoint_exists="false" -docker_name="backend-${plugin,,}" -# [ -d $PWD/backend ] && echo "$(ls -lla $PWD/backend | grep Dockerfile)" -[ -f $PWD/backend/Dockerfile ] && dockerfile_exists=true -[ -f $PWD/backend/entrypoint.sh ] && entrypoint_exists=true - -#build backend -if [[ "$dockerfile_exists" == "true" ]]; then - echo "Grabbing provided dockerfile." - echo "Building provided Dockerfile." - docker build -f $PWD/backend/Dockerfile -t "$docker_name" . - mkdir -p /tmp/output/$plugin/backend/out - # check entrypoint script exists - if [[ "$entrypoint_exists" == "true" ]]; then - echo "Running docker image "$docker_name" with provided entrypoint script." - docker run --rm -i -v $PWD/backend:/backend -v /tmp/output/$plugin/backend/out:/backend/out --entrypoint /backend/entrypoint.sh "$docker_name" - mkdir -p /tmp/output/$plugin/bin - cp -rv /tmp/output/$plugin/backend/out/. /tmp/output/$plugin/bin - else - echo "Running docker image "$docker_name" with entrypoint script specified in Dockerfile." - docker run --rm -i -v $PWD/backend:/backend -v /tmp/output/$plugin/backend/out:/backend/out "$docker_name" - mkdir -p /tmp/output/$plugin/bin - cp -rv /tmp/output/$plugin/backend/out/. /tmp/output/$plugin/bin - fi - docker image rm "$docker_name" - echo "Built $plugin backend" -# Dockerfile doesn't exist but entrypoint script does, run w/ default image -elif [[ "$dockerfile_exists" == "false" && "$entrypoint_exists" == "true" ]]; then - echo "Grabbing default docker image and using provided entrypoint script." - docker run --rm -i -v $PWD/backend:/backend -v /tmp/output/$plugin/backend/out:/backend/out ghcr.io/steamdeckhomebrew/holo-base:latest - mkdir -p /tmp/output/$plugin/bin - cp /tmp/output/$plugin/backend/out/. /tmp/output/$plugin/bin - echo "Built $plugin backend" -else - echo "Plugin $plugin does not have a backend" -fi - -#build frontend -docker run --rm -i -v $PWD:/plugin -v /tmp/output/$plugin:/out ghcr.io/steamdeckhomebrew/builder:latest -echo Built $plugin frontend -ls -lla /tmp/output/$plugin - -#make zip -mkdir -p /tmp/zips/ -mkdir -p /tmp/output/ -cd /tmp/output/${plugin} -zipname=/tmp/zips/${plugin}.zip -echo $plugin -# Names of the optional files (the license can either be called license or license.md, not both) -# (head is there to take the first file, because we're assuming there's only a single license file) -license="$(find . -maxdepth 1 -type f \( -iname "license" -o -iname "license.md" \) -printf '%P\n' | head -n 1)" -readme="$(find . -maxdepth 1 -type f -iname 'readme.md' -printf '%P\n')" -haspython="$(find . -maxdepth 1 -type f -name '*.py' -printf '%P\n')" -# Check if plugin has a bin folder, if so, add "bin" and it's contents to root dir -hasbin="$(find . -maxdepth 1 -type d -name 'bin' -printf '%P\n')" -# Check if plugin has a defaults folder, if so, add "default" contents to root dir -hasdefaults="$(find . -maxdepth 1 -type d -name 'defaults' -printf '%P\n')" -# if [[ "${{ secrets.STORE_ENV }}" == "testing" ]]; then -# long_sha="${{ github.event.pull_request.head.sha || github.sha }}" -# sha=$(echo $long_sha | cut -c1-7) -# cat $plugin/package.json | jq --arg jqsha "$sha" '.version |= . + "-" + $jqsha' | sudo tee $plugin/$sha-package.json -# sudo mv $plugin/$sha-package.json $plugin/package.json -# fi -# Add required plugin files (and directory) to zip file -echo "dist plugin.json package.json" -zip -r $zipname "dist" "plugin.json" "package.json" -if [ ! -z "$hasbin" ]; then - ls -al bin - echo "/bin" - zip -r $zipname "bin" -fi -if [ ! -z "$haspython" ]; then - echo "*.py" - find . -maxdepth 1 -type f -name '*.py' -exec zip -r $zipname {} \; -fi -if [ ! -z "$hasdefaults" ]; then - export workingdir=$PWD - cd defaults - export plugin="$plugin" - export zipname="$zipname" - if [ ! -f "defaults.txt" ]; then - find . -mindepth 1 -type d,f -name '*' -exec bash -c ' - for object do - outdir="/tmp/output" - name="$(basename $object)" - # echo "object = $object, name = $name" - if [ -e "$object" ]; then - sudo mv "$object" $outdir/$plugin/$name - moved="$?" - # echo "moved = $moved" - cd $workingdir - if [ "$moved" = "0" ]; then - zip -r $zipname $plugin/$name - fi - fi - done - ' find-sh {} + - else - if [[ ! "$plugin" =~ "plugin-template" ]]; then - printf "${red}defaults.txt found in defaults folder, please remove either defaults.txt or the defaults folder.${end}\n" - else - printf "plugin template, allowing defaults.txt\n" - fi - fi - cd "$workingdir" -fi -# Check if other files exist, and if they do, add them -echo "license:$plugin/$license readme:$plugin/$readme" -if [ ! -z "$license" ]; then - zip -r $zipname "$license" -fi -if [ ! -z "$readme" ]; then - zip -r $zipname "$readme" -fi diff --git a/decky_plugin.pyi b/decky_plugin.pyi new file mode 100644 index 0000000..6f7e580 --- /dev/null +++ b/decky_plugin.pyi @@ -0,0 +1,174 @@ +""" +This module exposes various constants and helpers useful for decky plugins. + +* Plugin's settings and configurations should be stored under `DECKY_PLUGIN_SETTINGS_DIR`. +* Plugin's runtime data should be stored under `DECKY_PLUGIN_RUNTIME_DIR`. +* Plugin's persistent log files should be stored under `DECKY_PLUGIN_LOG_DIR`. + +Avoid writing outside of `DECKY_HOME`, storing under the suggested paths is strongly recommended. + +Some basic migration helpers are available: `migrate_any`, `migrate_settings`, `migrate_runtime`, `migrate_logs`. + +A logging facility `logger` is available which writes to the recommended location. +""" + +__version__ = '0.1.0' + +import logging + +""" +Constants +""" + +HOME: str +""" +The home directory of the effective user running the process. +Environment variable: `HOME`. +If `root` was specified in the plugin's flags it will be `/root` otherwise the user whose home decky resides in. +e.g.: `/home/deck` +""" + +USER: str +""" +The effective username running the process. +Environment variable: `USER`. +It would be `root` if `root` was specified in the plugin's flags otherwise the user whose home decky resides in. +e.g.: `deck` +""" + +DECKY_VERSION: str +""" +The version of the decky loader. +Environment variable: `DECKY_VERSION`. +e.g.: `v2.5.0-pre1` +""" + +DECKY_USER: str +""" +The user whose home decky resides in. +Environment variable: `DECKY_USER`. +e.g.: `deck` +""" + + +DECKY_USER_HOME: str +""" +The home of the user where decky resides in. +Environment variable: `DECKY_USER_HOME`. +e.g.: `/home/deck` +""" + +DECKY_HOME: str +""" +The root of the decky folder. +Environment variable: `DECKY_HOME`. +e.g.: `/home/deck/homebrew` +""" + +DECKY_PLUGIN_SETTINGS_DIR: str +""" +The recommended path in which to store configuration files (created automatically). +Environment variable: `DECKY_PLUGIN_SETTINGS_DIR`. +e.g.: `/home/deck/homebrew/settings/decky-plugin-template` +""" + +DECKY_PLUGIN_RUNTIME_DIR: str +""" +The recommended path in which to store runtime data (created automatically). +Environment variable: `DECKY_PLUGIN_RUNTIME_DIR`. +e.g.: `/home/deck/homebrew/data/decky-plugin-template` +""" + +DECKY_PLUGIN_LOG_DIR: str +""" +The recommended path in which to store persistent logs (created automatically). +Environment variable: `DECKY_PLUGIN_LOG_DIR`. +e.g.: `/home/deck/homebrew/logs/decky-plugin-template` +""" + +DECKY_PLUGIN_DIR: str +""" +The root of the plugin's directory. +Environment variable: `DECKY_PLUGIN_DIR`. +e.g.: `/home/deck/homebrew/plugins/decky-plugin-template` +""" + +DECKY_PLUGIN_NAME: str +""" +The name of the plugin as specified in the 'plugin.json'. +Environment variable: `DECKY_PLUGIN_NAME`. +e.g.: `Example Plugin` +""" + +DECKY_PLUGIN_VERSION: str +""" +The version of the plugin as specified in the 'package.json'. +Environment variable: `DECKY_PLUGIN_VERSION`. +e.g.: `0.0.1` +""" + +DECKY_PLUGIN_AUTHOR: str +""" +The author of the plugin as specified in the 'plugin.json'. +Environment variable: `DECKY_PLUGIN_AUTHOR`. +e.g.: `John Doe` +""" + +DECKY_PLUGIN_LOG: str +""" +The path to the plugin's main logfile. +Environment variable: `DECKY_PLUGIN_LOG`. +e.g.: `/home/deck/homebrew/logs/decky-plugin-template/plugin.log` +""" + +""" +Migration helpers +""" + + +def migrate_any(target_dir: str, *files_or_directories: str) -> dict[str, str]: + """ + Migrate files and directories to a new location and remove old locations. + Specified files will be migrated to `target_dir`. + Specified directories will have their contents recursively migrated to `target_dir`. + + Returns the mapping of old -> new location. + """ + + +def migrate_settings(*files_or_directories: str) -> dict[str, str]: + """ + Migrate files and directories relating to plugin settings to the recommended location and remove old locations. + Specified files will be migrated to `DECKY_PLUGIN_SETTINGS_DIR`. + Specified directories will have their contents recursively migrated to `DECKY_PLUGIN_SETTINGS_DIR`. + + Returns the mapping of old -> new location. + """ + + +def migrate_runtime(*files_or_directories: str) -> dict[str, str]: + """ + Migrate files and directories relating to plugin runtime data to the recommended location and remove old locations + Specified files will be migrated to `DECKY_PLUGIN_RUNTIME_DIR`. + Specified directories will have their contents recursively migrated to `DECKY_PLUGIN_RUNTIME_DIR`. + + Returns the mapping of old -> new location. + """ + + +def migrate_logs(*files_or_directories: str) -> dict[str, str]: + """ + Migrate files and directories relating to plugin logs to the recommended location and remove old locations. + Specified files will be migrated to `DECKY_PLUGIN_LOG_DIR`. + Specified directories will have their contents recursively migrated to `DECKY_PLUGIN_LOG_DIR`. + + Returns the mapping of old -> new location. + """ + + +""" +Logging +""" + +logger: logging.Logger +"""The main plugin logger writing to `DECKY_PLUGIN_LOG`.""" diff --git a/defaults/defaults.txt b/defaults/defaults.txt new file mode 100644 index 0000000..ebf140b --- /dev/null +++ b/defaults/defaults.txt @@ -0,0 +1,13 @@ +If you have plain-text json configs, theme templates, or templates for usage for your plugin of any description you should have those files be in here. +Those files will be pulled into the zip during the build process and included with the upload. Example: CssLoader with it's themes in "default/themes" would have the "themes" folder will be added alongside with the dist folder, main.py, LICENSE and README files in the subfolder of the zip containing the plugin. +Files can also be put in here such as a config, just keep in mind that they this directory cannot be utilized to put files in arbitrary locations, just within the extracted root folder of the plugin, ex: CssLoader has "defaults/themes/..." setup in it's repo, but when packaged to go to the store, the file structure will be: + +- LICENSE +- README +- dist + - index.js +- main.py +- package.json +- plugin.json +- themes + - exampletheme.css \ No newline at end of file diff --git a/main.py b/main.py index 2b415fe..d406951 100644 --- a/main.py +++ b/main.py @@ -1,25 +1,56 @@ -import asyncio -import logging -import pathlib import os -import subprocess +from subprocess import Popen, PIPE, STDOUT +import asyncio +import re +import decky_plugin -PARENT_DIR = str(pathlib.Path(__file__).parent.resolve()) +class Plugin: + def log_subprocess_output(pipe): + for line in iter(pipe.readline, b''): # b'\n'-separated lines + decky_plugin.logger.info('.NET: %r', line) -logging.basicConfig( - format = '[deckystream] %(asctime)s %(levelname)s %(message)s') + backend_proc = None + # Asyncio-compatible long-running code, executed in a task when the plugin is loaded + async def _main(self): + decky_plugin.logger.info("decky-obs starting!") -os.environ['HOME'] = "/home/deck" -os.environ['XDG_RUNTIME_DIR'] = "/run/user/1000" -os.environ['LD_LIBRARY_PATH'] = PARENT_DIR + "/bin/lib" -os.environ['GST_PLUGIN_PATH'] = PARENT_DIR + "/bin/lib/gstreamer" + # Set environment variables + env_proc = dict(os.environ) + env_proc["DISPLAY"] = ":0" + env_proc["XDG_RUNTIME_DIR"] = "/run/user/1000" + ld_library_path = decky_plugin.DECKY_PLUGIN_DIR + "/bin/obs/bin/64bit/:" + decky_plugin.DECKY_PLUGIN_DIR + "/bin/ffmpeg-libs/" - -class Plugin: - async def _main(self): - self.backend_proc = subprocess.Popen([PARENT_DIR + "/bin/deckystream"]) - while True: - await asyncio.sleep(1) + if "LD_LIBRARY_PATH" in env_proc: + env_proc["LD_LIBRARY_PATH"] += ":" + ld_library_path + else: + env_proc["LD_LIBRARY_PATH"] = ld_library_path + # Start OBS recorder process + self.backend_proc = Popen( + [decky_plugin.DECKY_PLUGIN_DIR + "/bin/obs_recorder"], + env=env_proc, stdout=PIPE, stderr=STDOUT) + + # Log subprocess output + with self.backend_proc.stdout: + for line in iter(self.backend_proc.stdout.readline, b''): + decky_plugin.logger.info('.NET: %r', line) + + # Wait for process to finish + self.backend_proc.wait() + + # Function called first during the unload process, utilize this to handle your plugin being removed async def _unload(self): - self.backend_proc.kill() + decky_plugin.logger.info("decky-obs closing!") + if self.backend_proc is not None: + self.backend_proc.terminate() + try: + self.backend_proc.wait(timeout=5) # 5 seconds timeout + except subprocess.TimeoutExpired: + self.backend_proc.kill() + self.backend_proc = None + + pass + + # Migrations that should be performed before entering `_main()`. + # async def _migration(self): + # decky_plugin.logger.info("Migrating") \ No newline at end of file diff --git a/package.json b/package.json index 686340f..a374833 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "deckystream", + "name": "decky-plugin-template", "version": "0.0.1", - "description": "Basic plugin to allow recording and streaming from the steamdeck.", + "description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack", "scripts": { "build": "shx rm -rf dist && rollup -c", "watch": "rollup -c -w", @@ -14,10 +14,11 @@ "keywords": [ "decky", "plugin", + "plugin-template", "steam-deck", "deck" ], - "author": "Kieran Coldron ", + "author": "Jonas Dellinger ", "license": "BSD-3-Clause", "bugs": { "url": "https://github.com/SteamDeckHomebrew/decky-plugin-template/issues" @@ -38,10 +39,9 @@ "typescript": "^4.7.4" }, "dependencies": { - "@microsoft/signalr": "^7.0.2", - "decky-frontend-lib": "^3.18.6", - "react-icons": "^4.4.0", - "rooks": "^7.4.2" + "@microsoft/signalr": "8.0.0-rc.2.23480.2", + "decky-frontend-lib": "^3.21.1", + "react-icons": "^4.4.0" }, "pnpm": { "peerDependencyRules": { diff --git a/plugin.json b/plugin.json index 866a838..94e4ee0 100644 --- a/plugin.json +++ b/plugin.json @@ -1,10 +1,10 @@ { - "name": "DeckyStream", + "name": "OpenDeckStream", "author": "Epictek", - "flags": ["debug"], + "flags": ["debug", "_root"], "publish": { - "tags": ["recording"], - "description": "Basic plugin to allow recording and streaming (via NDI) from the steamdeck.", - "image": "https://opengraph.githubassets.com/1/Epictek/DeckyStream" + "tags": ["root"], + "description": "Streaming and record plugin.", + "image": "https://opengraph.githubassets.com/1/Epictek/OpenDeckStream" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b140f7d..1cf3852 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,89 +1,108 @@ -lockfileVersion: 5.4 - -specifiers: - '@microsoft/signalr': ^7.0.2 - '@rollup/plugin-commonjs': ^21.1.0 - '@rollup/plugin-json': ^4.1.0 - '@rollup/plugin-node-resolve': ^13.3.0 - '@rollup/plugin-replace': ^4.0.0 - '@rollup/plugin-typescript': ^8.3.3 - '@types/react': 16.14.0 - '@types/webpack': ^5.28.0 - decky-frontend-lib: ^3.18.6 - react-icons: ^4.4.0 - rollup: ^2.77.1 - rollup-plugin-import-assets: ^1.1.1 - rooks: ^7.4.2 - shx: ^0.3.4 - tslib: ^2.4.0 - typescript: ^4.7.4 +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false dependencies: - '@microsoft/signalr': 7.0.2 - decky-frontend-lib: 3.18.6 - react-icons: 4.4.0 - rooks: 7.4.2 + '@microsoft/signalr': + specifier: 8.0.0-rc.2.23480.2 + version: 8.0.0-rc.2.23480.2 + decky-frontend-lib: + specifier: ^3.21.1 + version: 3.21.1 + react-icons: + specifier: ^4.4.0 + version: 4.9.0 devDependencies: - '@rollup/plugin-commonjs': 21.1.0_rollup@2.77.1 - '@rollup/plugin-json': 4.1.0_rollup@2.77.1 - '@rollup/plugin-node-resolve': 13.3.0_rollup@2.77.1 - '@rollup/plugin-replace': 4.0.0_rollup@2.77.1 - '@rollup/plugin-typescript': 8.3.3_ekpmegaybmymq5m2rlmygb35zm - '@types/react': 16.14.0 - '@types/webpack': 5.28.0 - rollup: 2.77.1 - rollup-plugin-import-assets: 1.1.1_rollup@2.77.1 - shx: 0.3.4 - tslib: 2.4.0 - typescript: 4.7.4 + '@rollup/plugin-commonjs': + specifier: ^21.1.0 + version: 21.1.0(rollup@2.79.1) + '@rollup/plugin-json': + specifier: ^4.1.0 + version: 4.1.0(rollup@2.79.1) + '@rollup/plugin-node-resolve': + specifier: ^13.3.0 + version: 13.3.0(rollup@2.79.1) + '@rollup/plugin-replace': + specifier: ^4.0.0 + version: 4.0.0(rollup@2.79.1) + '@rollup/plugin-typescript': + specifier: ^8.3.3 + version: 8.5.0(rollup@2.79.1)(tslib@2.5.2)(typescript@4.9.5) + '@types/react': + specifier: 16.14.0 + version: 16.14.0 + '@types/webpack': + specifier: ^5.28.0 + version: 5.28.1 + rollup: + specifier: ^2.77.1 + version: 2.79.1 + rollup-plugin-import-assets: + specifier: ^1.1.1 + version: 1.1.1(rollup@2.79.1) + shx: + specifier: ^0.3.4 + version: 0.3.4 + tslib: + specifier: ^2.4.0 + version: 2.5.2 + typescript: + specifier: ^4.7.4 + version: 4.9.5 packages: - /@jridgewell/gen-mapping/0.3.2: - resolution: {integrity: sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==} + /@jridgewell/gen-mapping@0.3.3: + resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} engines: {node: '>=6.0.0'} dependencies: '@jridgewell/set-array': 1.1.2 - '@jridgewell/sourcemap-codec': 1.4.14 - '@jridgewell/trace-mapping': 0.3.14 + '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/trace-mapping': 0.3.18 dev: true - /@jridgewell/resolve-uri/3.1.0: + /@jridgewell/resolve-uri@3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} engines: {node: '>=6.0.0'} dev: true - /@jridgewell/set-array/1.1.2: + /@jridgewell/set-array@1.1.2: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} engines: {node: '>=6.0.0'} dev: true - /@jridgewell/source-map/0.3.2: - resolution: {integrity: sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==} + /@jridgewell/source-map@0.3.3: + resolution: {integrity: sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==} dependencies: - '@jridgewell/gen-mapping': 0.3.2 - '@jridgewell/trace-mapping': 0.3.14 + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.18 dev: true - /@jridgewell/sourcemap-codec/1.4.14: + /@jridgewell/sourcemap-codec@1.4.14: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} dev: true - /@jridgewell/trace-mapping/0.3.14: - resolution: {integrity: sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==} + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: true + + /@jridgewell/trace-mapping@0.3.18: + resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} dependencies: '@jridgewell/resolve-uri': 3.1.0 '@jridgewell/sourcemap-codec': 1.4.14 dev: true - /@microsoft/signalr/7.0.2: - resolution: {integrity: sha512-U+o33K2m6nnMojZzBrjrApKgYfiQ0A0t4I2F5oFJObgfzRSDS9v0YoYgkmva5nbPftUp3YcR5XmH0S/1+BZT6Q==} + /@microsoft/signalr@8.0.0-rc.2.23480.2: + resolution: {integrity: sha512-F21Ji5gca4iPBiZbdmDYHZ0zavB65G4549FR16mAZszS/dAjNdJWRe8o0JNjlNiHPi6IoNX489lbOWJdJXmpuA==} dependencies: abort-controller: 3.0.0 eventsource: 2.0.2 fetch-cookie: 2.1.0 - node-fetch: 2.6.8 + node-fetch: 2.7.0 ws: 7.5.9 transitivePeerDependencies: - bufferutil @@ -91,58 +110,58 @@ packages: - utf-8-validate dev: false - /@rollup/plugin-commonjs/21.1.0_rollup@2.77.1: + /@rollup/plugin-commonjs@21.1.0(rollup@2.79.1): resolution: {integrity: sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA==} engines: {node: '>= 8.0.0'} peerDependencies: rollup: ^2.38.3 dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.77.1 + '@rollup/pluginutils': 3.1.0(rollup@2.79.1) commondir: 1.0.1 estree-walker: 2.0.2 glob: 7.2.3 is-reference: 1.2.1 magic-string: 0.25.9 - resolve: 1.22.1 - rollup: 2.77.1 + resolve: 1.22.2 + rollup: 2.79.1 dev: true - /@rollup/plugin-json/4.1.0_rollup@2.77.1: + /@rollup/plugin-json@4.1.0(rollup@2.79.1): resolution: {integrity: sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==} peerDependencies: rollup: ^1.20.0 || ^2.0.0 dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.77.1 - rollup: 2.77.1 + '@rollup/pluginutils': 3.1.0(rollup@2.79.1) + rollup: 2.79.1 dev: true - /@rollup/plugin-node-resolve/13.3.0_rollup@2.77.1: + /@rollup/plugin-node-resolve@13.3.0(rollup@2.79.1): resolution: {integrity: sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==} engines: {node: '>= 10.0.0'} peerDependencies: rollup: ^2.42.0 dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.77.1 + '@rollup/pluginutils': 3.1.0(rollup@2.79.1) '@types/resolve': 1.17.1 - deepmerge: 4.2.2 - is-builtin-module: 3.1.0 + deepmerge: 4.3.1 + is-builtin-module: 3.2.1 is-module: 1.0.0 - resolve: 1.22.1 - rollup: 2.77.1 + resolve: 1.22.2 + rollup: 2.79.1 dev: true - /@rollup/plugin-replace/4.0.0_rollup@2.77.1: + /@rollup/plugin-replace@4.0.0(rollup@2.79.1): resolution: {integrity: sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==} peerDependencies: rollup: ^1.20.0 || ^2.0.0 dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.77.1 + '@rollup/pluginutils': 3.1.0(rollup@2.79.1) magic-string: 0.25.9 - rollup: 2.77.1 + rollup: 2.79.1 dev: true - /@rollup/plugin-typescript/8.3.3_ekpmegaybmymq5m2rlmygb35zm: - resolution: {integrity: sha512-55L9SyiYu3r/JtqdjhwcwaECXP7JeJ9h1Sg1VWRJKIutla2MdZQodTgcCNybXLMCnqpNLEhS2vGENww98L1npg==} + /@rollup/plugin-typescript@8.5.0(rollup@2.79.1)(tslib@2.5.2)(typescript@4.9.5): + resolution: {integrity: sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==} engines: {node: '>=8.0.0'} peerDependencies: rollup: ^2.14.0 @@ -152,14 +171,14 @@ packages: tslib: optional: true dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.77.1 - resolve: 1.22.1 - rollup: 2.77.1 - tslib: 2.4.0 - typescript: 4.7.4 + '@rollup/pluginutils': 3.1.0(rollup@2.79.1) + resolve: 1.22.2 + rollup: 2.79.1 + tslib: 2.5.2 + typescript: 4.9.5 dev: true - /@rollup/pluginutils/3.1.0_rollup@2.77.1: + /@rollup/pluginutils@3.1.0(rollup@2.79.1): resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} engines: {node: '>= 8.0.0'} peerDependencies: @@ -168,66 +187,62 @@ packages: '@types/estree': 0.0.39 estree-walker: 1.0.1 picomatch: 2.3.1 - rollup: 2.77.1 + rollup: 2.79.1 dev: true - /@types/eslint-scope/3.7.4: + /@types/eslint-scope@3.7.4: resolution: {integrity: sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==} dependencies: - '@types/eslint': 8.4.5 - '@types/estree': 0.0.51 + '@types/eslint': 8.40.0 + '@types/estree': 1.0.1 dev: true - /@types/eslint/8.4.5: - resolution: {integrity: sha512-dhsC09y1gpJWnK+Ff4SGvCuSnk9DaU0BJZSzOwa6GVSg65XtTugLBITDAAzRU5duGBoXBHpdR/9jHGxJjNflJQ==} + /@types/eslint@8.40.0: + resolution: {integrity: sha512-nbq2mvc/tBrK9zQQuItvjJl++GTN5j06DaPtp3hZCpngmG6Q3xoyEmd0TwZI0gAy/G1X0zhGBbr2imsGFdFV0g==} dependencies: - '@types/estree': 0.0.51 - '@types/json-schema': 7.0.11 + '@types/estree': 1.0.1 + '@types/json-schema': 7.0.12 dev: true - /@types/estree/0.0.39: + /@types/estree@0.0.39: resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==} dev: true - /@types/estree/0.0.51: - resolution: {integrity: sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==} - dev: true - - /@types/estree/1.0.0: - resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==} + /@types/estree@1.0.1: + resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} dev: true - /@types/json-schema/7.0.11: - resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} + /@types/json-schema@7.0.12: + resolution: {integrity: sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==} dev: true - /@types/node/18.6.1: - resolution: {integrity: sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg==} + /@types/node@20.2.5: + resolution: {integrity: sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==} dev: true - /@types/prop-types/15.7.5: + /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} dev: true - /@types/react/16.14.0: + /@types/react@16.14.0: resolution: {integrity: sha512-jJjHo1uOe+NENRIBvF46tJimUvPnmbQ41Ax0pEm7pRvhPg+wuj8VMOHHiMvaGmZRzRrCtm7KnL5OOE/6kHPK8w==} dependencies: '@types/prop-types': 15.7.5 - csstype: 3.1.0 + csstype: 3.1.2 dev: true - /@types/resolve/1.17.1: + /@types/resolve@1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 18.6.1 + '@types/node': 20.2.5 dev: true - /@types/webpack/5.28.0: - resolution: {integrity: sha512-8cP0CzcxUiFuA9xGJkfeVpqmWTk9nx6CWwamRGCj95ph1SmlRRk9KlCZ6avhCbZd4L68LvYT6l1kpdEnQXrF8w==} + /@types/webpack@5.28.1: + resolution: {integrity: sha512-qw1MqGZclCoBrpiSe/hokSgQM/su8Ocpl3L/YHE0L6moyaypg4+5F7Uzq7NgaPKPxUxUbQ4fLPLpDWdR27bCZw==} dependencies: - '@types/node': 18.6.1 + '@types/node': 20.2.5 tapable: 2.2.1 - webpack: 5.74.0 + webpack: 5.84.1 transitivePeerDependencies: - '@swc/core' - esbuild @@ -235,142 +250,142 @@ packages: - webpack-cli dev: true - /@webassemblyjs/ast/1.11.1: - resolution: {integrity: sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==} + /@webassemblyjs/ast@1.11.6: + resolution: {integrity: sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==} dependencies: - '@webassemblyjs/helper-numbers': 1.11.1 - '@webassemblyjs/helper-wasm-bytecode': 1.11.1 + '@webassemblyjs/helper-numbers': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6 dev: true - /@webassemblyjs/floating-point-hex-parser/1.11.1: - resolution: {integrity: sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==} + /@webassemblyjs/floating-point-hex-parser@1.11.6: + resolution: {integrity: sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==} dev: true - /@webassemblyjs/helper-api-error/1.11.1: - resolution: {integrity: sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==} + /@webassemblyjs/helper-api-error@1.11.6: + resolution: {integrity: sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==} dev: true - /@webassemblyjs/helper-buffer/1.11.1: - resolution: {integrity: sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==} + /@webassemblyjs/helper-buffer@1.11.6: + resolution: {integrity: sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==} dev: true - /@webassemblyjs/helper-numbers/1.11.1: - resolution: {integrity: sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==} + /@webassemblyjs/helper-numbers@1.11.6: + resolution: {integrity: sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==} dependencies: - '@webassemblyjs/floating-point-hex-parser': 1.11.1 - '@webassemblyjs/helper-api-error': 1.11.1 + '@webassemblyjs/floating-point-hex-parser': 1.11.6 + '@webassemblyjs/helper-api-error': 1.11.6 '@xtuc/long': 4.2.2 dev: true - /@webassemblyjs/helper-wasm-bytecode/1.11.1: - resolution: {integrity: sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==} + /@webassemblyjs/helper-wasm-bytecode@1.11.6: + resolution: {integrity: sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==} dev: true - /@webassemblyjs/helper-wasm-section/1.11.1: - resolution: {integrity: sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==} + /@webassemblyjs/helper-wasm-section@1.11.6: + resolution: {integrity: sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==} dependencies: - '@webassemblyjs/ast': 1.11.1 - '@webassemblyjs/helper-buffer': 1.11.1 - '@webassemblyjs/helper-wasm-bytecode': 1.11.1 - '@webassemblyjs/wasm-gen': 1.11.1 + '@webassemblyjs/ast': 1.11.6 + '@webassemblyjs/helper-buffer': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6 + '@webassemblyjs/wasm-gen': 1.11.6 dev: true - /@webassemblyjs/ieee754/1.11.1: - resolution: {integrity: sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==} + /@webassemblyjs/ieee754@1.11.6: + resolution: {integrity: sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==} dependencies: '@xtuc/ieee754': 1.2.0 dev: true - /@webassemblyjs/leb128/1.11.1: - resolution: {integrity: sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==} + /@webassemblyjs/leb128@1.11.6: + resolution: {integrity: sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==} dependencies: '@xtuc/long': 4.2.2 dev: true - /@webassemblyjs/utf8/1.11.1: - resolution: {integrity: sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==} + /@webassemblyjs/utf8@1.11.6: + resolution: {integrity: sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==} dev: true - /@webassemblyjs/wasm-edit/1.11.1: - resolution: {integrity: sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==} + /@webassemblyjs/wasm-edit@1.11.6: + resolution: {integrity: sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==} dependencies: - '@webassemblyjs/ast': 1.11.1 - '@webassemblyjs/helper-buffer': 1.11.1 - '@webassemblyjs/helper-wasm-bytecode': 1.11.1 - '@webassemblyjs/helper-wasm-section': 1.11.1 - '@webassemblyjs/wasm-gen': 1.11.1 - '@webassemblyjs/wasm-opt': 1.11.1 - '@webassemblyjs/wasm-parser': 1.11.1 - '@webassemblyjs/wast-printer': 1.11.1 + '@webassemblyjs/ast': 1.11.6 + '@webassemblyjs/helper-buffer': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6 + '@webassemblyjs/helper-wasm-section': 1.11.6 + '@webassemblyjs/wasm-gen': 1.11.6 + '@webassemblyjs/wasm-opt': 1.11.6 + '@webassemblyjs/wasm-parser': 1.11.6 + '@webassemblyjs/wast-printer': 1.11.6 dev: true - /@webassemblyjs/wasm-gen/1.11.1: - resolution: {integrity: sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==} + /@webassemblyjs/wasm-gen@1.11.6: + resolution: {integrity: sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==} dependencies: - '@webassemblyjs/ast': 1.11.1 - '@webassemblyjs/helper-wasm-bytecode': 1.11.1 - '@webassemblyjs/ieee754': 1.11.1 - '@webassemblyjs/leb128': 1.11.1 - '@webassemblyjs/utf8': 1.11.1 + '@webassemblyjs/ast': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6 + '@webassemblyjs/ieee754': 1.11.6 + '@webassemblyjs/leb128': 1.11.6 + '@webassemblyjs/utf8': 1.11.6 dev: true - /@webassemblyjs/wasm-opt/1.11.1: - resolution: {integrity: sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==} + /@webassemblyjs/wasm-opt@1.11.6: + resolution: {integrity: sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==} dependencies: - '@webassemblyjs/ast': 1.11.1 - '@webassemblyjs/helper-buffer': 1.11.1 - '@webassemblyjs/wasm-gen': 1.11.1 - '@webassemblyjs/wasm-parser': 1.11.1 + '@webassemblyjs/ast': 1.11.6 + '@webassemblyjs/helper-buffer': 1.11.6 + '@webassemblyjs/wasm-gen': 1.11.6 + '@webassemblyjs/wasm-parser': 1.11.6 dev: true - /@webassemblyjs/wasm-parser/1.11.1: - resolution: {integrity: sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==} + /@webassemblyjs/wasm-parser@1.11.6: + resolution: {integrity: sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==} dependencies: - '@webassemblyjs/ast': 1.11.1 - '@webassemblyjs/helper-api-error': 1.11.1 - '@webassemblyjs/helper-wasm-bytecode': 1.11.1 - '@webassemblyjs/ieee754': 1.11.1 - '@webassemblyjs/leb128': 1.11.1 - '@webassemblyjs/utf8': 1.11.1 + '@webassemblyjs/ast': 1.11.6 + '@webassemblyjs/helper-api-error': 1.11.6 + '@webassemblyjs/helper-wasm-bytecode': 1.11.6 + '@webassemblyjs/ieee754': 1.11.6 + '@webassemblyjs/leb128': 1.11.6 + '@webassemblyjs/utf8': 1.11.6 dev: true - /@webassemblyjs/wast-printer/1.11.1: - resolution: {integrity: sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==} + /@webassemblyjs/wast-printer@1.11.6: + resolution: {integrity: sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==} dependencies: - '@webassemblyjs/ast': 1.11.1 + '@webassemblyjs/ast': 1.11.6 '@xtuc/long': 4.2.2 dev: true - /@xtuc/ieee754/1.2.0: + /@xtuc/ieee754@1.2.0: resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} dev: true - /@xtuc/long/4.2.2: + /@xtuc/long@4.2.2: resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==} dev: true - /abort-controller/3.0.0: + /abort-controller@3.0.0: resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} engines: {node: '>=6.5'} dependencies: event-target-shim: 5.0.1 dev: false - /acorn-import-assertions/1.8.0_acorn@8.8.0: - resolution: {integrity: sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==} + /acorn-import-assertions@1.9.0(acorn@8.8.2): + resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==} peerDependencies: acorn: ^8 dependencies: - acorn: 8.8.0 + acorn: 8.8.2 dev: true - /acorn/8.8.0: - resolution: {integrity: sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==} + /acorn@8.8.2: + resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} hasBin: true dev: true - /ajv-keywords/3.5.2_ajv@6.12.6: + /ajv-keywords@3.5.2(ajv@6.12.6): resolution: {integrity: sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==} peerDependencies: ajv: ^6.9.1 @@ -378,7 +393,7 @@ packages: ajv: 6.12.6 dev: true - /ajv/6.12.6: + /ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} dependencies: fast-deep-equal: 3.1.3 @@ -387,93 +402,93 @@ packages: uri-js: 4.4.1 dev: true - /balanced-match/1.0.2: + /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true - /brace-expansion/1.1.11: + /brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} dependencies: balanced-match: 1.0.2 concat-map: 0.0.1 dev: true - /browserslist/4.21.2: - resolution: {integrity: sha512-MonuOgAtUB46uP5CezYbRaYKBNt2LxP0yX+Pmj4LkcDFGkn9Cbpi83d9sCjwQDErXsIJSzY5oKGDbgOlF/LPAA==} + /browserslist@4.21.7: + resolution: {integrity: sha512-BauCXrQ7I2ftSqd2mvKHGo85XR0u7Ru3C/Hxsy/0TkfCtjrmAbPdzLGasmoiBxplpDXlPvdjX9u7srIMfgasNA==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001370 - electron-to-chromium: 1.4.201 - node-releases: 2.0.6 - update-browserslist-db: 1.0.5_browserslist@4.21.2 + caniuse-lite: 1.0.30001489 + electron-to-chromium: 1.4.412 + node-releases: 2.0.12 + update-browserslist-db: 1.0.11(browserslist@4.21.7) dev: true - /buffer-from/1.1.2: + /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} dev: true - /builtin-modules/3.3.0: + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} dev: true - /caniuse-lite/1.0.30001370: - resolution: {integrity: sha512-3PDmaP56wz/qz7G508xzjx8C+MC2qEm4SYhSEzC9IBROo+dGXFWRuaXkWti0A9tuI00g+toiriVqxtWMgl350g==} + /caniuse-lite@1.0.30001489: + resolution: {integrity: sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==} dev: true - /chrome-trace-event/1.0.3: + /chrome-trace-event@1.0.3: resolution: {integrity: sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==} engines: {node: '>=6.0'} dev: true - /commander/2.20.3: + /commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} dev: true - /commondir/1.0.1: + /commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} dev: true - /concat-map/0.0.1: + /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true - /csstype/3.1.0: - resolution: {integrity: sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==} + /csstype@3.1.2: + resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} dev: true - /decky-frontend-lib/3.18.6: - resolution: {integrity: sha512-kM+kH/EuYCW+zsdYnNZa39EsU1bTF/iYn03zbeaTSIVwe/oxqOoEG2mwVaQdhk98jqY1uWZgayBQYnnTksMXFw==} + /decky-frontend-lib@3.21.1: + resolution: {integrity: sha512-30605ET9qqZ6St6I9WmMmLGgSrTIdMwo7xy85+lRaF1miUd2icOGEJjwnbVcZDdkal+1fJ3tNEDXlchVfG4TrA==} dev: false - /deepmerge/4.2.2: - resolution: {integrity: sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==} + /deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} dev: true - /electron-to-chromium/1.4.201: - resolution: {integrity: sha512-87D0gEHbhLZgZxZl2e9/rC/I2BicPC/y9wR/cuaJSqvkgN41s5EImi89S7YExHc7F0OBXiKsABZt9mmb9bqFcQ==} + /electron-to-chromium@1.4.412: + resolution: {integrity: sha512-lsdxyQVXw79Q1/yUWp4JDopW2M9pFjnbNF2/09d75qQL5ld8ddmGruQBeA0lP4HxcGIhrL0gFXqxJDWR58Whkw==} dev: true - /enhanced-resolve/5.10.0: - resolution: {integrity: sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==} + /enhanced-resolve@5.14.1: + resolution: {integrity: sha512-Vklwq2vDKtl0y/vtwjSesgJ5MYS7Etuk5txS8VdKL4AOS1aUlD96zqIfsOSLQsdv3xgMRbtkWM8eG9XDfKUPow==} engines: {node: '>=10.13.0'} dependencies: - graceful-fs: 4.2.10 + graceful-fs: 4.2.11 tapable: 2.2.1 dev: true - /es-module-lexer/0.9.3: - resolution: {integrity: sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==} + /es-module-lexer@1.2.1: + resolution: {integrity: sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==} dev: true - /escalade/3.1.1: + /escalade@3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} dev: true - /eslint-scope/5.1.1: + /eslint-scope@5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'} dependencies: @@ -481,70 +496,70 @@ packages: estraverse: 4.3.0 dev: true - /esrecurse/4.3.0: + /esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} dependencies: estraverse: 5.3.0 dev: true - /estraverse/4.3.0: + /estraverse@4.3.0: resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==} engines: {node: '>=4.0'} dev: true - /estraverse/5.3.0: + /estraverse@5.3.0: resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} engines: {node: '>=4.0'} dev: true - /estree-walker/0.6.1: + /estree-walker@0.6.1: resolution: {integrity: sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==} dev: true - /estree-walker/1.0.1: + /estree-walker@1.0.1: resolution: {integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==} dev: true - /estree-walker/2.0.2: + /estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} dev: true - /event-target-shim/5.0.1: + /event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} dev: false - /events/3.3.0: + /events@3.3.0: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} dev: true - /eventsource/2.0.2: + /eventsource@2.0.2: resolution: {integrity: sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==} engines: {node: '>=12.0.0'} dev: false - /fast-deep-equal/3.1.3: + /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true - /fast-json-stable-stringify/2.1.0: + /fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} dev: true - /fetch-cookie/2.1.0: + /fetch-cookie@2.1.0: resolution: {integrity: sha512-39+cZRbWfbibmj22R2Jy6dmTbAWC+oqun1f1FzQaNurkPDUP4C38jpeZbiXCR88RKRVDp8UcDrbFXkNhN+NjYg==} dependencies: - set-cookie-parser: 2.5.1 - tough-cookie: 4.1.2 + set-cookie-parser: 2.6.0 + tough-cookie: 4.1.3 dev: false - /fs.realpath/1.0.0: + /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true - /fsevents/2.3.2: + /fsevents@2.3.2: resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] @@ -552,15 +567,15 @@ packages: dev: true optional: true - /function-bind/1.1.1: + /function-bind@1.1.1: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true - /glob-to-regexp/0.4.1: + /glob-to-regexp@0.4.1: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} dev: true - /glob/7.2.3: + /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} dependencies: fs.realpath: 1.0.0 @@ -571,125 +586,121 @@ packages: path-is-absolute: 1.0.1 dev: true - /graceful-fs/4.2.10: - resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} dev: true - /has-flag/4.0.0: + /has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} dev: true - /has/1.0.3: + /has@1.0.3: resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} engines: {node: '>= 0.4.0'} dependencies: function-bind: 1.1.1 dev: true - /inflight/1.0.6: + /inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} dependencies: once: 1.4.0 wrappy: 1.0.2 dev: true - /inherits/2.0.4: + /inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: true - /interpret/1.4.0: + /interpret@1.4.0: resolution: {integrity: sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==} engines: {node: '>= 0.10'} dev: true - /is-builtin-module/3.1.0: - resolution: {integrity: sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==} + /is-builtin-module@3.2.1: + resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} engines: {node: '>=6'} dependencies: builtin-modules: 3.3.0 dev: true - /is-core-module/2.9.0: - resolution: {integrity: sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==} + /is-core-module@2.12.1: + resolution: {integrity: sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==} dependencies: has: 1.0.3 dev: true - /is-module/1.0.0: + /is-module@1.0.0: resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} dev: true - /is-reference/1.2.1: + /is-reference@1.2.1: resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} dependencies: - '@types/estree': 1.0.0 + '@types/estree': 1.0.1 dev: true - /jest-worker/27.5.1: + /jest-worker@27.5.1: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 18.6.1 + '@types/node': 20.2.5 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true - /json-parse-even-better-errors/2.3.1: + /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: true - /json-schema-traverse/0.4.1: + /json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} dev: true - /loader-runner/4.3.0: + /loader-runner@4.3.0: resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==} engines: {node: '>=6.11.5'} dev: true - /lodash.debounce/4.0.8: - resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} - dev: false - - /magic-string/0.25.9: + /magic-string@0.25.9: resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} dependencies: sourcemap-codec: 1.4.8 dev: true - /merge-stream/2.0.0: + /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: true - /mime-db/1.52.0: + /mime-db@1.52.0: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} engines: {node: '>= 0.6'} dev: true - /mime-types/2.1.35: + /mime-types@2.1.35: resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} engines: {node: '>= 0.6'} dependencies: mime-db: 1.52.0 dev: true - /minimatch/3.1.2: + /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: brace-expansion: 1.1.11 dev: true - /minimist/1.2.6: - resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} + /minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} dev: true - /neo-async/2.6.2: + /neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: true - /node-fetch/2.6.8: - resolution: {integrity: sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg==} + /node-fetch@2.7.0: + resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} peerDependencies: encoding: ^0.1.0 @@ -700,64 +711,54 @@ packages: whatwg-url: 5.0.0 dev: false - /node-releases/2.0.6: - resolution: {integrity: sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==} + /node-releases@2.0.12: + resolution: {integrity: sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==} dev: true - /once/1.4.0: + /once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: wrappy: 1.0.2 dev: true - /path-is-absolute/1.0.1: + /path-is-absolute@1.0.1: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} dev: true - /path-parse/1.0.7: + /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true - /performance-now/2.1.0: - resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} - dev: false - - /picocolors/1.0.0: + /picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} dev: true - /picomatch/2.3.1: + /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} dev: true - /psl/1.9.0: + /psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} dev: false - /punycode/2.1.1: - resolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==} + /punycode@2.3.0: + resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} engines: {node: '>=6'} - /querystringify/2.2.0: + /querystringify@2.2.0: resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} dev: false - /raf/3.4.1: - resolution: {integrity: sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==} - dependencies: - performance-now: 2.1.0 - dev: false - - /randombytes/2.1.0: + /randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} dependencies: safe-buffer: 5.2.1 dev: true - /react-icons/4.4.0: - resolution: {integrity: sha512-fSbvHeVYo/B5/L4VhB7sBA1i2tS8MkT0Hb9t2H1AVPkwGfVHLJCqyr2Py9dKMxsyM63Eng1GkdZfbWj+Fmv8Rg==} + /react-icons@4.9.0: + resolution: {integrity: sha512-ijUnFr//ycebOqujtqtV9PFS7JjhWg0QU6ykURVHuL4cbofvRCf3f6GMn9+fBktEFQOIVZnuAYLZdiyadRQRFg==} peerDependencies: react: '*' peerDependenciesMeta: @@ -765,90 +766,74 @@ packages: optional: true dev: false - /rechoir/0.6.2: + /rechoir@0.6.2: resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==} engines: {node: '>= 0.10'} dependencies: - resolve: 1.22.1 + resolve: 1.22.2 dev: true - /requires-port/1.0.0: + /requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} dev: false - /resolve/1.22.1: - resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==} + /resolve@1.22.2: + resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==} hasBin: true dependencies: - is-core-module: 2.9.0 + is-core-module: 2.12.1 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 dev: true - /rollup-plugin-import-assets/1.1.1_rollup@2.77.1: + /rollup-plugin-import-assets@1.1.1(rollup@2.79.1): resolution: {integrity: sha512-u5zJwOjguTf2N+wETq2weNKGvNkuVc1UX/fPgg215p5xPvGOaI6/BTc024E9brvFjSQTfIYqgvwogQdipknu1g==} peerDependencies: rollup: '>=1.9.0' dependencies: - rollup: 2.77.1 + rollup: 2.79.1 rollup-pluginutils: 2.8.2 url-join: 4.0.1 dev: true - /rollup-pluginutils/2.8.2: + /rollup-pluginutils@2.8.2: resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==} dependencies: estree-walker: 0.6.1 dev: true - /rollup/2.77.1: - resolution: {integrity: sha512-GhutNJrvTYD6s1moo+kyq7lD9DeR5HDyXo4bDFlDSkepC9kVKY+KK/NSZFzCmeXeia3kEzVuToQmHRdugyZHxw==} + /rollup@2.79.1: + resolution: {integrity: sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==} engines: {node: '>=10.0.0'} hasBin: true optionalDependencies: fsevents: 2.3.2 dev: true - /rooks/7.4.2: - resolution: {integrity: sha512-4vpjD3hGkc5hH7NZxViOUTmacwx5HhZH6CJjy0fQd4jR9zXzGjkmUncuFraqXj+vEsAC3LBq/OPHC5k1VBWbyg==} - engines: {node: '>=v10.24.1'} - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - react: - optional: true - react-dom: - optional: true - dependencies: - lodash.debounce: 4.0.8 - raf: 3.4.1 - dev: false - - /safe-buffer/5.2.1: + /safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} dev: true - /schema-utils/3.1.1: - resolution: {integrity: sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==} + /schema-utils@3.1.2: + resolution: {integrity: sha512-pvjEHOgWc9OWA/f/DE3ohBWTD6EleVLf7iFUkoSwAxttdBhB9QUebQgxER2kWueOvRJXPHNnyrvvh9eZINB8Eg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/json-schema': 7.0.11 + '@types/json-schema': 7.0.12 ajv: 6.12.6 - ajv-keywords: 3.5.2_ajv@6.12.6 + ajv-keywords: 3.5.2(ajv@6.12.6) dev: true - /serialize-javascript/6.0.0: - resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==} + /serialize-javascript@6.0.1: + resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==} dependencies: randombytes: 2.1.0 dev: true - /set-cookie-parser/2.5.1: - resolution: {integrity: sha512-1jeBGaKNGdEq4FgIrORu/N570dwoPYio8lSoYLWmX7sQ//0JY08Xh9o5pBcgmHQ/MbsYp/aZnOe1s1lIsbLprQ==} + /set-cookie-parser@2.6.0: + resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} dev: false - /shelljs/0.8.5: + /shelljs@0.8.5: resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==} engines: {node: '>=4'} hasBin: true @@ -858,50 +843,51 @@ packages: rechoir: 0.6.2 dev: true - /shx/0.3.4: + /shx@0.3.4: resolution: {integrity: sha512-N6A9MLVqjxZYcVn8hLmtneQWIJtp8IKzMP4eMnx+nqkvXoqinUPCbUFLp2UcWTEIUONhlk0ewxr/jaVGlc+J+g==} engines: {node: '>=6'} hasBin: true dependencies: - minimist: 1.2.6 + minimist: 1.2.8 shelljs: 0.8.5 dev: true - /source-map-support/0.5.21: + /source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} dependencies: buffer-from: 1.1.2 source-map: 0.6.1 dev: true - /source-map/0.6.1: + /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} dev: true - /sourcemap-codec/1.4.8: + /sourcemap-codec@1.4.8: resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} + deprecated: Please use @jridgewell/sourcemap-codec instead dev: true - /supports-color/8.1.1: + /supports-color@8.1.1: resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} engines: {node: '>=10'} dependencies: has-flag: 4.0.0 dev: true - /supports-preserve-symlinks-flag/1.0.0: + /supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} dev: true - /tapable/2.2.1: + /tapable@2.2.1: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} dev: true - /terser-webpack-plugin/5.3.3_webpack@5.74.0: - resolution: {integrity: sha512-Fx60G5HNYknNTNQnzQ1VePRuu89ZVYWfjRAeT5rITuCY/1b08s49e5kSQwHDirKZWuoKOBRFS98EUUoZ9kLEwQ==} + /terser-webpack-plugin@5.3.9(webpack@5.84.1): + resolution: {integrity: sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==} engines: {node: '>= 10.13.0'} peerDependencies: '@swc/core': '*' @@ -916,101 +902,101 @@ packages: uglify-js: optional: true dependencies: - '@jridgewell/trace-mapping': 0.3.14 + '@jridgewell/trace-mapping': 0.3.18 jest-worker: 27.5.1 - schema-utils: 3.1.1 - serialize-javascript: 6.0.0 - terser: 5.14.2 - webpack: 5.74.0 + schema-utils: 3.1.2 + serialize-javascript: 6.0.1 + terser: 5.17.6 + webpack: 5.84.1 dev: true - /terser/5.14.2: - resolution: {integrity: sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==} + /terser@5.17.6: + resolution: {integrity: sha512-V8QHcs8YuyLkLHsJO5ucyff1ykrLVsR4dNnS//L5Y3NiSXpbK1J+WMVUs67eI0KTxs9JtHhgEQpXQVHlHI92DQ==} engines: {node: '>=10'} hasBin: true dependencies: - '@jridgewell/source-map': 0.3.2 - acorn: 8.8.0 + '@jridgewell/source-map': 0.3.3 + acorn: 8.8.2 commander: 2.20.3 source-map-support: 0.5.21 dev: true - /tough-cookie/4.1.2: - resolution: {integrity: sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==} + /tough-cookie@4.1.3: + resolution: {integrity: sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==} engines: {node: '>=6'} dependencies: psl: 1.9.0 - punycode: 2.1.1 + punycode: 2.3.0 universalify: 0.2.0 url-parse: 1.5.10 dev: false - /tr46/0.0.3: + /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: false - /tslib/2.4.0: - resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} + /tslib@2.5.2: + resolution: {integrity: sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA==} dev: true - /typescript/4.7.4: - resolution: {integrity: sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==} + /typescript@4.9.5: + resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} hasBin: true dev: true - /universalify/0.2.0: + /universalify@0.2.0: resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==} engines: {node: '>= 4.0.0'} dev: false - /update-browserslist-db/1.0.5_browserslist@4.21.2: - resolution: {integrity: sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==} + /update-browserslist-db@1.0.11(browserslist@4.21.7): + resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==} hasBin: true peerDependencies: browserslist: '>= 4.21.0' dependencies: - browserslist: 4.21.2 + browserslist: 4.21.7 escalade: 3.1.1 picocolors: 1.0.0 dev: true - /uri-js/4.4.1: + /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: - punycode: 2.1.1 + punycode: 2.3.0 dev: true - /url-join/4.0.1: + /url-join@4.0.1: resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==} dev: true - /url-parse/1.5.10: + /url-parse@1.5.10: resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} dependencies: querystringify: 2.2.0 requires-port: 1.0.0 dev: false - /watchpack/2.4.0: + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} dependencies: glob-to-regexp: 0.4.1 - graceful-fs: 4.2.10 + graceful-fs: 4.2.11 dev: true - /webidl-conversions/3.0.1: + /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false - /webpack-sources/3.2.3: + /webpack-sources@3.2.3: resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==} engines: {node: '>=10.13.0'} dev: true - /webpack/5.74.0: - resolution: {integrity: sha512-A2InDwnhhGN4LYctJj6M1JEaGL7Luj6LOmyBHjcI8529cm5p6VXiTIW2sn6ffvEAKmveLzvu4jrihwXtPojlAA==} + /webpack@5.84.1: + resolution: {integrity: sha512-ZP4qaZ7vVn/K8WN/p990SGATmrL1qg4heP/MrVneczYtpDGJWlrgZv55vxaV2ul885Kz+25MP2kSXkPe3LZfmg==} engines: {node: '>=10.13.0'} hasBin: true peerDependencies: @@ -1020,27 +1006,27 @@ packages: optional: true dependencies: '@types/eslint-scope': 3.7.4 - '@types/estree': 0.0.51 - '@webassemblyjs/ast': 1.11.1 - '@webassemblyjs/wasm-edit': 1.11.1 - '@webassemblyjs/wasm-parser': 1.11.1 - acorn: 8.8.0 - acorn-import-assertions: 1.8.0_acorn@8.8.0 - browserslist: 4.21.2 + '@types/estree': 1.0.1 + '@webassemblyjs/ast': 1.11.6 + '@webassemblyjs/wasm-edit': 1.11.6 + '@webassemblyjs/wasm-parser': 1.11.6 + acorn: 8.8.2 + acorn-import-assertions: 1.9.0(acorn@8.8.2) + browserslist: 4.21.7 chrome-trace-event: 1.0.3 - enhanced-resolve: 5.10.0 - es-module-lexer: 0.9.3 + enhanced-resolve: 5.14.1 + es-module-lexer: 1.2.1 eslint-scope: 5.1.1 events: 3.3.0 glob-to-regexp: 0.4.1 - graceful-fs: 4.2.10 + graceful-fs: 4.2.11 json-parse-even-better-errors: 2.3.1 loader-runner: 4.3.0 mime-types: 2.1.35 neo-async: 2.6.2 - schema-utils: 3.1.1 + schema-utils: 3.1.2 tapable: 2.2.1 - terser-webpack-plugin: 5.3.3_webpack@5.74.0 + terser-webpack-plugin: 5.3.9(webpack@5.84.1) watchpack: 2.4.0 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -1049,18 +1035,18 @@ packages: - uglify-js dev: true - /whatwg-url/5.0.0: + /whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} dependencies: tr46: 0.0.3 webidl-conversions: 3.0.1 dev: false - /wrappy/1.0.2: + /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true - /ws/7.5.9: + /ws@7.5.9: resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} engines: {node: '>=8.3.0'} peerDependencies: diff --git a/.gitmodules b/py_modules/.keep similarity index 100% rename from .gitmodules rename to py_modules/.keep diff --git a/rollup.config.js b/rollup.config.js index 8717908..f11a008 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -24,12 +24,13 @@ export default defineConfig({ }) ], context: 'window', - external: ['react', 'react-dom'], + external: ["react", "react-dom", "decky-frontend-lib"], output: { - file: 'dist/index.js', + file: "dist/index.js", globals: { - react: 'SP_REACT', - 'react-dom': 'SP_REACTDOM', + react: "SP_REACT", + "react-dom": "SP_REACTDOM", + "decky-frontend-lib": "DFL" }, format: 'iife', exports: 'default', diff --git a/scripts/reload.js b/scripts/reload.js deleted file mode 100644 index 016ce8c..0000000 --- a/scripts/reload.js +++ /dev/null @@ -1,32 +0,0 @@ -require('dotenv').config() -const plugin = require("../plugin.json"); -const CDP = require('chrome-remote-interface'); - -const options = { - host: process.env.DECKIP, - port: 8081, -}; - -async function main() { - let client; - try { - // connect to endpoint - client = await CDP({...options, - target: (targets) => targets.find((target) => target.title == "Steam"), - }); - - // extract domains - const {Network, Page, Runtime} = client; - - await Runtime.evaluate({ expression: `console.log("Reloading ${plugin.name} from an unbelievably stupid dev script")` }); - await Runtime.evaluate({ expression: `importDeckyPlugin("${plugin.name}")` }); - } catch (err) { - console.error(err); - } finally { - if (client) { - await client.close(); - } - } -} - -main(); diff --git a/src/classes.ts b/src/classes.ts deleted file mode 100644 index 93e769a..0000000 --- a/src/classes.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { findModule } from "decky-frontend-lib"; - -export const mediaPageClasses = findModule((mod) => { - if (typeof mod !== 'object') return false; - - if (mod.ScreenshotGrid && mod.ScreenshotHeaderBanner) { - return true; - } - - return false; -}); - -export const gamepadTabbedPageClasses = findModule((mod) => { - if (typeof mod !== 'object') return false; - - if (mod.TabCount && mod.TabTitle) { - return true; - } - - return false; -}); \ No newline at end of file diff --git a/src/components/VideoCard.tsx b/src/components/VideoCard.tsx deleted file mode 100644 index 8267e20..0000000 --- a/src/components/VideoCard.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import { Focusable, joinClassNames, Menu, MenuItem, showContextMenu, showModal, Spinner } from "decky-frontend-lib"; -import { FunctionComponent, useCallback, useLayoutEffect, useRef, useState } from "react"; -import { useIntersectionObserverRef } from "rooks"; -import { mediaPageClasses } from "../classes"; -import VideoModal from "./VideoModal"; - -interface VideoCardProps { - path: string -} - -// type VideoLoadQueueItem = (load: boolean) => void; - -// let loadQueue: VideoLoadQueueItem[] = []; - -// export function clearQueue() { -// console.log("clearing queue") -// loadQueue = []; -// } - -// function loadVideo() { -// if (loadQueue.length == 0) { -// console.log("done loading videos") -// return; -// } -// const elem = loadQueue[0]; -// elem(true); -// } - -const VideoCard: FunctionComponent = ({ path }) => { - const [duration, setDuration] = useState(0); - const [load, setLoad] = useState(false); - const [loaded, setLoaded] = useState(false); - - const videoRef = useRef(null); - const source = ; - const filenameArr = path.split("/"); - const filename = filenameArr[filenameArr.length - 1]; - // useLayoutEffect(() => { - // loadQueue.push(setLoad) - // if (loadQueue.length == 1) { - // loadVideo(); - // } - // }, []); - const intersectionCallback = useCallback(async (entries) => { - if (entries && entries[0]?.isIntersecting && !load) { - console.log("loading", path, load) - setLoad(true); - } - }, [load]); - const [intersectRef] = useIntersectionObserverRef(intersectionCallback); - useLayoutEffect(() => { - if (!videoRef?.current) return; - const el = () => { - console.log("finished loading", path) - // loadQueue.shift(); - setLoaded(true); - videoRef?.current?.duration && setDuration(videoRef.current.duration); - // loadVideo(); - } - videoRef?.current?.addEventListener("loadeddata", el); - return () => { - videoRef?.current?.removeEventListener("loadeddata", el); - } - }, [load]) - - - const Delete = (path: string) => { - fetch(`http://localhost:6969/delete${path}`, { - method: "DELETE", headers: { - Accept: "application/json", - "Content-Type": "application/json", - }}) - - } - - return ( - - { - showContextMenu( - - Delete(path)}>Delete - - )}} - onActivate={() =>{ - showModal(, window) - }} className={mediaPageClasses.ImageContainer}> -
- {load && } - {!loaded &&
} -
-
-
- {filename} -
-
-
- {duration && `${duration}s`} -
-
-
-
-
- ); -} - -export default VideoCard; \ No newline at end of file diff --git a/src/components/VideoModal.tsx b/src/components/VideoModal.tsx deleted file mode 100644 index 149200b..0000000 --- a/src/components/VideoModal.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { findSP, Focusable, GamepadButton } from "decky-frontend-lib"; -import { - FunctionComponent, - ReactNode, - useEffect, - useLayoutEffect, - useRef, -} from "react"; - -interface VideoModalProps { - source: ReactNode; - closeModal?(): void; -} - -const VideoModal: FunctionComponent = ({ - source, - closeModal, -}) => { - const focusableRef = useRef(null); - const videoRef = useRef(null); - useLayoutEffect(() => { - focusableRef?.current?.focus(); - videoRef!.current!.volume = 0.3; - videoRef!.current!.play(); - // videoRef?.current?.requestFullscreen(); - // const el = () => { - // videoRef?.current?.requestFullscreen(); - // } - // videoRef?.current?.addEventListener("load", el); - // return () => { - // videoRef?.current?.removeEventListener("load", el); - // } - }, []); - useEffect(() => { - const SP = findSP(); - SP.document.getElementById("header")!.style.display = "none"; - SP.document.getElementById("Footer")!.style.display = "none"; - return () => { - SP.document.getElementById("header")!.style.display = ""; - SP.document.getElementById("Footer")!.style.display = ""; - }; - }, []); - return ( - videoRef?.current?.paused ? videoRef?.current?.play() : videoRef?.current?.pause()} onCancel={closeModal} onGamepadDirection={(evt) => { - switch (evt.detail.button) { - case GamepadButton.DIR_LEFT: - videoRef!.current!.currentTime = videoRef!.current!.currentTime - 5 - break; - case GamepadButton.DIR_RIGHT: - videoRef!.current!.currentTime = videoRef!.current!.currentTime + 5 - break; - } - }}> - - - ); -}; - -export default VideoModal; diff --git a/src/components/VideosTab.tsx b/src/components/VideosTab.tsx deleted file mode 100644 index ca9e09d..0000000 --- a/src/components/VideosTab.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { Focusable, ServerAPI } from "decky-frontend-lib"; -import { FunctionComponent, useEffect, useState } from "react"; -import { mediaPageClasses } from "../classes"; -import VideoCard from "./VideoCard"; - -interface VideosTabProps { - ServerAPI: ServerAPI -} - -const VideosTab: FunctionComponent = () => { - const [videoList, setVideoList] = useState([]); - useEffect(() => { - fetch('http://localhost:6969/list', { - method: "GET", headers: { - Accept: "application/json", - "Content-Type": "application/json", - } - }).then((data) => { - data.json().then((json) => { - console.log(data) - setVideoList(json as string[]) - }); - }); - }, []); - - return ( -
-
-
- Newest first -
-
- - {videoList.map(video => )} - -
- ); -} - -export default VideosTab; \ No newline at end of file diff --git a/src/components/VideosTabAddon.tsx b/src/components/VideosTabAddon.tsx deleted file mode 100644 index 685daaa..0000000 --- a/src/components/VideosTabAddon.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { ServerAPI } from "decky-frontend-lib"; -import { FunctionComponent, useEffect, useState } from "react"; -import { gamepadTabbedPageClasses } from "../classes"; - -interface VideosTabAddonProps { - ServerAPI: ServerAPI -} - -const VideosTabAddon: FunctionComponent = () => { - const [count, setCount] = useState(0); - useEffect(() => { - (async() => { - const videoAmount = (await (await fetch('http://localhost:6969/list-count', { - method: "GET", headers: { - Accept: "application/json", - "Content-Type": "application/json", - } - })).text()); - - setCount(videoAmount as unknown as number); - })(); - }, []) - return
{count}
; -} - -export default VideosTabAddon; \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index dd8dafe..f588439 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,333 +1,213 @@ import { - afterPatch, - ButtonItem, - definePlugin, - Dropdown, - DropdownOption, - PanelSection, - PanelSectionRow, - Router, - ServerAPI, - staticClasses, - Tab, - ToggleField, - wrapReactType + ButtonItem, + definePlugin, + Dropdown, + PanelSection, + PanelSectionRow, + // ProgressBar, + Router, + ServerAPI, + staticClasses, + ToggleField, } from "decky-frontend-lib"; -import {useEffect, useState, VFC} from "react"; -import {FaCircle, FaStop, FaVideo, FaVideoSlash} from "react-icons/fa"; -import VideosTab from "./components/VideosTab"; -import VideosTabAddon from "./components/VideosTabAddon"; - -import {HubConnection, HubConnectionBuilder, HubConnectionState} from "@microsoft/signalr"; - -interface DeckyStreamConfig { - ShadowEnabled: boolean; - StreamType: "ndi" | "rtmp"; - RtmpEndpoint?: string; - MicEnabled: boolean; +import { useEffect, useState, VFC } from "react"; +import { FaVideo } from "react-icons/fa"; +import { HubConnection, HubConnectionBuilder } from "@microsoft/signalr"; + + +interface ConfigType { + replayBufferEnabled: boolean, + replayBufferSeconds: number } +const Content: VFC<{ serverAPI: ServerAPI, connection: HubConnection }> = ({ serverAPI, connection }) => { -const Content: VFC<{ ServerAPI: ServerAPI, Connection: HubConnection}> = ({ServerAPI, Connection}) => { + const [PeakVolume, SetPeakVolume] = useState(0); - Connection.on("StreamingStatusChange", (status) => { - console.log("StreamingStatusChange", status); - setIsStreaming(status); - }) + const [Config, SetConfig] = useState({replayBufferSeconds: 60, replayBufferEnabled: true} as ConfigType); - Connection.on("RecordingStatusChange", (status) => { - console.log("RecordingStatusChange", status) - setIsRecording(status); - }) - - Connection.on("GstreamerStateChange", (state, reason) => { - console.log(state, reason) - }) + useEffect(() => { + console.log("registering"); + const handleVolumePeakChanged = (channel: number, peak: number) => { + console.log(peak); + SetPeakVolume(peak); + }; - - const [isRecording, setIsRecording] = useState(false); - const [isStreaming, setIsStreaming] = useState(false); + connection.invoke("GetConfig").then((config : ConfigType) => { + SetConfig(config); + // setBufferEnabled(config.replayBufferEnabled) + }); + connection.invoke("GetStatus").then((status : any) => { + console.log("Status:" + status); + setIsRecording(status.recording); + }); - const options: DropdownOption[] = [{data: "ndi", label: "NDIā„¢"}, {data: "rtmp", label: "RTMP"}]; + connection.on("OnVolumePeakChanged", handleVolumePeakChanged); - var [config, setConfig] = useState({ShadowEnabled: false, MicEnabled: false, StreamType: "ndi", RtmpEndpoint: undefined} as DeckyStreamConfig); + return () => { + console.log("unregistering"); + connection.off("OnVolumePeakChanged", handleVolumePeakChanged); + }; + }, []); - useEffect(() => { - if (Connection.state == HubConnectionState.Connected) { - Connection.invoke("SetConfig", config); - } - }, [config]) - - useEffect(() => { - - Connection.invoke("GetRecordingStatus").then((data) => setIsRecording(data)); - Connection.invoke("GetStreamingStatus").then((data) => setIsStreaming(data)); - - Connection.invoke("GetConfig").then((data) => { - setConfig(data); - }); - }, []); - - async function StopRecord() { - var resp = await Connection.invoke("StopStream"); - if (resp) { - ServerAPI.toaster.toast({ - title: "Stopping Recording", - body: "Recording has stopped", - showToast: true - }); - } - } + // const [volume, setVolume] = useState(0); - async function StartRecord() { - var resp = await Connection.invoke("StartRecord"); - if (resp) { - ServerAPI.toaster.toast({ - title: "Started Recording", - body: "Recording has started", - showToast: true - }); - } else { - ServerAPI.toaster.toast({ - title: "Recording failed to start", - body: "Check logs", - critical: true, - showToast: true - }); + // const [bufferEnabled, setBufferEnabled] = useState(false); - } - } + const ToggleBuffer = (checked : boolean) => { + SaveConfig({ ...Config, replayBufferEnabled: checked }); - async function StopStreaming() { - var resp = await Connection.invoke("StopStream"); + // setBufferEnabled(checked); + connection.invoke("BufferOutput", checked); + } - if (resp) { - ServerAPI.toaster.toast({ - title: "Stopping stream", - body: "Stream has ended", - showToast: true - }); - } - } + const SaveConfig = (Config: ConfigType) => { + connection.invoke("SaveConfig", Config); + SetConfig(Config); + } - async function StartStreaming() { - var resp = await Connection.invoke("StartStream"); - - if (resp) { - ServerAPI.toaster.toast({ - title: "Started Stream", - body: "Stream has started", - showToast: true - }); - } else { - ServerAPI.toaster.toast({ - title: "Stream failed to start", - body: "Check logs", - critical: true, - showToast: true - }); - } + const ChangeBufferSeconds = async (seconds: number) => { + await SaveConfig({ ...Config, replayBufferSeconds: seconds }); + + await connection.invoke("UpdateBufferSettings"); + + } + + // useEffect(() => { + // connection.invoke("SetSpeakerVolume", volume); + // }, [volume]) + + const [isRecording, setIsRecording] = useState(false); + + const ToggleRecording = () => { + if (!isRecording) { + connection.invoke("StartRecording").then(() => { + setIsRecording(true); + }).catch(() => { + + }) + } else { + connection.invoke("StopRecording").then(() => { + setIsRecording(false); + serverAPI.toaster.toast({ + title: "Recording saved", + // body: "Tap to view", + body: "", + icon: , + critical: true, + //onClick: () => Router.Navigate("/media/tab/videos") + }) + }).catch(() => { + + }) } - - - - - return ( - - - - { - if (checked) { - await setConfig({...config, ShadowEnabled: true}); - await Connection.invoke("StartShadow"); - } else { - await setConfig({...config, ShadowEnabled: false}); - await Connection.invoke("StopShadow"); - - } - } - } - > - - - - - {!isRecording ? - { - await StartRecord(); - } - } - > -
- -
Start Recording
-
-
- : - { - await StopRecord(); - } - } - > -
- - -
Stop Recording
-
- -
- } -
- - - {!isStreaming ? - { - StartStreaming(); - } - } - > -
- -
Start Streaming
-
-
- : - { - StopStreaming(); - } - } - > -
- -
Stop Streaming
-
- - -
- } -
- - (x.data == config.StreamType))} - onChange={(x) => { - setConfig({...config, StreamType: x.data}); - }} - /> - - - { - setConfig({...config, MicEnabled: e}); - } - } label="Microphone"> - - -
- ); + } + + return ( + + + + + ChangeBufferSeconds(x.data)} /> + + + {isRecording ? "Stop Recording" : "Start Recording"} + + + + + {/* */} + + {/*
+ +
*/} +
+
+ ); }; - -export default definePlugin((ServerAPI: ServerAPI) => { - - const connection = new HubConnectionBuilder() - .withUrl("http://localhost:6969/streamhub") - .withAutomaticReconnect() - .build(); - - connection.start() - - - async function handleButtonInput(val: any[]) { - let isPressed = false; - - for (const inputs of val) { - - // noinspection JSBitwiseOperatorUsage - if (inputs.ulButtons && inputs.ulButtons & (1 << 13) && inputs.ulButtons & (1 << 14)) { - if (!isPressed) { - isPressed = true; - await connection.invoke("SaveShadow"); - ServerAPI.toaster.toast({ - title: "Clip saved", - body: "Tap to view", - icon: , - critical: true, - onClick: () => Router.Navigate("/media/tab/videos") - }) - - } - } else if (isPressed) { - (Router as any).DisableHomeAndQuickAccessButtons(); - setTimeout(() => { - (Router as any).EnableHomeAndQuickAccessButtons(); - }, 1000) - isPressed = false; - } +export default definePlugin((serverApi: ServerAPI) => { + + const connection = new HubConnectionBuilder() + .withUrl("http://localhost:9988/SignalrHub") + .withAutomaticReconnect() + .build(); + + connection.start().then(() => { + console.log("Connected to ODS backend"); + console.log(connection.invoke("GetConfig")); + }).catch((err) => { + console.error(err.toString()); + }); + + let isPressed = false; + + async function handleButtonInput(val: any[]) { + for (const inputs of val) { + // noinspection JSBitwiseOperatorUsage + if (inputs.ulButtons && inputs.ulButtons & (1 << 13) && inputs.ulButtons & (1 << 14)) { + if (!isPressed) { + isPressed = true; + var config = await connection.invoke("GetConfig"); + if (!config.replayBufferEnabled) continue; + + connection.invoke("SaveReplayBuffer").then(() => { + serverApi.toaster.toast({ + title: "Clip saved", + // body: "Tap to view", + body: "", + icon: , + critical: true, + //onClick: () => Router.Navigate("/media/tab/videos") + }) + }).catch(() => { + serverApi.toaster.toast({ + title: "Failed to save clip", + body: "", + icon: , + critical: true, + }) + }) } + } else if (isPressed) { + (Router as any).DisableHomeAndQuickAccessButtons(); + setTimeout(() => { + (Router as any).EnableHomeAndQuickAccessButtons(); + }, 1000) + isPressed = false; + } } + } - const inputRegistration = window.SteamClient.Input.RegisterForControllerStateChanges(handleButtonInput) - const suspendRequestRegistration = window.SteamClient.System.RegisterForOnSuspendRequest(async () => { - await connection.invoke("Suspend"); + const inputRegistration = window.SteamClient.Input.RegisterForControllerStateChanges(handleButtonInput) + const suspendRequestRegistration = window.SteamClient.System.RegisterForOnSuspendRequest(async () => { + //todo: implement + }); - }); - - const suspendResumeRegistration = window.SteamClient.System.RegisterForOnResumeFromSuspend(async () => { - await connection.invoke("ResumeSuspend"); - }); + const suspendResumeRegistration = window.SteamClient.System.RegisterForOnResumeFromSuspend(async () => { + //todo: implement + }); - const mediaPatch = ServerAPI.routerHook.addPatch("/media", (route: any) => { - afterPatch(route.children, "type", (_: any, res: any) => { - wrapReactType(res); - afterPatch(res.type, "type", (_: any, res: any) => { - if (res?.props?.children[1]?.props?.tabs && !res?.props?.children[1]?.props?.tabs?.find((tab: Tab) => tab.id == "videos")) res.props.children[1].props.tabs.push({ - id: "videos", - title: "Videos", - content: , - footer: { - onMenuActionDescription: "Filter", - onMenuButton: () => { - console.log("menu") - } - }, - renderTabAddon: () => - }) - return res; - }); - return res; - }) - return route; - }) - - - return { - title:
DeckyStream
, - content: , - icon: , - onDismount() { - inputRegistration.unregister(); - suspendRequestRegistration.unregister(); - suspendResumeRegistration.unregister(); - ServerAPI.routerHook.removePatch("/media", mediaPatch); - }, - }; + + return { + title:
OpenDeckStream
, + content: , + icon: , + onDismount() { + inputRegistration.unregister(); + suspendRequestRegistration.unregister(); + suspendResumeRegistration.unregister(); + connection.stop(); + }, + }; }); diff --git a/tsconfig.json b/tsconfig.json index 13b0c35..c2bc719 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,6 @@ "noImplicitThis": true, "noImplicitAny": true, "strict": true, - "suppressImplicitAnyIndexErrors": true, "allowSyntheticDefaultImports": true, "skipLibCheck": true },