diff --git a/README.md b/README.md index 18dd3cc..2346870 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,113 @@ +# Stremio-RaspberryPi +![github-small](https://github.com/shivasiddharth/Stremio-RaspberryPi/blob/Awesome/images/Banner.jpg) + ## **If you like the work and if you would like to get me a :coffee: :smile:** [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7GH3YDCHZ36QN) -# Stremio-RaspberryPi - -## Steps to run Stremio in Raspberry Pi - -### Clone the git project -``` -git clone https://github.com/shivasiddharth/Stremio-RaspberryPi -``` - -### Make the scripts executable -``` -sudo chmod +x /home/${USER}/Stremio-RaspberryPi/scripts/installer.sh -sudo chmod +x /home/${USER}/Stremio-RaspberryPi/scripts/service-installer.sh -sudo chmod +x /home/${USER}/Stremio-RaspberryPi/src/server-launcher.sh -sudo chmod +x /home/${USER}/Stremio-RaspberryPi/src/client-launcher.sh -``` - -### Run the installer -``` -sudo /home/${USER}/Stremio-RaspberryPi/scripts/installer.sh -``` - -### After the installation, try opening the Stremio server and client manually using the following commands or use the Launcher Shortcuts created on the desktop -Open first terminal and run -``` -/home/${USER}/Stremio-RaspberryPi/src/server-launcher.sh -``` - -Open second terminal and run -``` -/home/${USER}/Stremio-RaspberryPi/src/client-launcher.sh -``` - -### After verification if desired, set Stremio to auto start on boot -There will be a minor delay ~1Min between the launch of Server Service and Client Service. This is to ensure that the Client starts after the Server. -Run the service installer -``` -sudo /home/${USER}/Stremio-RaspberryPi/scripts/service-installer.sh -``` - -Enable and start the service -``` -systemctl --user enable stremio-server.service -systemctl --user enable stremio-client.service -systemctl --user start stremio-server.service -systemctl --user start stremio-client.service -``` - -### Fix for screen tearing -Open a terminal and run -``` -sudo raspi-config -``` -In that, Navigate to Advanced Options -> Compositor -> xcompmgr composition manager -> Choose “No” - - -### Note - - If you have closed or stopped the background Stremio services, then if you wish to start them again, you can use the service desktop shortcuts. - - You can manually start the Stremio server and client using the Stremio Launcher desktop shortcuts. - - If your cursor is stuck after running ```systemctl --user start stremio-server.service```, press Ctrl+C on keyboard to break free. - - You can access Stremio on Apple iPads and iPhones with the server running on Raspberry Pi. Refer to https://www.youtube.com/watch?v=cYmpVh_GWJg + + + + +********** +## Installation Using Binaries +********** +1. Download the Zip files containing the binaries from the Releases section. +2. Place it in the /home/${USER}/ directory. +3. Add Debian sources as given below: + Buster Users: + ``` + echo "deb http://ftp.us.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list + echo "deb http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list + sudo apt-get update + ``` + Bullseye Users: + ``` + echo "deb http://ftp.us.debian.org/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list + echo "deb http://deb.debian.org/debian bullseye main contrib non-free" >> /etc/apt/sources.list + sudo apt-get update + ``` +4. Change directory as given below: + 64-Bit Users: + ``` + cd /home/${USER}/Stremio-4.4.142-arm64-64-bit/ + ``` + 32-Bit Users: + ``` + cd /home/${USER}/Stremio-4.4.142-armhf-32-bit/ + ``` +5. Perform the installation as given below (Replace x.x.xxx with the version numbers on the file): + 64-Bit Users: + ``` + sudo apt-get install ./libfdk-aac1_0.1.6-1_arm64.deb ./stremio_x.x.xxx-1_arm64.deb -f + ``` + 32-Bit Users: + ``` + sudo apt-get install ./libfdk-aac1_0.1.6-1_armhf.deb ./stremio_x.x.xxx-1_armhf.deb -f + ``` +6. Now you should have Stremio installed. Grab some snacks and enjoy the show. + + + +********** +## Building from source +********** +1. Add Debian sources as given below: + Buster Users: + ``` + echo "deb http://ftp.us.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list + echo "deb http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list + sudo apt-get update + ``` + Bullseye Users: + ``` + echo "deb http://ftp.us.debian.org/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list + echo "deb http://deb.debian.org/debian bullseye main contrib non-free" >> /etc/apt/sources.list + sudo apt-get update + ``` +2. Clone the stremio-shell using: + ``` + git clone --recurse-submodules -j8 git://github.com/shivasiddharth/stremio-shell.git + ``` +3. Change directory using: + ``` + cd /home/${USER}/stremio-shell/ + ``` +4. Install dependencies using: + ``` + sed 's/#.*//' ./Requirements.txt | xargs sudo apt-get install -y + ``` +5. Make using: + ``` + qmake + ``` +6. Build binaries using: + ``` + make -f release.makefile + ``` +7. Prepare server using: + ``` + cp ./server.js ./build/ && ln -s "$(which node)" ./build/node + ``` +8. Run Stremio using: + ``` + ./build/stremio + ``` + or + ``` + /home/${USER}/stremio-shell/build/stremio + ``` + + + +********** +## Note +********** +1. After the ```sudo apt-get update``` command for adding sources, if you get a key error like shown below: + ![github-small](https://github.com/shivasiddharth/Stremio-RaspberryPi/blob/Awesome/images/Key_Error.png) + Fix the issue using (Replace XXXXXXXXXXXX with the first alphanumeric character key): + ``` + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXXXX + ``` +2. For remote access of server, go into setting and select your IP address from the **Enable remote HTTPS connections** dropdown menu as shown below. + ![github-small](https://github.com/shivasiddharth/Stremio-RaspberryPi/blob/Awesome/images/Remote-connection.png) +3. For accessing the Stremio server remotely and securely (Expecially from Apple devices), use the **Streaming HTTPS endpoint:** link as shown below. + ![github-small](https://github.com/shivasiddharth/Stremio-RaspberryPi/blob/Awesome/images/Streaming-Server-Link.png) diff --git a/Requirements.txt b/Requirements.txt deleted file mode 100644 index 61eb2dc..0000000 --- a/Requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -qtcreator -qt5-qmake -qtbase5-dev -qtchooser -qtbase5-dev-tools -g++ -pkgconf -libssl-dev -libmpv-dev -nodejs diff --git a/images/Banner.jpg b/images/Banner.jpg new file mode 100644 index 0000000..8d8d7ba Binary files /dev/null and b/images/Banner.jpg differ diff --git a/images/Key_Error.png b/images/Key_Error.png new file mode 100644 index 0000000..8839564 Binary files /dev/null and b/images/Key_Error.png differ diff --git a/images/Remote-connection.png b/images/Remote-connection.png new file mode 100644 index 0000000..b7db203 Binary files /dev/null and b/images/Remote-connection.png differ diff --git a/images/Streaming-Server-Link.png b/images/Streaming-Server-Link.png new file mode 100644 index 0000000..f369d58 Binary files /dev/null and b/images/Streaming-Server-Link.png differ diff --git a/scripts/Stremio-Client-Service-Shortcut.sh b/scripts/Stremio-Client-Service-Shortcut.sh deleted file mode 100644 index e8dd50e..0000000 --- a/scripts/Stremio-Client-Service-Shortcut.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -systemctl --user restart stremio-client.service diff --git a/scripts/Stremio-Server-Service-Shortcut.sh b/scripts/Stremio-Server-Service-Shortcut.sh deleted file mode 100644 index ecf4024..0000000 --- a/scripts/Stremio-Server-Service-Shortcut.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -systemctl --user restart stremio-server.service diff --git a/scripts/installer.sh b/scripts/installer.sh deleted file mode 100644 index 0e917c8..0000000 --- a/scripts/installer.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# Script for running Stremio on Raspberry Pi boards -# -# Written by https://github.com/shivasiddharth - -echo "" -echo "" -set -o errexit - -scripts_dir="$(dirname "${BASH_SOURCE[0]}")" -GIT_DIR="$(realpath $(dirname ${BASH_SOURCE[0]})/..)" - -# make sure we're running as the owner of the checkout directory -RUN_AS="$(ls -ld "$scripts_dir" | awk 'NR==1 {print $3}')" -if [ "$USER" != "$RUN_AS" ] -then - echo "This script must run as $RUN_AS, trying to change user..." - exec sudo -u $RUN_AS $0 -fi -echo "Get your popcorn while we prep your Pi......" -echo "" -echo "" -echo "Updating the OS......." -echo "" -sudo apt-get update -y -echo "" -echo "Installing required packages........" -echo "" -sed 's/#.*//' ${GIT_DIR}/Requirements.txt | xargs sudo apt-get install -y -echo "" -echo "Finished installing the packages........" -echo "" -echo "Changing username in the service files........" -echo "" -sed -i 's/__USER__/'${USER}'/g' ${GIT_DIR}/systemd/stremio-client.service -sed -i 's/__USER__/'${USER}'/g' ${GIT_DIR}/systemd/stremio-server.service -echo "" -echo "Creating desktop shortcuts ............." -echo "" -echo "" -sudo chmod +x ${GIT_DIR}/scripts/Stremio-Server-Service-Shortcut.sh -sudo chmod +x ${GIT_DIR}/scripts/Stremio-Client-Service-Shortcut.sh -sudo chmod +x ${GIT_DIR}/src/client-launcher.sh -sudo chmod +x ${GIT_DIR}/src/server-launcher.sh -sudo \cp ${GIT_DIR}/scripts/Stremio-Server-Service-Shortcut.sh /home/${USER}/Desktop/Stremio-Server-Service -sudo \cp ${GIT_DIR}/scripts/Stremio-Client-Service-Shortcut.sh /home/${USER}/Desktop/Stremio-Client-Service -sudo \cp ${GIT_DIR}/src/server-launcher.sh /home/${USER}/Desktop/Stremio-Server-Launcher -sudo \cp ${GIT_DIR}/src/client-launcher.sh /home/${USER}/Desktop/Stremio-Client-Launcher -echo "" -echo "" -echo "Finished installing. Sit back and enjoy the show............." diff --git a/scripts/service-installer.sh b/scripts/service-installer.sh deleted file mode 100644 index 2b524da..0000000 --- a/scripts/service-installer.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Install systemd service files for running on startup. -# -# Written by https://github.com/shivasiddharth - -set -o errexit - -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root (use sudo)" 1>&2 - exit 1 -fi - -#Get the checkout directory -GIT_DIR="$(realpath $(dirname ${BASH_SOURCE[0]})/..)" - -#Get the owner of the checkout directory -GIT_OWNER="$(ls -ld "$GIT_DIR" | awk 'NR==1 {print $3}')" - -cd "$(dirname "${BASH_SOURCE[0]}")/.." -repo_path="$PWD" - - -for service in systemd/*.service; do - sed "s:/home/__USER__/Stremio-RaspberryPi:${repo_path}:g;s:__USER__:${GIT_OWNER}:g" "$service" \ - > "/etc/systemd/user/$(basename "$service")" -done diff --git a/src/client-launcher.sh b/src/client-launcher.sh deleted file mode 100644 index 7610bea..0000000 --- a/src/client-launcher.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# -# Script to launch Stremio web interface in kiosk mode -# -# Written by https://github.com/shivasiddharth - - -# Run Chromium and open tabs -/usr/bin/chromium-browser --app=https://app.strem.io/shell-v4.4/ --window-position=0,0 --start-fullscreen --use-gl=angle diff --git a/src/server-launcher.sh b/src/server-launcher.sh deleted file mode 100644 index d9672f9..0000000 --- a/src/server-launcher.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# -# Script to launch Stremio server -# -# Written by https://github.com/shivasiddharth - -# Start the server -cd /home/pi/Stremio-RaspberryPi/stremio-shell/ -node ./server.js diff --git a/stremio-shell/.dockerignore b/stremio-shell/.dockerignore deleted file mode 100644 index 04a67d4..0000000 --- a/stremio-shell/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -dist-linux/* -Makefile diff --git a/stremio-shell/.gitignore b/stremio-shell/.gitignore deleted file mode 100644 index bc180eb..0000000 --- a/stremio-shell/.gitignore +++ /dev/null @@ -1,50 +0,0 @@ - -*.slo -*.lo -*.o -*.a -*.la -*.lai -*.so -*.dll -*.dylib - -# Qt-es - -.qmake.cache -.qmake.stash -*.pro.user -*.pro.user.* -*.qbs.user -*.qbs.user.* -*.moc -moc_*.cpp -qrc_*.cpp -ui_*.h -Makefile* -build-*/ -stremio.app/* -/build/* -moc_*.h - -# QtCreator - -*.autosave - -# QtCtreator Qml -*.qmlproject.user -*.qmlproject.user.* - -# QtCtreator CMake -CMakeLists.txt.user* - - -.DS_Store - -debug/* -release/* - -moc_predefs\.h - -# binary on Linux -stremio diff --git a/stremio-shell/.gitmodules b/stremio-shell/.gitmodules deleted file mode 100644 index 287b88c..0000000 --- a/stremio-shell/.gitmodules +++ /dev/null @@ -1,10 +0,0 @@ -[submodule "deps/libmpv"] - path = deps/libmpv - url = https://github.com/Ivshti/libmpv -[submodule "deps/singleapplication"] - path = deps/singleapplication - url = http://github.com/itay-grudev/SingleApplication -[submodule "deps/chroma"] - path = deps/chroma - url = https://github.com/Ivshti/razerchroma - diff --git a/stremio-shell/AppImage.makefile b/stremio-shell/AppImage.makefile deleted file mode 100644 index 83c0f57..0000000 --- a/stremio-shell/AppImage.makefile +++ /dev/null @@ -1,55 +0,0 @@ - -VERSION := $(shell grep -oPm1 'VERSION=\K.+' stremio.pro) - -NSS_DIR := /usr/lib/x86_64-linux-gnu/nss - -DEST_DIR := dist-linux -BUILD_DIR := build -RELEASE_DIR := release - -QT_BIN_PATH ?= /usr/share/qt5 - -ICON_BIN := images/stremio.png - -SERVER_JS := ${DEST_DIR}/server.js -STREMIO_DESKTOP := stremio.desktop - -STREMIO_BIN := ${BUILD_DIR}/stremio -NODE_BIN := $(shell which node) -FFMPEG_BIN := $(shell which ffmpeg) - -QT_RESOURCES = ${QT_BIN_PATH}/resources -QT_TRANSLATIONS = ${QT_BIN_PATH}/translations - - -APPIMAGE_FILE := Stremio-v${VERSION}-x86_64.AppImage - - -ALL: ${APPIMAGE_FILE} - -${DEST_DIR}: ${STREMIO_BIN} ${NODE_BIN} ${FFMPEG_BIN} ${ICON_BIN} ${STREMIO_DESKTOP} ${QT_RESOURCES} ${QT_TRANSLATIONS} - mkdir -p ${DEST_DIR}/lib - cp -r $^ ${DEST_DIR}/ - cp -r ${NSS_DIR} ${DEST_DIR}/lib/ - -${APPIMAGE_FILE}: ${SERVER_JS} linuxdeployqt - ./linuxdeployqt --appimage-extract - #This will create Stremio-x86_64.AppImage - ./squashfs-root/AppRun ${DEST_DIR}/stremio -qmldir=. -bundle-non-qt-libs -appimage - -${SERVER_JS}: ${DEST_DIR} - wget "https://s3-eu-west-1.amazonaws.com/stremio-artifacts/four/v${VERSION}/server.js" -qO ${SERVER_JS} || rm ${SERVER_JS} - -linuxdeployqt: - wget "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" -qO $@ || rm $@ - chmod 700 $@ - -clean: - rm -rf linuxdeployqt ${BUILD_DIR} ${DEST_DIR} ${RELEASE_DIR} ${APPIMAGE_FILE} - -${STREMIO_BIN}: ${BUILD_DIR} - cd ${BUILD_DIR} && qmake .. && make -j - -${BUILD_DIR}: - mkdir ${BUILD_DIR} - diff --git a/stremio-shell/Info.plist b/stremio-shell/Info.plist deleted file mode 100644 index 44873a2..0000000 --- a/stremio-shell/Info.plist +++ /dev/null @@ -1,74 +0,0 @@ - - - - - NSPrincipalClass - NSApplication - CFBundleIconFile - @ICON@ - CFBundlePackageType - APPL - CFBundleGetInfoString - Stremio from Smart Code LTD @2019 - CFBundleSignature - ???? - CFBundleExecutable - @EXECUTABLE@ - CFBundleIdentifier - @BUNDLEIDENTIFIER@ - NOTE - Watch Instantly All the Video Content You Enjoy in One Place - NSHumanReadableCopyright - (c) 2019 Smart Code LTD - CFBundleVersion - @FULL_VERSION@ - CFBundleURLTypes - - - CFBundleTypeRole - Viewer - CFBundleURLIconFile - stremio - CFBundleURLName - Stremio URL - CFBundleURLSchemes - - stremio - - - - CFBundleTypeRole - Viewer - CFBundleURLIconFile - stremio - CFBundleURLName - BitTorrent Magnet URL - CFBundleURLSchemes - - magnet - - - - CFBundleDocumentTypes - - - CFBundleTypeExtensions - - torrent - - CFBundleTypeIconFile - stremio - CFBundleTypeName - BitTorrent Document - CFBundleTypeRole - Viewer - LSTypeIsPackage - - NSPersistentStoreTypeKey - XML - - - NSSupportsAutomaticGraphicsSwitching - - - diff --git a/stremio-shell/LICENSE.md b/stremio-shell/LICENSE.md deleted file mode 100644 index 175443c..0000000 --- a/stremio-shell/LICENSE.md +++ /dev/null @@ -1,595 +0,0 @@ -GNU General Public License -========================== - -_Version 3, 29 June 2007_ -_Copyright © 2007 Free Software Foundation, Inc. <>_ - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - -## Preamble - -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. - -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. - -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. - -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. - -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. - -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. - -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. - -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 -<>. diff --git a/stremio-shell/autoupdater.cpp b/stremio-shell/autoupdater.cpp deleted file mode 100644 index a341eb1..0000000 --- a/stremio-shell/autoupdater.cpp +++ /dev/null @@ -1,346 +0,0 @@ -#include -#include - -AutoUpdater::AutoUpdater() { - init_public_key(); -} - -// HANDLE FATAL ERRORS -void AutoUpdater::emitFatalError(QString msg, QVariant err = QVariant()) { - this->abort(); - emit error(msg, err); -} - -// IS INSTALLED? -bool AutoUpdater::isInstalled() { - - QString dirPath = QDir::toNativeSeparators(QCoreApplication::applicationDirPath()); - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - - // Windows - if (env.contains("LOCALAPPDATA") && dirPath.startsWith(env.value("LOCALAPPDATA"))) return true; - if (env.contains("ProgramFiles") && dirPath.startsWith(env.value("ProgramFiles"))) return true; - if (env.contains("ProgramFiles(x86)") && dirPath.startsWith(env.value("ProgramFiles(x86)"))) return true; - - // macOS - if (dirPath.contains("/Applications") && dirPath.contains(".app")) return true; - - // Linux - appImage - if (dirPath.startsWith("/tmp/.mount_")) return true; - - // Other UNIX - // Disabled, because we cannot update those cases - //if (dirPath.contains("/usr/bin") || dir.contains("/usr/local") || dir.contains("/opt")) return true; - - return false; -} - -// WRAPPERS for public slots to make sure we execute on our thread -void AutoUpdater::checkForUpdates(QString endpoint, QString userAgent) { - if (inProgress) return; - inProgress = true; - QMetaObject::invokeMethod(this, "checkForUpdatesPerform", Qt::QueuedConnection, Q_ARG(QString, endpoint), Q_ARG(QString, userAgent)); -} -void AutoUpdater::updateFromVersionDesc(QUrl versionDesc, QByteArray base64Sig) { - if (inProgress) return; - inProgress = true; - QMetaObject::invokeMethod(this, "updateFromVersionDescPerform", Qt::QueuedConnection, Q_ARG(QUrl, versionDesc), - Q_ARG(QByteArray, base64Sig)); -} -void AutoUpdater::abort() { - QMetaObject::invokeMethod(this, "abortPerform", Qt::QueuedConnection); -} - -// SETTINGS -void AutoUpdater::setForceFullUpdate(bool force) { - forceFullUpdate = force; -} - -// UTILS -bool AutoUpdater::moveFileToAppDir(QString from) { - QDir dir; - QFileInfo oldFile = QFileInfo(from); - QString dest = QCoreApplication::applicationDirPath() + QDir::separator() + oldFile.fileName(); - - if (! QFile::exists(from)) return false; - - if (QFile::exists(dest)) { - if (! QFile::remove(dest)) return false; - } - - return dir.rename(from, dest); -} - -int AutoUpdater::executeCmd(QString cmd, QStringList args, bool noWait = false) { - QProcess proc; - - proc.setProcessChannelMode(QProcess::ForwardedChannels); - - if (noWait) { - proc.startDetached(cmd, args); - return -1; - } - - proc.start(cmd, args); - - // We mostly need quick commands executed, and waiting for them in that func removes a huge layer of complexity - if (! proc.waitForFinished(5 * 60 * 1000)) return -1; - - return proc.exitCode(); -} - -bool AutoUpdater::isOnline() { - QNetworkConfigurationManager mgr; - return mgr.isOnline(); -} - -// CHECK FOR UPDATES -void AutoUpdater::checkForUpdatesPerform(QString endpoint, QString userAgent) -{ - if (! manager) manager = new QNetworkAccessManager(this); - - QByteArray serverHash = getFileChecksum(QCoreApplication::applicationDirPath() + QDir::separator() + SERVER_FNAME); - QByteArray asarHash = getFileChecksum(QCoreApplication::applicationDirPath() + QDir::separator() + ASAR_FNAME); - - QUrl url = QUrl(endpoint); - QUrlQuery query = QUrlQuery(url); - - query.addQueryItem("serverSum", serverHash.toHex()); - query.addQueryItem("asarSum", asarHash.toHex()); - query.addQueryItem("shellVersion", QCoreApplication::applicationVersion()); - - url.setQuery(query); - auto request = QNetworkRequest(QUrl(url)); - request.setRawHeader("User-Agent", userAgent.toUtf8()); - currentCheck = manager->get(request); - QObject::connect(currentCheck, &QNetworkReply::finished, this, &AutoUpdater::checkForUpdatesFinished); -} - -void AutoUpdater::checkForUpdatesFinished() -{ - if (currentCheck == NULL) { - emitFatalError("internal error - currentCheck NULL on checkForUpdatesFinished"); - return; - } - - QNetworkReply* reply = currentCheck; - reply->deleteLater(); - currentCheck = NULL; - - if (reply->error() == QNetworkReply::NoError) { - QJsonParseError *error = NULL; - QJsonDocument jsonResponse = QJsonDocument::fromJson(reply->readAll(), error); - - emit checkFinished(jsonResponse.toVariant()); - - if (jsonResponse.isObject()) { - QJsonObject obj = jsonResponse.object(); - - if (obj.value("upToDate").toBool()) { - // NO NEW VERSION, DO NOTHING - inProgress = false; - } else { - updateFromVersionDescPerform( - QUrl(obj.value("versionDesc").toString()), - QByteArray::fromBase64(obj.value("signature").toString().toUtf8()) - ); - } - } else if (error) { - emitFatalError("JSON parse error on checkForUpdates "+error->errorString()); - } else { - emitFatalError("Unable to understand response from checkForUpdates"); - } - - delete error; - } else if (reply->error() != QNetworkReply::OperationCanceledError) { - emitFatalError("Network error on checkForUpdates "+reply->url().toString(), reply->error()); - } -} - - -// GET & VERIFY (SIGNATURE) VERSION DESC -void AutoUpdater::updateFromVersionDescPerform(QUrl versionDesc, QByteArray base64Sig) { - currentCheck = manager->get(QNetworkRequest(versionDesc)); - currentCheck->setProperty("signature", base64Sig); - QObject::connect(currentCheck, &QNetworkReply::finished, this, &AutoUpdater::updateFromVersionDescFinished); -} - -void AutoUpdater::updateFromVersionDescFinished() { - if (currentCheck == NULL) { - emitFatalError("internal error - currentCheck NULL on updateFromVersionDescFinished"); - return; - } - - QNetworkReply* reply = currentCheck; - reply->deleteLater(); - currentCheck = NULL; - - if (reply->error() == QNetworkReply::NoError) { - QByteArray dataReply = reply->readAll(); - QByteArray sig = reply->property("signature").toByteArray(); - - if (verify_sig( - (const byte*)dataReply.data(), dataReply.size(), - (const byte*)sig.data(), sig.length() - ) != 0) { - emitFatalError("Unable to verify update signature"); - } else { - QJsonParseError *error = NULL; - QJsonDocument jsonResponse = QJsonDocument::fromJson(dataReply, error); - - if (jsonResponse.isObject()) { - prepareUpdate(jsonResponse); - } else if (error) { - emitFatalError("JSON parse error on updateFromVersionDesc "+error->errorString()); - } else { - emitFatalError("Unable to understand response from updateFromVersionDesc"); - } - - delete error; - } - } else if (reply->error() != QNetworkReply::OperationCanceledError) { - emitFatalError("Network error on updateFromVersionDesc "+reply->url().toString(), reply->error()); - } -} - -// DETERMINE WHAT TO DOWNLOAD FROM versionDesc -void AutoUpdater::prepareUpdate(QJsonDocument versionDescDoc) { - currentVersionDesc = versionDescDoc; - - QJsonObject versionDesc = versionDescDoc.object(); - QJsonObject files = versionDesc.value("files").toObject(); - - QVector toDownload; - - if (forceFullUpdate - || versionDesc.value("shellVersion").toString() != QCoreApplication::applicationVersion() - ) { - toDownload = FULL_UPDATE_FILES; - } else { - toDownload = PARTIAL_UPDATE_FILES; - } - - if (! toDownload.length()) { - emitFatalError("internal error - no files to download. Unsupported OS?"); - return; - } - - foreach (const QString &prop, toDownload) { - QJsonObject file = files.value(prop).toObject(); - - if (! (file.contains("url") && file.contains("checksum"))) continue; - - enqueueDownload( - QUrl(file.value("url").toString()), - QByteArray::fromHex(file.value("checksum").toString().toUtf8()) - ); - } - - startNextDownload(); -} - - -// DOWNLOAD & VERIFY (CHECKSUM) -QByteArray AutoUpdater::getFileChecksum(QString path) { - QCryptographicHash crypto(QCryptographicHash::Sha256); - QFile file(path); - file.open(QFile::ReadOnly); - while (!file.atEnd()) { crypto.addData(file.read(FILE_READ_CHUNK)); } - return crypto.result(); -} - -void AutoUpdater::enqueueDownload(QUrl from, QByteArray checksum) { - downloadQueue.enqueue(fDownload(from, checksum)); -} - -void AutoUpdater::startNextDownload() { - if (downloadQueue.isEmpty()) { - inProgress = false; - emit prepared(preparedFiles, QVariant(currentVersionDesc.object())); - return; - } - - fDownload next = downloadQueue.dequeue(); - QUrl url = next.first; - QByteArray checksum = next.second; - - // WARNING: TODO: do we want to make a separate dir inside tempPath? ; we should ensure downloadFile always overrides - QString dest = QDir::tempPath() + QDir::separator() + url.fileName(); - - // Check if the download is already downloaded - could happen if we try to do a full upgrade when we've - // already prepared one - // Sketchy case: if the file does not exist, getFileChecksum would return the default sha256 hash; - - // this would actually prevent a case where the version descriptor is generated from empty files from breaking - // the system - because this check would return true, and then the file wouldn't exist at all, emitting an error - // (this shouldn't be able to happen, but still...) - if (checksum == getFileChecksum(dest)) { - preparedFiles.push_back(dest); - startNextDownload(); - return; - } - - // Start the download - output.setFileName(dest); - if (!output.open(QIODevice::WriteOnly)) { - emitFatalError("error opening file "+dest+" for download: "+output.errorString()); - return; - } - - currentDownload = manager->get(QNetworkRequest(url)); - currentDownload->setProperty("checksum", checksum); - QObject::connect(currentDownload, &QNetworkReply::readyRead, this, &AutoUpdater::downloadReadyRead); - QObject::connect(currentDownload, &QNetworkReply::finished, this, &AutoUpdater::downloadFinished); -} - -void AutoUpdater::downloadReadyRead() -{ - output.write(currentDownload->readAll()); -} - -void AutoUpdater::downloadFinished() -{ - output.close(); - - if (currentDownload == NULL) { - emitFatalError("internal error - currentDownload NULL on downloadFinished"); - return; - } - - QNetworkReply* reply = currentDownload; - reply->deleteLater(); - currentDownload = NULL; - - if (reply->error() == QNetworkReply::NoError) { - QString dest = output.fileName(); - QByteArray checksum = reply->property("checksum").toByteArray(); - - if (checksum == getFileChecksum(dest)) { - preparedFiles.push_back(dest); - startNextDownload(); - } else { - emitFatalError("Unable to verify checksum for file "+dest); - } - } else if (reply->error() != QNetworkReply::OperationCanceledError) { - emitFatalError("Network error on downloadFinished "+reply->url().toString(), reply->error()); - } -} - - -// ABORT -void AutoUpdater::abortPerform() { - // EXPLANATION: those will be aborted, and then in the 'finished' handler, they will be deleted via ->deleteLater() - // since the event handlers are executed in the event loop, one might think calling .checkForVer() right after - // .abort() will re-set currentCheck before the 'finished' handler is executed - // This is not a problem, because all public methods call the internal ones with invokeMethod and queuedConnection - if (currentCheck) currentCheck->abort(); - if (currentDownload) currentDownload->abort(); - - currentVersionDesc = QJsonDocument(); - - downloadQueue = QQueue(); - preparedFiles = QVariantList(); - - output.close(); - - inProgress = false; -} diff --git a/stremio-shell/autoupdater.h b/stremio-shell/autoupdater.h deleted file mode 100644 index 7d123dc..0000000 --- a/stremio-shell/autoupdater.h +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Mixing C and C++ :( -extern "C" { -#include -} - -#define FILE_READ_CHUNK 8192 - -// TODO Move to somewhere? Document that we can override? -#define SERVER_FNAME "server.js" -#define ASAR_FNAME "stremio.asar" - -#define PARTIAL_UPDATE_FILES { SERVER_FNAME, ASAR_FNAME } - -#if defined(Q_OS_WIN) - #define FULL_UPDATE_FILES { "windows" } -#elif defined(Q_OS_MACOS) - #define FULL_UPDATE_FILES { "mac" } -#elif defined(Q_OS_LINUX) - #define FULL_UPDATE_FILES { "linux" } -#else - #define FULL_UPDATE_FILES { } -#endif - -typedef QPair fDownload; - -class AutoUpdater : public QObject -{ - Q_OBJECT - - public: - AutoUpdater(); - - public slots: - bool isInstalled(); - void checkForUpdates(QString, QString); - void updateFromVersionDesc(QUrl, QByteArray); - - void abort(); - - void setForceFullUpdate(bool); - - bool moveFileToAppDir(QString); - int executeCmd(QString, QStringList, bool); - bool isOnline(); - - signals: - void error(QString, QVariant); - void checkFinished(QVariant); - void prepared(QVariantList, QVariant); - - private slots: - void abortPerform(); - - void checkForUpdatesPerform(QString, QString); - void checkForUpdatesFinished(); - - void updateFromVersionDescPerform(QUrl, QByteArray); - void updateFromVersionDescFinished(); - - void prepareUpdate(QJsonDocument); - - void downloadFinished(); - void downloadReadyRead(); - - void emitFatalError(QString, QVariant); - - private: - void enqueueDownload(QUrl, QByteArray); - void startNextDownload(); - - QByteArray getFileChecksum(QString); - - QNetworkAccessManager* manager = NULL; - - // State; must be reset on abort - QJsonDocument currentVersionDesc; - - QNetworkReply* currentCheck = NULL; - QNetworkReply* currentDownload = NULL; - - QFile output; - - // Download queue, prepared files - QQueue downloadQueue; - QVariantList preparedFiles; - - // options - bool forceFullUpdate = false; - - // progress tracking - bool inProgress = false; - -}; diff --git a/stremio-shell/autoupdater.js b/stremio-shell/autoupdater.js deleted file mode 100644 index 4d2163f..0000000 --- a/stremio-shell/autoupdater.js +++ /dev/null @@ -1,184 +0,0 @@ - // - // AUTO UPDATER - // - // signal autoUpdaterErr(var msg, var err); - // signal autoUpdaterRestartTimer(); - function initAutoUpdater(autoUpdater, autoUpdaterErr, shortTimer, longTimer, restartTimer, userAgent) { - var endpoints = ["https://www.strem.io/updater/check", "https://www.stremio.com/updater/check", - "https://www.stremio.net/updater/check"]; - var fallbackSite = "https://www.stremio.com/?fromFailedAutoupdate=true"; - var doAutoupdate = autoUpdater.isInstalled() - - // On Linux, because we use AppImage, we cannot do partial updates - because we can't replace files - // in the read-only mountpoint - if (Qt.platform.os === "linux" && doAutoupdate) autoUpdater.setForceFullUpdate(true); - - var args = Qt.application.arguments - if (args.indexOf("--autoupdater-force-full") > -1) autoUpdater.setForceFullUpdate(true); - if (args.indexOf("--autoupdater-force") > -1) doAutoupdate = true; - - var endpointArg = "--autoupdater-endpoint=" - args.forEach(function(arg) { if (arg.indexOf(endpointArg) === 0) endpoints = [arg.slice(endpointArg.length)] }) - autoUpdater.endpoint = function() { - return endpoints[Math.floor(Math.random()*endpoints.length)] - } - - if (! doAutoupdate) { - console.log("Auto-updater: skipping, possibly not running an installed app?") - return - } - - // This is the timeout we use to check periodically; the signal is handled in the main (UI) thread - var onTriggered - shortTimer.triggered.connect(onTriggered = function() { - // WARNING: what if .isOnline() fails on some system?? it's based on QNetworkConfigurationManager - // can we trust it?? - if (autoUpdater.isOnline()) { - console.log("Auto-updater: checking for new version") - autoUpdater.abort() - autoUpdater.checkForUpdates(autoUpdater.endpoint(), userAgent) - - } else { - console.log("Auto-update: skip check because we're not online") - shortTimer.restart() - } - }) - onTriggered(); // initial check - - // Re-start this timer only from the main thread - restartTimer.connect(function() { - longTimer.restart(); - }); - - // WARNING: all of the slot handlers are handled in another thread, that's why we need the autoUpdaterErr() - // signal - to bring execution back to UI thread - autoUpdater.checkFinished.connect(function(check) { - // reset the notif, so there's no chance we'd trigger a re-start while downloading new ver - if (check && !check.upToDate) autoUpdater.onNotifClicked = null; - - if (check && check.upToDate) console.log("Auto-updater: up to date"); - if (check && !check.upToDate) console.log("Auto-updater: updating to latest ver: "+check.versionDesc) - else restartTimer() // no new ver, schedule a new check - }) - - // signal hack to bring it back to the main thread - autoUpdater.error.connect(function(msg, err) { - autoUpdaterErr(msg, err); - }); - autoUpdaterErr.connect(function(msg, err) { - // send to front-end, so we can handle accordingly - transport.queueEvent("autoupdater-error", { - err: err, - msg: msg - }); - - longTimer.restart() - - // Display the error only if it's not QNetworkReply::HostNotFound (3) and not QNetworkReply::TimeoutError (4) - // - this usually happens when we are not connected; sometimes autoupdater.isOnline() reports wrong - if (err !== 3 && err !== 4) { - errorDialog.text = "Auto updater error" - errorDialog.detailedText = msg - errorDialog.visible = true - } - }) - - autoUpdater.prepared.connect(function(preparedFiles, version) { - var firstFile = preparedFiles[0]; - - console.log("Auto-updater: prepared update "+preparedFiles.join(", ")) - - // When we finish preparing an update, we must call transport.queueEvent so that the app can receive - // a notification event once it loads - // Then, we must set .onNotifClicked to what we'll do when the notification is clicked - - if (preparedFiles.length == 2) { - // - // Prepare partial auto-update - // - console.log("Auto-updater: executing partial update") - var failed = false - preparedFiles.forEach(function(f) { if (!autoUpdater.moveFileToAppDir(f)) failed = true }) - if (failed) { - autoUpdaterErr("preparing partial update failed", null) - return - } - transport.queueEvent("autoupdater-show-notif", { mode: "reload" }) - autoUpdater.onNotifClicked = function() { - splashScreen.visible = true - pulseOpacity.running = true - webView.reloadAndBypassCache() - streamingServer.fastReload = true - streamingServer.terminate() - } - } else if (Qt.platform.os === "osx" && firstFile && firstFile.match(".dmg$")) { - // - // Prepare macOS auto-update (extract from .dmg) - // - console.log("Auto-updater: executing OSX update"); - - var ver = version.version; - var args = ["-c", - "DMG=\""+firstFile+"\"" - +"&& NEW=/Applications/$(date +%s).app" - +"&& MNT=\"/Volumes/Stremio "+ver+"\"" - - +"&& hdiutil attach \"$DMG\" -nobrowse -noautoopen" // NOTE: this returns 0, - // even if it's already mounted - //+"&& MNT=$(hdiutil attach \"$DMG\" -nobrowse -noautoopen | awk -F'/Volumes/' '/Apple_HFS/ {print $2}') &&" - // WARNING: I'm not sure about this working on every OSX ver - - +"&& cp -R \"$MNT\"/*.app \"$NEW\"" - +"&& rm -rf /Applications/Stremio.app && mv \"$NEW\" \"/Applications/Stremio.app\"" - +"&& xattr -d com.apple.quarantine /Applications/Stremio.app" - +"; hdiutil detach \"$MNT\"" - ]; - - var code = autoUpdater.executeCmd("/bin/sh", args, false) - if (code !== 0) { - autoUpdaterErr("preparing macOS .app failed", null); - return; - } - - transport.queueEvent("autoupdater-show-notif", { mode: "restart" }) - autoUpdater.onNotifClicked = function() { - autoUpdater.executeCmd("/bin/sh", ["-c", "sleep 5; open -n /Applications/Stremio.app"], true) - quitApp(); - } - } else if ( Qt.platform.os === "windows" && firstFile && firstFile.match(".exe") ) { - // - // Prepare launch-based auto-update (launch new installer/appimage on Windows) - // - transport.queueEvent("autoupdater-show-notif", { mode: "launchNew" }) - autoUpdater.onNotifClicked = function() { - Qt.openUrlExternally("file:///"+firstFile.replace(/\\/g,'/')) - quitApp(); - } - } else if (Qt.platform.os === "linux" && firstFile && firstFile.match(".appimage")) { - // - // Prepare AppImage-based update (put in home dir and launch) - // - console.log("Auto-updater: executing Linux update"); - - var baseName = firstFile.split("/").pop() - var code = autoUpdater.executeCmd("/bin/sh", - ["-c", "mv '"+firstFile+"' $HOME; chmod +x $HOME/'"+baseName+"'"], false) - if (code !== 0) { - autoUpdaterErr("preparing Linux .appimage failed", null); - return; - } - transport.queueEvent("autoupdater-show-notif", { mode: "launchNew" }) - autoUpdater.onNotifClicked = function() { - autoUpdater.executeCmd("/bin/sh", ["-c", "$HOME/'"+baseName+"'"], true) - // crappy, but otherwise we have to write code to get env var - quitApp(); - } - } else { - autoUpdaterErr("Insane auto-update: "+preparedFiles.join(", "), null) - } - - // WARNING: this seems to randomly crash the program in rare cases if called more than once - // in this signal handler... - restartTimer() - }) - } diff --git a/stremio-shell/build_windows.bat b/stremio-shell/build_windows.bat deleted file mode 100644 index cae05ae..0000000 --- a/stremio-shell/build_windows.bat +++ /dev/null @@ -1,17 +0,0 @@ -SETLOCAL -SET VERSION=4.4.10 -SET BUILD_DIR=build - -:: Set up VS environment -CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 - -IF NOT EXIST "%BUILD_DIR%" mkdir "%BUILD_DIR%" -PUSHD "%BUILD_DIR%" - -qmake .. -nmake - -IF NOT EXIST "server.js" powershell -Command "(New-Object Net.WebClient).DownloadFile('https://s3-eu-west-1.amazonaws.com/stremio-artifacts/four/v%VERSION%/server.js', 'server.js')" - -POPD -ENDLOCAL \ No newline at end of file diff --git a/stremio-shell/deployment.pri b/stremio-shell/deployment.pri deleted file mode 100644 index ad31908..0000000 --- a/stremio-shell/deployment.pri +++ /dev/null @@ -1,17 +0,0 @@ -unix:!android { - isEmpty(target.path) { - qnx { - target.path = $$PREFIX/tmp/$${TARGET}/bin - } else { - target.path = $$PREFIX/opt/$${TARGET} - } - export(target.path) - } - static.files = smartcode-stremio.desktop - static.path = $$target.path - export(static.path) - INSTALLS += static - INSTALLS += target -} - -export(INSTALLS) diff --git a/stremio-shell/deps/chroma/ChromaSDK/ChromaAppInfo.xml b/stremio-shell/deps/chroma/ChromaSDK/ChromaAppInfo.xml deleted file mode 100644 index b5c0d80..0000000 --- a/stremio-shell/deps/chroma/ChromaSDK/ChromaAppInfo.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Razer Chroma SDK Sample Application - Razer Chroma SDK Sample Application - - - - diff --git a/stremio-shell/deps/chroma/ChromaSDK/inc/RzChromaSDKDefines.h b/stremio-shell/deps/chroma/ChromaSDK/inc/RzChromaSDKDefines.h deleted file mode 100644 index c2cd4ef..0000000 --- a/stremio-shell/deps/chroma/ChromaSDK/inc/RzChromaSDKDefines.h +++ /dev/null @@ -1,153 +0,0 @@ -//! \file RzChromaSDKDefines.h -//! \brief Definitions of global and static variables. - -#ifndef _RZSCHROMADKDEFINES_H_ -#define _RZSCHROMADKDEFINES_H_ - -#pragma once - -#ifndef GUID_DEFINED -#include -#endif - -namespace ChromaSDK -{ - // Keyboards - //! Razer Blackwidow Chroma device. - // {2EA1BB63-CA28-428D-9F06-196B88330BBB} - static const GUID BLACKWIDOW_CHROMA = - { 0x2ea1bb63, 0xca28, 0x428d, { 0x9f, 0x06, 0x19, 0x6b, 0x88, 0x33, 0x0b, 0xbb } }; - - //! Razer Blackwidow Chroma Tournament Edition device. - // {ED1C1B82-BFBE-418F-B49D-D03F05B149DF} - static const GUID BLACKWIDOW_CHROMA_TE = - { 0xed1c1b82, 0xbfbe, 0x418f, { 0xb4, 0x9d, 0xd0, 0x3f, 0x5, 0xb1, 0x49, 0xdf } }; - - //! Razer Deathstalker device. - // {18C5AD9B-4326-4828-92C4-2669A66D2283} - static const GUID DEATHSTALKER_CHROMA = - { 0x18c5ad9b, 0x4326, 0x4828, { 0x92, 0xc4, 0x26, 0x69, 0xa6, 0x6d, 0x22, 0x83 } }; - - //! Overwatch Keyboard. - // {872AB2A9-7959-4478-9FED-15F6186E72E4} - static const GUID OVERWATCH_KEYBOARD = - { 0x872ab2a9, 0x7959, 0x4478, { 0x9f, 0xed, 0x15, 0xf6, 0x18, 0x6e, 0x72, 0xe4 } }; - - //! Razer Blackwidow X Chroma device. - // {5AF60076-ADE9-43D4-B574-52599293B554} - static const GUID BLACKWIDOW_X_CHROMA = - { 0x5af60076, 0xade9, 0x43d4, { 0xb5, 0x74, 0x52, 0x59, 0x92, 0x93, 0xb5, 0x54 } }; - - //! Razer Blackwidow X TE Chroma device. - // {2D84DD51-3290-4AAC-9A89-D8AFDE38B57C} - static const GUID BLACKWIDOW_X_TE_CHROMA = - { 0x2d84dd51, 0x3290, 0x4aac, { 0x9a, 0x89, 0xd8, 0xaf, 0xde, 0x38, 0xb5, 0x7c } }; - - //! Razer Ornata Chroma - // {803378C1-CC48-4970-8539-D828CC1D420A} - static const GUID ORNATA_CHROMA = - { 0x803378c1, 0xcc48, 0x4970,{ 0x85, 0x39, 0xd8, 0x28, 0xcc, 0x1d, 0x42, 0xa } }; - - //! Razer Blade Stealth. - // {C83BDFE8-E7FC-40E0-99DB-872E23F19891} - static const GUID BLADE_STEALTH = - { 0xc83bdfe8, 0xe7fc, 0x40e0, { 0x99, 0xdb, 0x87, 0x2e, 0x23, 0xf1, 0x98, 0x91 } }; - - //! Razer Blade - // {F2BEDFAF-A0FE-4651-9D41-B6CE603A3DDD} - static const GUID BLADE = - { 0xf2bedfaf, 0xa0fe, 0x4651, { 0x9d, 0x41, 0xb6, 0xce, 0x60, 0x3a, 0x3d, 0xdd } }; - - - // Mice - //! Razer Deathadder Chroma device. - // {AEC50D91-B1F1-452F-8E16-7B73F376FDF3} - static const GUID DEATHADDER_CHROMA = - { 0xaec50d91, 0xb1f1, 0x452f, { 0x8e, 0x16, 0x7b, 0x73, 0xf3, 0x76, 0xfd, 0xf3 } }; - - //! Razer Mamba Chroma Tournament Edition device. - // {7EC00450-E0EE-4289-89D5-0D879C19061A} - static const GUID MAMBA_CHROMA_TE = - { 0x7ec00450, 0xe0ee, 0x4289, { 0x89, 0xd5, 0xd, 0x87, 0x9c, 0x19, 0x6, 0x1a } }; - - //! Razer Diamondback device. - // {FF8A5929-4512-4257-8D59-C647BF9935D0} - static const GUID DIAMONDBACK_CHROMA = - { 0xff8a5929, 0x4512, 0x4257, { 0x8d, 0x59, 0xc6, 0x47, 0xbf, 0x99, 0x35, 0xd0 } }; - - //! Razer Mamba device. - // {D527CBDC-EB0A-483A-9E89-66D50463EC6C} - static const GUID MAMBA_CHROMA = - { 0xd527cbdc, 0xeb0a, 0x483a, { 0x9e, 0x89, 0x66, 0xd5, 0x4, 0x63, 0xec, 0x6c } }; - - //! Razer Naga Epic device. - // {D714C50B-7158-4368-B99C-601ACB985E98} - static const GUID NAGA_EPIC_CHROMA = - { 0xd714c50b, 0x7158, 0x4368, { 0xb9, 0x9c, 0x60, 0x1a, 0xcb, 0x98, 0x5e, 0x98 } }; - - //! Razer Naga device. - // {F1876328-6CA4-46AE-BE04-BE812B414433} - static const GUID NAGA_CHROMA = - { 0xf1876328, 0x6ca4, 0x46ae, { 0xbe, 0x4, 0xbe, 0x81, 0x2b, 0x41, 0x44, 0x33 } }; - - //! Razer Orochi Chroma device. - // {52C15681-4ECE-4DD9-8A52-A1418459EB34} - static const GUID OROCHI_CHROMA = - { 0x52c15681, 0x4ece, 0x4dd9, { 0x8a, 0x52, 0xa1, 0x41, 0x84, 0x59, 0xeb, 0x34 } }; - - //! Razer Naga Hex Chroma device. - // {195D70F5-F285-4CFF-99F2-B8C0E9658DB4} - static const GUID NAGA_HEX_CHROMA = - { 0x195d70f5, 0xf285, 0x4cff, { 0x99, 0xf2, 0xb8, 0xc0, 0xe9, 0x65, 0x8d, 0xb4 } }; - - - // Headsets - //! Razer Kraken 7.1 Chroma device. - // {CD1E09A5-D5E6-4A6C-A93B-E6D9BF1D2092} - static const GUID KRAKEN71_CHROMA = - { 0xcd1e09a5, 0xd5e6, 0x4a6c, { 0xa9, 0x3b, 0xe6, 0xd9, 0xbf, 0x1d, 0x20, 0x92 } }; - - //! Razer ManO'War device. - // {DF3164D7-5408-4A0E-8A7F-A7412F26BEBF} - static const GUID MANOWAR_CHROMA = - { 0xdf3164d7, 0x5408, 0x4a0e, { 0x8a, 0x7f, 0xa7, 0x41, 0x2f, 0x26, 0xbe, 0xbf } }; - - - // Mouse mat - //! Razer Firefly device. - // {80F95A94-73D2-48CA-AE9A-0986789A9AF2} - static const GUID FIREFLY_CHROMA = - { 0x80f95a94, 0x73d2, 0x48ca, { 0xae, 0x9a, 0x9, 0x86, 0x78, 0x9a, 0x9a, 0xf2 } }; - - - // Keypads - //! Razer Tartarus device. - // {00F0545C-E180-4AD1-8E8A-419061CE505E} - static const GUID TARTARUS_CHROMA = - { 0xf0545c, 0xe180, 0x4ad1, { 0x8e, 0x8a, 0x41, 0x90, 0x61, 0xce, 0x50, 0x5e } }; - - //! Razer Orbweaver device. - // {9D24B0AB-0162-466C-9640-7A924AA4D9FD} - static const GUID ORBWEAVER_CHROMA = - { 0x9d24b0ab, 0x162, 0x466c, { 0x96, 0x40, 0x7a, 0x92, 0x4a, 0xa4, 0xd9, 0xfd } }; - - - // Systems - // {35F6F18D-1AE5-436C-A575-AB44A127903A} - static const GUID LENOVO_Y900 = - { 0x35f6f18d, 0x1ae5, 0x436c, { 0xa5, 0x75, 0xab, 0x44, 0xa1, 0x27, 0x90, 0x3a } }; - - // {47DB1FA7-6B9B-4EE6-B6F4-4071A3B2053B} - static const GUID LENOVO_Y27 = - { 0x47db1fa7, 0x6b9b, 0x4ee6, { 0xb6, 0xf4, 0x40, 0x71, 0xa3, 0xb2, 0x5, 0x3b } }; - - - // Accessories - // {0201203B-62F3-4C50-83DD-598BABD208E0} - static const GUID CORE_CHROMA = - { 0x201203b, 0x62f3, 0x4c50, { 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } }; - - -} - -#endif diff --git a/stremio-shell/deps/chroma/ChromaSDK/inc/RzChromaSDKTypes.h b/stremio-shell/deps/chroma/ChromaSDK/inc/RzChromaSDKTypes.h deleted file mode 100644 index d4c9e98..0000000 --- a/stremio-shell/deps/chroma/ChromaSDK/inc/RzChromaSDKTypes.h +++ /dev/null @@ -1,785 +0,0 @@ -//! \file RzChromaSDKTypes.h -//! \brief Data types. - -#ifndef _RZCHROMASDKTYPES_H_ -#define _RZCHROMASDKTYPES_H_ - -#pragma once - -typedef LONG RZRESULT; //!< Return result. -typedef GUID RZEFFECTID; //!< Effect Id. -typedef GUID RZDEVICEID; //!< Device Id. -typedef unsigned int RZDURATION; //!< Milliseconds. -typedef size_t RZSIZE; //!< Size. -typedef void* PRZPARAM; //!< Context sensitive pointer. -typedef DWORD RZID; //!< Generic data type for Identifier. -typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable) - -namespace ChromaSDK -{ - //! Event notification Window message - const UINT WM_CHROMA_EVENT = WM_APP+0x2000; - - //! Chroma generic effects. Note: Not all devices supported the listed effects. - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_WAVE, //!< Wave effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect. - CHROMA_BREATHING, //!< Breathing effect. - CHROMA_BLINKING, //!< Blinking effect. - CHROMA_REACTIVE, //!< Reactive effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_CUSTOM, //!< Custom effect. For mice, please see Mouse::CHROMA_CUSTOM2. - CHROMA_RESERVED, //!< TODO - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Device info. - typedef struct DEVICE_INFO_TYPE - { - //! Device types. - enum DeviceType - { - DEVICE_KEYBOARD = 1, //!< Keyboard device. - DEVICE_MOUSE = 2, //!< Mouse device. - DEVICE_HEADSET = 3, //!< Headset device. - DEVICE_MOUSEPAD = 4, //!< Mousepad device. - DEVICE_KEYPAD = 5, //!< Keypad device. - DEVICE_SYSTEM = 6, //!< System device. - DEVICE_INVALID //!< Invalid device. - } DeviceType; - - DWORD Connected; //!< Number of devices connected. - } DEVICE_INFO_TYPE; - - const RZSIZE MAX_ROW = 30; //!< Maximum rows for custom effects. - const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects. - - //! Blinking effect. - typedef struct BLINKING_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - COLORREF Color; //!< Blinking color - } BLINKING_EFFECT_TYPE; - - //! Breathing effect. - typedef struct BREATHING_EFFECT_TYPE - { - RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Breathing effect types. - enum _Type - { - ONE_COLOR = 1, //!< 1 color (Only fill Color1). - TWO_COLORS, //!< 2 colors. - RANDOM_COLORS //!< Random colors - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect. - typedef struct CUSTOM_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - RZCOLOR Color[MAX_ROW][MAX_COLUMN]; - } CUSTOM_EFFECT_TYPE; - - //! No effect. - typedef struct NO_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - } NO_EFFECT_TYPE; - - //! Reactive effect. - typedef struct REACTIVE_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Duration of the effect. - enum _Duration - { - DURATION_SHORT = 1, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; //!< The time taken for the effect to fade away. - - COLORREF Color; //!< Color of the effect. - } REACTIVE_EFFECT_TYPE; - - //! Spectrum cycling effect. - typedef struct SPECTRUMCYCLING_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - } SPECTRUMCYCLING_EFFECT_TYPE; - - //! Starlight effect. - typedef struct STARLIGHT_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Starlight effect types. - enum _Type - { - TWO_COLORS = 1, //!< 2 colors. - RANDOM_COLORS //!< Random colors - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - - //! Duration of the effect. - enum _Duration - { - DURATION_SHORT = 1, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; //!< The time taken for the effect to fade away. - - } STARLIGHT_EFFECT_TYPE; - - //! Static effect. - typedef struct STATIC_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - COLORREF Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Wave effect. - typedef struct WAVE_EFFECT_TYPE - { - RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE) - DWORD Param; //!< Extra parameters. - - //! Direction of effect. - enum _Direction - { - DIRECTION_LEFT_TO_RIGHT = 1, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_FRONT_TO_BACK, //!< Front to back - DIRECTION_BACK_TO_FRONT //!< Back top front - } Direction; - } WAVE_EFFECT_TYPE; - - //! Keyboards - namespace Keyboard - { - //! Definitions of keys. - typedef enum RZKEY - { - RZKEY_ESC = 0x0001, /*!< Esc (VK_ESCAPE) */ - RZKEY_F1 = 0x0003, /*!< F1 (VK_F1) */ - RZKEY_F2 = 0x0004, /*!< F2 (VK_F2) */ - RZKEY_F3 = 0x0005, /*!< F3 (VK_F3) */ - RZKEY_F4 = 0x0006, /*!< F4 (VK_F4) */ - RZKEY_F5 = 0x0007, /*!< F5 (VK_F5) */ - RZKEY_F6 = 0x0008, /*!< F6 (VK_F6) */ - RZKEY_F7 = 0x0009, /*!< F7 (VK_F7) */ - RZKEY_F8 = 0x000A, /*!< F8 (VK_F8) */ - RZKEY_F9 = 0x000B, /*!< F9 (VK_F9) */ - RZKEY_F10 = 0x000C, /*!< F10 (VK_F10) */ - RZKEY_F11 = 0x000D, /*!< F11 (VK_F11) */ - RZKEY_F12 = 0x000E, /*!< F12 (VK_F12) */ - RZKEY_1 = 0x0102, /*!< 1 (VK_1) */ - RZKEY_2 = 0x0103, /*!< 2 (VK_2) */ - RZKEY_3 = 0x0104, /*!< 3 (VK_3) */ - RZKEY_4 = 0x0105, /*!< 4 (VK_4) */ - RZKEY_5 = 0x0106, /*!< 5 (VK_5) */ - RZKEY_6 = 0x0107, /*!< 6 (VK_6) */ - RZKEY_7 = 0x0108, /*!< 7 (VK_7) */ - RZKEY_8 = 0x0109, /*!< 8 (VK_8) */ - RZKEY_9 = 0x010A, /*!< 9 (VK_9) */ - RZKEY_0 = 0x010B, /*!< 0 (VK_0) */ - RZKEY_A = 0x0302, /*!< A (VK_A) */ - RZKEY_B = 0x0407, /*!< B (VK_B) */ - RZKEY_C = 0x0405, /*!< C (VK_C) */ - RZKEY_D = 0x0304, /*!< D (VK_D) */ - RZKEY_E = 0x0204, /*!< E (VK_E) */ - RZKEY_F = 0x0305, /*!< F (VK_F) */ - RZKEY_G = 0x0306, /*!< G (VK_G) */ - RZKEY_H = 0x0307, /*!< H (VK_H) */ - RZKEY_I = 0x0209, /*!< I (VK_I) */ - RZKEY_J = 0x0308, /*!< J (VK_J) */ - RZKEY_K = 0x0309, /*!< K (VK_K) */ - RZKEY_L = 0x030A, /*!< L (VK_L) */ - RZKEY_M = 0x0409, /*!< M (VK_M) */ - RZKEY_N = 0x0408, /*!< N (VK_N) */ - RZKEY_O = 0x020A, /*!< O (VK_O) */ - RZKEY_P = 0x020B, /*!< P (VK_P) */ - RZKEY_Q = 0x0202, /*!< Q (VK_Q) */ - RZKEY_R = 0x0205, /*!< R (VK_R) */ - RZKEY_S = 0x0303, /*!< S (VK_S) */ - RZKEY_T = 0x0206, /*!< T (VK_T) */ - RZKEY_U = 0x0208, /*!< U (VK_U) */ - RZKEY_V = 0x0406, /*!< V (VK_V) */ - RZKEY_W = 0x0203, /*!< W (VK_W) */ - RZKEY_X = 0x0404, /*!< X (VK_X) */ - RZKEY_Y = 0x0207, /*!< Y (VK_Y) */ - RZKEY_Z = 0x0403, /*!< Z (VK_Z) */ - RZKEY_NUMLOCK = 0x0112, /*!< Numlock (VK_NUMLOCK) */ - RZKEY_NUMPAD0 = 0x0513, /*!< Numpad 0 (VK_NUMPAD0) */ - RZKEY_NUMPAD1 = 0x0412, /*!< Numpad 1 (VK_NUMPAD1) */ - RZKEY_NUMPAD2 = 0x0413, /*!< Numpad 2 (VK_NUMPAD2) */ - RZKEY_NUMPAD3 = 0x0414, /*!< Numpad 3 (VK_NUMPAD3) */ - RZKEY_NUMPAD4 = 0x0312, /*!< Numpad 4 (VK_NUMPAD4) */ - RZKEY_NUMPAD5 = 0x0313, /*!< Numpad 5 (VK_NUMPAD5) */ - RZKEY_NUMPAD6 = 0x0314, /*!< Numpad 6 (VK_NUMPAD6) */ - RZKEY_NUMPAD7 = 0x0212, /*!< Numpad 7 (VK_NUMPAD7) */ - RZKEY_NUMPAD8 = 0x0213, /*!< Numpad 8 (VK_NUMPAD8) */ - RZKEY_NUMPAD9 = 0x0214, /*!< Numpad 9 (VK_ NUMPAD9*/ - RZKEY_NUMPAD_DIVIDE = 0x0113, /*!< Divide (VK_DIVIDE) */ - RZKEY_NUMPAD_MULTIPLY = 0x0114, /*!< Multiply (VK_MULTIPLY) */ - RZKEY_NUMPAD_SUBTRACT = 0x0115, /*!< Subtract (VK_SUBTRACT) */ - RZKEY_NUMPAD_ADD = 0x0215, /*!< Add (VK_ADD) */ - RZKEY_NUMPAD_ENTER = 0x0415, /*!< Enter (VK_RETURN - Extended) */ - RZKEY_NUMPAD_DECIMAL = 0x0514, /*!< Decimal (VK_DECIMAL) */ - RZKEY_PRINTSCREEN = 0x000F, /*!< Print Screen (VK_PRINT) */ - RZKEY_SCROLL = 0x0010, /*!< Scroll Lock (VK_SCROLL) */ - RZKEY_PAUSE = 0x0011, /*!< Pause (VK_PAUSE) */ - RZKEY_INSERT = 0x010F, /*!< Insert (VK_INSERT) */ - RZKEY_HOME = 0x0110, /*!< Home (VK_HOME) */ - RZKEY_PAGEUP = 0x0111, /*!< Page Up (VK_PRIOR) */ - RZKEY_DELETE = 0x020f, /*!< Delete (VK_DELETE) */ - RZKEY_END = 0x0210, /*!< End (VK_END) */ - RZKEY_PAGEDOWN = 0x0211, /*!< Page Down (VK_NEXT) */ - RZKEY_UP = 0x0410, /*!< Up (VK_UP) */ - RZKEY_LEFT = 0x050F, /*!< Left (VK_LEFT) */ - RZKEY_DOWN = 0x0510, /*!< Down (VK_DOWN) */ - RZKEY_RIGHT = 0x0511, /*!< Right (VK_RIGHT) */ - RZKEY_TAB = 0x0201, /*!< Tab (VK_TAB) */ - RZKEY_CAPSLOCK = 0x0301, /*!< Caps Lock(VK_CAPITAL) */ - RZKEY_BACKSPACE = 0x010E, /*!< Backspace (VK_BACK) */ - RZKEY_ENTER = 0x030E, /*!< Enter (VK_RETURN) */ - RZKEY_LCTRL = 0x0501, /*!< Left Control(VK_LCONTROL) */ - RZKEY_LWIN = 0x0502, /*!< Left Window (VK_LWIN) */ - RZKEY_LALT = 0x0503, /*!< Left Alt (VK_LMENU) */ - RZKEY_SPACE = 0x0507, /*!< Spacebar (VK_SPACE) */ - RZKEY_RALT = 0x050B, /*!< Right Alt (VK_RMENU) */ - RZKEY_FN = 0x050C, /*!< Function key. */ - RZKEY_RMENU = 0x050D, /*!< Right Menu (VK_APPS) */ - RZKEY_RCTRL = 0x050E, /*!< Right Control (VK_RCONTROL) */ - RZKEY_LSHIFT = 0x0401, /*!< Left Shift (VK_LSHIFT) */ - RZKEY_RSHIFT = 0x040E, /*!< Right Shift (VK_RSHIFT) */ - RZKEY_MACRO1 = 0x0100, /*!< Macro Key 1 */ - RZKEY_MACRO2 = 0x0200, /*!< Macro Key 2 */ - RZKEY_MACRO3 = 0x0300, /*!< Macro Key 3 */ - RZKEY_MACRO4 = 0x0400, /*!< Macro Key 4 */ - RZKEY_MACRO5 = 0x0500, /*!< Macro Key 5 */ - RZKEY_OEM_1 = 0x0101, /*!< ~ (tilde/半角/全角) (VK_OEM_3) */ - RZKEY_OEM_2 = 0x010C, /*!< -- (minus) (VK_OEM_MINUS) */ - RZKEY_OEM_3 = 0x010D, /*!< = (equal) (VK_OEM_PLUS) */ - RZKEY_OEM_4 = 0x020C, /*!< [ (left sqaure bracket) (VK_OEM_4) */ - RZKEY_OEM_5 = 0x020D, /*!< ] (right square bracket) (VK_OEM_6) */ - RZKEY_OEM_6 = 0x020E, /*!< \ (backslash) (VK_OEM_5) */ - RZKEY_OEM_7 = 0x030B, /*!< ; (semi-colon) (VK_OEM_1) */ - RZKEY_OEM_8 = 0x030C, /*!< ' (apostrophe) (VK_OEM_7) */ - RZKEY_OEM_9 = 0x040A, /*!< , (comma) (VK_OEM_COMMA) */ - RZKEY_OEM_10 = 0x040B, /*!< . (period) (VK_OEM_PERIOD) */ - RZKEY_OEM_11 = 0x040C, /*!< / (forward slash) (VK_OEM_2) */ - RZKEY_EUR_1 = 0x030D, /*!< "#" (VK_OEM_5) */ - RZKEY_EUR_2 = 0x0402, /*!< \ (VK_OEM_102) */ - RZKEY_JPN_1 = 0x0015, /*!< ¥ (0xFF) */ - RZKEY_JPN_2 = 0x040D, /*!< \ (0xC1) */ - RZKEY_JPN_3 = 0x0504, /*!< 無変換 (VK_OEM_PA1) */ - RZKEY_JPN_4 = 0x0509, /*!< 変換 (0xFF) */ - RZKEY_JPN_5 = 0x050A, /*!< ひらがな/カタカナ (0xFF) */ - RZKEY_KOR_1 = 0x0015, /*!< | (0xFF) */ - RZKEY_KOR_2 = 0x030D, /*!< (VK_OEM_5) */ - RZKEY_KOR_3 = 0x0402, /*!< (VK_OEM_102) */ - RZKEY_KOR_4 = 0x040D, /*!< (0xC1) */ - RZKEY_KOR_5 = 0x0504, /*!< (VK_OEM_PA1) */ - RZKEY_KOR_6 = 0x0509, /*!< 한/영 (0xFF) */ - RZKEY_KOR_7 = 0x050A, /*!< (0xFF) */ - RZKEY_INVALID = 0xFFFF /*!< Invalid keys. */ - } RZKEY; - - //! Definition of LEDs. - typedef enum RZLED - { - RZLED_LOGO = 0x0014 /*!< Razer logo */ - } RZLED; - - //! Maximum number of rows in a keyboard. - const RZSIZE MAX_ROW = 6; - - //! Maximum number of columns in a keyboard. - const RZSIZE MAX_COLUMN = 22; - - //! Maximum number of keys. - const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN; - - //! Maximum number of custom effects. - const RZSIZE MAX_CUSTOM_EFFECTS = MAX_KEYS; - - //! Keyboard LED layout. - const COLORREF RZKEY_LAYOUT[MAX_ROW][MAX_COLUMN] = {}; - - //! Chroma keyboard effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BREATHING, //!< Breathing effect. - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_REACTIVE, //!< Reactive effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect. - CHROMA_WAVE, //!< Wave effect. - CHROMA_RESERVED, //!< TODO. - CHROMA_CUSTOM_KEY, //!< Custom effects with keys. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - // Chroma keyboard effects - //! Breathing effect type - typedef struct BREATHING_EFFECT_TYPE - { - //! Breathing effects. - enum Type - { - TWO_COLORS = 1, //!< 2 colors - RANDOM_COLORS, //!< Random colors - INVALID //!< Invalid type - } Type; - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect using a matrix type. - typedef struct CUSTOM_EFFECT_TYPE - { - COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns. - } CUSTOM_EFFECT_TYPE; - - //! Custom effect with keys. - typedef struct CUSTOM_KEY_EFFECT_TYPE - { - COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns. - COLORREF Key[MAX_ROW][MAX_COLUMN]; //!< Keys information. 6 rows by 22 columns. To indidate there is a key effect, OR with 0x01000000. i.e. Key[0][1] = 0x01000000 | Color; - } CUSTOM_KEY_EFFECT_TYPE; - - //! Reactive effect type - typedef struct REACTIVE_EFFECT_TYPE - { - //! Duration of the effect. - enum Duration - { - DURATION_NONE=0, //!< No duration. - DURATION_SHORT, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG, //!< Long duration. - DURATION_INVALID //!< Invalid duration. - } Duration; //!< The time taken for the effect to fade away. - - COLORREF Color; //!< Color of the effect - } REACTIVE_EFFECT_TYPE; - - //! Starlight effect. - typedef struct STARLIGHT_EFFECT_TYPE - { - //! Starlight effect types. - enum _Type - { - TWO_COLORS = 1, //!< 2 colors. - RANDOM_COLORS //!< Random colors - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - - //! Duration of the effect. - enum _Duration - { - DURATION_SHORT = 1, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; //!< The time taken for the effect to fade away. - - } STARLIGHT_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - COLORREF Color; //!< Color of the effect - } STATIC_EFFECT_TYPE; - - //! Wave effect type - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - DIRECTION_NONE=0, //!< No direction. - DIRECTION_LEFT_TO_RIGHT, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_INVALID //!< Invalid direction. - } Direction; //!< Direction of the wave. - } WAVE_EFFECT_TYPE; - } - - //! Mice - namespace Mouse - { - //! Maximum number of custom LEDs (old definition to maintain backward compatibility). - const RZSIZE MAX_LEDS = 30; - - //! Mice LED layout (old definition to maintain backward compatibility). - const RZCOLOR RZLED_LAYOUT[MAX_LEDS] = {}; - - //! Maximum number of rows of the virtual grid. - const RZSIZE MAX_ROW = 9; - - //! Maximum number of columns of the virtual grid. - const RZSIZE MAX_COLUMN = 7; - - //! Maximum number of LEDs of the virtual grid. - const RZSIZE MAX_LEDS2 = MAX_ROW * MAX_COLUMN; - - //! Mice LED virtual grid layout. - const RZCOLOR RZLED_LAYOUT2[MAX_ROW][MAX_COLUMN] = {}; - - //! Mouse LED Id defintion (old definition to maintain backward compatibility). - typedef enum RZLED - { - RZLED_NONE = 0, //!< No LED. - RZLED_SCROLLWHEEL = 1, //!< Scroll Wheel LED. - RZLED_LOGO = 2, //!< Logo LED. - RZLED_BACKLIGHT = 3, //!< Backlight or numpad. - RZLED_SIDE_STRIP1 = 4, //!< Side strip LED 1. (For Mamba TE, starts from top left hand) - RZLED_SIDE_STRIP2 = 5, //!< Side strip LED 2. (For Mamba TE) - RZLED_SIDE_STRIP3 = 6, //!< Side strip LED 3. (For Mamba TE) - RZLED_SIDE_STRIP4 = 7, //!< Side strip LED 4. (For Mamba TE) - RZLED_SIDE_STRIP5 = 8, //!< Side strip LED 5. (For Mamba TE) - RZLED_SIDE_STRIP6 = 9, //!< Side strip LED 6. (For Mamba TE) - RZLED_SIDE_STRIP7 = 10, //!< Side strip LED 7. (For Mamba TE) - RZLED_SIDE_STRIP8 = 11, //!< Side strip LED 8. (For Mamba TE) - RZLED_SIDE_STRIP9 = 12, //!< Side strip LED 9. (For Mamba TE) - RZLED_SIDE_STRIP10 = 13, //!< Side strip LED 10. (For Mamba TE) - RZLED_SIDE_STRIP11 = 14, //!< Side strip LED 11. (For Mamba TE) - RZLED_SIDE_STRIP12 = 15, //!< Side strip LED 12. (For Mamba TE) - RZLED_SIDE_STRIP13 = 16, //!< Side strip LED 13. (For Mamba TE) - RZLED_SIDE_STRIP14 = 17, //!< Side strip LED 14. (For Mamba TE) - RZLED_ALL = 0xFFFF - } RZLED; - - //! Mouse LED Id defintion for the virtual grid. - typedef enum RZLED2 - { - RZLED2_SCROLLWHEEL = 0x0203, //!< Scroll Wheel LED. - RZLED2_LOGO = 0x0703, //!< Logo LED. - RZLED2_BACKLIGHT = 0x0403, //!< Backlight LED. - RZLED2_LEFT_SIDE1 = 0x0100, //!< Left LED 1. - RZLED2_LEFT_SIDE2 = 0x0200, //!< Left LED 2. - RZLED2_LEFT_SIDE3 = 0x0300, //!< Left LED 3. - RZLED2_LEFT_SIDE4 = 0x0400, //!< Left LED 4. - RZLED2_LEFT_SIDE5 = 0x0500, //!< Left LED 5. - RZLED2_LEFT_SIDE6 = 0x0600, //!< Left LED 6. - RZLED2_LEFT_SIDE7 = 0x0700, //!< Left LED 7. - RZLED2_BOTTOM1 = 0x0801, //!< Bottom LED 1. - RZLED2_BOTTOM2 = 0x0802, //!< Bottom LED 2. - RZLED2_BOTTOM3 = 0x0803, //!< Bottom LED 3. - RZLED2_BOTTOM4 = 0x0804, //!< Bottom LED 4. - RZLED2_BOTTOM5 = 0x0805, //!< Bottom LED 5. - RZLED2_RIGHT_SIDE1 = 0x0106, //!< Right LED 1. - RZLED2_RIGHT_SIDE2 = 0x0206, //!< Right LED 2. - RZLED2_RIGHT_SIDE3 = 0x0306, //!< Right LED 3. - RZLED2_RIGHT_SIDE4 = 0x0406, //!< Right LED 4. - RZLED2_RIGHT_SIDE5 = 0x0506, //!< Right LED 5. - RZLED2_RIGHT_SIDE6 = 0x0606, //!< Right LED 6. - RZLED2_RIGHT_SIDE7 = 0x0706 //!< Right LED 7. - } RZLED2; - - //! Chroma mouse effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BLINKING, //!< Blinking effect. - CHROMA_BREATHING, //!< Breathing effect. - CHROMA_CUSTOM, //!< Custom effect (old definition to maintain backward compatibility). - CHROMA_REACTIVE, //!< Reactive effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_WAVE, //!< Wave effect. - CHROMA_CUSTOM2, //!< Custom effects using a virtual grid. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - COLORREF Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Blinking effect type. - typedef struct BLINKING_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - COLORREF Color; //!< Color. - } BLINKING_EFFECT_TYPE; - - //! Breathing effect. - typedef struct BREATHING_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - - //! Breathing type. - enum Type - { - ONE_COLOR = 1, //!< 1 color (Only fill Color1). - TWO_COLORS, //!< 2 colors. - RANDOM_COLORS, //!< Random colors - INVALID //!< Invalid type - } Type; - - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect. - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE; - - //! Custom effect using virtual grid. - //! Indexes of the LED are defined in RZLED2.i.e. Row = HIBYTE(RZLED2_SCROLLWHEEL), Column = LOBYTE(RZLED2_SCROLLWHEEL) - typedef struct CUSTOM_EFFECT_TYPE2 - { - RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE2; - - //! Reactive effect. - typedef struct REACTIVE_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - - //! Duration of the effect. - enum Duration - { - DURATION_NONE=0, //!< No duration. - DURATION_SHORT, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG //!< Long duration. - } Duration; - - RZCOLOR Color; //!< Color of the effect. - } REACTIVE_EFFECT_TYPE; - - //! No effect. - typedef struct NO_EFFECT_TYPE - { - RZLED LEDId; //!< LED Id - } NO_EFFECT_TYPE; - - //! Spectrum cycling. - typedef struct SPECTRUMCYCLING_EFFECT_TYPE - { - RZLED LEDId; //!< LED id. - } SPECTRUMCYCLING_EFFECT_TYPE; - - //! Wave effect. - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - FRONT_TO_BACK, //!< Front to back - BACK_TO_FRONT //!< Back to front - } Direction; - } WAVE_EFFECT_TYPE; - } - - //! Headsets - namespace Headset - { - //! Maximum number of LEDs - const RZSIZE MAX_LEDS = 5; - - //! Chroma headset effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_BREATHING, //!< Breathing effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect. - CHROMA_CUSTOM, //!< Custom effects. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - COLORREF Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Breathing effect type. - typedef struct BREATHING_EFFECT_TYPE - { - COLORREF Color; //!< Color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect type. - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< Array of colors. - } CUSTOM_EFFECT_TYPE; - } - - //! Mousepads - namespace Mousepad - { - //! Maximum number of LEDs - const RZSIZE MAX_LEDS = 15; - - //! Chroma mousepad effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BREATHING, //!< Breathing effect. - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_WAVE, //!< Wave effect. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - // Chroma mousepad effects - //! Breathing effect type. - typedef struct BREATHING_EFFECT_TYPE - { - //! Breathing effects. - enum Type - { - TWO_COLORS = 1, //!< 2 colors - RANDOM_COLORS, //!< Random colors - INVALID - } Type; - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect type. - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_LEDS]; //!< An array of colors for all the sides of the mousepad. First LED starts from top-right corner. - //!< LED 0-4 right side, 5-9 bottom side, 10-14 left side. - } CUSTOM_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - COLORREF Color; //!< Color of the effect - } STATIC_EFFECT_TYPE; - - //! Wave effect type - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - DIRECTION_NONE=0, //!< No direction. - DIRECTION_LEFT_TO_RIGHT, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_INVALID //!< Invalid direction. - } Direction; //!< Direction of the wave. - } WAVE_EFFECT_TYPE; - } - - //! Keypads - namespace Keypad - { - //! Maximum number of rows. - const RZSIZE MAX_ROW = 4; - - //! Maximum number of columns. - const RZSIZE MAX_COLUMN = 5; - - //! Total number of keys. - const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN; - - //! Chroma keypad effect types - typedef enum EFFECT_TYPE - { - CHROMA_NONE = 0, //!< No effect. - CHROMA_BREATHING, //!< Breathing effect. - CHROMA_CUSTOM, //!< Custom effect. - CHROMA_REACTIVE, //!< Reactive effect. - CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect. - CHROMA_STATIC, //!< Static effect. - CHROMA_WAVE, //!< Wave effect. - CHROMA_INVALID //!< Invalid effect. - } EFFECT_TYPE; - - // Chroma keypad effects - //! Breathing effect type. - typedef struct BREATHING_EFFECT_TYPE - { - //! Breathing effects. - enum Type - { - TWO_COLORS = 1, //!< 2 colors - RANDOM_COLORS, //!< Random colors - INVALID //!< Invalid type - } Type; - COLORREF Color1; //!< First color. - COLORREF Color2; //!< Second color. - } BREATHING_EFFECT_TYPE; - - //! Custom effect type - typedef struct CUSTOM_EFFECT_TYPE - { - RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Custom effect. - //!< For Razer Tartarus Chroma only Color[0] is valid. Use index '0' to change the keypad color. - } CUSTOM_EFFECT_TYPE; - - //! Reactive effect type - typedef struct REACTIVE_EFFECT_TYPE - { - //! Duration of the effect. - enum Duration - { - DURATION_NONE=0, //!< No duration. - DURATION_SHORT, //!< Short duration. - DURATION_MEDIUM, //!< Medium duration. - DURATION_LONG, //!< Long duration. - DURATION_INVALID //!< Invalid duration. - } Duration; //!< The time taken for the effect to fade away. - - COLORREF Color; //!< Color of the effect - } REACTIVE_EFFECT_TYPE; - - //! Static effect type - typedef struct STATIC_EFFECT_TYPE - { - RZCOLOR Color; //!< Color of the effect. - } STATIC_EFFECT_TYPE; - - //! Wave effect type - typedef struct WAVE_EFFECT_TYPE - { - //! Direction of the wave effect. - enum Direction - { - DIRECTION_NONE=0, //!< No direction. - DIRECTION_LEFT_TO_RIGHT, //!< Left to right. - DIRECTION_RIGHT_TO_LEFT, //!< Right to left. - DIRECTION_INVALID //!< Invalid direction. - } Direction; //!< Direction of the wave. - } WAVE_EFFECT_TYPE; - } -} - -#endif diff --git a/stremio-shell/deps/chroma/ChromaSDK/inc/RzErrors.h b/stremio-shell/deps/chroma/ChromaSDK/inc/RzErrors.h deleted file mode 100644 index 6d3f29b..0000000 --- a/stremio-shell/deps/chroma/ChromaSDK/inc/RzErrors.h +++ /dev/null @@ -1,46 +0,0 @@ - -//! \file RzErrors.h -//! \brief Error codes for Chroma SDK. If the error is not defined here, refer to WinError.h from the Windows SDK. - -#ifndef _RZERRORS_H_ -#define _RZERRORS_H_ - -#pragma once - -// Error codes -//! Invalid -#define RZRESULT_INVALID -1L -//! Success -#define RZRESULT_SUCCESS 0L -//! Access denied -#define RZRESULT_ACCESS_DENIED 5L -//! Invalid handle -#define RZRESULT_INVALID_HANDLE 6L -//! Not supported -#define RZRESULT_NOT_SUPPORTED 50L -//! Invalid parameter. -#define RZRESULT_INVALID_PARAMETER 87L -//! The service has not been started -#define RZRESULT_SERVICE_NOT_ACTIVE 1062L -//! Cannot start more than one instance of the specified program. -#define RZRESULT_SINGLE_INSTANCE_APP 1152L -//! Device not connected -#define RZRESULT_DEVICE_NOT_CONNECTED 1167L -//! Element not found. -#define RZRESULT_NOT_FOUND 1168L -//! Request aborted. -#define RZRESULT_REQUEST_ABORTED 1235L -//! An attempt was made to perform an initialization operation when initialization has already been completed. -#define RZRESULT_ALREADY_INITIALIZED 1247L -//! Resource not available or disabled -#define RZRESULT_RESOURCE_DISABLED 4309L -//! Device not available or supported -#define RZRESULT_DEVICE_NOT_AVAILABLE 4319L -//! The group or resource is not in the correct state to perform the requested operation. -#define RZRESULT_NOT_VALID_STATE 5023L -//! No more items -#define RZRESULT_NO_MORE_ITEMS 259L -//! General failure. -#define RZRESULT_FAILED 2147500037L - -#endif diff --git a/stremio-shell/deps/chroma/ChromaSDKImpl.cpp b/stremio-shell/deps/chroma/ChromaSDKImpl.cpp deleted file mode 100644 index 38a5d0e..0000000 --- a/stremio-shell/deps/chroma/ChromaSDKImpl.cpp +++ /dev/null @@ -1,1739 +0,0 @@ -//! \example ChromaSDKImpl.cpp - -#include "stdafx.h" -#include "ChromaSDKImpl.h" - -#ifdef _WIN64 -#define CHROMASDKDLL _T("RzChromaSDK64.dll") -#else -#define CHROMASDKDLL _T("RzChromaSDK.dll") -#endif - -using namespace ChromaSDK; -using namespace ChromaSDK::Keyboard; -using namespace ChromaSDK::Keypad; -using namespace ChromaSDK::Mouse; -using namespace ChromaSDK::Mousepad; -using namespace ChromaSDK::Headset; - -typedef RZRESULT (*INIT)(void); -typedef RZRESULT (*UNINIT)(void); -typedef RZRESULT (*CREATEEFFECT)(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId); -typedef RZRESULT (*CREATEKEYBOARDEFFECT)(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId); -typedef RZRESULT (*CREATEHEADSETEFFECT)(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId); -typedef RZRESULT (*CREATEMOUSEPADEFFECT)(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId); -typedef RZRESULT (*CREATEMOUSEEFFECT)(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId); -typedef RZRESULT (*CREATEKEYPADEFFECT)(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId); -typedef RZRESULT (*SETEFFECT)(RZEFFECTID EffectId); -typedef RZRESULT (*DELETEEFFECT)(RZEFFECTID EffectId); -typedef RZRESULT (*REGISTEREVENTNOTIFICATION)(HWND hWnd); -typedef RZRESULT (*UNREGISTEREVENTNOTIFICATION)(void); -typedef RZRESULT (*QUERYDEVICE)(RZDEVICEID DeviceId, ChromaSDK::DEVICE_INFO_TYPE &DeviceInfo); - -INIT Init = NULL; -UNINIT UnInit = NULL; -CREATEEFFECT CreateEffect = NULL; -CREATEKEYBOARDEFFECT CreateKeyboardEffect = NULL; -CREATEMOUSEEFFECT CreateMouseEffect = NULL; -CREATEHEADSETEFFECT CreateHeadsetEffect = NULL; -CREATEMOUSEPADEFFECT CreateMousepadEffect = NULL; -CREATEKEYPADEFFECT CreateKeypadEffect = NULL; -SETEFFECT SetEffect = NULL; -DELETEEFFECT DeleteEffect = NULL; -QUERYDEVICE QueryDevice = NULL; - -DWORD WINAPI Thread_LoadingAnimationOnKeyboard(LPVOID lpParameter) -{ - RZEFFECTID Frame0 = GUID_NULL; - RZEFFECTID Frame1 = GUID_NULL; - RZEFFECTID Frame2 = GUID_NULL; - RZEFFECTID Frame3 = GUID_NULL; - RZEFFECTID Frame4 = GUID_NULL; - RZEFFECTID Frame5 = GUID_NULL; - RZEFFECTID Frame6 = GUID_NULL; - - if(CreateKeyboardEffect) - { - // Loading animation - ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE Effect = {}; - - // Create the animation frames if not created - CreateKeyboardEffect(ChromaSDK::Keyboard::CHROMA_NONE, NULL, &Frame0); - - for(UINT r=0; r0; --i) - { - CustomEffect.Color[i] = ORANGE; - - CreateMousepadEffect(ChromaSDK::Mousepad::CHROMA_CUSTOM, &CustomEffect, NULL); - - Sleep(50); - } - } - - return 0; -} - -DWORD WINAPI Thread_LoadingAnimationOnMice(LPVOID lpParameter) -{ - if(CreateMouseEffect) - { - // This works too! - // Using old interface. - //ChromaSDK::Mouse::CUSTOM_EFFECT_TYPE CustomEffect = {}; - - //CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM, &CustomEffect, NULL); - - //Sleep(500); - - //for(UINT i=0; i<7; i++) - //{ - // CustomEffect.Color[RZLED_SIDE_STRIP7-i] = ORANGE; - // CustomEffect.Color[RZLED_SIDE_STRIP14-i] = ORANGE; - - // if(i == 2) - // { - // CustomEffect.Color[RZLED_LOGO] = ORANGE; - // } - // else if(i == 6) - // { - // CustomEffect.Color[RZLED_SCROLLWHEEL] = ORANGE; - // } - - // CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM, &CustomEffect, NULL); - - // Sleep(50); - //} - - // Using the new mice virtual grid - ChromaSDK::Mouse::CUSTOM_EFFECT_TYPE2 CustomEffect = {}; - - CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM2, &CustomEffect, NULL); - - Sleep(500); - - //for(UINT i=0; i<7; i++) - //{ - // CustomEffect.Color[HIBYTE(RZLED2_LEFT_SIDE7)-i][0] = ORANGE; - // CustomEffect.Color[HIBYTE(RZLED2_RIGHT_SIDE7)-i][6] = ORANGE; - - // if(i == 0) - // { - // // For Razer Diamondback bottom LEDs. - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM1)] = RED; - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM5)] = RED; - // } - // else if(i == 2) - // { - // CustomEffect.Color[HIBYTE(RZLED2_LOGO)][LOBYTE(RZLED2_LOGO)] = ORANGE; - - // // For Razer Diamondback bottom LEDs. - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM2)] = RED; - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM4)] = RED; - // } - // else if(i == 4) - // { - // // For Razer Naga Epic numpad LED. - // CustomEffect.Color[HIBYTE(RZLED2_BACKLIGHT)][LOBYTE(RZLED2_BACKLIGHT)] = ORANGE; - // } - // else if(i == 6) - // { - // CustomEffect.Color[HIBYTE(RZLED2_SCROLLWHEEL)][LOBYTE(RZLED2_SCROLLWHEEL)] = ORANGE; - - // // For Razer Diamondback bottom LEDs. - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM3)] = RED; - // } - - // CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM2, &CustomEffect, NULL); - - // Sleep(50); - //} - - for(INT row=Mouse::MAX_ROW-1; row>=0; row--) - { - for(UINT col=0; col0; --i) - { - CustomEffect.Color[i] = ORANGE; - - CreateMousepadEffect(ChromaSDK::Mousepad::CHROMA_CUSTOM, &CustomEffect, NULL); - - Sleep(50); - } - } - - return 0; -} - -DWORD WINAPI Thread_LoadingAnimationOnMice(LPVOID lpParameter) -{ - if(CreateMouseEffect) - { - // This works too! - // Using old interface. - //ChromaSDK::Mouse::CUSTOM_EFFECT_TYPE CustomEffect = {}; - - //CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM, &CustomEffect, NULL); - - //Sleep(500); - - //for(UINT i=0; i<7; i++) - //{ - // CustomEffect.Color[RZLED_SIDE_STRIP7-i] = ORANGE; - // CustomEffect.Color[RZLED_SIDE_STRIP14-i] = ORANGE; - - // if(i == 2) - // { - // CustomEffect.Color[RZLED_LOGO] = ORANGE; - // } - // else if(i == 6) - // { - // CustomEffect.Color[RZLED_SCROLLWHEEL] = ORANGE; - // } - - // CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM, &CustomEffect, NULL); - - // Sleep(50); - //} - - // Using the new mice virtual grid - ChromaSDK::Mouse::CUSTOM_EFFECT_TYPE2 CustomEffect = {}; - - CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM2, &CustomEffect, NULL); - - Sleep(500); - - //for(UINT i=0; i<7; i++) - //{ - // CustomEffect.Color[HIBYTE(RZLED2_LEFT_SIDE7)-i][0] = ORANGE; - // CustomEffect.Color[HIBYTE(RZLED2_RIGHT_SIDE7)-i][6] = ORANGE; - - // if(i == 0) - // { - // // For Razer Diamondback bottom LEDs. - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM1)] = RED; - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM5)] = RED; - // } - // else if(i == 2) - // { - // CustomEffect.Color[HIBYTE(RZLED2_LOGO)][LOBYTE(RZLED2_LOGO)] = ORANGE; - - // // For Razer Diamondback bottom LEDs. - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM2)] = RED; - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM4)] = RED; - // } - // else if(i == 4) - // { - // // For Razer Naga Epic numpad LED. - // CustomEffect.Color[HIBYTE(RZLED2_BACKLIGHT)][LOBYTE(RZLED2_BACKLIGHT)] = ORANGE; - // } - // else if(i == 6) - // { - // CustomEffect.Color[HIBYTE(RZLED2_SCROLLWHEEL)][LOBYTE(RZLED2_SCROLLWHEEL)] = ORANGE; - - // // For Razer Diamondback bottom LEDs. - // CustomEffect.Color[8][LOBYTE(RZLED2_BOTTOM3)] = RED; - // } - - // CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM2, &CustomEffect, NULL); - - // Sleep(50); - //} - - for(INT row=Mouse::MAX_ROW-1; row>=0; row--) - { - for(UINT col=0; col -#include // for assert - -#include "RzChromaSDKDefines.h" -#include "RzChromaSDKTypes.h" -#include "RzErrors.h" - -const COLORREF BLACK = RGB(0,0,0); -const COLORREF WHITE = RGB(255,255,255); -const COLORREF RED = RGB(255,0,0); -const COLORREF GREEN = RGB(0,255,0); -const COLORREF BLUE = RGB(0,0,255); -const COLORREF YELLOW = RGB(255,255,0); -const COLORREF PURPLE = RGB(128,0,128); -const COLORREF CYAN = RGB(00,255,255); -const COLORREF ORANGE = RGB(255,165,00); -const COLORREF PINK = RGB(255,192,203); -const COLORREF GREY = RGB(125, 125, 125); - -#define ALL_DEVICES 0 -#define KEYBOARD_DEVICES 1 -#define MOUSEMAT_DEVICES 2 -#define MOUSE_DEVICES 3 -#define HEADSET_DEVICES 4 -#define KEYPAD_DEVICES 5 - -class CChromaSDKImpl -{ -public: - CChromaSDKImpl(); - ~CChromaSDKImpl(); - - BOOL Initialize(); - BOOL UnInitialize(); - - void PlayLoadingAnimation(UINT DeviceType); - void ShowKeys(UINT DeviceType, UINT NumKeys, UINT VKey[], COLORREF Color, BOOL Animate=FALSE); - void ShowKeysWithCustomCol(UINT DeviceType, UINT NumKeys, UINT VKey[], COLORREF Colors[], BOOL Animate=FALSE); - void ShowLevel(UINT DeviceType, UINT Hp, UINT Ammo); - void ShowAlert(UINT DeviceType, COLORREF Color); - void ShowGauge(UINT DeviceType, UINT Level); - void ShowBitmap(UINT DeviceType, HBITMAP hBitmap); - void ShowDamageEffect(UINT DeviceType); - void ShowColor(UINT DeviceType, COLORREF Color); - void ResetEffects(UINT DeviceType); - BOOL IsDeviceConnected(RZDEVICEID DeviceId); - -private: - HMODULE m_ChromaSDKModule; -}; - -#endif diff --git a/stremio-shell/deps/chroma/chroma.pri b/stremio-shell/deps/chroma/chroma.pri deleted file mode 100644 index 7cd3f8f..0000000 --- a/stremio-shell/deps/chroma/chroma.pri +++ /dev/null @@ -1,10 +0,0 @@ -HEADERS += $$PWD/chroma.h -SOURCES += $$PWD/chroma.cpp - -INCLUDEPATH += $$PWD/ChromaSDK/inc -INCLUDEPATH += $$PWD - -win32 { - msvc:LIBS += user32.lib - gcc:LIBS += -luser32 -} diff --git a/stremio-shell/deps/libmpv/README.md b/stremio-shell/deps/libmpv/README.md deleted file mode 100644 index b524e25..0000000 --- a/stremio-shell/deps/libmpv/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# libmpv - -libmpv headers and linking libraries - -Linking libraries are only provided for `win32`, and `win32-x64` will be added. For other operating systems, use `pkg-config` and system-wide libmpv - - -## VERSION - -The `.lib` files for Windows are updated from those builds: - -https://mpv.srsfckn.biz/mpv-dev-20170212.7z - - -## Windows - how to generate `mpv.lib` - -This `mpv.lib` for Windows was generated using the instructions on [MPV's wiki](https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md#linking-libmpv-with-msvc-programs) from the [srsfckn MPV windows builds](https://mpv.srsfckn.biz) Dev package. - - -### x86 - -``` -CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 -lib /def:mpv.def /name:mpv-1.dll /out:mpv.lib /MACHINE:X86 -``` - -### x64 - -``` -CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 -lib /def:mpv.def /name:mpv-1.dll /out:mpv.lib /MACHINE:X64 -``` - - - -## Mac - -The files in `lib/` are taken from the brew build of `libmpv`, 0.24.0 version in particular. The reason to use particular dylibs commited to the repo is to ensure we have consistency, since we take the include files from here either way. - -It also ensures we have a consistency in versions (0.24.0) - -### Fix `rpath` if you copy files - -When you copy files from system deps, you can do something like that to fix `rpath` - -``` -find $1/*.dylib | while read LINE -do - otool -l "$LINE" | grep "name " | grep "/usr/local/Cellar" | cut -d " " -f11 | while read LIB - do - echo "$LINE -> $LIB" - install_name_tool -change "$LIB" "@executable_path/../Frameworks/$(basename $LIB)" $LINE - done -done -``` diff --git a/stremio-shell/deps/libmpv/include/mpv/client.h b/stremio-shell/deps/libmpv/include/mpv/client.h deleted file mode 100644 index 488ccb3..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/client.h +++ /dev/null @@ -1,1875 +0,0 @@ -/* Copyright (C) 2017 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Note: the client API is licensed under ISC (see above) to enable - * other wrappers outside of mpv. But keep in mind that the - * mpv core is by default still GPLv2+ - unless built with - * --enable-lgpl, which makes it LGPLv2+. - */ - -#ifndef MPV_CLIENT_API_H_ -#define MPV_CLIENT_API_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Mechanisms provided by this API - * ------------------------------- - * - * This API provides general control over mpv playback. It does not give you - * direct access to individual components of the player, only the whole thing. - * It's somewhat equivalent to MPlayer's slave mode. You can send commands, - * retrieve or set playback status or settings with properties, and receive - * events. - * - * The API can be used in two ways: - * 1) Internally in mpv, to provide additional features to the command line - * player. Lua scripting uses this. (Currently there is no plugin API to - * get a client API handle in external user code. It has to be a fixed - * part of the player at compilation time.) - * 2) Using mpv as a library with mpv_create(). This basically allows embedding - * mpv in other applications. - * - * Documentation - * ------------- - * - * The libmpv C API is documented directly in this header. Note that most - * actual interaction with this player is done through - * options/commands/properties, which can be accessed through this API. - * Essentially everything is done with them, including loading a file, - * retrieving playback progress, and so on. - * - * These are documented elsewhere: - * * http://mpv.io/manual/master/#options - * * http://mpv.io/manual/master/#list-of-input-commands - * * http://mpv.io/manual/master/#properties - * - * You can also look at the examples here: - * * https://github.com/mpv-player/mpv-examples/tree/master/libmpv - * - * Event loop - * ---------- - * - * In general, the API user should run an event loop in order to receive events. - * This event loop should call mpv_wait_event(), which will return once a new - * mpv client API is available. It is also possible to integrate client API - * usage in other event loops (e.g. GUI toolkits) with the - * mpv_set_wakeup_callback() function, and then polling for events by calling - * mpv_wait_event() with a 0 timeout. - * - * Note that the event loop is detached from the actual player. Not calling - * mpv_wait_event() will not stop playback. It will eventually congest the - * event queue of your API handle, though. - * - * Synchronous vs. asynchronous calls - * ---------------------------------- - * - * The API allows both synchronous and asynchronous calls. Synchronous calls - * have to wait until the playback core is ready, which currently can take - * an unbounded time (e.g. if network is slow or unresponsive). Asynchronous - * calls just queue operations as requests, and return the result of the - * operation as events. - * - * Asynchronous calls - * ------------------ - * - * The client API includes asynchronous functions. These allow you to send - * requests instantly, and get replies as events at a later point. The - * requests are made with functions carrying the _async suffix, and replies - * are returned by mpv_wait_event() (interleaved with the normal event stream). - * - * A 64 bit userdata value is used to allow the user to associate requests - * with replies. The value is passed as reply_userdata parameter to the request - * function. The reply to the request will have the reply - * mpv_event->reply_userdata field set to the same value as the - * reply_userdata parameter of the corresponding request. - * - * This userdata value is arbitrary and is never interpreted by the API. Note - * that the userdata value 0 is also allowed, but then the client must be - * careful not accidentally interpret the mpv_event->reply_userdata if an - * event is not a reply. (For non-replies, this field is set to 0.) - * - * Currently, asynchronous calls are always strictly ordered (even with - * synchronous calls) for each client, although that may change in the future. - * - * Multithreading - * -------------- - * - * The client API is generally fully thread-safe, unless otherwise noted. - * Currently, there is no real advantage in using more than 1 thread to access - * the client API, since everything is serialized through a single lock in the - * playback core. - * - * Basic environment requirements - * ------------------------------ - * - * This documents basic requirements on the C environment. This is especially - * important if mpv is used as library with mpv_create(). - * - * - The LC_NUMERIC locale category must be set to "C". If your program calls - * setlocale(), be sure not to use LC_ALL, or if you do, reset LC_NUMERIC - * to its sane default: setlocale(LC_NUMERIC, "C"). - * - If a X11 based VO is used, mpv will set the xlib error handler. This error - * handler is process-wide, and there's no proper way to share it with other - * xlib users within the same process. This might confuse GUI toolkits. - * - mpv uses some other libraries that are not library-safe, such as Fribidi - * (used through libass), ALSA, FFmpeg, and possibly more. - * - The FPU precision must be set at least to double precision. - * - On Windows, mpv will call timeBeginPeriod(1). - * - On memory exhaustion, mpv will kill the process. - * - In certain cases, mpv may start sub processes (such as with the ytdl - * wrapper script). - * - Using UNIX IPC (off by default) will override the SIGPIPE signal handler, - * and set it to SIG_IGN. - * - * Encoding of filenames - * --------------------- - * - * mpv uses UTF-8 everywhere. - * - * On some platforms (like Linux), filenames actually do not have to be UTF-8; - * for this reason libmpv supports non-UTF-8 strings. libmpv uses what the - * kernel uses and does not recode filenames. At least on Linux, passing a - * string to libmpv is like passing a string to the fopen() function. - * - * On Windows, filenames are always UTF-8, libmpv converts between UTF-8 and - * UTF-16 when using win32 API functions. libmpv never uses or accepts - * filenames in the local 8 bit encoding. It does not use fopen() either; - * it uses _wfopen(). - * - * On OS X, filenames and other strings taken/returned by libmpv can have - * inconsistent unicode normalization. This can sometimes lead to problems. - * You have to hope for the best. - * - * Also see the remarks for MPV_FORMAT_STRING. - * - * Embedding the video window - * -------------------------- - * - * Using the opengl-cb API (in opengl_cb.h) is recommended. This API requires - * you to create and maintain an OpenGL context, to which you can render - * video using a specific API call. This API does not include keyboard or mouse - * input directly. - * - * There is an older way to embed the native mpv window into your own. You have - * to get the raw window handle, and set it as "wid" option. This works on X11, - * win32, and OSX only. It's much easier to use than the opengl-cb API, but - * also has various problems. - * - * Also see client API examples and the mpv manpage. There is an extensive - * discussion here: - * https://github.com/mpv-player/mpv-examples/tree/master/libmpv#methods-of-embedding-the-video-window - * - * Compatibility - * ------------- - * - * mpv development doesn't stand still, and changes to mpv internals as well as - * to its interface can cause compatibility issues to client API users. - * - * The API is versioned (see MPV_CLIENT_API_VERSION), and changes to it are - * documented in DOCS/client-api-changes.rst. The C API itself will probably - * remain compatible for a long time, but the functionality exposed by it - * could change more rapidly. For example, it's possible that options are - * renamed, or change the set of allowed values. - * - * Defensive programming should be used to potentially deal with the fact that - * options, commands, and properties could disappear, change their value range, - * or change the underlying datatypes. It might be a good idea to prefer - * MPV_FORMAT_STRING over other types to decouple your code from potential - * mpv changes. - */ - -/** - * The version is incremented on each API change. The 16 lower bits form the - * minor version number, and the 16 higher bits the major version number. If - * the API becomes incompatible to previous versions, the major version - * number is incremented. This affects only C part, and not properties and - * options. - * - * Every API bump is described in DOCS/client-api-changes.rst - * - * You can use MPV_MAKE_VERSION() and compare the result with integer - * relational operators (<, >, <=, >=). - */ -#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL) -#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 101) - -/** - * The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before - * including any libmpv headers. Then deprecated symbols will be excluded - * from the headers. (Of course, deprecated properties and commands and - * other functionality will still work.) - */ -#ifndef MPV_ENABLE_DEPRECATED -#define MPV_ENABLE_DEPRECATED 1 -#endif - -/** - * Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with. - */ -unsigned long mpv_client_api_version(void); - -/** - * Client context used by the client API. Every client has its own private - * handle. - */ -typedef struct mpv_handle mpv_handle; - -/** - * List of error codes than can be returned by API functions. 0 and positive - * return values always mean success, negative values are always errors. - */ -typedef enum mpv_error { - /** - * No error happened (used to signal successful operation). - * Keep in mind that many API functions returning error codes can also - * return positive values, which also indicate success. API users can - * hardcode the fact that ">= 0" means success. - */ - MPV_ERROR_SUCCESS = 0, - /** - * The event ringbuffer is full. This means the client is choked, and can't - * receive any events. This can happen when too many asynchronous requests - * have been made, but not answered. Probably never happens in practice, - * unless the mpv core is frozen for some reason, and the client keeps - * making asynchronous requests. (Bugs in the client API implementation - * could also trigger this, e.g. if events become "lost".) - */ - MPV_ERROR_EVENT_QUEUE_FULL = -1, - /** - * Memory allocation failed. - */ - MPV_ERROR_NOMEM = -2, - /** - * The mpv core wasn't configured and initialized yet. See the notes in - * mpv_create(). - */ - MPV_ERROR_UNINITIALIZED = -3, - /** - * Generic catch-all error if a parameter is set to an invalid or - * unsupported value. This is used if there is no better error code. - */ - MPV_ERROR_INVALID_PARAMETER = -4, - /** - * Trying to set an option that doesn't exist. - */ - MPV_ERROR_OPTION_NOT_FOUND = -5, - /** - * Trying to set an option using an unsupported MPV_FORMAT. - */ - MPV_ERROR_OPTION_FORMAT = -6, - /** - * Setting the option failed. Typically this happens if the provided option - * value could not be parsed. - */ - MPV_ERROR_OPTION_ERROR = -7, - /** - * The accessed property doesn't exist. - */ - MPV_ERROR_PROPERTY_NOT_FOUND = -8, - /** - * Trying to set or get a property using an unsupported MPV_FORMAT. - */ - MPV_ERROR_PROPERTY_FORMAT = -9, - /** - * The property exists, but is not available. This usually happens when the - * associated subsystem is not active, e.g. querying audio parameters while - * audio is disabled. - */ - MPV_ERROR_PROPERTY_UNAVAILABLE = -10, - /** - * Error setting or getting a property. - */ - MPV_ERROR_PROPERTY_ERROR = -11, - /** - * General error when running a command with mpv_command and similar. - */ - MPV_ERROR_COMMAND = -12, - /** - * Generic error on loading (usually used with mpv_event_end_file.error). - */ - MPV_ERROR_LOADING_FAILED = -13, - /** - * Initializing the audio output failed. - */ - MPV_ERROR_AO_INIT_FAILED = -14, - /** - * Initializing the video output failed. - */ - MPV_ERROR_VO_INIT_FAILED = -15, - /** - * There was no audio or video data to play. This also happens if the - * file was recognized, but did not contain any audio or video streams, - * or no streams were selected. - */ - MPV_ERROR_NOTHING_TO_PLAY = -16, - /** - * When trying to load the file, the file format could not be determined, - * or the file was too broken to open it. - */ - MPV_ERROR_UNKNOWN_FORMAT = -17, - /** - * Generic error for signaling that certain system requirements are not - * fulfilled. - */ - MPV_ERROR_UNSUPPORTED = -18, - /** - * The API function which was called is a stub only. - */ - MPV_ERROR_NOT_IMPLEMENTED = -19, - /** - * Unspecified error. - */ - MPV_ERROR_GENERIC = -20 -} mpv_error; - -/** - * Return a string describing the error. For unknown errors, the string - * "unknown error" is returned. - * - * @param error error number, see enum mpv_error - * @return A static string describing the error. The string is completely - * static, i.e. doesn't need to be deallocated, and is valid forever. - */ -const char *mpv_error_string(int error); - -/** - * General function to deallocate memory returned by some of the API functions. - * Call this only if it's explicitly documented as allowed. Calling this on - * mpv memory not owned by the caller will lead to undefined behavior. - * - * @param data A valid pointer returned by the API, or NULL. - */ -void mpv_free(void *data); - -/** - * Return the name of this client handle. Every client has its own unique - * name, which is mostly used for user interface purposes. - * - * @return The client name. The string is read-only and is valid until the - * mpv_handle is destroyed. - */ -const char *mpv_client_name(mpv_handle *ctx); - -/** - * Create a new mpv instance and an associated client API handle to control - * the mpv instance. This instance is in a pre-initialized state, - * and needs to be initialized to be actually used with most other API - * functions. - * - * Some API functions will return MPV_ERROR_UNINITIALIZED in the uninitialized - * state. You can call mpv_set_property() (or mpv_set_property_string() and - * other variants, and before mpv 0.21.0 mpv_set_option() etc.) to set initial - * options. After this, call mpv_initialize() to start the player, and then use - * e.g. mpv_command() to start playback of a file. - * - * The point of separating handle creation and actual initialization is that - * you can configure things which can't be changed during runtime. - * - * Unlike the command line player, this will have initial settings suitable - * for embedding in applications. The following settings are different: - * - stdin/stdout/stderr and the terminal will never be accessed. This is - * equivalent to setting the --no-terminal option. - * (Technically, this also suppresses C signal handling.) - * - No config files will be loaded. This is roughly equivalent to using - * --config=no. Since libmpv 1.15, you can actually re-enable this option, - * which will make libmpv load config files during mpv_initialize(). If you - * do this, you are strongly encouraged to set the "config-dir" option too. - * (Otherwise it will load the mpv command line player's config.) - * For example: - * mpv_set_option_string(mpv, "config-dir", "/my/path"); // set config root - * mpv_set_option_string(mpv, "config", "yes"); // enable config loading - * (call mpv_initialize() _after_ this) - * - Idle mode is enabled, which means the playback core will enter idle mode - * if there are no more files to play on the internal playlist, instead of - * exiting. This is equivalent to the --idle option. - * - Disable parts of input handling. - * - Most of the different settings can be viewed with the command line player - * by running "mpv --show-profile=libmpv". - * - * All this assumes that API users want a mpv instance that is strictly - * isolated from the command line player's configuration, user settings, and - * so on. You can re-enable disabled features by setting the appropriate - * options. - * - * The mpv command line parser is not available through this API, but you can - * set individual options with mpv_set_property(). Files for playback must be - * loaded with mpv_command() or others. - * - * Note that you should avoid doing concurrent accesses on the uninitialized - * client handle. (Whether concurrent access is definitely allowed or not has - * yet to be decided.) - * - * @return a new mpv client API handle. Returns NULL on error. Currently, this - * can happen in the following situations: - * - out of memory - * - LC_NUMERIC is not set to "C" (see general remarks) - */ -mpv_handle *mpv_create(void); - -/** - * Initialize an uninitialized mpv instance. If the mpv instance is already - * running, an error is retuned. - * - * This function needs to be called to make full use of the client API if the - * client API handle was created with mpv_create(). - * - * Only the following options require to be set _before_ mpv_initialize(): - * - options which are only read at initialization time: - * - config - * - config-dir - * - input-conf - * - load-scripts - * - script - * - player-operation-mode - * - input-app-events (OSX) - * - all encoding mode options - * - * @return error code - */ -int mpv_initialize(mpv_handle *ctx); - -/** - * Disconnect and destroy the mpv_handle. ctx will be deallocated with this - * API call. - * - * If the last mpv_handle is detached, the core player is destroyed. In - * addition, if there are only weak mpv_handles (such as created by - * mpv_create_weak_client() or internal scripts), these mpv_handles will - * be sent MPV_EVENT_SHUTDOWN. This function may block until these clients - * have responded to the shutdown event, and the core is finally destroyed. - */ -void mpv_destroy(mpv_handle *ctx); - -#if MPV_ENABLE_DEPRECATED -/** - * @deprecated use mpv_destroy(), which has exactly the same semantics (the - * deprecation is a mere rename) - * - * Since mpv client API version 1.29: - * If the last mpv_handle is detached, the core player is destroyed. In - * addition, if there are only weak mpv_handles (such as created by - * mpv_create_weak_client() or internal scripts), these mpv_handles will - * be sent MPV_EVENT_SHUTDOWN. This function may block until these clients - * have responded to the shutdown event, and the core is finally destroyed. - * - * Before mpv client API version 1.29: - * This left the player running. If you want to be sure that the - * player is terminated, send a "quit" command, and wait until the - * MPV_EVENT_SHUTDOWN event is received, or use mpv_terminate_destroy(). - */ -void mpv_detach_destroy(mpv_handle *ctx); -#endif - -/** - * Similar to mpv_destroy(), but brings the player and all clients down - * as well, and waits until all of them are destroyed. This function blocks. The - * advantage over mpv_destroy() is that while mpv_destroy() merely - * detaches the client handle from the player, this function quits the player, - * waits until all other clients are destroyed (i.e. all mpv_handles are - * detached), and also waits for the final termination of the player. - * - * Since mpv_destroy() is called somewhere on the way, it's not safe to - * call other functions concurrently on the same context. - * - * Since mpv client API version 1.29: - * The first call on any mpv_handle will block until the core is destroyed. - * This means it will wait until other mpv_handle have been destroyed. If you - * want asynchronous destruction, just run the "quit" command, and then react - * to the MPV_EVENT_SHUTDOWN event. - * If another mpv_handle already called mpv_terminate_destroy(), this call will - * not actually block. It will destroy the mpv_handle, and exit immediately, - * while other mpv_handles might still be uninitializing. - * - * Before mpv client API version 1.29: - * If this is called on a mpv_handle that was not created with mpv_create(), - * this function will merely send a quit command and then call - * mpv_destroy(), without waiting for the actual shutdown. - */ -void mpv_terminate_destroy(mpv_handle *ctx); - -/** - * Create a new client handle connected to the same player core as ctx. This - * context has its own event queue, its own mpv_request_event() state, its own - * mpv_request_log_messages() state, its own set of observed properties, and - * its own state for asynchronous operations. Otherwise, everything is shared. - * - * This handle should be destroyed with mpv_destroy() if no longer - * needed. The core will live as long as there is at least 1 handle referencing - * it. Any handle can make the core quit, which will result in every handle - * receiving MPV_EVENT_SHUTDOWN. - * - * This function can not be called before the main handle was initialized with - * mpv_initialize(). The new handle is always initialized, unless ctx=NULL was - * passed. - * - * @param ctx Used to get the reference to the mpv core; handle-specific - * settings and parameters are not used. - * If NULL, this function behaves like mpv_create() (ignores name). - * @param name The client name. This will be returned by mpv_client_name(). If - * the name is already in use, or contains non-alphanumeric - * characters (other than '_'), the name is modified to fit. - * If NULL, an arbitrary name is automatically chosen. - * @return a new handle, or NULL on error - */ -mpv_handle *mpv_create_client(mpv_handle *ctx, const char *name); - -/** - * This is the same as mpv_create_client(), but the created mpv_handle is - * treated as a weak reference. If all mpv_handles referencing a core are - * weak references, the core is automatically destroyed. (This still goes - * through normal uninit of course. Effectively, if the last non-weak mpv_handle - * is destroyed, then the weak mpv_handles receive MPV_EVENT_SHUTDOWN and are - * asked to terminate as well.) - * - * Note if you want to use this like refcounting: you have to be aware that - * mpv_terminate_destroy() _and_ mpv_destroy() for the last non-weak - * mpv_handle will block until all weak mpv_handles are destroyed. - */ -mpv_handle *mpv_create_weak_client(mpv_handle *ctx, const char *name); - -/** - * Load a config file. This loads and parses the file, and sets every entry in - * the config file's default section as if mpv_set_option_string() is called. - * - * The filename should be an absolute path. If it isn't, the actual path used - * is unspecified. (Note: an absolute path starts with '/' on UNIX.) If the - * file wasn't found, MPV_ERROR_INVALID_PARAMETER is returned. - * - * If a fatal error happens when parsing a config file, MPV_ERROR_OPTION_ERROR - * is returned. Errors when setting options as well as other types or errors - * are ignored (even if options do not exist). You can still try to capture - * the resulting error messages with mpv_request_log_messages(). Note that it's - * possible that some options were successfully set even if any of these errors - * happen. - * - * @param filename absolute path to the config file on the local filesystem - * @return error code - */ -int mpv_load_config_file(mpv_handle *ctx, const char *filename); - -#if MPV_ENABLE_DEPRECATED - -/** - * This does nothing since mpv 0.23.0 (API version 1.24). Below is the - * description of the old behavior. - * - * Stop the playback thread. This means the core will stop doing anything, and - * only run and answer to client API requests. This is sometimes useful; for - * example, no new frame will be queued to the video output, so doing requests - * which have to wait on the video output can run instantly. - * - * Suspension is reentrant and recursive for convenience. Any thread can call - * the suspend function multiple times, and the playback thread will remain - * suspended until the last thread resumes it. Note that during suspension, all - * clients still have concurrent access to the core, which is serialized through - * a single mutex. - * - * Call mpv_resume() to resume the playback thread. You must call mpv_resume() - * for each mpv_suspend() call. Calling mpv_resume() more often than - * mpv_suspend() is not allowed. - * - * Calling this on an uninitialized player (see mpv_create()) will deadlock. - * - * @deprecated This function, as well as mpv_resume(), are deprecated, and - * will stop doing anything soon. Their semantics were never - * well-defined, and their usefulness is extremely limited. The - * calls will remain stubs in order to keep ABI compatibility. - */ -void mpv_suspend(mpv_handle *ctx); - -/** - * See mpv_suspend(). - */ -void mpv_resume(mpv_handle *ctx); - -#endif - -/** - * Return the internal time in microseconds. This has an arbitrary start offset, - * but will never wrap or go backwards. - * - * Note that this is always the real time, and doesn't necessarily have to do - * with playback time. For example, playback could go faster or slower due to - * playback speed, or due to playback being paused. Use the "time-pos" property - * instead to get the playback status. - * - * Unlike other libmpv APIs, this can be called at absolutely any time (even - * within wakeup callbacks), as long as the context is valid. - * - * Safe to be called from mpv render API threads. - */ -int64_t mpv_get_time_us(mpv_handle *ctx); - -/** - * Data format for options and properties. The API functions to get/set - * properties and options support multiple formats, and this enum describes - * them. - */ -typedef enum mpv_format { - /** - * Invalid. Sometimes used for empty values. - */ - MPV_FORMAT_NONE = 0, - /** - * The basic type is char*. It returns the raw property string, like - * using ${=property} in input.conf (see input.rst). - * - * NULL isn't an allowed value. - * - * Warning: although the encoding is usually UTF-8, this is not always the - * case. File tags often store strings in some legacy codepage, - * and even filenames don't necessarily have to be in UTF-8 (at - * least on Linux). If you pass the strings to code that requires - * valid UTF-8, you have to sanitize it in some way. - * On Windows, filenames are always UTF-8, and libmpv converts - * between UTF-8 and UTF-16 when using win32 API functions. See - * the "Encoding of filenames" section for details. - * - * Example for reading: - * - * char *result = NULL; - * if (mpv_get_property(ctx, "property", MPV_FORMAT_STRING, &result) < 0) - * goto error; - * printf("%s\n", result); - * mpv_free(result); - * - * Or just use mpv_get_property_string(). - * - * Example for writing: - * - * char *value = "the new value"; - * // yep, you pass the address to the variable - * // (needed for symmetry with other types and mpv_get_property) - * mpv_set_property(ctx, "property", MPV_FORMAT_STRING, &value); - * - * Or just use mpv_set_property_string(). - * - */ - MPV_FORMAT_STRING = 1, - /** - * The basic type is char*. It returns the OSD property string, like - * using ${property} in input.conf (see input.rst). In many cases, this - * is the same as the raw string, but in other cases it's formatted for - * display on OSD. It's intended to be human readable. Do not attempt to - * parse these strings. - * - * Only valid when doing read access. The rest works like MPV_FORMAT_STRING. - */ - MPV_FORMAT_OSD_STRING = 2, - /** - * The basic type is int. The only allowed values are 0 ("no") - * and 1 ("yes"). - * - * Example for reading: - * - * int result; - * if (mpv_get_property(ctx, "property", MPV_FORMAT_FLAG, &result) < 0) - * goto error; - * printf("%s\n", result ? "true" : "false"); - * - * Example for writing: - * - * int flag = 1; - * mpv_set_property(ctx, "property", MPV_FORMAT_FLAG, &flag); - */ - MPV_FORMAT_FLAG = 3, - /** - * The basic type is int64_t. - */ - MPV_FORMAT_INT64 = 4, - /** - * The basic type is double. - */ - MPV_FORMAT_DOUBLE = 5, - /** - * The type is mpv_node. - * - * For reading, you usually would pass a pointer to a stack-allocated - * mpv_node value to mpv, and when you're done you call - * mpv_free_node_contents(&node). - * You're expected not to write to the data - if you have to, copy it - * first (which you have to do manually). - * - * For writing, you construct your own mpv_node, and pass a pointer to the - * API. The API will never write to your data (and copy it if needed), so - * you're free to use any form of allocation or memory management you like. - * - * Warning: when reading, always check the mpv_node.format member. For - * example, properties might change their type in future versions - * of mpv, or sometimes even during runtime. - * - * Example for reading: - * - * mpv_node result; - * if (mpv_get_property(ctx, "property", MPV_FORMAT_NODE, &result) < 0) - * goto error; - * printf("format=%d\n", (int)result.format); - * mpv_free_node_contents(&result). - * - * Example for writing: - * - * mpv_node value; - * value.format = MPV_FORMAT_STRING; - * value.u.string = "hello"; - * mpv_set_property(ctx, "property", MPV_FORMAT_NODE, &value); - */ - MPV_FORMAT_NODE = 6, - /** - * Used with mpv_node only. Can usually not be used directly. - */ - MPV_FORMAT_NODE_ARRAY = 7, - /** - * See MPV_FORMAT_NODE_ARRAY. - */ - MPV_FORMAT_NODE_MAP = 8, - /** - * A raw, untyped byte array. Only used only with mpv_node, and only in - * some very special situations. (Currently, only for the screenshot-raw - * command.) - */ - MPV_FORMAT_BYTE_ARRAY = 9 -} mpv_format; - -/** - * Generic data storage. - * - * If mpv writes this struct (e.g. via mpv_get_property()), you must not change - * the data. In some cases (mpv_get_property()), you have to free it with - * mpv_free_node_contents(). If you fill this struct yourself, you're also - * responsible for freeing it, and you must not call mpv_free_node_contents(). - */ -typedef struct mpv_node { - union { - char *string; /** valid if format==MPV_FORMAT_STRING */ - int flag; /** valid if format==MPV_FORMAT_FLAG */ - int64_t int64; /** valid if format==MPV_FORMAT_INT64 */ - double double_; /** valid if format==MPV_FORMAT_DOUBLE */ - /** - * valid if format==MPV_FORMAT_NODE_ARRAY - * or if format==MPV_FORMAT_NODE_MAP - */ - struct mpv_node_list *list; - /** - * valid if format==MPV_FORMAT_BYTE_ARRAY - */ - struct mpv_byte_array *ba; - } u; - /** - * Type of the data stored in this struct. This value rules what members in - * the given union can be accessed. The following formats are currently - * defined to be allowed in mpv_node: - * - * MPV_FORMAT_STRING (u.string) - * MPV_FORMAT_FLAG (u.flag) - * MPV_FORMAT_INT64 (u.int64) - * MPV_FORMAT_DOUBLE (u.double_) - * MPV_FORMAT_NODE_ARRAY (u.list) - * MPV_FORMAT_NODE_MAP (u.list) - * MPV_FORMAT_BYTE_ARRAY (u.ba) - * MPV_FORMAT_NONE (no member) - * - * If you encounter a value you don't know, you must not make any - * assumptions about the contents of union u. - */ - mpv_format format; -} mpv_node; - -/** - * (see mpv_node) - */ -typedef struct mpv_node_list { - /** - * Number of entries. Negative values are not allowed. - */ - int num; - /** - * MPV_FORMAT_NODE_ARRAY: - * values[N] refers to value of the Nth item - * - * MPV_FORMAT_NODE_MAP: - * values[N] refers to value of the Nth key/value pair - * - * If num > 0, values[0] to values[num-1] (inclusive) are valid. - * Otherwise, this can be NULL. - */ - mpv_node *values; - /** - * MPV_FORMAT_NODE_ARRAY: - * unused (typically NULL), access is not allowed - * - * MPV_FORMAT_NODE_MAP: - * keys[N] refers to key of the Nth key/value pair. If num > 0, keys[0] to - * keys[num-1] (inclusive) are valid. Otherwise, this can be NULL. - * The keys are in random order. The only guarantee is that keys[N] belongs - * to the value values[N]. NULL keys are not allowed. - */ - char **keys; -} mpv_node_list; - -/** - * (see mpv_node) - */ -typedef struct mpv_byte_array { - /** - * Pointer to the data. In what format the data is stored is up to whatever - * uses MPV_FORMAT_BYTE_ARRAY. - */ - void *data; - /** - * Size of the data pointed to by ptr. - */ - size_t size; -} mpv_byte_array; - -/** - * Frees any data referenced by the node. It doesn't free the node itself. - * Call this only if the mpv client API set the node. If you constructed the - * node yourself (manually), you have to free it yourself. - * - * If node->format is MPV_FORMAT_NONE, this call does nothing. Likewise, if - * the client API sets a node with this format, this function doesn't need to - * be called. (This is just a clarification that there's no danger of anything - * strange happening in these cases.) - */ -void mpv_free_node_contents(mpv_node *node); - -/** - * Set an option. Note that you can't normally set options during runtime. It - * works in uninitialized state (see mpv_create()), and in some cases in at - * runtime. - * - * Using a format other than MPV_FORMAT_NODE is equivalent to constructing a - * mpv_node with the given format and data, and passing the mpv_node to this - * function. - * - * Note: this is semi-deprecated. For most purposes, this is not needed anymore. - * Starting with mpv version 0.21.0 (version 1.23) most options can be set - * with mpv_set_property() (and related functions), and even before - * mpv_initialize(). In some obscure corner cases, using this function - * to set options might still be required (see below, and also section - * "Inconsistencies between options and properties" on the manpage). Once - * these are resolved, the option setting functions might be fully - * deprecated. - * - * The following options still need to be set either _before_ - * mpv_initialize() with mpv_set_property() (or related functions), or - * with mpv_set_option() (or related functions) at any time: - * - options shadowed by deprecated properties: - * - demuxer (property deprecated in 0.21.0) - * - idle (property deprecated in 0.21.0) - * - fps (property deprecated in 0.21.0) - * - cache (property deprecated in 0.21.0) - * - length (property deprecated in 0.10.0) - * - audio-samplerate (property deprecated in 0.10.0) - * - audio-channels (property deprecated in 0.10.0) - * - audio-format (property deprecated in 0.10.0) - * - deprecated options shadowed by properties: - * - chapter (option deprecated in 0.21.0) - * - playlist-pos (option deprecated in 0.21.0) - * The deprecated properties were removed in mpv 0.23.0. - * - * @param name Option name. This is the same as on the mpv command line, but - * without the leading "--". - * @param format see enum mpv_format. - * @param[in] data Option value (according to the format). - * @return error code - */ -int mpv_set_option(mpv_handle *ctx, const char *name, mpv_format format, - void *data); - -/** - * Convenience function to set an option to a string value. This is like - * calling mpv_set_option() with MPV_FORMAT_STRING. - * - * @return error code - */ -int mpv_set_option_string(mpv_handle *ctx, const char *name, const char *data); - -/** - * Send a command to the player. Commands are the same as those used in - * input.conf, except that this function takes parameters in a pre-split - * form. - * - * The commands and their parameters are documented in input.rst. - * - * Does not use OSD and string expansion by default (unlike mpv_command_string() - * and input.conf). - * - * @param[in] args NULL-terminated list of strings. Usually, the first item - * is the command, and the following items are arguments. - * @return error code - */ -int mpv_command(mpv_handle *ctx, const char **args); - -/** - * Same as mpv_command(), but allows passing structured data in any format. - * In particular, calling mpv_command() is exactly like calling - * mpv_command_node() with the format set to MPV_FORMAT_NODE_ARRAY, and - * every arg passed in order as MPV_FORMAT_STRING. - * - * Does not use OSD and string expansion by default. - * - * @param[in] args mpv_node with format set to MPV_FORMAT_NODE_ARRAY; each entry - * is an argument using an arbitrary format (the format must be - * compatible to the used command). Usually, the first item is - * the command name (as MPV_FORMAT_STRING). - * @param[out] result Optional, pass NULL if unused. If not NULL, and if the - * function succeeds, this is set to command-specific return - * data. You must call mpv_free_node_contents() to free it - * (again, only if the command actually succeeds). - * Not many commands actually use this at all. - * @return error code (the result parameter is not set on error) - */ -int mpv_command_node(mpv_handle *ctx, mpv_node *args, mpv_node *result); - -/** - * Same as mpv_command, but use input.conf parsing for splitting arguments. - * This is slightly simpler, but also more error prone, since arguments may - * need quoting/escaping. - * - * This also has OSD and string expansion enabled by default. - */ -int mpv_command_string(mpv_handle *ctx, const char *args); - -/** - * Same as mpv_command, but run the command asynchronously. - * - * Commands are executed asynchronously. You will receive a - * MPV_EVENT_COMMAND_REPLY event. (This event will also have an - * error code set if running the command failed.) - * - * This has nothing to do with the "async" command prefix, although they might - * be unified in the future. For now, calling this API means that the command - * will be synchronously executed on the core, without blocking the API user. - * - * * Safe to be called from mpv render API threads. - * - * @param reply_userdata the value mpv_event.reply_userdata of the reply will - * be set to (see section about asynchronous calls) - * @param args NULL-terminated list of strings (see mpv_command()) - * @return error code (if parsing or queuing the command fails) - */ -int mpv_command_async(mpv_handle *ctx, uint64_t reply_userdata, - const char **args); - -/** - * Same as mpv_command_node(), but run it asynchronously. Basically, this - * function is to mpv_command_node() what mpv_command_async() is to - * mpv_command(). - * - * See mpv_command_async() for details. Retrieving the result is not - * supported yet. - * - * Safe to be called from mpv render API threads. - * - * @param reply_userdata the value mpv_event.reply_userdata of the reply will - * be set to (see section about asynchronous calls) - * @param args as in mpv_command_node() - * @return error code (if parsing or queuing the command fails) - */ -int mpv_command_node_async(mpv_handle *ctx, uint64_t reply_userdata, - mpv_node *args); - -/** - * Set a property to a given value. Properties are essentially variables which - * can be queried or set at runtime. For example, writing to the pause property - * will actually pause or unpause playback. - * - * If the format doesn't match with the internal format of the property, access - * usually will fail with MPV_ERROR_PROPERTY_FORMAT. In some cases, the data - * is automatically converted and access succeeds. For example, MPV_FORMAT_INT64 - * is always converted to MPV_FORMAT_DOUBLE, and access using MPV_FORMAT_STRING - * usually invokes a string parser. The same happens when calling this function - * with MPV_FORMAT_NODE: the underlying format may be converted to another - * type if possible. - * - * Using a format other than MPV_FORMAT_NODE is equivalent to constructing a - * mpv_node with the given format and data, and passing the mpv_node to this - * function. (Before API version 1.21, this was different.) - * - * Note: starting with mpv 0.21.0 (client API version 1.23), this can be used to - * set options in general. It even can be used before mpv_initialize() - * has been called. If called before mpv_initialize(), setting properties - * not backed by options will result in MPV_ERROR_PROPERTY_UNAVAILABLE. - * In some cases, properties and options still conflict. In these cases, - * mpv_set_property() accesses the options before mpv_initialize(), and - * the properties after mpv_initialize(). These conflicts will be removed - * in mpv 0.23.0. See mpv_set_option() for further remarks. - * - * @param name The property name. See input.rst for a list of properties. - * @param format see enum mpv_format. - * @param[in] data Option value. - * @return error code - */ -int mpv_set_property(mpv_handle *ctx, const char *name, mpv_format format, - void *data); - -/** - * Convenience function to set a property to a string value. - * - * This is like calling mpv_set_property() with MPV_FORMAT_STRING. - */ -int mpv_set_property_string(mpv_handle *ctx, const char *name, const char *data); - -/** - * Set a property asynchronously. You will receive the result of the operation - * as MPV_EVENT_SET_PROPERTY_REPLY event. The mpv_event.error field will contain - * the result status of the operation. Otherwise, this function is similar to - * mpv_set_property(). - * - * Safe to be called from mpv render API threads. - * - * @param reply_userdata see section about asynchronous calls - * @param name The property name. - * @param format see enum mpv_format. - * @param[in] data Option value. The value will be copied by the function. It - * will never be modified by the client API. - * @return error code if sending the request failed - */ -int mpv_set_property_async(mpv_handle *ctx, uint64_t reply_userdata, - const char *name, mpv_format format, void *data); - -/** - * Read the value of the given property. - * - * If the format doesn't match with the internal format of the property, access - * usually will fail with MPV_ERROR_PROPERTY_FORMAT. In some cases, the data - * is automatically converted and access succeeds. For example, MPV_FORMAT_INT64 - * is always converted to MPV_FORMAT_DOUBLE, and access using MPV_FORMAT_STRING - * usually invokes a string formatter. - * - * @param name The property name. - * @param format see enum mpv_format. - * @param[out] data Pointer to the variable holding the option value. On - * success, the variable will be set to a copy of the option - * value. For formats that require dynamic memory allocation, - * you can free the value with mpv_free() (strings) or - * mpv_free_node_contents() (MPV_FORMAT_NODE). - * @return error code - */ -int mpv_get_property(mpv_handle *ctx, const char *name, mpv_format format, - void *data); - -/** - * Return the value of the property with the given name as string. This is - * equivalent to mpv_get_property() with MPV_FORMAT_STRING. - * - * See MPV_FORMAT_STRING for character encoding issues. - * - * On error, NULL is returned. Use mpv_get_property() if you want fine-grained - * error reporting. - * - * @param name The property name. - * @return Property value, or NULL if the property can't be retrieved. Free - * the string with mpv_free(). - */ -char *mpv_get_property_string(mpv_handle *ctx, const char *name); - -/** - * Return the property as "OSD" formatted string. This is the same as - * mpv_get_property_string, but using MPV_FORMAT_OSD_STRING. - * - * @return Property value, or NULL if the property can't be retrieved. Free - * the string with mpv_free(). - */ -char *mpv_get_property_osd_string(mpv_handle *ctx, const char *name); - -/** - * Get a property asynchronously. You will receive the result of the operation - * as well as the property data with the MPV_EVENT_GET_PROPERTY_REPLY event. - * You should check the mpv_event.error field on the reply event. - * - * Safe to be called from mpv render API threads. - * - * @param reply_userdata see section about asynchronous calls - * @param name The property name. - * @param format see enum mpv_format. - * @return error code if sending the request failed - */ -int mpv_get_property_async(mpv_handle *ctx, uint64_t reply_userdata, - const char *name, mpv_format format); - -/** - * Get a notification whenever the given property changes. You will receive - * updates as MPV_EVENT_PROPERTY_CHANGE. Note that this is not very precise: - * for some properties, it may not send updates even if the property changed. - * This depends on the property, and it's a valid feature request to ask for - * better update handling of a specific property. (For some properties, like - * ``clock``, which shows the wall clock, this mechanism doesn't make too - * much sense anyway.) - * - * Property changes are coalesced: the change events are returned only once the - * event queue becomes empty (e.g. mpv_wait_event() would block or return - * MPV_EVENT_NONE), and then only one event per changed property is returned. - * - * Normally, change events are sent only if the property value changes according - * to the requested format. mpv_event_property will contain the property value - * as data member. - * - * Warning: if a property is unavailable or retrieving it caused an error, - * MPV_FORMAT_NONE will be set in mpv_event_property, even if the - * format parameter was set to a different value. In this case, the - * mpv_event_property.data field is invalid. - * - * If the property is observed with the format parameter set to MPV_FORMAT_NONE, - * you get low-level notifications whether the property _may_ have changed, and - * the data member in mpv_event_property will be unset. With this mode, you - * will have to determine yourself whether the property really changd. On the - * other hand, this mechanism can be faster and uses less resources. - * - * Observing a property that doesn't exist is allowed. (Although it may still - * cause some sporadic change events.) - * - * Keep in mind that you will get change notifications even if you change a - * property yourself. Try to avoid endless feedback loops, which could happen - * if you react to the change notifications triggered by your own change. - * - * Only the mpv_handle on which this was called will receive the property - * change events, or can unobserve them. - * - * Safe to be called from mpv render API threads. - * - * @param reply_userdata This will be used for the mpv_event.reply_userdata - * field for the received MPV_EVENT_PROPERTY_CHANGE - * events. (Also see section about asynchronous calls, - * although this function is somewhat different from - * actual asynchronous calls.) - * If you have no use for this, pass 0. - * Also see mpv_unobserve_property(). - * @param name The property name. - * @param format see enum mpv_format. Can be MPV_FORMAT_NONE to omit values - * from the change events. - * @return error code (usually fails only on OOM or unsupported format) - */ -int mpv_observe_property(mpv_handle *mpv, uint64_t reply_userdata, - const char *name, mpv_format format); - -/** - * Undo mpv_observe_property(). This will remove all observed properties for - * which the given number was passed as reply_userdata to mpv_observe_property. - * - * Safe to be called from mpv render API threads. - * - * @param registered_reply_userdata ID that was passed to mpv_observe_property - * @return negative value is an error code, >=0 is number of removed properties - * on success (includes the case when 0 were removed) - */ -int mpv_unobserve_property(mpv_handle *mpv, uint64_t registered_reply_userdata); - -typedef enum mpv_event_id { - /** - * Nothing happened. Happens on timeouts or sporadic wakeups. - */ - MPV_EVENT_NONE = 0, - /** - * Happens when the player quits. The player enters a state where it tries - * to disconnect all clients. Most requests to the player will fail, and - * the client should react to this and quit with mpv_destroy() as soon as - * possible. - */ - MPV_EVENT_SHUTDOWN = 1, - /** - * See mpv_request_log_messages(). - */ - MPV_EVENT_LOG_MESSAGE = 2, - /** - * Reply to a mpv_get_property_async() request. - * See also mpv_event and mpv_event_property. - */ - MPV_EVENT_GET_PROPERTY_REPLY = 3, - /** - * Reply to a mpv_set_property_async() request. - * (Unlike MPV_EVENT_GET_PROPERTY, mpv_event_property is not used.) - */ - MPV_EVENT_SET_PROPERTY_REPLY = 4, - /** - * Reply to a mpv_command_async() request. - */ - MPV_EVENT_COMMAND_REPLY = 5, - /** - * Notification before playback start of a file (before the file is loaded). - */ - MPV_EVENT_START_FILE = 6, - /** - * Notification after playback end (after the file was unloaded). - * See also mpv_event and mpv_event_end_file. - */ - MPV_EVENT_END_FILE = 7, - /** - * Notification when the file has been loaded (headers were read etc.), and - * decoding starts. - */ - MPV_EVENT_FILE_LOADED = 8, -#if MPV_ENABLE_DEPRECATED - /** - * The list of video/audio/subtitle tracks was changed. (E.g. a new track - * was found. This doesn't necessarily indicate a track switch; for this, - * MPV_EVENT_TRACK_SWITCHED is used.) - * - * @deprecated This is equivalent to using mpv_observe_property() on the - * "track-list" property. The event is redundant, and might - * be removed in the far future. - */ - MPV_EVENT_TRACKS_CHANGED = 9, - /** - * A video/audio/subtitle track was switched on or off. - * - * @deprecated This is equivalent to using mpv_observe_property() on the - * "vid", "aid", and "sid" properties. The event is redundant, - * and might be removed in the far future. - */ - MPV_EVENT_TRACK_SWITCHED = 10, -#endif - /** - * Idle mode was entered. In this mode, no file is played, and the playback - * core waits for new commands. (The command line player normally quits - * instead of entering idle mode, unless --idle was specified. If mpv - * was started with mpv_create(), idle mode is enabled by default.) - */ - MPV_EVENT_IDLE = 11, -#if MPV_ENABLE_DEPRECATED - /** - * Playback was paused. This indicates the user pause state. - * - * The user pause state is the state the user requested (changed with the - * "pause" property). There is an internal pause state too, which is entered - * if e.g. the network is too slow (the "core-idle" property generally - * indicates whether the core is playing or waiting). - * - * This event is sent whenever any pause states change, not only the user - * state. You might get multiple events in a row while these states change - * independently. But the event ID sent always indicates the user pause - * state. - * - * If you don't want to deal with this, use mpv_observe_property() on the - * "pause" property and ignore MPV_EVENT_PAUSE/UNPAUSE. Likewise, the - * "core-idle" property tells you whether video is actually playing or not. - * - * @deprecated The event is redundant with mpv_observe_property() as - * mentioned above, and might be removed in the far future. - */ - MPV_EVENT_PAUSE = 12, - /** - * Playback was unpaused. See MPV_EVENT_PAUSE for not so obvious details. - * - * @deprecated The event is redundant with mpv_observe_property() as - * explained in the MPV_EVENT_PAUSE comments, and might be - * removed in the far future. - */ - MPV_EVENT_UNPAUSE = 13, -#endif - /** - * Sent every time after a video frame is displayed. Note that currently, - * this will be sent in lower frequency if there is no video, or playback - * is paused - but that will be removed in the future, and it will be - * restricted to video frames only. - */ - MPV_EVENT_TICK = 14, -#if MPV_ENABLE_DEPRECATED - /** - * @deprecated This was used internally with the internal "script_dispatch" - * command to dispatch keyboard and mouse input for the OSC. - * It was never useful in general and has been completely - * replaced with "script-binding". - * This event never happens anymore, and is included in this - * header only for compatibility. - */ - MPV_EVENT_SCRIPT_INPUT_DISPATCH = 15, -#endif - /** - * Triggered by the script-message input command. The command uses the - * first argument of the command as client name (see mpv_client_name()) to - * dispatch the message, and passes along all arguments starting from the - * second argument as strings. - * See also mpv_event and mpv_event_client_message. - */ - MPV_EVENT_CLIENT_MESSAGE = 16, - /** - * Happens after video changed in some way. This can happen on resolution - * changes, pixel format changes, or video filter changes. The event is - * sent after the video filters and the VO are reconfigured. Applications - * embedding a mpv window should listen to this event in order to resize - * the window if needed. - * Note that this event can happen sporadically, and you should check - * yourself whether the video parameters really changed before doing - * something expensive. - */ - MPV_EVENT_VIDEO_RECONFIG = 17, - /** - * Similar to MPV_EVENT_VIDEO_RECONFIG. This is relatively uninteresting, - * because there is no such thing as audio output embedding. - */ - MPV_EVENT_AUDIO_RECONFIG = 18, -#if MPV_ENABLE_DEPRECATED - /** - * Happens when metadata (like file tags) is possibly updated. (It's left - * unspecified whether this happens on file start or only when it changes - * within a file.) - * - * @deprecated This is equivalent to using mpv_observe_property() on the - * "metadata" property. The event is redundant, and might - * be removed in the far future. - */ - MPV_EVENT_METADATA_UPDATE = 19, -#endif - /** - * Happens when a seek was initiated. Playback stops. Usually it will - * resume with MPV_EVENT_PLAYBACK_RESTART as soon as the seek is finished. - */ - MPV_EVENT_SEEK = 20, - /** - * There was a discontinuity of some sort (like a seek), and playback - * was reinitialized. Usually happens after seeking, or ordered chapter - * segment switches. The main purpose is allowing the client to detect - * when a seek request is finished. - */ - MPV_EVENT_PLAYBACK_RESTART = 21, - /** - * Event sent due to mpv_observe_property(). - * See also mpv_event and mpv_event_property. - */ - MPV_EVENT_PROPERTY_CHANGE = 22, -#if MPV_ENABLE_DEPRECATED - /** - * Happens when the current chapter changes. - * - * @deprecated This is equivalent to using mpv_observe_property() on the - * "chapter" property. The event is redundant, and might - * be removed in the far future. - */ - MPV_EVENT_CHAPTER_CHANGE = 23, -#endif - /** - * Happens if the internal per-mpv_handle ringbuffer overflows, and at - * least 1 event had to be dropped. This can happen if the client doesn't - * read the event queue quickly enough with mpv_wait_event(), or if the - * client makes a very large number of asynchronous calls at once. - * - * Event delivery will continue normally once this event was returned - * (this forces the client to empty the queue completely). - */ - MPV_EVENT_QUEUE_OVERFLOW = 24, - /** - * Triggered if a hook handler was registered with mpv_hook_add(), and the - * hook is invoked. If you receive this, you must handle it, and continue - * the hook with mpv_hook_continue(). - * See also mpv_event and mpv_event_hook. - */ - MPV_EVENT_HOOK = 25, - // Internal note: adjust INTERNAL_EVENT_BASE when adding new events. -} mpv_event_id; - -/** - * Return a string describing the event. For unknown events, NULL is returned. - * - * Note that all events actually returned by the API will also yield a non-NULL - * string with this function. - * - * @param event event ID, see see enum mpv_event_id - * @return A static string giving a short symbolic name of the event. It - * consists of lower-case alphanumeric characters and can include "-" - * characters. This string is suitable for use in e.g. scripting - * interfaces. - * The string is completely static, i.e. doesn't need to be deallocated, - * and is valid forever. - */ -const char *mpv_event_name(mpv_event_id event); - -typedef struct mpv_event_property { - /** - * Name of the property. - */ - const char *name; - /** - * Format of the data field in the same struct. See enum mpv_format. - * This is always the same format as the requested format, except when - * the property could not be retrieved (unavailable, or an error happened), - * in which case the format is MPV_FORMAT_NONE. - */ - mpv_format format; - /** - * Received property value. Depends on the format. This is like the - * pointer argument passed to mpv_get_property(). - * - * For example, for MPV_FORMAT_STRING you get the string with: - * - * char *value = *(char **)(event_property->data); - * - * Note that this is set to NULL if retrieving the property failed (the - * format will be MPV_FORMAT_NONE). - * See mpv_event.error for the status. - */ - void *data; -} mpv_event_property; - -/** - * Numeric log levels. The lower the number, the more important the message is. - * MPV_LOG_LEVEL_NONE is never used when receiving messages. The string in - * the comment after the value is the name of the log level as used for the - * mpv_request_log_messages() function. - * Unused numeric values are unused, but reserved for future use. - */ -typedef enum mpv_log_level { - MPV_LOG_LEVEL_NONE = 0, /// "no" - disable absolutely all messages - MPV_LOG_LEVEL_FATAL = 10, /// "fatal" - critical/aborting errors - MPV_LOG_LEVEL_ERROR = 20, /// "error" - simple errors - MPV_LOG_LEVEL_WARN = 30, /// "warn" - possible problems - MPV_LOG_LEVEL_INFO = 40, /// "info" - informational message - MPV_LOG_LEVEL_V = 50, /// "v" - noisy informational message - MPV_LOG_LEVEL_DEBUG = 60, /// "debug" - very noisy technical information - MPV_LOG_LEVEL_TRACE = 70, /// "trace" - extremely noisy -} mpv_log_level; - -typedef struct mpv_event_log_message { - /** - * The module prefix, identifies the sender of the message. As a special - * case, if the message buffer overflows, this will be set to the string - * "overflow" (which doesn't appear as prefix otherwise), and the text - * field will contain an informative message. - */ - const char *prefix; - /** - * The log level as string. See mpv_request_log_messages() for possible - * values. The level "no" is never used here. - */ - const char *level; - /** - * The log message. It consists of 1 line of text, and is terminated with - * a newline character. (Before API version 1.6, it could contain multiple - * or partial lines.) - */ - const char *text; - /** - * The same contents as the level field, but as a numeric ID. - * Since API version 1.6. - */ - mpv_log_level log_level; -} mpv_event_log_message; - -/// Since API version 1.9. -typedef enum mpv_end_file_reason { - /** - * The end of file was reached. Sometimes this may also happen on - * incomplete or corrupted files, or if the network connection was - * interrupted when playing a remote file. It also happens if the - * playback range was restricted with --end or --frames or similar. - */ - MPV_END_FILE_REASON_EOF = 0, - /** - * Playback was stopped by an external action (e.g. playlist controls). - */ - MPV_END_FILE_REASON_STOP = 2, - /** - * Playback was stopped by the quit command or player shutdown. - */ - MPV_END_FILE_REASON_QUIT = 3, - /** - * Some kind of error happened that lead to playback abort. Does not - * necessarily happen on incomplete or broken files (in these cases, both - * MPV_END_FILE_REASON_ERROR or MPV_END_FILE_REASON_EOF are possible). - * - * mpv_event_end_file.error will be set. - */ - MPV_END_FILE_REASON_ERROR = 4, - /** - * The file was a playlist or similar. When the playlist is read, its - * entries will be appended to the playlist after the entry of the current - * file, the entry of the current file is removed, and a MPV_EVENT_END_FILE - * event is sent with reason set to MPV_END_FILE_REASON_REDIRECT. Then - * playback continues with the playlist contents. - * Since API version 1.18. - */ - MPV_END_FILE_REASON_REDIRECT = 5, -} mpv_end_file_reason; - -typedef struct mpv_event_end_file { - /** - * Corresponds to the values in enum mpv_end_file_reason (the "int" type - * will be replaced with mpv_end_file_reason on the next ABI bump). - * - * Unknown values should be treated as unknown. - */ - int reason; - /** - * If reason==MPV_END_FILE_REASON_ERROR, this contains a mpv error code - * (one of MPV_ERROR_...) giving an approximate reason why playback - * failed. In other cases, this field is 0 (no error). - * Since API version 1.9. - */ - int error; -} mpv_event_end_file; - -#if MPV_ENABLE_DEPRECATED -/** @deprecated see MPV_EVENT_SCRIPT_INPUT_DISPATCH for remarks - */ -typedef struct mpv_event_script_input_dispatch { - int arg0; - const char *type; -} mpv_event_script_input_dispatch; -#endif - -typedef struct mpv_event_client_message { - /** - * Arbitrary arguments chosen by the sender of the message. If num_args > 0, - * you can access args[0] through args[num_args - 1] (inclusive). What - * these arguments mean is up to the sender and receiver. - * None of the valid items are NULL. - */ - int num_args; - const char **args; -} mpv_event_client_message; - -typedef struct mpv_event_hook { - /** - * The hook name as passed to mpv_hook_add(). - */ - const char *name; - /** - * Internal ID that must be passed to mpv_hook_continue(). - */ - uint64_t id; -} mpv_event_hook; - -typedef struct mpv_event { - /** - * One of mpv_event. Keep in mind that later ABI compatible releases might - * add new event types. These should be ignored by the API user. - */ - mpv_event_id event_id; - /** - * This is mainly used for events that are replies to (asynchronous) - * requests. It contains a status code, which is >= 0 on success, or < 0 - * on error (a mpv_error value). Usually, this will be set if an - * asynchronous request fails. - * Used for: - * MPV_EVENT_GET_PROPERTY_REPLY - * MPV_EVENT_SET_PROPERTY_REPLY - * MPV_EVENT_COMMAND_REPLY - */ - int error; - /** - * If the event is in reply to a request (made with this API and this - * API handle), this is set to the reply_userdata parameter of the request - * call. Otherwise, this field is 0. - * Used for: - * MPV_EVENT_GET_PROPERTY_REPLY - * MPV_EVENT_SET_PROPERTY_REPLY - * MPV_EVENT_COMMAND_REPLY - * MPV_EVENT_PROPERTY_CHANGE - */ - uint64_t reply_userdata; - /** - * The meaning and contents of the data member depend on the event_id: - * MPV_EVENT_GET_PROPERTY_REPLY: mpv_event_property* - * MPV_EVENT_PROPERTY_CHANGE: mpv_event_property* - * MPV_EVENT_LOG_MESSAGE: mpv_event_log_message* - * MPV_EVENT_CLIENT_MESSAGE: mpv_event_client_message* - * MPV_EVENT_END_FILE: mpv_event_end_file* - * other: NULL - * - * Note: future enhancements might add new event structs for existing or new - * event types. - */ - void *data; -} mpv_event; - -/** - * Enable or disable the given event. - * - * Some events are enabled by default. Some events can't be disabled. - * - * (Informational note: currently, all events are enabled by default, except - * MPV_EVENT_TICK.) - * - * Safe to be called from mpv render API threads. - * - * @param event See enum mpv_event_id. - * @param enable 1 to enable receiving this event, 0 to disable it. - * @return error code - */ -int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable); - -/** - * Enable or disable receiving of log messages. These are the messages the - * command line player prints to the terminal. This call sets the minimum - * required log level for a message to be received with MPV_EVENT_LOG_MESSAGE. - * - * @param min_level Minimal log level as string. Valid log levels: - * no fatal error warn info v debug trace - * The value "no" disables all messages. This is the default. - * An exception is the value "terminal-default", which uses the - * log level as set by the "--msg-level" option. This works - * even if the terminal is disabled. (Since API version 1.19.) - * Also see mpv_log_level. - * @return error code - */ -int mpv_request_log_messages(mpv_handle *ctx, const char *min_level); - -/** - * Wait for the next event, or until the timeout expires, or if another thread - * makes a call to mpv_wakeup(). Passing 0 as timeout will never wait, and - * is suitable for polling. - * - * The internal event queue has a limited size (per client handle). If you - * don't empty the event queue quickly enough with mpv_wait_event(), it will - * overflow and silently discard further events. If this happens, making - * asynchronous requests will fail as well (with MPV_ERROR_EVENT_QUEUE_FULL). - * - * Only one thread is allowed to call this on the same mpv_handle at a time. - * The API won't complain if more than one thread calls this, but it will cause - * race conditions in the client when accessing the shared mpv_event struct. - * Note that most other API functions are not restricted by this, and no API - * function internally calls mpv_wait_event(). Additionally, concurrent calls - * to different mpv_handles are always safe. - * - * As long as the timeout is 0, this is safe to be called from mpv render API - * threads. - * - * @param timeout Timeout in seconds, after which the function returns even if - * no event was received. A MPV_EVENT_NONE is returned on - * timeout. A value of 0 will disable waiting. Negative values - * will wait with an infinite timeout. - * @return A struct containing the event ID and other data. The pointer (and - * fields in the struct) stay valid until the next mpv_wait_event() - * call, or until the mpv_handle is destroyed. You must not write to - * the struct, and all memory referenced by it will be automatically - * released by the API on the next mpv_wait_event() call, or when the - * context is destroyed. The return value is never NULL. - */ -mpv_event *mpv_wait_event(mpv_handle *ctx, double timeout); - -/** - * Interrupt the current mpv_wait_event() call. This will wake up the thread - * currently waiting in mpv_wait_event(). If no thread is waiting, the next - * mpv_wait_event() call will return immediately (this is to avoid lost - * wakeups). - * - * mpv_wait_event() will receive a MPV_EVENT_NONE if it's woken up due to - * this call. But note that this dummy event might be skipped if there are - * already other events queued. All what counts is that the waiting thread - * is woken up at all. - * - * Safe to be called from mpv render API threads. - */ -void mpv_wakeup(mpv_handle *ctx); - -/** - * Set a custom function that should be called when there are new events. Use - * this if blocking in mpv_wait_event() to wait for new events is not feasible. - * - * Keep in mind that the callback will be called from foreign threads. You - * must not make any assumptions of the environment, and you must return as - * soon as possible (i.e. no long blocking waits). Exiting the callback through - * any other means than a normal return is forbidden (no throwing exceptions, - * no longjmp() calls). You must not change any local thread state (such as - * the C floating point environment). - * - * You are not allowed to call any client API functions inside of the callback. - * In particular, you should not do any processing in the callback, but wake up - * another thread that does all the work. The callback is meant strictly for - * notification only, and is called from arbitrary core parts of the player, - * that make no considerations for reentrant API use or allowing the callee to - * spend a lot of time doing other things. Keep in mind that it's also possible - * that the callback is called from a thread while a mpv API function is called - * (i.e. it can be reentrant). - * - * In general, the client API expects you to call mpv_wait_event() to receive - * notifications, and the wakeup callback is merely a helper utility to make - * this easier in certain situations. Note that it's possible that there's - * only one wakeup callback invocation for multiple events. You should call - * mpv_wait_event() with no timeout until MPV_EVENT_NONE is reached, at which - * point the event queue is empty. - * - * If you actually want to do processing in a callback, spawn a thread that - * does nothing but call mpv_wait_event() in a loop and dispatches the result - * to a callback. - * - * Only one wakeup callback can be set. - * - * @param cb function that should be called if a wakeup is required - * @param d arbitrary userdata passed to cb - */ -void mpv_set_wakeup_callback(mpv_handle *ctx, void (*cb)(void *d), void *d); - -/** - * Block until all asynchronous requests are done. This affects functions like - * mpv_command_async(), which return immediately and return their result as - * events. - * - * This is a helper, and somewhat equivalent to calling mpv_wait_event() in a - * loop until all known asynchronous requests have sent their reply as event, - * except that the event queue is not emptied. - * - * In case you called mpv_suspend() before, this will also forcibly reset the - * suspend counter of the given handle. - */ -void mpv_wait_async_requests(mpv_handle *ctx); - -/** - * A hook is like a synchronous event that blocks the player. You register - * a hook handler with this function. You will get an event, which you need - * to handle, and once things are ready, you can let the player continue with - * mpv_hook_continue(). - * - * Currently, hooks can't be removed explicitly. But they will be implicitly - * removed if the mpv_handle it was registered with is destroyed. This also - * continues the hook if it was being handled by the destroyed mpv_handle (but - * this should be avoided, as it might mess up order of hook execution). - * - * Hook handlers are ordered globally by priority and order of registration. - * Handlers for the same hook with same priority are invoked in order of - * registration (the handler registered first is run first). Handlers with - * lower priority are run first (which seems backward). - * - * See the "Hooks" section in the manpage to see which hooks are currently - * defined. - * - * Some hooks might be reentrant (so you get multiple MPV_EVENT_HOOK for the - * same hook). If this can happen for a specific hook type, it will be - * explicitly documented in the manpage. - * - * Only the mpv_handle on which this was called will receive the hook events, - * or can "continue" them. - * - * @param reply_userdata This will be used for the mpv_event.reply_userdata - * field for the received MPV_EVENT_HOOK events. - * If you have no use for this, pass 0. - * @param name The hook name. This should be one of the documented names. But - * if the name is unknown, the hook event will simply be never - * raised. - * @param priority See remarks above. Use 0 as a neutral default. - * @return error code (usually fails only on OOM) - */ -int mpv_hook_add(mpv_handle *ctx, uint64_t reply_userdata, - const char *name, int priority); - -/** - * Respond to a MPV_EVENT_HOOK event. You must call this after you have handled - * the event. There is no way to "cancel" or "stop" the hook. - * - * Calling this will will typically unblock the player for whatever the hook - * is responsible for (e.g. for the "on_load" hook it lets it continue - * playback). - * - * It is explicitly undefined behavior to call this more than once for each - * MPV_EVENT_HOOK, to pass an incorrect ID, or to call this on a mpv_handle - * different from the one that registered the handler and received the event. - * - * @param id This must be the value of the mpv_event_hook.id field for the - * corresponding MPV_EVENT_HOOK. - * @return error code - */ -int mpv_hook_continue(mpv_handle *ctx, uint64_t id); - -#if MPV_ENABLE_DEPRECATED - -/** - * Return a UNIX file descriptor referring to the read end of a pipe. This - * pipe can be used to wake up a poll() based processing loop. The purpose of - * this function is very similar to mpv_set_wakeup_callback(), and provides - * a primitive mechanism to handle coordinating a foreign event loop and the - * libmpv event loop. The pipe is non-blocking. It's closed when the mpv_handle - * is destroyed. This function always returns the same value (on success). - * - * This is in fact implemented using the same underlying code as for - * mpv_set_wakeup_callback() (though they don't conflict), and it is as if each - * callback invocation writes a single 0 byte to the pipe. When the pipe - * becomes readable, the code calling poll() (or select()) on the pipe should - * read all contents of the pipe and then call mpv_wait_event(c, 0) until - * no new events are returned. The pipe contents do not matter and can just - * be discarded. There is not necessarily one byte per readable event in the - * pipe. For example, the pipes are non-blocking, and mpv won't block if the - * pipe is full. Pipes are normally limited to 4096 bytes, so if there are - * more than 4096 events, the number of readable bytes can not equal the number - * of events queued. Also, it's possible that mpv does not write to the pipe - * once it's guaranteed that the client was already signaled. See the example - * below how to do it correctly. - * - * Example: - * - * int pipefd = mpv_get_wakeup_pipe(mpv); - * if (pipefd < 0) - * error(); - * while (1) { - * struct pollfd pfds[1] = { - * { .fd = pipefd, .events = POLLIN }, - * }; - * // Wait until there are possibly new mpv events. - * poll(pfds, 1, -1); - * if (pfds[0].revents & POLLIN) { - * // Empty the pipe. Doing this before calling mpv_wait_event() - * // ensures that no wakeups are missed. It's not so important to - * // make sure the pipe is really empty (it will just cause some - * // additional wakeups in unlikely corner cases). - * char unused[256]; - * read(pipefd, unused, sizeof(unused)); - * while (1) { - * mpv_event *ev = mpv_wait_event(mpv, 0); - * // If MPV_EVENT_NONE is received, the event queue is empty. - * if (ev->event_id == MPV_EVENT_NONE) - * break; - * // Process the event. - * ... - * } - * } - * } - * - * @deprecated this function will be removed in the future. If you need this - * functionality, use mpv_set_wakeup_callback(), create a pipe - * manually, and call write() on your pipe in the callback. - * - * @return A UNIX FD of the read end of the wakeup pipe, or -1 on error. - * On MS Windows/MinGW, this will always return -1. - */ -int mpv_get_wakeup_pipe(mpv_handle *ctx); - -/** - * @deprecated use render.h - */ -typedef enum mpv_sub_api { - /** - * For using mpv's OpenGL renderer on an external OpenGL context. - * mpv_get_sub_api(MPV_SUB_API_OPENGL_CB) returns mpv_opengl_cb_context*. - * This context can be used with mpv_opengl_cb_* functions. - * Will return NULL if unavailable (if OpenGL support was not compiled in). - * See opengl_cb.h for details. - * - * @deprecated use render.h - */ - MPV_SUB_API_OPENGL_CB = 1 -} mpv_sub_api; - -/** - * This is used for additional APIs that are not strictly part of the core API. - * See the individual mpv_sub_api member values. - * - * @deprecated use render.h - */ -void *mpv_get_sub_api(mpv_handle *ctx, mpv_sub_api sub_api); - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/stremio-shell/deps/libmpv/include/mpv/mpv.def b/stremio-shell/deps/libmpv/include/mpv/mpv.def deleted file mode 100644 index b74378c..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/mpv.def +++ /dev/null @@ -1,58 +0,0 @@ -mpv_client_api_version -mpv_client_name -mpv_command -mpv_command_async -mpv_command_node -mpv_command_node_async -mpv_command_string -mpv_create -mpv_create_client -mpv_create_weak_client -mpv_destroy -mpv_detach_destroy -mpv_error_string -mpv_event_name -mpv_free -mpv_free_node_contents -mpv_get_property -mpv_get_property_async -mpv_get_property_osd_string -mpv_get_property_string -mpv_get_sub_api -mpv_get_time_us -mpv_get_wakeup_pipe -mpv_hook_add -mpv_hook_continue -mpv_initialize -mpv_load_config_file -mpv_observe_property -mpv_opengl_cb_draw -mpv_opengl_cb_init_gl -mpv_opengl_cb_report_flip -mpv_opengl_cb_render -mpv_opengl_cb_set_update_callback -mpv_opengl_cb_uninit_gl -mpv_render_context_create -mpv_render_context_free -mpv_render_context_get_info -mpv_render_context_render -mpv_render_context_report_swap -mpv_render_context_set_parameter -mpv_render_context_set_update_callback -mpv_render_context_update -mpv_request_event -mpv_request_log_messages -mpv_resume -mpv_set_option -mpv_set_option_string -mpv_set_property -mpv_set_property_async -mpv_set_property_string -mpv_set_wakeup_callback -mpv_stream_cb_add_ro -mpv_suspend -mpv_terminate_destroy -mpv_unobserve_property -mpv_wait_async_requests -mpv_wait_event -mpv_wakeup \ No newline at end of file diff --git a/stremio-shell/deps/libmpv/include/mpv/mpv.pc.in b/stremio-shell/deps/libmpv/include/mpv/mpv.pc.in deleted file mode 100644 index 5686343..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/mpv.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@PREFIX@ -exec_prefix=@PREFIX@ -libdir=@LIBDIR@ -includedir=@INCDIR@ - -Name: mpv -Description: mpv media player client library -Version: @VERSION@ -Requires: -Libs: -L${libdir} -lmpv -Libs.private: @PRIV_LIBS@ -Cflags: -I${includedir} diff --git a/stremio-shell/deps/libmpv/include/mpv/opengl_cb.h b/stremio-shell/deps/libmpv/include/mpv/opengl_cb.h deleted file mode 100644 index 6820681..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/opengl_cb.h +++ /dev/null @@ -1,339 +0,0 @@ -/* Copyright (C) 2017 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MPV_CLIENT_API_OPENGL_CB_H_ -#define MPV_CLIENT_API_OPENGL_CB_H_ - -#include "client.h" - -#if !MPV_ENABLE_DEPRECATED -#error "This header and all API provided by it is deprecated. Use render.h instead." -#else - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * - * Overview - * -------- - * - * Warning: this API is deprecated. A very similar API is provided by render.h - * and render_gl.h. The deprecated API is emulated with the new API. - * - * This API can be used to make mpv render into a foreign OpenGL context. It - * can be used to handle video display. - * - * The renderer needs to be explicitly initialized with mpv_opengl_cb_init_gl(), - * and then video can be drawn with mpv_opengl_cb_draw(). The user thread can - * be notified by new frames with mpv_opengl_cb_set_update_callback(). - * - * You can output and embed video without this API by setting the mpv "wid" - * option to a native window handle (see "Embedding the video window" section - * in the client.h header). In general, using the opengl-cb API is recommended, - * because window embedding can cause various issues, especially with GUI - * toolkits and certain platforms. - * - * OpenGL interop - * -------------- - * - * This assumes the OpenGL context lives on a certain thread controlled by the - * API user. The following functions require access to the OpenGL context: - * mpv_opengl_cb_init_gl - * mpv_opengl_cb_draw - * mpv_opengl_cb_uninit_gl - * - * The OpenGL context is indirectly accessed through the OpenGL function - * pointers returned by the get_proc_address callback in mpv_opengl_cb_init_gl. - * Generally, mpv will not load the system OpenGL library when using this API. - * - * Only "desktop" OpenGL version 2.1 and later and OpenGL ES version 2.0 and - * later are supported. With OpenGL 2.1, the GL_ARB_texture_rg is required. The - * renderer was written for the OpenGL 3.x core profile, with additional support - * for OpenGL 2.1 and OpenGL ES 2.0. - * - * Note that some hardware decoding interop API (as set with the "hwdec" option) - * may actually access some sort of host API, such as EGL. - * - * OpenGL state - * ------------ - * - * OpenGL has a large amount of implicit state. All the mpv functions mentioned - * above expect that the OpenGL state is reasonably set to OpenGL standard - * defaults. Likewise, mpv will attempt to leave the OpenGL context with - * standard defaults. The following state is excluded from this: - * - * - the glViewport state - * - the glScissor state (but GL_SCISSOR_TEST is in its default value) - * - glBlendFuncSeparate() state (but GL_BLEND is in its default value) - * - glClearColor() state - * - mpv may overwrite the callback set with glDebugMessageCallback() - * - mpv always disables GL_DITHER at init - * - * Messing with the state could be avoided by creating shared OpenGL contexts, - * but this is avoided for the sake of compatibility and interoperability. - * - * On OpenGL 2.1, mpv will strictly call functions like glGenTextures() to - * create OpenGL objects. You will have to do the same. This ensures that - * objects created by mpv and the API users don't clash. Also, legacy state - * must be either in its defaults, or not interfere with core state. - * - * Threading - * --------- - * - * The mpv_opengl_cb_* functions can be called from any thread, under the - * following conditions: - * - only one of the mpv_opengl_cb_* functions can be called at the same time - * (unless they belong to different mpv cores created by mpv_create()) - * - for functions which need an OpenGL context (see above) the OpenGL context - * must be "current" in the current thread, and it must be the same context - * as used with mpv_opengl_cb_init_gl() - * - never can be called from within the callbacks set with - * mpv_set_wakeup_callback() or mpv_opengl_cb_set_update_callback() - * - * Context and handle lifecycle - * ---------------------------- - * - * Video initialization will fail if the OpenGL context was not initialized yet - * (with mpv_opengl_cb_init_gl()). Likewise, mpv_opengl_cb_uninit_gl() will - * disable video. - * - * When the mpv core is destroyed (e.g. via mpv_terminate_destroy()), the OpenGL - * context must have been uninitialized. If this doesn't happen, undefined - * behavior will result. - * - * Hardware decoding - * ----------------- - * - * Hardware decoding via opengl_cb is fully supported, but requires some - * additional setup. (At least if direct hardware decoding modes are wanted, - * instead of copying back surface data from GPU to CPU RAM.) - * - * While "normal" mpv loads the OpenGL hardware decoding interop on demand, - * this can't be done with opengl_cb for internal technical reasons. Instead, - * it loads them by default, even if hardware decoding is not going to be used. - * In older mpv releases, this had to be done by setting the - * "opengl-hwdec-interop" or "hwdec-preload" options before calling - * mpv_opengl_cb_init_gl(). You can still use the newer "gpu-hwdec-interop" - * option to prevent loading of interop, or to load only a specific interop. - * - * There may be certain requirements on the OpenGL implementation: - * - Windows: ANGLE is required (although in theory GL/DX interop could be used) - * - Intel/Linux: EGL is required, and also a glMPGetNativeDisplay() callback - * must be provided (see sections below) - * - nVidia/Linux: Both GLX and EGL should work (GLX is required if vdpau is - * used, e.g. due to old drivers.) - * - OSX: CGL is required (CGLGetCurrentContext() returning non-NULL) - * - iOS: EAGL is required (EAGLContext.currentContext returning non-nil) - * - * Once these things are setup, hardware decoding can be enabled/disabled at - * any time by setting the "hwdec" property. - * - * Special windowing system interop considerations - * ------------------------------------------------ - * - * In some cases, libmpv needs to have access to the windowing system's handles. - * This can be a pointer to a X11 "Display" for example. Usually this is needed - * only for hardware decoding. - * - * You can communicate these handles to libmpv by adding a pseudo-OpenGL - * extension "GL_MP_MPGetNativeDisplay" to the additional extension string when - * calling mpv_opengl_cb_init_gl(). The get_proc_address callback should resolve - * a function named "glMPGetNativeDisplay", which has the signature: - * - * void* GLAPIENTRY glMPGetNativeDisplay(const char* name) - * - * See below what names are defined. Usually, libmpv will use the native handle - * up until mpv_opengl_cb_uninit_gl() is called. If the name is not anything - * you know/expected, return NULL from the function. - */ - -// Legacy - not supported anymore. -struct mpv_opengl_cb_window_pos { - int x; // left coordinates of window (usually 0) - int y; // top coordinates of window (usually 0) - int width; // width of GL window - int height; // height of GL window -}; - -// Legacy - not supported anymore. -struct mpv_opengl_cb_drm_params { - // DRM fd (int). set this to -1 if invalid. - int fd; - - // currently used crtc id - int crtc_id; - - // currently used connector id - int connector_id; - - // pointer to the drmModeAtomicReq that is being used for the renderloop. - // This atomic request pointer should be usually created at every renderloop. - struct _drmModeAtomicReq *atomic_request; -}; - -/** - * nVidia/Linux via VDPAU requires GLX, which does not have this problem (the - * GLX API can return the current X11 Display). - * - * Windowing system interop on MS win32 - * ------------------------------------ - * - * You should use ANGLE, and make sure your application and libmpv are linked - * to the same ANGLE DLLs. libmpv will pick the device context (needed for - * hardware decoding) from the current ANGLE EGL context. - */ - -/** - * Opaque context, returned by mpv_get_sub_api(MPV_SUB_API_OPENGL_CB). - * - * A context is bound to the mpv_handle it was retrieved from. The context - * will always be the same (for the same mpv_handle), and is valid until the - * mpv_handle it belongs to is released. - */ -typedef struct mpv_opengl_cb_context mpv_opengl_cb_context; - -typedef void (*mpv_opengl_cb_update_fn)(void *cb_ctx); -typedef void *(*mpv_opengl_cb_get_proc_address_fn)(void *fn_ctx, const char *name); - -/** - * Set the callback that notifies you when a new video frame is available, or - * if the video display configuration somehow changed and requires a redraw. - * Similar to mpv_set_wakeup_callback(), you must not call any mpv API from - * the callback, and all the other listed restrictions apply (such as not - * exiting the callback by throwing exceptions). - * - * @param callback callback(callback_ctx) is called if the frame should be - * redrawn - * @param callback_ctx opaque argument to the callback - */ -void mpv_opengl_cb_set_update_callback(mpv_opengl_cb_context *ctx, - mpv_opengl_cb_update_fn callback, - void *callback_ctx); - -/** - * Initialize the mpv OpenGL state. This retrieves OpenGL function pointers via - * get_proc_address, and creates OpenGL objects needed by mpv internally. It - * will also call APIs needed for rendering hardware decoded video in OpenGL, - * according to the mpv "hwdec" option. - * - * You must free the associated state at some point by calling the - * mpv_opengl_cb_uninit_gl() function. Not doing so may result in memory leaks - * or worse. - * - * @param exts optional _additional_ extension string, can be NULL - * @param get_proc_address callback used to retrieve function pointers to OpenGL - * functions. This is used for both standard functions - * and extension functions. (The extension string is - * checked whether extensions are really available.) - * The callback will be called from this function only - * (it is not stored and never used later). - * Usually, GL context APIs do this for you (e.g. with - * glXGetProcAddressARB or wglGetProcAddress), but - * some APIs do not always return pointers for all - * standard functions (even if present); in this case - * you have to compensate by looking up these functions - * yourself. - * @param get_proc_address_ctx arbitrary opaque user context passed to the - * get_proc_address callback - * @return error code (same as normal mpv_* API), including but not limited to: - * MPV_ERROR_UNSUPPORTED: the OpenGL version is not supported - * (or required extensions are missing) - * MPV_ERROR_INVALID_PARAMETER: the OpenGL state was already initialized - */ -int mpv_opengl_cb_init_gl(mpv_opengl_cb_context *ctx, const char *exts, - mpv_opengl_cb_get_proc_address_fn get_proc_address, - void *get_proc_address_ctx); - -/** - * Render video. Requires that the OpenGL state is initialized. - * - * The video will use the full provided framebuffer. Options like "panscan" are - * applied to determine which part of the video should be visible and how the - * video should be scaled. You can change these options at runtime by using the - * mpv property API. - * - * The renderer will reconfigure itself every time the output rectangle/size - * is changed. (If you want to do animations, it might be better to do the - * animation on a FBO instead.) - * - * This function implicitly pulls a video frame from the internal queue and - * renders it. If no new frame is available, the previous frame is redrawn. - * The update callback set with mpv_opengl_cb_set_update_callback() notifies - * you when a new frame was added. - * - * @param fbo The framebuffer object to render on. Because the renderer might - * manage multiple FBOs internally for the purpose of video - * postprocessing, it will always bind and unbind FBOs itself. If - * you want mpv to render on the main framebuffer, pass 0. - * @param w Width of the framebuffer. This is either the video size if the fbo - * parameter is 0, or the allocated size of the texture backing the - * fbo. The renderer will always use the full size of the fbo. - * @param h Height of the framebuffer. Same as with the w parameter, except - * that this parameter can be negative. In this case, the video - * frame will be rendered flipped. - * @return 0 - */ -int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int w, int h); - -/** - * Deprecated. Use mpv_opengl_cb_draw(). This function is equivalent to: - * - * int mpv_opengl_cb_render(mpv_opengl_cb_context *ctx, int fbo, int vp[4]) - * { return mpv_opengl_cb_draw(ctx, fbo, vp[2], vp[3]); } - * - * vp[0] and vp[1] used to have a meaning, but are ignored in newer versions. - * - * This function will be removed in the future without version bump (this API - * was never marked as stable). - */ -int mpv_opengl_cb_render(mpv_opengl_cb_context *ctx, int fbo, int vp[4]); - -/** - * Tell the renderer that a frame was flipped at the given time. This is - * optional, but can help the player to achieve better timing. - * - * Note that calling this at least once informs libmpv that you will use this - * function. If you use it inconsistently, expect bad video playback. - * - * If this is called while no video or no OpenGL is initialized, it is ignored. - * - * @param time The mpv time (using mpv_get_time_us()) at which the flip call - * returned. If 0 is passed, mpv_get_time_us() is used instead. - * Currently, this parameter is ignored. - * @return error code - */ -int mpv_opengl_cb_report_flip(mpv_opengl_cb_context *ctx, int64_t time); - -/** - * Destroy the mpv OpenGL state. - * - * If video is still active (e.g. a file playing), video will be disabled - * forcefully. - * - * Calling this multiple times is ok. - * - * @return error code - */ -int mpv_opengl_cb_uninit_gl(mpv_opengl_cb_context *ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* else #if MPV_ENABLE_DEPRECATED */ - -#endif diff --git a/stremio-shell/deps/libmpv/include/mpv/qthelper.hpp b/stremio-shell/deps/libmpv/include/mpv/qthelper.hpp deleted file mode 100644 index 0f66490..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/qthelper.hpp +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (C) 2017 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MPV_CLIENT_API_QTHELPER_H_ -#define MPV_CLIENT_API_QTHELPER_H_ - -#include - -/** - * Note: these helpers are provided for convenience for C++/Qt applications. - * This is based on the public API in client.h, and it does not encode any - * knowledge that is not known or guaranteed outside of the C client API. You - * can even copy and modify this code as you like, or implement similar things - * for other languages. - */ - -#include - -#include -#include -#include -#include -#include -#include - -namespace mpv { -namespace qt { - -// Wrapper around mpv_handle. Does refcounting under the hood. -class Handle -{ - struct container { - container(mpv_handle *h) : mpv(h) {} - ~container() { mpv_terminate_destroy(mpv); } - mpv_handle *mpv; - }; - QSharedPointer sptr; -public: - // Construct a new Handle from a raw mpv_handle with refcount 1. If the - // last Handle goes out of scope, the mpv_handle will be destroyed with - // mpv_terminate_destroy(). - // Never destroy the mpv_handle manually when using this wrapper. You - // will create dangling pointers. Just let the wrapper take care of - // destroying the mpv_handle. - // Never create multiple wrappers from the same raw mpv_handle; copy the - // wrapper instead (that's what it's for). - static Handle FromRawHandle(mpv_handle *handle) { - Handle h; - h.sptr = QSharedPointer(new container(handle)); - return h; - } - - // Return the raw handle; for use with the libmpv C API. - operator mpv_handle*() const { return sptr ? (*sptr).mpv : 0; } -}; - -static inline QVariant node_to_variant(const mpv_node *node) -{ - switch (node->format) { - case MPV_FORMAT_STRING: - return QVariant(QString::fromUtf8(node->u.string)); - case MPV_FORMAT_FLAG: - return QVariant(static_cast(node->u.flag)); - case MPV_FORMAT_INT64: - return QVariant(static_cast(node->u.int64)); - case MPV_FORMAT_DOUBLE: - return QVariant(node->u.double_); - case MPV_FORMAT_NODE_ARRAY: { - mpv_node_list *list = node->u.list; - QVariantList qlist; - for (int n = 0; n < list->num; n++) - qlist.append(node_to_variant(&list->values[n])); - return QVariant(qlist); - } - case MPV_FORMAT_NODE_MAP: { - mpv_node_list *list = node->u.list; - QVariantMap qmap; - for (int n = 0; n < list->num; n++) { - qmap.insert(QString::fromUtf8(list->keys[n]), - node_to_variant(&list->values[n])); - } - return QVariant(qmap); - } - default: // MPV_FORMAT_NONE, unknown values (e.g. future extensions) - return QVariant(); - } -} - -struct node_builder { - node_builder(const QVariant& v) { - set(&node_, v); - } - ~node_builder() { - free_node(&node_); - } - mpv_node *node() { return &node_; } -private: - Q_DISABLE_COPY(node_builder) - mpv_node node_; - mpv_node_list *create_list(mpv_node *dst, bool is_map, int num) { - dst->format = is_map ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NODE_ARRAY; - mpv_node_list *list = new mpv_node_list(); - dst->u.list = list; - if (!list) - goto err; - list->values = new mpv_node[num](); - if (!list->values) - goto err; - if (is_map) { - list->keys = new char*[num](); - if (!list->keys) - goto err; - } - return list; - err: - free_node(dst); - return NULL; - } - char *dup_qstring(const QString &s) { - QByteArray b = s.toUtf8(); - char *r = new char[b.size() + 1]; - if (r) - std::memcpy(r, b.data(), b.size() + 1); - return r; - } - bool test_type(const QVariant &v, QMetaType::Type t) { - // The Qt docs say: "Although this function is declared as returning - // "QVariant::Type(obsolete), the return value should be interpreted - // as QMetaType::Type." - // So a cast really seems to be needed to avoid warnings (urgh). - return static_cast(v.type()) == static_cast(t); - } - void set(mpv_node *dst, const QVariant &src) { - if (test_type(src, QMetaType::QString)) { - dst->format = MPV_FORMAT_STRING; - dst->u.string = dup_qstring(src.toString()); - if (!dst->u.string) - goto fail; - } else if (test_type(src, QMetaType::Bool)) { - dst->format = MPV_FORMAT_FLAG; - dst->u.flag = src.toBool() ? 1 : 0; - } else if (test_type(src, QMetaType::Int) || - test_type(src, QMetaType::LongLong) || - test_type(src, QMetaType::UInt) || - test_type(src, QMetaType::ULongLong)) - { - dst->format = MPV_FORMAT_INT64; - dst->u.int64 = src.toLongLong(); - } else if (test_type(src, QMetaType::Double)) { - dst->format = MPV_FORMAT_DOUBLE; - dst->u.double_ = src.toDouble(); - } else if (src.canConvert()) { - QVariantList qlist = src.toList(); - mpv_node_list *list = create_list(dst, false, qlist.size()); - if (!list) - goto fail; - list->num = qlist.size(); - for (int n = 0; n < qlist.size(); n++) - set(&list->values[n], qlist[n]); - } else if (src.canConvert()) { - QVariantMap qmap = src.toMap(); - mpv_node_list *list = create_list(dst, true, qmap.size()); - if (!list) - goto fail; - list->num = qmap.size(); - for (int n = 0; n < qmap.size(); n++) { - list->keys[n] = dup_qstring(qmap.keys()[n]); - if (!list->keys[n]) { - free_node(dst); - goto fail; - } - set(&list->values[n], qmap.values()[n]); - } - } else { - goto fail; - } - return; - fail: - dst->format = MPV_FORMAT_NONE; - } - void free_node(mpv_node *dst) { - switch (dst->format) { - case MPV_FORMAT_STRING: - delete[] dst->u.string; - break; - case MPV_FORMAT_NODE_ARRAY: - case MPV_FORMAT_NODE_MAP: { - mpv_node_list *list = dst->u.list; - if (list) { - for (int n = 0; n < list->num; n++) { - if (list->keys) - delete[] list->keys[n]; - if (list->values) - free_node(&list->values[n]); - } - delete[] list->keys; - delete[] list->values; - } - delete list; - break; - } - default: ; - } - dst->format = MPV_FORMAT_NONE; - } -}; - -/** - * RAII wrapper that calls mpv_free_node_contents() on the pointer. - */ -struct node_autofree { - mpv_node *ptr; - node_autofree(mpv_node *a_ptr) : ptr(a_ptr) {} - ~node_autofree() { mpv_free_node_contents(ptr); } -}; - -#if MPV_ENABLE_DEPRECATED - -/** - * Return the given property as mpv_node converted to QVariant, or QVariant() - * on error. - * - * @deprecated use get_property() instead - * - * @param name the property name - */ -static inline QVariant get_property_variant(mpv_handle *ctx, const QString &name) -{ - mpv_node node; - if (mpv_get_property(ctx, name.toUtf8().data(), MPV_FORMAT_NODE, &node) < 0) - return QVariant(); - node_autofree f(&node); - return node_to_variant(&node); -} - -/** - * Set the given property as mpv_node converted from the QVariant argument. - - * @deprecated use set_property() instead - */ -static inline int set_property_variant(mpv_handle *ctx, const QString &name, - const QVariant &v) -{ - node_builder node(v); - return mpv_set_property(ctx, name.toUtf8().data(), MPV_FORMAT_NODE, node.node()); -} - -/** - * Set the given option as mpv_node converted from the QVariant argument. - * - * @deprecated use set_property() instead - */ -static inline int set_option_variant(mpv_handle *ctx, const QString &name, - const QVariant &v) -{ - node_builder node(v); - return mpv_set_option(ctx, name.toUtf8().data(), MPV_FORMAT_NODE, node.node()); -} - -/** - * mpv_command_node() equivalent. Returns QVariant() on error (and - * unfortunately, the same on success). - * - * @deprecated use command() instead - */ -static inline QVariant command_variant(mpv_handle *ctx, const QVariant &args) -{ - node_builder node(args); - mpv_node res; - if (mpv_command_node(ctx, node.node(), &res) < 0) - return QVariant(); - node_autofree f(&res); - return node_to_variant(&res); -} - -#endif - -/** - * This is used to return error codes wrapped in QVariant for functions which - * return QVariant. - * - * You can use get_error() or is_error() to extract the error status from a - * QVariant value. - */ -struct ErrorReturn -{ - /** - * enum mpv_error value (or a value outside of it if ABI was extended) - */ - int error; - - ErrorReturn() : error(0) {} - explicit ErrorReturn(int err) : error(err) {} -}; - -/** - * Return the mpv error code packed into a QVariant, or 0 (success) if it's not - * an error value. - * - * @return error code (<0) or success (>=0) - */ -static inline int get_error(const QVariant &v) -{ - if (!v.canConvert()) - return 0; - return v.value().error; -} - -/** - * Return whether the QVariant carries a mpv error code. - */ -static inline bool is_error(const QVariant &v) -{ - return get_error(v) < 0; -} - -/** - * Return the given property as mpv_node converted to QVariant, or QVariant() - * on error. - * - * @param name the property name - * @return the property value, or an ErrorReturn with the error code - */ -static inline QVariant get_property(mpv_handle *ctx, const QString &name) -{ - mpv_node node; - int err = mpv_get_property(ctx, name.toUtf8().data(), MPV_FORMAT_NODE, &node); - if (err < 0) - return QVariant::fromValue(ErrorReturn(err)); - node_autofree f(&node); - return node_to_variant(&node); -} - -/** - * Set the given property as mpv_node converted from the QVariant argument. - * - * @return mpv error code (<0 on error, >= 0 on success) - */ -static inline int set_property(mpv_handle *ctx, const QString &name, - const QVariant &v) -{ - node_builder node(v); - return mpv_set_property(ctx, name.toUtf8().data(), MPV_FORMAT_NODE, node.node()); -} - -/** - * mpv_command_node() equivalent. - * - * @param args command arguments, with args[0] being the command name as string - * @return the property value, or an ErrorReturn with the error code - */ -static inline QVariant command(mpv_handle *ctx, const QVariant &args) -{ - node_builder node(args); - mpv_node res; - int err = mpv_command_node(ctx, node.node(), &res); - if (err < 0) - return QVariant::fromValue(ErrorReturn(err)); - node_autofree f(&res); - return node_to_variant(&res); -} - -} -} - -Q_DECLARE_METATYPE(mpv::qt::ErrorReturn) - -#endif diff --git a/stremio-shell/deps/libmpv/include/mpv/render.h b/stremio-shell/deps/libmpv/include/mpv/render.h deleted file mode 100644 index 253b2b4..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/render.h +++ /dev/null @@ -1,596 +0,0 @@ -/* Copyright (C) 2018 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MPV_CLIENT_API_RENDER_H_ -#define MPV_CLIENT_API_RENDER_H_ - -#include "client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Overview - * -------- - * - * This API can be used to make mpv render using supported graphic APIs (such - * as OpenGL). It can be used to handle video display. - * - * The renderer needs to be created with mpv_render_context_create() before - * you start playback (or otherwise cause a VO to be created). Then (with most - * backends) mpv_render_context_render() can be used to explicitly render the - * current video frame. Use mpv_render_context_set_update_callback() to get - * notified when there is a new frame to draw. - * - * Preferably rendering should be done in a separate thread. If you call - * normal libmpv API functions on the renderer thread, deadlocks can result - * (these are made non-fatal with timeouts, but user experience will obviously - * suffer). See "Threading" section below. - * - * You can output and embed video without this API by setting the mpv "wid" - * option to a native window handle (see "Embedding the video window" section - * in the client.h header). In general, using the render API is recommended, - * because window embedding can cause various issues, especially with GUI - * toolkits and certain platforms. - * - * Supported backends - * ------------------ - * - * OpenGL: via MPV_RENDER_API_TYPE_OPENGL, see render_gl.h header. - * - * Threading - * --------- - * - * You are recommended to do rendering on a separate thread than normal libmpv - * use. - * - * The mpv_render_* functions can be called from any thread, under the - * following conditions: - * - only one of the mpv_render_* functions can be called at the same time - * (unless they belong to different mpv cores created by mpv_create()) - * - never can be called from within the callbacks set with - * mpv_set_wakeup_callback() or mpv_render_context_set_update_callback() - * - if the OpenGL backend is used, for all functions the OpenGL context - * must be "current" in the calling thread, and it must be the same OpenGL - * context as the mpv_render_context was created with. Otherwise, undefined - * behavior will occur. - * - the thread does not call libmpv API functions other than the mpv_render_* - * functions, except APIs which are declared as safe (see below). Likewise, - * there must be no lock or wait dependency from the render thread to a - * thread using other libmpv functions. Basically, the situation that your - * render thread waits for a "not safe" libmpv API function to return must - * not happen. If you ignore this requirement, deadlocks can happen, which - * are made non-fatal with timeouts; then playback quality will be degraded, - * and the message - * mpv_render_context_render() not being called or stuck. - * is logged. If you set MPV_RENDER_PARAM_ADVANCED_CONTROL, you promise that - * this won't happen, and must absolutely guarantee it, or a real deadlock - * will freeze the mpv core thread forever. - * - * libmpv functions which are safe to call from a render thread are: - * - functions marked with "Safe to be called from mpv render API threads." - * - client.h functions which don't have an explicit or implicit mpv_handle - * parameter - * - mpv_render_* functions; but only for the same mpv_render_context pointer. - * If the pointer is different, mpv_render_context_free() is not safe. (The - * reason is that if MPV_RENDER_PARAM_ADVANCED_CONTROL is set, it may have - * to process still queued requests from the core, which it can do only for - * the current context, while requests for other contexts would deadlock. - * Also, it may have to wait and block for the core to terminate the video - * chain to make sure no resources are used after context destruction.) - * - if the mpv_handle parameter refers to a different mpv core than the one - * you're rendering for (very obscure, but allowed) - * - * Context and handle lifecycle - * ---------------------------- - * - * Video initialization will fail if the render context was not initialized yet - * (with mpv_render_context_create()), or it will revert to a VO that creates - * its own window. - * - * Currently, there can be only 1 mpv_render_context at a time per mpv core. - * - * Calling mpv_render_context_free() while a VO is using the render context is - * active will disable video. - * - * You must free the context with mpv_render_context_free() before the mpv core - * is destroyed. If this doesn't happen, undefined behavior will result. - */ - -/** - * Opaque context, returned by mpv_render_context_create(). - */ -typedef struct mpv_render_context mpv_render_context; - -/** - * Parameters for mpv_render_param (which is used in a few places such as - * mpv_render_context_create(). - * - * Also see mpv_render_param for conventions and how to use it. - */ -typedef enum mpv_render_param_type { - /** - * Not a valid value, but also used to terminate a params array. Its value - * is always guaranteed to be 0 (even if the ABI changes in the future). - */ - MPV_RENDER_PARAM_INVALID = 0, - /** - * The render API to use. Valid for mpv_render_context_create(). - * - * Type: char* - * - * Defined APIs: - * - * MPV_RENDER_API_TYPE_OPENGL: - * OpenGL desktop 2.1 or later (preferably core profile compatible to - * OpenGL 3.2), or OpenGLES 2.0 or later. - * Providing MPV_RENDER_PARAM_OPENGL_INIT_PARAMS is required. - * It is expected that an OpenGL context is valid and "current" when - * calling mpv_render_* functions (unless specified otherwise). It - * must be the same context for the same mpv_render_context. - */ - MPV_RENDER_PARAM_API_TYPE = 1, - /** - * Required parameters for initializing the OpenGL renderer. Valid for - * mpv_render_context_create(). - * Type: mpv_opengl_init_params* - */ - MPV_RENDER_PARAM_OPENGL_INIT_PARAMS = 2, - /** - * Describes a GL render target. Valid for mpv_render_context_render(). - * Type: mpv_opengl_fbo* - */ - MPV_RENDER_PARAM_OPENGL_FBO = 3, - /** - * Control flipped rendering. Valid for mpv_render_context_render(). - * Type: int* - * If the value is set to 0, render normally. Otherwise, render it flipped, - * which is needed e.g. when rendering to an OpenGL default framebuffer - * (which has a flipped coordinate system). - */ - MPV_RENDER_PARAM_FLIP_Y = 4, - /** - * Control surface depth. Valid for mpv_render_context_render(). - * Type: int* - * This implies the depth of the surface passed to the render function in - * bits per channel. If omitted or set to 0, the renderer will assume 8. - * Typically used to control dithering. - */ - MPV_RENDER_PARAM_DEPTH = 5, - /** - * ICC profile blob. Valid for mpv_render_context_set_parameter(). - * Type: mpv_byte_array* - * Set an ICC profile for use with the "icc-profile-auto" option. (If the - * option is not enabled, the ICC data will not be used.) - */ - MPV_RENDER_PARAM_ICC_PROFILE = 6, - /** - * Ambient light in lux. Valid for mpv_render_context_set_parameter(). - * Type: int* - * This can be used for automatic gamma correction. - */ - MPV_RENDER_PARAM_AMBIENT_LIGHT = 7, - /** - * X11 Display, sometimes used for hwdec. Valid for - * mpv_render_context_create(). The Display must stay valid for the lifetime - * of the mpv_render_context. - * Type: Display* - */ - MPV_RENDER_PARAM_X11_DISPLAY = 8, - /** - * Wayland display, sometimes used for hwdec. Valid for - * mpv_render_context_create(). The wl_display must stay valid for the - * lifetime of the mpv_render_context. - * Type: struct wl_display* - */ - MPV_RENDER_PARAM_WL_DISPLAY = 9, - /** - * Better control about rendering and enabling some advanced features. Valid - * for mpv_render_context_create(). - * - * This conflates multiple requirements the API user promises to abide if - * this option is enabled: - * - * - The API user's render thread, which is calling the mpv_render_*() - * functions, never waits for the core. Otherwise deadlocks can happen. - * See "Threading" section. - * - The callback set with mpv_render_context_set_update_callback() can now - * be called even if there is no new frame. The API user should call the - * mpv_render_context_update() function, and interpret the return value - * for whether a new frame should be rendered. - * - Correct functionality is impossible if the update callback is not set, - * or not set soon enough after mpv_render_context_create() (the core can - * block while waiting for you to call mpv_render_context_update(), and - * if the update callback is not correctly set, it will deadlock, or - * block for too long). - * - * In general, setting this option will enable the following features (and - * possibly more): - * - * - "Direct rendering", which means the player decodes directly to a - * texture, which saves a copy per video frame ("vd-lavc-dr" option - * needs to be enabled, and the rendering backend as well as the - * underlying GPU API/driver needs to have support for it). - * - Rendering screenshots with the GPU API if supported by the backend - * (instead of using a suboptimal software fallback via libswscale). - * - * Type: int*: 0 for disable (default), 1 for enable - */ - MPV_RENDER_PARAM_ADVANCED_CONTROL = 10, - /** - * Return information about the next frame to render. Valid for - * mpv_render_context_get_info(). - * - * Type: mpv_render_frame_info* - * - * It strictly returns information about the _next_ frame. The implication - * is that e.g. mpv_render_context_update()'s return value will have - * MPV_RENDER_UPDATE_FRAME set, and the user is supposed to call - * mpv_render_context_render(). If there is no next frame, then the - * return value will have is_valid set to 0. - */ - MPV_RENDER_PARAM_NEXT_FRAME_INFO = 11, - /** - * Enable or disable video timing. Valid for mpv_render_context_render(). - * - * Type: int*: 0 for disable, 1 for enable (default) - * - * When video is timed to audio, the player attempts to render video a bit - * ahead, and then do a blocking wait until the target display time is - * reached. This blocks mpv_render_context_render() for up to the amount - * specified with the "video-timing-offset" global option. You can set - * this parameter to 0 to disable this kind of waiting. If you do, it's - * recommended to use the target time value in mpv_render_frame_info to - * wait yourself, or to set the "video-timing-offset" to 0 instead. - * - * Disabling this without doing anything in addition will result in A/V sync - * being slightly off. - */ - MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME = 12, - /** - * Use to skip rendering in mpv_render_context_render(). - * - * Type: int*: 0 for rendering (default), 1 for skipping - * - * If this is set, you don't need to pass a target surface to the render - * function (and if you do, it's completely ignored). This can still call - * into the lower level APIs (i.e. if you use OpenGL, the OpenGL context - * must be set). - * - * Be aware that the render API will consider this frame as having been - * rendered. All other normal rules also apply, for example about whether - * you have to call mpv_render_context_report_swap(). It also does timing - * in the same way. - */ - MPV_RENDER_PARAM_SKIP_RENDERING = 13, - /** - * DRM display, contains drm display handles. - * Valid for mpv_render_context_create(). - * Type : struct mpv_opengl_drm_params* - */ - MPV_RENDER_PARAM_DRM_DISPLAY = 14, - /** - * DRM osd size, contains osd dimensions. - * Valid for mpv_render_context_create(). - * Type : struct mpv_opengl_drm_osd_size* - */ - MPV_RENDER_PARAM_DRM_OSD_SIZE = 15, -} mpv_render_param_type; - -/** - * Used to pass arbitrary parameters to some mpv_render_* functions. The - * meaning of the data parameter is determined by the type, and each - * MPV_RENDER_PARAM_* documents what type the value must point to. - * - * Each value documents the required data type as the pointer you cast to - * void* and set on mpv_render_param.data. For example, if MPV_RENDER_PARAM_FOO - * documents the type as Something* , then the code should look like this: - * - * Something foo = {...}; - * mpv_render_param param; - * param.type = MPV_RENDER_PARAM_FOO; - * param.data = & foo; - * - * Normally, the data field points to exactly 1 object. If the type is char*, - * it points to a 0-terminated string. - * - * In all cases (unless documented otherwise) the pointers need to remain - * valid during the call only. Unless otherwise documented, the API functions - * will not write to the params array or any data pointed to it. - * - * As a convention, parameter arrays are always terminated by type==0. There - * is no specific order of the parameters required. The order of the 2 fields in - * this struct is guaranteed (even after ABI changes). - */ -typedef struct mpv_render_param { - enum mpv_render_param_type type; - void *data; -} mpv_render_param; - - -/** - * Predefined values for MPV_RENDER_PARAM_API_TYPE. - */ -#define MPV_RENDER_API_TYPE_OPENGL "opengl" - -/** - * Flags used in mpv_render_frame_info.flags. Each value represents a bit in it. - */ -typedef enum mpv_render_frame_info_flag { - /** - * Set if there is actually a next frame. If unset, there is no next frame - * yet, and other flags and fields that require a frame to be queued will - * be unset. - * - * This is set for _any_ kind of frame, even for redraw requests. - * - * Note that when this is unset, it simply means no new frame was - * decoded/queued yet, not necessarily that the end of the video was - * reached. A new frame can be queued after some time. - * - * If the return value of mpv_render_context_render() had the - * MPV_RENDER_UPDATE_FRAME flag set, this flag will usually be set as well, - * unless the frame is rendered, or discarded by other asynchronous events. - */ - MPV_RENDER_FRAME_INFO_PRESENT = 1 << 0, - /** - * If set, the frame is not an actual new video frame, but a redraw request. - * For example if the video is paused, and an option that affects video - * rendering was changed (or any other reason), an update request can be - * issued and this flag will be set. - * - * Typically, redraw frames will not be subject to video timing. - * - * Implies MPV_RENDER_FRAME_INFO_PRESENT. - */ - MPV_RENDER_FRAME_INFO_REDRAW = 1 << 1, - /** - * If set, this is supposed to reproduce the previous frame perfectly. This - * is usually used for certain "video-sync" options ("display-..." modes). - * Typically the renderer will blit the video from a FBO. Unset otherwise. - * - * Implies MPV_RENDER_FRAME_INFO_PRESENT. - */ - MPV_RENDER_FRAME_INFO_REPEAT = 1 << 2, - /** - * If set, the player timing code expects that the user thread blocks on - * vsync (by either delaying the render call, or by making a call to - * mpv_render_context_report_swap() at vsync time). - * - * Implies MPV_RENDER_FRAME_INFO_PRESENT. - */ - MPV_RENDER_FRAME_INFO_BLOCK_VSYNC = 1 << 3, -} mpv_render_frame_info_flag; - -/** - * Information about the next video frame that will be rendered. Can be - * retrieved with MPV_RENDER_PARAM_NEXT_FRAME_INFO. - */ -typedef struct mpv_render_frame_info { - /** - * A bitset of mpv_render_frame_info_flag values (i.e. multiple flags are - * combined with bitwise or). - */ - uint64_t flags; - /** - * Absolute time at which the frame is supposed to be displayed. This is in - * the same unit and base as the time returned by mpv_get_time_us(). For - * frames that are redrawn, or if vsync locked video timing is used (see - * "video-sync" option), then this can be 0. The "video-timing-offset" - * option determines how much "headroom" the render thread gets (but a high - * enough frame rate can reduce it anyway). mpv_render_context_render() will - * normally block until the time is elapsed, unless you pass it - * MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME = 0. - */ - int64_t target_time; -} mpv_render_frame_info; - -/** - * Initialize the renderer state. Depending on the backend used, this will - * access the underlying GPU API and initialize its own objects. - * - * You must free the context with mpv_render_context_free(). Not doing so before - * the mpv core is destroyed may result in memory leaks or crashes. - * - * Currently, only at most 1 context can exists per mpv core (it represents the - * main video output). - * - * You should pass the following parameters: - * - MPV_RENDER_PARAM_API_TYPE to select the underlying backend/GPU API. - * - Backend-specific init parameter, like MPV_RENDER_PARAM_OPENGL_INIT_PARAMS. - * - Setting MPV_RENDER_PARAM_ADVANCED_CONTROL and following its rules is - * strongly recommended. - * - If you want to use hwdec, possibly hwdec interop resources. - * - * @param res set to the context (on success) or NULL (on failure). The value - * is never read and always overwritten. - * @param mpv handle used to get the core (the mpv_render_context won't depend - * on this specific handle, only the core referenced by it) - * @param params an array of parameters, terminated by type==0. It's left - * unspecified what happens with unknown parameters. At least - * MPV_RENDER_PARAM_API_TYPE is required, and most backends will - * require another backend-specific parameter. - * @return error code, including but not limited to: - * MPV_ERROR_UNSUPPORTED: the OpenGL version is not supported - * (or required extensions are missing) - * MPV_ERROR_NOT_IMPLEMENTED: an unknown API type was provided, or - * support for the requested API was not - * built in the used libmpv binary. - * MPV_ERROR_INVALID_PARAMETER: at least one of the provided parameters was - * not valid. - */ -int mpv_render_context_create(mpv_render_context **res, mpv_handle *mpv, - mpv_render_param *params); - -/** - * Attempt to change a single parameter. Not all backends and parameter types - * support all kinds of changes. - * - * @param ctx a valid render context - * @param param the parameter type and data that should be set - * @return error code. If a parameter could actually be changed, this returns - * success, otherwise an error code depending on the parameter type - * and situation. - */ -int mpv_render_context_set_parameter(mpv_render_context *ctx, - mpv_render_param param); - -/** - * Retrieve information from the render context. This is NOT a counterpart to - * mpv_render_context_set_parameter(), because you generally can't read - * parameters set with it, and this function is not meant for this purpose. - * Instead, this is for communicating information from the renderer back to the - * user. See mpv_render_param_type; entries which support this function - * explicitly mention it, and for other entries you can assume it will fail. - * - * You pass param with param.type set and param.data pointing to a variable - * of the required data type. The function will then overwrite that variable - * with the returned value (at least on success). - * - * @param ctx a valid render context - * @param param the parameter type and data that should be retrieved - * @return error code. If a parameter could actually be retrieved, this returns - * success, otherwise an error code depending on the parameter type - * and situation. MPV_ERROR_NOT_IMPLEMENTED is used for unknown - * param.type, or if retrieving it is not supported. - */ -int mpv_render_context_get_info(mpv_render_context *ctx, - mpv_render_param param); - -typedef void (*mpv_render_update_fn)(void *cb_ctx); - -/** - * Set the callback that notifies you when a new video frame is available, or - * if the video display configuration somehow changed and requires a redraw. - * Similar to mpv_set_wakeup_callback(), you must not call any mpv API from - * the callback, and all the other listed restrictions apply (such as not - * exiting the callback by throwing exceptions). - * - * This can be called from any thread, except from an update callback. In case - * of the OpenGL backend, no OpenGL state or API is accessed. - * - * Calling this will raise an update callback immediately. - * - * @param callback callback(callback_ctx) is called if the frame should be - * redrawn - * @param callback_ctx opaque argument to the callback - */ -void mpv_render_context_set_update_callback(mpv_render_context *ctx, - mpv_render_update_fn callback, - void *callback_ctx); - -/** - * The API user is supposed to call this when the update callback was invoked - * (like all mpv_render_* functions, this has to happen on the render thread, - * and _not_ from the update callback itself). - * - * This is optional if MPV_RENDER_PARAM_ADVANCED_CONTROL was not set (default). - * Otherwise, it's a hard requirement that this is called after each update - * callback. If multiple update callback happened, and the function could not - * be called sooner, it's OK to call it once after the last callback. - * - * If an update callback happens during or after this function, the function - * must be called again at the soonest possible time. - * - * If MPV_RENDER_PARAM_ADVANCED_CONTROL was set, this will do additional work - * such as allocating textures for the video decoder. - * - * @return a bitset of mpv_render_update_flag values (i.e. multiple flags are - * combined with bitwise or). Typically, this will tell the API user - * what should happen next. E.g. if the MPV_RENDER_UPDATE_FRAME flag is - * set, mpv_render_context_render() should be called. If flags unknown - * to the API user are set, or if the return value is 0, nothing needs - * to be done. - */ -uint64_t mpv_render_context_update(mpv_render_context *ctx); - -/** - * Flags returned by mpv_render_context_update(). Each value represents a bit - * in the function's return value. - */ -typedef enum mpv_render_update_flag { - /** - * A new video frame must be rendered. mpv_render_context_render() must be - * called. - */ - MPV_RENDER_UPDATE_FRAME = 1 << 0, -} mpv_render_context_flag; - -/** - * Render video. - * - * Typically renders the video to a target surface provided via mpv_render_param - * (the details depend on the backend in use). Options like "panscan" are - * applied to determine which part of the video should be visible and how the - * video should be scaled. You can change these options at runtime by using the - * mpv property API. - * - * The renderer will reconfigure itself every time the target surface - * configuration (such as size) is changed. - * - * This function implicitly pulls a video frame from the internal queue and - * renders it. If no new frame is available, the previous frame is redrawn. - * The update callback set with mpv_render_context_set_update_callback() - * notifies you when a new frame was added. The details potentially depend on - * the backends and the provided parameters. - * - * Generally, libmpv will invoke your update callback some time before the video - * frame should be shown, and then lets this function block until the supposed - * display time. This will limit your rendering to video FPS. You can prevent - * this by setting the "video-timing-offset" global option to 0. (This applies - * only to "audio" video sync mode.) - * - * You should pass the following parameters: - * - Backend-specific target object, such as MPV_RENDER_PARAM_OPENGL_FBO. - * - Possibly transformations, such as MPV_RENDER_PARAM_FLIP_Y. - * - * @param ctx a valid render context - * @param params an array of parameters, terminated by type==0. Which parameters - * are required depends on the backend. It's left unspecified what - * happens with unknown parameters. - * @return error code - */ -int mpv_render_context_render(mpv_render_context *ctx, mpv_render_param *params); - -/** - * Tell the renderer that a frame was flipped at the given time. This is - * optional, but can help the player to achieve better timing. - * - * Note that calling this at least once informs libmpv that you will use this - * function. If you use it inconsistently, expect bad video playback. - * - * If this is called while no video is initialized, it is ignored. - * - * @param ctx a valid render context - */ -void mpv_render_context_report_swap(mpv_render_context *ctx); - -/** - * Destroy the mpv renderer state. - * - * If video is still active (e.g. a file playing), video will be disabled - * forcefully. - * - * @param ctx a valid render context. After this function returns, this is not - * a valid pointer anymore. NULL is also allowed and does nothing. - */ -void mpv_render_context_free(mpv_render_context *ctx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/stremio-shell/deps/libmpv/include/mpv/render_gl.h b/stremio-shell/deps/libmpv/include/mpv/render_gl.h deleted file mode 100644 index 4d771f2..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/render_gl.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Copyright (C) 2018 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MPV_CLIENT_API_RENDER_GL_H_ -#define MPV_CLIENT_API_RENDER_GL_H_ - -#include "render.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * OpenGL backend - * -------------- - * - * This header contains definitions for using OpenGL with the render.h API. - * - * OpenGL interop - * -------------- - * - * The OpenGL backend has some special rules, because OpenGL itself uses - * implicit per-thread contexts, which causes additional API problems. - * - * This assumes the OpenGL context lives on a certain thread controlled by the - * API user. All mpv_render_* APIs have to be assumed to implicitly use the - * OpenGL context if you pass a mpv_render_context using the OpenGL backend, - * unless specified otherwise. - * - * The OpenGL context is indirectly accessed through the OpenGL function - * pointers returned by the get_proc_address callback in mpv_opengl_init_params. - * Generally, mpv will not load the system OpenGL library when using this API. - * - * OpenGL state - * ------------ - * - * OpenGL has a large amount of implicit state. All the mpv functions mentioned - * above expect that the OpenGL state is reasonably set to OpenGL standard - * defaults. Likewise, mpv will attempt to leave the OpenGL context with - * standard defaults. The following state is excluded from this: - * - * - the glViewport state - * - the glScissor state (but GL_SCISSOR_TEST is in its default value) - * - glBlendFuncSeparate() state (but GL_BLEND is in its default value) - * - glClearColor() state - * - mpv may overwrite the callback set with glDebugMessageCallback() - * - mpv always disables GL_DITHER at init - * - * Messing with the state could be avoided by creating shared OpenGL contexts, - * but this is avoided for the sake of compatibility and interoperability. - * - * On OpenGL 2.1, mpv will strictly call functions like glGenTextures() to - * create OpenGL objects. You will have to do the same. This ensures that - * objects created by mpv and the API users don't clash. Also, legacy state - * must be either in its defaults, or not interfere with core state. - * - * API use - * ------- - * - * The mpv_render_* API is used. That API supports multiple backends, and this - * section documents specifics for the OpenGL backend. - * - * Use mpv_render_context_create() with MPV_RENDER_PARAM_API_TYPE set to - * MPV_RENDER_API_TYPE_OPENGL, and MPV_RENDER_PARAM_OPENGL_INIT_PARAMS provided. - * - * Call mpv_render_context_render() with MPV_RENDER_PARAM_OPENGL_FBO to render - * the video frame to an FBO. - * - * Hardware decoding - * ----------------- - * - * Hardware decoding via this API is fully supported, but requires some - * additional setup. (At least if direct hardware decoding modes are wanted, - * instead of copying back surface data from GPU to CPU RAM.) - * - * There may be certain requirements on the OpenGL implementation: - * - * - Windows: ANGLE is required (although in theory GL/DX interop could be used) - * - Intel/Linux: EGL is required, and also the native display resource needs - * to be provided (e.g. MPV_RENDER_PARAM_X11_DISPLAY for X11 and - * MPV_RENDER_PARAM_WL_DISPLAY for Wayland) - * - nVidia/Linux: Both GLX and EGL should work (GLX is required if vdpau is - * used, e.g. due to old drivers.) - * - OSX: CGL is required (CGLGetCurrentContext() returning non-NULL) - * - iOS: EAGL is required (EAGLContext.currentContext returning non-nil) - * - * Once these things are setup, hardware decoding can be enabled/disabled at - * any time by setting the "hwdec" property. - */ - -/** - * For initializing the mpv OpenGL state via MPV_RENDER_PARAM_OPENGL_INIT_PARAMS. - */ -typedef struct mpv_opengl_init_params { - /** - * This retrieves OpenGL function pointers, and will use them in subsequent - * operation. - * Usually, GL context APIs do this for you (e.g. with glXGetProcAddressARB - * or wglGetProcAddress), but some APIs do not always return pointers for - * all standard functions (even if present); in this case you have to - * compensate by looking up these functions yourself and returning them - * from this callback. - */ - void *(*get_proc_address)(void *ctx, const char *name); - /** - * Value passed as ctx parameter to get_proc_address(). - */ - void *get_proc_address_ctx; - /** - * This should not be used. It is deprecated and will be removed or ignored - * when the opengl_cb API is removed. - */ - const char *extra_exts; -} mpv_opengl_init_params; - -/** - * For MPV_RENDER_PARAM_OPENGL_FBO. - */ -typedef struct mpv_opengl_fbo { - /** - * Framebuffer object name. This must be either a valid FBO generated by - * glGenFramebuffers() that is complete and color-renderable, or 0. If the - * value is 0, this refers to the OpenGL default framebuffer. - */ - int fbo; - /** - * Valid dimensions. This must refer to the size of the framebuffer. This - * must always be set. - */ - int w, h; - /** - * Underlying texture internal format (e.g. GL_RGBA8), or 0 if unknown. If - * this is the default framebuffer, this can be an equivalent. - */ - int internal_format; -} mpv_opengl_fbo; - -typedef struct mpv_opengl_drm_params { - /** - * DRM fd (int). Set to a negative number if invalid. - */ - int fd; - - /** - * Currently used crtc id - */ - int crtc_id; - - /** - * Currently used connector id - */ - int connector_id; - - /** - * Pointer to a drmModeAtomicReq pointer that is being used for the renderloop. - * This pointer should hold a pointer to the atomic request pointer - * The atomic request pointer is usually changed at every renderloop. - */ - struct _drmModeAtomicReq **atomic_request_ptr; - - /** - * DRM render node. Used for VAAPI interop. - * Set to a negative number if invalid. - */ - int render_fd; -} mpv_opengl_drm_params; - -typedef struct mpv_opengl_drm_osd_size { - /** - * size of the OSD in pixels. - */ - int width, height; -} mpv_opengl_drm_osd_size; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/stremio-shell/deps/libmpv/include/mpv/stream_cb.h b/stremio-shell/deps/libmpv/include/mpv/stream_cb.h deleted file mode 100644 index ec48a3c..0000000 --- a/stremio-shell/deps/libmpv/include/mpv/stream_cb.h +++ /dev/null @@ -1,229 +0,0 @@ -/* Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Note: the client API is licensed under ISC (see above) to ease - * interoperability with other licenses. But keep in mind that the - * mpv core is still mostly GPLv2+. It's up to lawyers to decide - * whether applications using this API are affected by the GPL. - * One argument against this is that proprietary applications - * using mplayer in slave mode is apparently tolerated, and this - * API is basically equivalent to slave mode. - */ - -#ifndef MPV_CLIENT_API_STREAM_CB_H_ -#define MPV_CLIENT_API_STREAM_CB_H_ - -#include "client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Warning: this API is not stable yet. - * - * Overview - * -------- - * - * This API can be used to make mpv read from a stream with a custom - * implementation. This interface is inspired by funopen on BSD and - * fopencookie on linux. The stream is backed by user-defined callbacks - * which can implement customized open, read, seek, size and close behaviors. - * - * Usage - * ----- - * - * Register your stream callbacks with the mpv_stream_cb_add_ro() function. You - * have to provide a mpv_stream_cb_open_ro_fn callback to it (open_fn argument). - * - * Once registered, you can `loadfile myprotocol://myfile`. Your open_fn will be - * invoked with the URI and you must fill out the provided mpv_stream_cb_info - * struct. This includes your stream callbacks (like read_fn), and an opaque - * cookie, which will be passed as the first argument to all the remaining - * stream callbacks. - * - * Note that your custom callbacks must not invoke libmpv APIs as that would - * cause a deadlock. - * - * Stream lifetime - * --------------- - * - * A stream remains valid until its close callback has been called. It's up to - * libmpv to call the close callback, and the libmpv user cannot close it - * directly with the stream_cb API. - * - * For example, if you consider your custom stream to become suddenly invalid - * (maybe because the underlying stream died), libmpv will continue using your - * stream. All you can do is returning errors from each callback, until libmpv - * gives up and closes it. - * - * Protocol registration and lifetime - * ---------------------------------- - * - * Protocols remain registered until the mpv instance is terminated. This means - * in particular that it can outlive the mpv_handle that was used to register - * it, but once mpv_terminate_destroy() is called, your registered callbacks - * will not be called again. - * - * Protocol unregistration is finished after the mpv core has been destroyed - * (e.g. after mpv_terminate_destroy() has returned). - * - * If you do not call mpv_terminate_destroy() yourself (e.g. plugin-style code), - * you will have to deal with the registration or even streams outliving your - * code. Here are some possible ways to do this: - * - call mpv_terminate_destroy(), which destroys the core, and will make sure - * all streams are closed once this function returns - * - you refcount all resources your stream "cookies" reference, so that it - * doesn't matter if streams live longer than expected - * - create "cancellation" semantics: after your protocol has been unregistered, - * notify all your streams that are still opened, and make them drop all - * referenced resources - then return errors from the stream callbacks as - * long as the stream is still opened - * - */ - -/** - * Read callback used to implement a custom stream. The semantics of the - * callback match read(2) in blocking mode. Short reads are allowed (you can - * return less bytes than requested, and libmpv will retry reading the rest - * with a nother call). If no data can be immediately read, the callback must - * block until there is new data. A return of 0 will be interpreted as final - * EOF, although libmpv might retry the read, or seek to a different position. - * - * @param cookie opaque cookie identifying the stream, - * returned from mpv_stream_cb_open_fn - * @param buf buffer to read data into - * @param size of the buffer - * @return number of bytes read into the buffer - * @return 0 on EOF - * @return -1 on error - */ -typedef int64_t (*mpv_stream_cb_read_fn)(void *cookie, char *buf, uint64_t nbytes); - -/** - * Seek callback used to implement a custom stream. - * - * Note that mpv will issue a seek to position 0 immediately after opening. This - * is used to test whether the stream is seekable (since seekability might - * depend on the URI contents, not just the protocol). Return - * MPV_ERROR_UNSUPPORTED if seeking is not implemented for this stream. This - * seek also servies to establish the fact that streams start at position 0. - * - * This callback can be NULL, in which it behaves as if always returning - * MPV_ERROR_UNSUPPORTED. - * - * @param cookie opaque cookie identifying the stream, - * returned from mpv_stream_cb_open_fn - * @param offset target absolut stream position - * @return the resulting offset of the stream - * MPV_ERROR_UNSUPPORTED or MPV_ERROR_GENERIC if the seek failed - */ -typedef int64_t (*mpv_stream_cb_seek_fn)(void *cookie, int64_t offset); - -/** - * Size callback used to implement a custom stream. - * - * Return MPV_ERROR_UNSUPPORTED if no size is known. - * - * This callback can be NULL, in which it behaves as if always returning - * MPV_ERROR_UNSUPPORTED. - * - * @param cookie opaque cookie identifying the stream, - * returned from mpv_stream_cb_open_fn - * @return the total size in bytes of the stream - */ -typedef int64_t (*mpv_stream_cb_size_fn)(void *cookie); - -/** - * Close callback used to implement a custom stream. - * - * @param cookie opaque cookie identifying the stream, - * returned from mpv_stream_cb_open_fn - */ -typedef void (*mpv_stream_cb_close_fn)(void *cookie); - -/** - * See mpv_stream_cb_open_ro_fn callback. - */ -typedef struct mpv_stream_cb_info { - /** - * Opaque user-provided value, which will be passed to the other callbacks. - * The close callback will be called to release the cookie. It is not - * interpreted by mpv. It doesn't even need to be a valid pointer. - * - * The user sets this in the mpv_stream_cb_open_ro_fn callback. - */ - void *cookie; - - /** - * Callbacks set by the user in the mpv_stream_cb_open_ro_fn callback. Some - * of them are optional, and can be left unset. - * - * The following callbacks are mandatory: read_fn, close_fn - */ - mpv_stream_cb_read_fn read_fn; - mpv_stream_cb_seek_fn seek_fn; - mpv_stream_cb_size_fn size_fn; - mpv_stream_cb_close_fn close_fn; -} mpv_stream_cb_info; - -/** - * Open callback used to implement a custom read-only (ro) stream. The user - * must set the callback fields in the passed info struct. The cookie field - * also can be set to store state associated to the stream instance. - * - * Note that the info struct is valid only for the duration of this callback. - * You can't change the callbacks or the pointer to the cookie at a later point. - * - * Each stream instance created by the open callback can have different - * callbacks. - * - * The close_fn callback will terminate the stream instance. The pointers to - * your callbacks and cookie will be discarded, and the callbacks will not be - * called again. - * - * @param user_data opaque user data provided via mpv_stream_cb_add() - * @param uri name of the stream to be opened (with protocol prefix) - * @param info fields which the user should fill - * @return 0 on success, MPV_ERROR_LOADING_FAILED if the URI cannot be opened. - */ -typedef int (*mpv_stream_cb_open_ro_fn)(void *user_data, char *uri, - mpv_stream_cb_info *info); - -/** - * Add a custom stream protocol. This will register a protocol handler under - * the given protocol prefix, and invoke the given callbacks if an URI with the - * matching protocol prefix is opened. - * - * The "ro" is for read-only - only read-only streams can be registered with - * this function. - * - * The callback remains registered until the mpv core is registered. - * - * If a custom stream with the same name is already registered, then the - * MPV_ERROR_INVALID_PARAMETER error is returned. - * - * @param protocol protocol prefix, for example "foo" for "foo://" URIs - * @param user_data opaque pointer passed into the mpv_stream_cb_open_fn - * callback. - * @return error code - */ -int mpv_stream_cb_add_ro(mpv_handle *ctx, const char *protocol, void *user_data, - mpv_stream_cb_open_ro_fn open_fn); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/stremio-shell/deps/libmpv/mac/bin/ffmpeg b/stremio-shell/deps/libmpv/mac/bin/ffmpeg deleted file mode 100644 index 6270e73..0000000 Binary files a/stremio-shell/deps/libmpv/mac/bin/ffmpeg and /dev/null differ diff --git a/stremio-shell/deps/libmpv/mpv.def b/stremio-shell/deps/libmpv/mpv.def deleted file mode 100644 index d97ff7a..0000000 --- a/stremio-shell/deps/libmpv/mpv.def +++ /dev/null @@ -1,59 +0,0 @@ -EXPORTS -mpv_client_api_version -mpv_client_name -mpv_command -mpv_command_async -mpv_command_node -mpv_command_node_async -mpv_command_string -mpv_create -mpv_create_client -mpv_create_weak_client -mpv_destroy -mpv_detach_destroy -mpv_error_string -mpv_event_name -mpv_free -mpv_free_node_contents -mpv_get_property -mpv_get_property_async -mpv_get_property_osd_string -mpv_get_property_string -mpv_get_sub_api -mpv_get_time_us -mpv_get_wakeup_pipe -mpv_hook_add -mpv_hook_continue -mpv_initialize -mpv_load_config_file -mpv_observe_property -mpv_opengl_cb_draw -mpv_opengl_cb_init_gl -mpv_opengl_cb_render -mpv_opengl_cb_report_flip -mpv_opengl_cb_set_update_callback -mpv_opengl_cb_uninit_gl -mpv_render_context_create -mpv_render_context_free -mpv_render_context_get_info -mpv_render_context_render -mpv_render_context_report_swap -mpv_render_context_set_parameter -mpv_render_context_set_update_callback -mpv_render_context_update -mpv_request_event -mpv_request_log_messages -mpv_resume -mpv_set_option -mpv_set_option_string -mpv_set_property -mpv_set_property_async -mpv_set_property_string -mpv_set_wakeup_callback -mpv_stream_cb_add_ro -mpv_suspend -mpv_terminate_destroy -mpv_unobserve_property -mpv_wait_async_requests -mpv_wait_event -mpv_wakeup \ No newline at end of file diff --git a/stremio-shell/deps/libmpv/win32-x64/mpv.lib b/stremio-shell/deps/libmpv/win32-x64/mpv.lib deleted file mode 100644 index fa270c4..0000000 Binary files a/stremio-shell/deps/libmpv/win32-x64/mpv.lib and /dev/null differ diff --git a/stremio-shell/deps/libmpv/win32/mpv.lib b/stremio-shell/deps/libmpv/win32/mpv.lib deleted file mode 100644 index afa314d..0000000 Binary files a/stremio-shell/deps/libmpv/win32/mpv.lib and /dev/null differ diff --git a/stremio-shell/deps/singleapplication/CHANGELOG.md b/stremio-shell/deps/singleapplication/CHANGELOG.md deleted file mode 100644 index 90ef30b..0000000 --- a/stremio-shell/deps/singleapplication/CHANGELOG.md +++ /dev/null @@ -1,141 +0,0 @@ -Changelog -========= - -__3.0.8__ ---------- - -* Bug fix - changed QApplication::instance() to QCoreApplication::instance() - - _Evgeniy Bazhenov_ - -__3.0.7a__ ----------- - -* Fixed compilation error with Mingw32 in MXE thanks to Vitaly Tonkacheyev. -* Removed QMutex used for thread safe behaviour. The implementation now uses - QCoreApplication::instance() to get an instance to SingleApplication for - memory deallocation. - -__3.0.6a__ ----------- - -* Reverted GetUserName API usage on Windows. Fixed bug with missing library. -* Fixed bug in the Calculator example, preventing it's window to be raised - on Windows. - - Special thanks to Charles Gunawan. - -__3.0.5a__ ----------- - -* Fixed a memory leak in the SingleApplicationPrivate destructor. - - _Sergei Moiseev_ - -__3.0.4a__ ----------- - -* Fixed shadow and uninitialised variable warnings. - - _Paul Walmsley_ - -__3.0.3a__ ----------- - -* Removed Microsoft Windows specific code for getting username due to - multiple problems and compiler differences on Windows platforms. On - Windows the shared memory block in User mode now includes the user's - home path (which contains the user's username). - -* Explicitly getting absolute path of the user's home directory as on Unix - a relative path (`~`) may be returned. - -__3.0.2a__ ----------- - -* Fixed bug on Windows when username containing wide characters causes the - library to crash. - - _Le Liu_ - -__3.0.1a__ ----------- - -* Allows the application path and version to be excluded from the server name - hash. The following flags were added for this purpose: - * `SingleApplication::Mode::ExcludeAppVersion` - * `SingleApplication::Mode::ExcludeAppPath` -* Allow a non elevated process to connect to a local server created by an - elevated process run by the same user on Windows -* Fixes a problem with upper case letters in paths on Windows - - _Le Liu_ - -__v3.0a__ ---------- - -* Depricated secondary instances count. -* Added a sendMessage() method to send a message to the primary instance. -* Added a receivedMessage() signal, emitted when a message is received from a - secondary instance. -* The SingleApplication constructor's third parameter is now a bool - specifying if the current instance should be allowed to run as a secondary - instance if there is already a primary instance. -* The SingleApplication constructor accept a fourth parameter specifying if - the SingleApplication block should be User-wide or System-wide. -* SingleApplication no longer relies on `applicationName` and - `organizationName` to be set. It instead concatenates all of the following - data and computes a `SHA256` hash which is used as the key of the - `QSharedMemory` block and the `QLocalServer`. Since at least - `applicationFilePath` is always present there is no need to explicitly set - any of the following prior to initialising `SingleApplication`. - * `QCoreApplication::applicationName` - * `QCoreApplication::applicationVersion` - * `QCoreApplication::applicationFilePath` - * `QCoreApplication::organizationName` - * `QCoreApplication::organizationDomain` - * User name or home directory path if in User mode -* The primary instance is no longer notified when a secondary instance had - been started by default. A `Mode` flag for this feature exists. -* Added `instanceNumber()` which represents a unique identifier for each - secondary instance started. When called from the primary instance will - return `0`. - -__v2.4__ --------- - -* Stability improvements -* Support for secondary instances. -* The library now recovers safely after the primary process has crashed -and the shared memory had not been deleted. - -__v2.3__ --------- - -* Improved pimpl design and inheritance safety. - - _Vladislav Pyatnichenko_ - -__v2.2__ --------- - -* The `QAPPLICATION_CLASS` macro can now be defined in the file including the -Single Application header or with a `DEFINES+=` statement in the project file. - -__v2.1__ --------- - -* A race condition can no longer occur when starting two processes nearly - simultaneously. - - Fix issue [#3](https://github.com/itay-grudev/SingleApplication/issues/3) - -__v2.0__ --------- - -* SingleApplication is now being passed a reference to `argc` instead of a - copy. - - Fix issue [#1](https://github.com/itay-grudev/SingleApplication/issues/1) - -* Improved documentation. diff --git a/stremio-shell/deps/singleapplication/LICENSE b/stremio-shell/deps/singleapplication/LICENSE deleted file mode 100644 index 85b2a14..0000000 --- a/stremio-shell/deps/singleapplication/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Itay Grudev 2015 - 2016 - -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. - -Note: Some of the examples include code not distributed under the terms of the -MIT License. diff --git a/stremio-shell/deps/singleapplication/README.md b/stremio-shell/deps/singleapplication/README.md deleted file mode 100644 index e003ab4..0000000 --- a/stremio-shell/deps/singleapplication/README.md +++ /dev/null @@ -1,274 +0,0 @@ -SingleApplication -================= - -This is a replacement of the QtSingleApplication for `Qt5`. - -Keeps the Primary Instance of your Application and kills each subsequent -instances. It can (if enabled) spawn secondary (non-related to the primary) -instances and can send data to the primary instance from secondary instances. - -Usage ------ - -The `SingleApplication` class inherits from whatever `Q[Core|Gui]Application` -class you specify via the `QAPPLICATION_CLASS` macro (`QCoreApplication` is the -default). Further usage is similar to the use of the `Q[Core|Gui]Application` -classes. - -The library sets up a `QLocalServer` and a `QSharedMemory` block. The first -instance of your Application is your Primary Instance. It would check if the -shared memory block exists and if not it will start a `QLocalServer` and listen -for connections. Each subsequent instance of your application would check if the -shared memory block exists and if it does, it will connect to the QLocalServer -to notify the primary instance that a new instance had been started, after which -it would terminate with status code `0`. In the Primary Instance -`SingleApplication` would emit the `instanceStarted()` signal upon detecting -that a new instance had been started. - -The library uses `stdlib` to terminate the program with the `exit()` function. - -You can use the library as if you use any other `QCoreApplication` derived -class: - -```cpp -#include -#include - -int main( int argc, char* argv[] ) -{ - SingleApplication app( argc, argv ); - - return app.exec(); -} -``` - -To include the library files I would recommend that you add it as a git -submodule to your project and include it's contents with a `.pri` file. Here is -how: - -```bash -git submodule add git@github.com:itay-grudev/SingleApplication.git singleapplication -``` - -Then include the `singleapplication.pri` file in your `.pro` project file. Also -don't forget to specify which `QCoreApplication` class your app is using if it -is not `QCoreApplication`. - -```qmake -include(singleapplication/singleapplication.pri) -DEFINES += QAPPLICATION_CLASS=QApplication -``` - -The `Instance Started` signal ------------------------- - -The SingleApplication class implements a `instanceStarted()` signal. You can -bind to that signal to raise your application's window when a new instance had -been started, for example. - -```cpp -// window is a QWindow instance -QObject::connect( - &app, - &SingleApplication::instanceStarted, - &window, - &QWindow::raise -); -``` - -Using `SingleApplication::instance()` is a neat way to get the -`SingleApplication` instance for binding to it's signals anywhere in your -program. - -Secondary Instances -------------------- - -If you want to be able to launch additional Secondary Instances (not related to -your Primary Instance) you have to enable that with the third parameter of the -`SingleApplication` constructor. The default is `false` meaning no Secondary -Instances. Here is an example of how you would start a Secondary Instance send -a message with the command line arguments to the primary instance and then shut -down. - -```cpp -int main(int argc, char *argv[]) -{ - SingleApplication app( argc, argv, true ); - - if( app.isSecondary() ) { - app.sendMessage( app.arguments().join(' ')).toUtf8() ); - app.exit( 0 ); - } - - return app.exec(); -} -``` - -*__Note:__ A secondary instance won't cause the emission of the -`instanceStarted()` signal by default. See `SingleApplication::Mode` for more -details.* - -You can check whether your instance is a primary or secondary with the following -methods: - -```cpp -app.isPrimary(); -// or -app.isSecondary(); -``` - -*__Note:__ If your Primary Instance is terminated a newly launched instance -will replace the Primary one even if the Secondary flag has been set.* - -API ---- - -### Members - -```cpp -SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100 ) -``` - -Depending on whether `allowSecondary` is set, this constructor may terminate -your app if there is already a primary instance running. Additional `Options` -can be specified to set whether the SingleApplication block should work -user-wide or system-wide. Additionally the `Mode::SecondaryNotification` may be -used to notify the primary instance whenever a secondary instance had been -started (disabled by default). `timeout` specifies the maximum time in -milliseconds to wait for blocking operations. - -*__Note:__ `argc` and `argv` may be changed as Qt removes arguments that it -recognizes.* - -*__Note:__ `Mode::SecondaryNotification` only works if set on both the primary -and the secondary instance.* - -*__Note:__ Operating system can restrict the shared memory blocks to the same -user, in which case the User/System modes will have no effect and the block will -be user wide.* - ---- - -```cpp -bool SingleApplication::sendMessage( QByteArray message, int timeout = 100 ) -``` - -Sends `message` to the Primary Instance. Uses `timeout` as a the maximum timeout -in milliseconds for blocking functions - ---- - -```cpp -bool SingleApplication::isPrimary() -``` - -Returns if the instance is the primary instance. - ---- - -```cpp -bool SingleApplication::isSecondary() -``` -Returns if the instance is a secondary instance. - ---- - -```cpp -quint32 SingleApplication::instanceId() -``` - -Returns a unique identifier for the current instance - -### Signals - -```cpp -void SingleApplication::instanceStarted() -``` - -Triggered whenever a new instance had been started, except for secondary -instances if the `Mode::SecondaryNotification` flag is not specified. - ---- - -```cpp -void SingleApplication::receivedMessage( quint32 instanceId, QByteArray message ) -``` - -Triggered whenever there is a message received from a secondary instance. - ---- - -### Flags - -```cpp -enum SingleApplication::Mode -``` - -* `Mode::User` - The SingleApplication block should apply user wide. This adds - user specific data to the key used for the shared memory and server name. - This is the default functionality. -* `Mode::System` – The SingleApplication block applies system-wide. -* `Mode::SecondaryNotification` – Whether to trigger `instanceStarted()` even - whenever secondary instances are started. -* `Mode::ExcludeAppPath` – Excludes the application path from the server name - (and memory block) hash. -* `Mode::ExcludeAppVersion` – Excludes the application version from the server - name (and memory block) hash. - -*__Note:__ `Mode::SecondaryNotification` only works if set on both the primary -and the secondary instance.* - -*__Note:__ Operating system can restrict the shared memory blocks to the same -user, in which case the User/System modes will have no effect and the block will -be user wide.* - ---- - -Versioning ----------- - -Each major version introduces either very significant changes or is not -backwards compatible with the previous version. Minor versions only add -additional features, bug fixes or performance improvements and are backwards -compatible with the previous release. See [`CHANGELOG.md`](CHANGELOG.md) for -more details. - -Implementation --------------- - -The library is implemented with a QSharedMemory block which is thread safe and -guarantees a race condition will not occur. It also uses a QLocalSocket to -notify the main process that a new instance had been spawned and thus invoke the -`instanceStarted()` signal. - -To handle an issue on `*nix` systems, where the operating system owns the shared -memory block and if the program crashes the memory remains untouched, the -library binds to the following signals and closes the program with -`error code = 128 + signum` where signum is the number representation of the -signal listed below. Handling the signal is required in order to safely delete -the `QSharedMemory` block. Each of these signals are potentially lethal and will -results in process termination. - -* `SIGHUP` - `1`, Hangup. -* `SIGINT` - `2`, Terminal interrupt signal -* `SIGQUIT` - `3`, Terminal quit signal. -* `SIGILL` - `4`, Illegal instruction. -* `SIGABRT` - `6`, Process abort signal. -* `SIGBUS` - `7`, Access to an undefined portion of a memory object. -* `SIGFPE` - `8`, Erroneous arithmetic operation (such as division by zero). -* `SIGSEGV` - `11`, Invalid memory reference. -* `SIGSYS` - `12`, Bad system call. -* `SIGPIPE` - `13`, Write on a pipe with no one to read it. -* `SIGALRM` - `14`, Alarm clock. -* `SIGTERM` - `15`, Termination signal. -* `SIGXCPU` - `24`, CPU time limit exceeded. -* `SIGXFSZ` - `25`, File size limit exceeded. - -Additionally the library can recover from being killed with uncatchable signals -and will reset the memory block given that there are no other instances running. - -License -------- -This library and it's supporting documentation are released under -`The MIT License (MIT)` with the exception of some of the examples distributed -under the BSD license. diff --git a/stremio-shell/deps/singleapplication/examples/basic/basic.pro b/stremio-shell/deps/singleapplication/examples/basic/basic.pro deleted file mode 100644 index b7af16c..0000000 --- a/stremio-shell/deps/singleapplication/examples/basic/basic.pro +++ /dev/null @@ -1,5 +0,0 @@ -# Single Application implementation -include(../../singleapplication.pri) -DEFINES += QAPPLICATION_CLASS=QCoreApplication - -SOURCES += main.cpp diff --git a/stremio-shell/deps/singleapplication/examples/basic/main.cpp b/stremio-shell/deps/singleapplication/examples/basic/main.cpp deleted file mode 100644 index 4787d1c..0000000 --- a/stremio-shell/deps/singleapplication/examples/basic/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main(int argc, char *argv[]) -{ - // Allow secondary instances - SingleApplication app( argc, argv ); - - return app.exec(); -} diff --git a/stremio-shell/deps/singleapplication/examples/calculator/button.cpp b/stremio-shell/deps/singleapplication/examples/calculator/button.cpp deleted file mode 100644 index 0d622b1..0000000 --- a/stremio-shell/deps/singleapplication/examples/calculator/button.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * 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. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** 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 -** OWNER 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." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "button.h" - -//! [0] -Button::Button(const QString &text, QWidget *parent) - : QToolButton(parent) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - setText(text); -} -//! [0] - -//! [1] -QSize Button::sizeHint() const -//! [1] //! [2] -{ - QSize size = QToolButton::sizeHint(); - size.rheight() += 20; - size.rwidth() = qMax(size.width(), size.height()); - return size; -} -//! [2] diff --git a/stremio-shell/deps/singleapplication/examples/calculator/button.h b/stremio-shell/deps/singleapplication/examples/calculator/button.h deleted file mode 100644 index b06edc1..0000000 --- a/stremio-shell/deps/singleapplication/examples/calculator/button.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * 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. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** 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 -** OWNER 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." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BUTTON_H -#define BUTTON_H - -#include - -//! [0] -class Button : public QToolButton -{ - Q_OBJECT - -public: - explicit Button(const QString &text, QWidget *parent = 0); - - QSize sizeHint() const Q_DECL_OVERRIDE; -}; -//! [0] - -#endif diff --git a/stremio-shell/deps/singleapplication/examples/calculator/calculator.cpp b/stremio-shell/deps/singleapplication/examples/calculator/calculator.cpp deleted file mode 100644 index cbcc29b..0000000 --- a/stremio-shell/deps/singleapplication/examples/calculator/calculator.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * 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. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** 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 -** OWNER 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." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include "button.h" -#include "calculator.h" - -//! [0] -Calculator::Calculator(QWidget *parent) - : QWidget(parent) -{ - sumInMemory = 0.0; - sumSoFar = 0.0; - factorSoFar = 0.0; - waitingForOperand = true; -//! [0] - -//! [1] - display = new QLineEdit("0"); -//! [1] //! [2] - display->setReadOnly(true); - display->setAlignment(Qt::AlignRight); - display->setMaxLength(15); - - QFont font = display->font(); - font.setPointSize(font.pointSize() + 8); - display->setFont(font); -//! [2] - -//! [4] - for (int i = 0; i < NumDigitButtons; ++i) { - digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); - } - - Button *pointButton = createButton(tr("."), SLOT(pointClicked())); - Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked())); - - Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); - Button *clearButton = createButton(tr("Clear"), SLOT(clear())); - Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); - - Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); - Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); - Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); - Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); - - Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked())); - Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked())); - Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); - Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); - - Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); - Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked())); - Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); - Button *equalButton = createButton(tr("="), SLOT(equalClicked())); -//! [4] - -//! [5] - QGridLayout *mainLayout = new QGridLayout; -//! [5] //! [6] - mainLayout->setSizeConstraint(QLayout::SetFixedSize); - mainLayout->addWidget(display, 0, 0, 1, 6); - mainLayout->addWidget(backspaceButton, 1, 0, 1, 2); - mainLayout->addWidget(clearButton, 1, 2, 1, 2); - mainLayout->addWidget(clearAllButton, 1, 4, 1, 2); - - mainLayout->addWidget(clearMemoryButton, 2, 0); - mainLayout->addWidget(readMemoryButton, 3, 0); - mainLayout->addWidget(setMemoryButton, 4, 0); - mainLayout->addWidget(addToMemoryButton, 5, 0); - - for (int i = 1; i < NumDigitButtons; ++i) { - int row = ((9 - i) / 3) + 2; - int column = ((i - 1) % 3) + 1; - mainLayout->addWidget(digitButtons[i], row, column); - } - - mainLayout->addWidget(digitButtons[0], 5, 1); - mainLayout->addWidget(pointButton, 5, 2); - mainLayout->addWidget(changeSignButton, 5, 3); - - mainLayout->addWidget(divisionButton, 2, 4); - mainLayout->addWidget(timesButton, 3, 4); - mainLayout->addWidget(minusButton, 4, 4); - mainLayout->addWidget(plusButton, 5, 4); - - mainLayout->addWidget(squareRootButton, 2, 5); - mainLayout->addWidget(powerButton, 3, 5); - mainLayout->addWidget(reciprocalButton, 4, 5); - mainLayout->addWidget(equalButton, 5, 5); - setLayout(mainLayout); - - setWindowTitle(tr("Calculator")); -} -//! [6] - -//! [7] -void Calculator::digitClicked() -{ - Button *clickedButton = qobject_cast