├── .gitignore ├── README.md ├── build.sh ├── clean.sh ├── compile.sh ├── download.sh ├── framework-meta ├── Info.plist └── libmpv │ ├── Headers │ ├── client.h │ ├── libmpv.h │ ├── render.h │ ├── render_gl.h │ └── stream_cb.h │ └── Modules │ └── module.modulemap ├── help ├── configure-help.txt └── ffmpeg-configure-help.txt ├── install-gas-preprocessor.sh ├── install-openssl.sh ├── patch-ffmpeg.diff ├── patch-mpv.diff ├── patch.diff ├── scripts ├── ffmpeg-build ├── freetype-build ├── fribidi-build ├── harfbuzz-build ├── libass-build ├── mpv-build ├── patch-waf.diff └── uchardet-build └── xcframework.sh /.gitignore: -------------------------------------------------------------------------------- 1 | openssl-src/ 2 | lib-ios/ 3 | lib-tv/ 4 | downloads/ 5 | src/ 6 | scratch-ios/ 7 | scratch-tv/ 8 | openssl-ios/ 9 | openssl-tv/ 10 | openssl/ 11 | lib/ 12 | .DS_Store 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mpv iOS build scripts 2 | 3 | 本腳本的目的是構建 tvOS 和 iOS 可用的 mpv 靜態庫。 4 | 5 | These are build scripts for building [libmpv](https://github.com/mpv-player/mpv), and its dependencies: 6 | 7 | - FFmpeg 8 | - libass 9 | - freetype 10 | - harfbuzz 11 | - fribidi 12 | - uchardet 13 | 14 | ## Configuration 15 | 16 | Tested with: 17 | 18 | - macOS 14.0 19 | - Xcode 15.0 20 | 21 | ## Brew 22 | 23 | https://gist.github.com/dbrookman/74b8bcfb37a23452f7137b83bca9580f 24 | 25 | ``` 26 | brew install pkg-config brotli 27 | brew install --build-from-source --only-dependencies mpv 28 | ``` 29 | 30 | ## 使用 31 | 32 | 1. 運行 `./install-openssl.sh` 以生成 tvOS / iOS 所需的 openssl。 33 | 2. 運行 `./clean.sh && ./download.sh` 執行清理、下載的步驟。 34 | 3. 運行 `./build.sh` 即可開始 Build 的過程。 35 | 4. 運行 `./xcframework.sh` 即可構建 xcframework 庫。 36 | 37 | `build.sh` 存在一個 Bug,第一次下載構建時候會失敗,重新執行即可。 38 | 39 | 本腳本移除了 x86_64 的框架支持。 40 | 41 | 如果需要更新 openssl 版本號,修改 `install-openssl.sh` 中的 version 即可。 42 | 並非所有的 openssl 版本號都可用,最後測試 1.1.1w 可正常通過編譯。 43 | 如若遇到缺少 gas-preprocessor 提示,請執行 `install-gas-preprocessor.sh` 44 | 45 | ## 最小版本號問題 46 | 47 | https://juejin.cn/post/7182833413835980859 48 | 49 | 追加了最小版本號:15.1 50 | 修改最小版本號需要修改兩個地方: 51 | 52 | 1. `framework-meta/Info.plist` 把 MinimumOSVersion 改成所需要的值。 53 | 2. `xcframework.sh` 把 Add :MinimumOSVersion string 15.1 的 15.1 改成所需要的值。 54 | 55 | ## Download 版本 56 | 57 | 更新最適配的版本 mpv 0.35.1 + ffmpeg 6.0 58 | 59 | ## Diff patch 60 | 61 | `diff -u a.file b.file > patch.diff` 62 | `diff -Nur ./src/mpv-0.35.1-b/ ./src/mpv-0.35.1/ > patch-mpv.diff` 63 | `rm -rf scratch-ios scratch-tv && ./compile.sh -p tv -e development` 64 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | rm -rf scratch-ios scratch-tv 4 | ./compile.sh -p ios -e development && ./compile.sh -p tv -e development 5 | ./compile.sh -p ios -e distribution && ./compile.sh -p tv -e distribution 6 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | rm -rf downloads src scratch-ios scratch-tv lib-ios lib-tv -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | LIBRARIES="libuchardet libfribidi libfreetype libharfbuzz libass ffmpeg libmpv libssl" 4 | IOS_SDK_VERSION=$(xcrun -sdk iphoneos --show-sdk-version) 5 | TVOS_SDK_VERSION=$(xcrun -sdk appletvos --show-sdk-version) 6 | DEPLOYMENT_TARGET="15.0" 7 | 8 | export PKG_CONFIG_PATH 9 | export LDFLAGS 10 | export CFLAGS 11 | export CXXFLAGS 12 | export COMMON_OPTIONS 13 | export ENVIRONMENT 14 | export ARCH 15 | export PLATFORM 16 | export CMAKE_OSX_ARCHITECTURES 17 | 18 | while getopts "p:e:" OPTION; do 19 | case $OPTION in 20 | e) 21 | ENVIRONMENT=$(echo "$OPTARG" | awk '{print tolower($0)}') 22 | ;; 23 | p) 24 | PLATFORM=$(echo "$OPTARG" | awk '{print tolower($0)}') 25 | ;; 26 | ?) 27 | echo "Invalid option" 28 | exit 1 29 | ;; 30 | esac 31 | done 32 | 33 | export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:$PATH" 34 | 35 | if [[ "$ENVIRONMENT" = "distribution" ]]; then 36 | ARCHS="arm64" 37 | elif [[ "$ENVIRONMENT" = "development" ]]; then 38 | ARCHS="arm64" 39 | elif [[ "$ENVIRONMENT" = "" ]]; then 40 | echo "An environment option is required (-e development or -e distribution)" 41 | exit 1 42 | else 43 | echo "Unhandled environment option" 44 | exit 1 45 | fi 46 | 47 | if [[ "$PLATFORM" = "ios" ]]; then 48 | SDK_VERSION=$IOS_SDK_VERSION 49 | PLATFORM_SIMULATOR="iPhoneSimulator" 50 | PLATFORM_DEVICE="iPhoneOS" 51 | SDKPATH_SIMULATOR="$(xcodebuild -sdk iphonesimulator -version Path)" 52 | SDKPATH_DEVICE="$(xcodebuild -sdk iphoneos -version Path)" 53 | MIN_VERSION_SIMULATOR_CFLAG="-mios-simulator-version-min" 54 | MIN_VERSION_SIMULATOR_LDFLAG="-Wl,-ios_simulator_version_min" 55 | MIN_VERSION_DEVICE_CFLAG="-mios-version-min" 56 | MIN_VERSION_DEVICE_LDFLAG="-Wl,-ios_version_min" 57 | elif [[ "$PLATFORM" = "tv" ]]; then 58 | SDK_VERSION=$TVOS_SDK_VERSION 59 | PLATFORM_SIMULATOR="AppleTVSimulator" 60 | PLATFORM_DEVICE="AppleTVOS" 61 | SDKPATH_SIMULATOR="$(xcodebuild -sdk appletvsimulator -version Path)" 62 | SDKPATH_DEVICE="$(xcodebuild -sdk appletvos -version Path)" 63 | MIN_VERSION_SIMULATOR_CFLAG="-mtvos-simulator-version-min" 64 | MIN_VERSION_SIMULATOR_LDFLAG="-Wl,-tvos_simulator_version_min" 65 | MIN_VERSION_DEVICE_CFLAG="-mtvos-version-min" 66 | MIN_VERSION_DEVICE_LDFLAG="-Wl,-tvos_version_min" 67 | elif [[ "$PLATFORM" = "" ]]; then 68 | echo "A platform option is required (-p ios or -p tv)" 69 | exit 1 70 | else 71 | echo "Unhandled platform option" 72 | exit 1 73 | fi 74 | 75 | ROOT="$(pwd)" 76 | SCRIPTS="$ROOT/scripts" 77 | SCRATCH="$ROOT/scratch-$PLATFORM" 78 | export SRC="$ROOT/src" 79 | 80 | for ARCH in $ARCHS; do 81 | echo "ARCH -- "$ARCH 82 | if [[ $ARCH = "arm64" ]]; then 83 | HOSTFLAG="aarch64" 84 | CMAKE_OSX_ARCHITECTURES=$ARCH 85 | if [[ "$ENVIRONMENT" = "development" ]]; then 86 | PLATFORM=$PLATFORM_SIMULATOR 87 | export SDKPATH=$SDKPATH_SIMULATOR 88 | ACFLAGS="-arch $ARCH -isysroot $SDKPATH $MIN_VERSION_SIMULATOR_CFLAG=$DEPLOYMENT_TARGET" 89 | ALDFLAGS="-arch $ARCH -isysroot $SDKPATH $MIN_VERSION_SIMULATOR_LDFLAG,$DEPLOYMENT_TARGET -lbz2" 90 | OPENSSL="$ROOT/openssl/$PLATFORM$SDK_VERSION-arm64.sdk" 91 | else 92 | PLATFORM=$PLATFORM_DEVICE 93 | export SDKPATH=$SDKPATH_DEVICE 94 | ACFLAGS="-arch $ARCH -isysroot $SDKPATH $MIN_VERSION_DEVICE_CFLAG=$DEPLOYMENT_TARGET" 95 | ALDFLAGS="-arch $ARCH -isysroot $SDKPATH $MIN_VERSION_DEVICE_LDFLAG,$DEPLOYMENT_TARGET -lbz2" 96 | OPENSSL="$ROOT/openssl/$PLATFORM$SDK_VERSION-arm64.sdk" 97 | fi 98 | elif [[ $ARCH = "x86_64" ]]; then 99 | HOSTFLAG="x86_64" 100 | CMAKE_OSX_ARCHITECTURES=$ARCH 101 | PLATFORM=$PLATFORM_SIMULATOR 102 | export SDKPATH=$SDKPATH_SIMULATOR 103 | ACFLAGS="-arch $ARCH -isysroot $SDKPATH $MIN_VERSION_SIMULATOR_CFLAG=$DEPLOYMENT_TARGET" 104 | ALDFLAGS="-arch $ARCH -isysroot $SDKPATH $MIN_VERSION_SIMULATOR_LDFLAG,$DEPLOYMENT_TARGET -lbz2" 105 | OPENSSL="$ROOT/openssl/$PLATFORM$SDK_VERSION-$HOSTFLAG.sdk" 106 | else 107 | echo "Unhandled architecture option" 108 | exit 1 109 | fi 110 | 111 | CFLAGS="$ACFLAGS -fembed-bitcode -Os" 112 | LDFLAGS="$ALDFLAGS -fembed-bitcode -Os" 113 | CXXFLAGS="$CFLAGS" 114 | 115 | echo "OPENSSL PTAH -->$OPENSSL" 116 | CFLAGS="$CFLAGS -I$OPENSSL/include" 117 | LDFLAGS="$LDFLAGS -L$OPENSSL/lib" 118 | 119 | mkdir -p $SCRATCH 120 | 121 | PKG_CONFIG_PATH="$SCRATCH/$ARCH-$ENVIRONMENT/lib/pkgconfig" 122 | COMMON_OPTIONS="--prefix=$SCRATCH/$ARCH-$ENVIRONMENT --exec-prefix=$SCRATCH/$ARCH-$ENVIRONMENT --build=x86_64-apple-darwin14 --enable-static \ 123 | --disable-shared --disable-dependency-tracking --with-pic --host=$HOSTFLAG" 124 | 125 | for LIBRARY in $LIBRARIES; do 126 | case $LIBRARY in 127 | "libfribidi") 128 | mkdir -p $SCRATCH/$ARCH-$ENVIRONMENT/fribidi && cd $_ && $SCRIPTS/fribidi-build 129 | ;; 130 | "libfreetype") 131 | mkdir -p $SCRATCH/$ARCH-$ENVIRONMENT/freetype && cd $_ && $SCRIPTS/freetype-build 132 | ;; 133 | "libharfbuzz") 134 | mkdir -p $SCRATCH/$ARCH-$ENVIRONMENT/harfbuzz && cd $_ && $SCRIPTS/harfbuzz-build 135 | ;; 136 | "libass") 137 | mkdir -p $SCRATCH/$ARCH-$ENVIRONMENT/libass && cd $_ && $SCRIPTS/libass-build 138 | ;; 139 | "libuchardet") 140 | mkdir -p $SCRATCH/$ARCH-$ENVIRONMENT/uchardet && cd $_ && $SCRIPTS/uchardet-build 141 | ;; 142 | "ffmpeg") 143 | mkdir -p $SCRATCH/$ARCH-$ENVIRONMENT/ffmpeg && cd $_ && $SCRIPTS/ffmpeg-build 144 | ;; 145 | "libmpv") 146 | if [[ "$ENVIRONMENT" = "development" ]]; then 147 | CFLAGS="$ACFLAGS -fembed-bitcode -g2 -Og" 148 | LDFLAGS="$ALDFLAGS -fembed-bitcode -g2 -Og" 149 | fi 150 | $SCRIPTS/mpv-build && cp $SRC/mpv*/build/libmpv.a "$SCRATCH/$ARCH-$ENVIRONMENT/lib" 151 | ;; 152 | "libssl") 153 | cp -a $OPENSSL/include/. $SCRATCH/$ARCH-$ENVIRONMENT/include/ 154 | cp -a $OPENSSL/lib/. $SCRATCH/$ARCH-$ENVIRONMENT/lib/ 155 | ;; 156 | esac 157 | done 158 | done 159 | -------------------------------------------------------------------------------- /download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # Change to preferred versions 4 | MPV_VERSION="0.35.1" 5 | FFMPEG_VERSION="5.1.3" 6 | LIBASS_VERSION="0.14.0" 7 | FREETYPE_VERSION="2.10.0" 8 | HARFBUZZ_VERSION="4.3.0" 9 | FRIBIDI_VERSION="1.0.8" 10 | UCHARDET_VERSION="0.0.7" 11 | 12 | MPV_URL="https://github.com/mpv-player/mpv/archive/v$MPV_VERSION.tar.gz" 13 | FFMPEG_URL="http://www.ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" 14 | LIBASS_URL="https://github.com/libass/libass/releases/download/$LIBASS_VERSION/libass-$LIBASS_VERSION.tar.gz" 15 | FREETYPE_URL="https://sourceforge.net/projects/freetype/files/freetype2/$FREETYPE_VERSION/freetype-$FREETYPE_VERSION.tar.gz" 16 | HARFBUZZ_URL="https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION/harfbuzz-$HARFBUZZ_VERSION.tar.xz" 17 | FRIBIDI_URL="https://github.com/fribidi/fribidi/releases/download/v$FRIBIDI_VERSION/fribidi-$FRIBIDI_VERSION.tar.bz2" 18 | UCHARDET_URL="https://www.freedesktop.org/software/uchardet/releases/uchardet-$UCHARDET_VERSION.tar.xz" 19 | 20 | rm -rf src 21 | mkdir -p src downloads 22 | for URL in $UCHARDET_URL $FREETYPE_URL $HARFBUZZ_URL $FRIBIDI_URL $LIBASS_URL $FFMPEG_URL $MPV_URL; do 23 | TARNAME=${URL##*/} 24 | if [ ! -f "downloads/$TARNAME" ]; then 25 | echo $URL 26 | curl -f -L -- $URL >downloads/$TARNAME 27 | fi 28 | echo "$TARNAME" 29 | tar xvf downloads/$TARNAME -C src 30 | done 31 | 32 | sed -i "" "s/typedef ptrdiff_t GLsizeiptr;/typedef intptr_t GLsizeiptr;/" ./src/mpv-$MPV_VERSION/video/out/opengl/gl_headers.h 33 | 34 | patch -p0 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | {NAME} 9 | CFBundleIdentifier 10 | com.na.{NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | {NAME} 15 | CFBundlePackageType 16 | FMWK 17 | MinimumOSVersion 18 | 15.1 19 | CFBundleShortVersionString 20 | 1.0.0 21 | CFBundleVersion 22 | 1 23 | 24 | -------------------------------------------------------------------------------- /framework-meta/libmpv/Headers/client.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 the mpv developers 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | /* 17 | * Note: the client API is licensed under ISC (see above) to enable 18 | * other wrappers outside of mpv. But keep in mind that the 19 | * mpv core is by default still GPLv2+ - unless built with 20 | * --enable-lgpl, which makes it LGPLv2+. 21 | */ 22 | 23 | #ifndef MPV_CLIENT_API_H_ 24 | #define MPV_CLIENT_API_H_ 25 | 26 | #include 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * Mechanisms provided by this API 35 | * ------------------------------- 36 | * 37 | * This API provides general control over mpv playback. It does not give you 38 | * direct access to individual components of the player, only the whole thing. 39 | * It's somewhat equivalent to MPlayer's slave mode. You can send commands, 40 | * retrieve or set playback status or settings with properties, and receive 41 | * events. 42 | * 43 | * The API can be used in two ways: 44 | * 1) Internally in mpv, to provide additional features to the command line 45 | * player. Lua scripting uses this. (Currently there is no plugin API to 46 | * get a client API handle in external user code. It has to be a fixed 47 | * part of the player at compilation time.) 48 | * 2) Using mpv as a library with mpv_create(). This basically allows embedding 49 | * mpv in other applications. 50 | * 51 | * Documentation 52 | * ------------- 53 | * 54 | * The libmpv C API is documented directly in this header. Note that most 55 | * actual interaction with this player is done through 56 | * options/commands/properties, which can be accessed through this API. 57 | * Essentially everything is done with them, including loading a file, 58 | * retrieving playback progress, and so on. 59 | * 60 | * These are documented elsewhere: 61 | * * http://mpv.io/manual/master/#options 62 | * * http://mpv.io/manual/master/#list-of-input-commands 63 | * * http://mpv.io/manual/master/#properties 64 | * 65 | * You can also look at the examples here: 66 | * * https://github.com/mpv-player/mpv-examples/tree/master/libmpv 67 | * 68 | * Event loop 69 | * ---------- 70 | * 71 | * In general, the API user should run an event loop in order to receive events. 72 | * This event loop should call mpv_wait_event(), which will return once a new 73 | * mpv client API is available. It is also possible to integrate client API 74 | * usage in other event loops (e.g. GUI toolkits) with the 75 | * mpv_set_wakeup_callback() function, and then polling for events by calling 76 | * mpv_wait_event() with a 0 timeout. 77 | * 78 | * Note that the event loop is detached from the actual player. Not calling 79 | * mpv_wait_event() will not stop playback. It will eventually congest the 80 | * event queue of your API handle, though. 81 | * 82 | * Synchronous vs. asynchronous calls 83 | * ---------------------------------- 84 | * 85 | * The API allows both synchronous and asynchronous calls. Synchronous calls 86 | * have to wait until the playback core is ready, which currently can take 87 | * an unbounded time (e.g. if network is slow or unresponsive). Asynchronous 88 | * calls just queue operations as requests, and return the result of the 89 | * operation as events. 90 | * 91 | * Asynchronous calls 92 | * ------------------ 93 | * 94 | * The client API includes asynchronous functions. These allow you to send 95 | * requests instantly, and get replies as events at a later point. The 96 | * requests are made with functions carrying the _async suffix, and replies 97 | * are returned by mpv_wait_event() (interleaved with the normal event stream). 98 | * 99 | * A 64 bit userdata value is used to allow the user to associate requests 100 | * with replies. The value is passed as reply_userdata parameter to the request 101 | * function. The reply to the request will have the reply 102 | * mpv_event->reply_userdata field set to the same value as the 103 | * reply_userdata parameter of the corresponding request. 104 | * 105 | * This userdata value is arbitrary and is never interpreted by the API. Note 106 | * that the userdata value 0 is also allowed, but then the client must be 107 | * careful not accidentally interpret the mpv_event->reply_userdata if an 108 | * event is not a reply. (For non-replies, this field is set to 0.) 109 | * 110 | * Asynchronous calls may be reordered in arbitrarily with other synchronous 111 | * and asynchronous calls. If you want a guaranteed order, you need to wait 112 | * until asynchronous calls report completion before doing the next call. 113 | * 114 | * See also the section "Asynchronous command details" in the manpage. 115 | * 116 | * Multithreading 117 | * -------------- 118 | * 119 | * The client API is generally fully thread-safe, unless otherwise noted. 120 | * Currently, there is no real advantage in using more than 1 thread to access 121 | * the client API, since everything is serialized through a single lock in the 122 | * playback core. 123 | * 124 | * Basic environment requirements 125 | * ------------------------------ 126 | * 127 | * This documents basic requirements on the C environment. This is especially 128 | * important if mpv is used as library with mpv_create(). 129 | * 130 | * - The LC_NUMERIC locale category must be set to "C". If your program calls 131 | * setlocale(), be sure not to use LC_ALL, or if you do, reset LC_NUMERIC 132 | * to its sane default: setlocale(LC_NUMERIC, "C"). 133 | * - If a X11 based VO is used, mpv will set the xlib error handler. This error 134 | * handler is process-wide, and there's no proper way to share it with other 135 | * xlib users within the same process. This might confuse GUI toolkits. 136 | * - mpv uses some other libraries that are not library-safe, such as Fribidi 137 | * (used through libass), ALSA, FFmpeg, and possibly more. 138 | * - The FPU precision must be set at least to double precision. 139 | * - On Windows, mpv will call timeBeginPeriod(1). 140 | * - On memory exhaustion, mpv will kill the process. 141 | * - In certain cases, mpv may start sub processes (such as with the ytdl 142 | * wrapper script). 143 | * - Using UNIX IPC (off by default) will override the SIGPIPE signal handler, 144 | * and set it to SIG_IGN. 145 | * - mpv will reseed the legacy C random number generator by calling srand() at 146 | * some random point once. 147 | * 148 | * Encoding of filenames 149 | * --------------------- 150 | * 151 | * mpv uses UTF-8 everywhere. 152 | * 153 | * On some platforms (like Linux), filenames actually do not have to be UTF-8; 154 | * for this reason libmpv supports non-UTF-8 strings. libmpv uses what the 155 | * kernel uses and does not recode filenames. At least on Linux, passing a 156 | * string to libmpv is like passing a string to the fopen() function. 157 | * 158 | * On Windows, filenames are always UTF-8, libmpv converts between UTF-8 and 159 | * UTF-16 when using win32 API functions. libmpv never uses or accepts 160 | * filenames in the local 8 bit encoding. It does not use fopen() either; 161 | * it uses _wfopen(). 162 | * 163 | * On OS X, filenames and other strings taken/returned by libmpv can have 164 | * inconsistent unicode normalization. This can sometimes lead to problems. 165 | * You have to hope for the best. 166 | * 167 | * Also see the remarks for MPV_FORMAT_STRING. 168 | * 169 | * Embedding the video window 170 | * -------------------------- 171 | * 172 | * Using the render API (in render_cb.h) is recommended. This API requires 173 | * you to create and maintain an OpenGL context, to which you can render 174 | * video using a specific API call. This API does not include keyboard or mouse 175 | * input directly. 176 | * 177 | * There is an older way to embed the native mpv window into your own. You have 178 | * to get the raw window handle, and set it as "wid" option. This works on X11, 179 | * win32, and OSX only. It's much easier to use than the render API, but 180 | * also has various problems. 181 | * 182 | * Also see client API examples and the mpv manpage. There is an extensive 183 | * discussion here: 184 | * https://github.com/mpv-player/mpv-examples/tree/master/libmpv#methods-of-embedding-the-video-window 185 | * 186 | * Compatibility 187 | * ------------- 188 | * 189 | * mpv development doesn't stand still, and changes to mpv internals as well as 190 | * to its interface can cause compatibility issues to client API users. 191 | * 192 | * The API is versioned (see MPV_CLIENT_API_VERSION), and changes to it are 193 | * documented in DOCS/client-api-changes.rst. The C API itself will probably 194 | * remain compatible for a long time, but the functionality exposed by it 195 | * could change more rapidly. For example, it's possible that options are 196 | * renamed, or change the set of allowed values. 197 | * 198 | * Defensive programming should be used to potentially deal with the fact that 199 | * options, commands, and properties could disappear, change their value range, 200 | * or change the underlying datatypes. It might be a good idea to prefer 201 | * MPV_FORMAT_STRING over other types to decouple your code from potential 202 | * mpv changes. 203 | * 204 | * Also see: DOCS/compatibility.rst 205 | * 206 | * Future changes 207 | * -------------- 208 | * 209 | * This are the planned changes that will most likely be done on the next major 210 | * bump of the library: 211 | * 212 | * - remove all symbols and include files that are marked as deprecated 213 | * - reassign enum numerical values to remove gaps 214 | * - remove the mpv_opengl_init_params.extra_exts field 215 | * - change the type of mpv_event_end_file.reason 216 | * - disabling all events by default 217 | */ 218 | 219 | /** 220 | * The version is incremented on each API change. The 16 lower bits form the 221 | * minor version number, and the 16 higher bits the major version number. If 222 | * the API becomes incompatible to previous versions, the major version 223 | * number is incremented. This affects only C part, and not properties and 224 | * options. 225 | * 226 | * Every API bump is described in DOCS/client-api-changes.rst 227 | * 228 | * You can use MPV_MAKE_VERSION() and compare the result with integer 229 | * relational operators (<, >, <=, >=). 230 | */ 231 | #define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL) 232 | #define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 107) 233 | 234 | /** 235 | * The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before 236 | * including any libmpv headers. Then deprecated symbols will be excluded 237 | * from the headers. (Of course, deprecated properties and commands and 238 | * other functionality will still work.) 239 | */ 240 | #ifndef MPV_ENABLE_DEPRECATED 241 | #define MPV_ENABLE_DEPRECATED 1 242 | #endif 243 | 244 | /** 245 | * Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with. 246 | */ 247 | unsigned long mpv_client_api_version(void); 248 | 249 | /** 250 | * Client context used by the client API. Every client has its own private 251 | * handle. 252 | */ 253 | typedef struct mpv_handle mpv_handle; 254 | 255 | /** 256 | * List of error codes than can be returned by API functions. 0 and positive 257 | * return values always mean success, negative values are always errors. 258 | */ 259 | typedef enum mpv_error { 260 | /** 261 | * No error happened (used to signal successful operation). 262 | * Keep in mind that many API functions returning error codes can also 263 | * return positive values, which also indicate success. API users can 264 | * hardcode the fact that ">= 0" means success. 265 | */ 266 | MPV_ERROR_SUCCESS = 0, 267 | /** 268 | * The event ringbuffer is full. This means the client is choked, and can't 269 | * receive any events. This can happen when too many asynchronous requests 270 | * have been made, but not answered. Probably never happens in practice, 271 | * unless the mpv core is frozen for some reason, and the client keeps 272 | * making asynchronous requests. (Bugs in the client API implementation 273 | * could also trigger this, e.g. if events become "lost".) 274 | */ 275 | MPV_ERROR_EVENT_QUEUE_FULL = -1, 276 | /** 277 | * Memory allocation failed. 278 | */ 279 | MPV_ERROR_NOMEM = -2, 280 | /** 281 | * The mpv core wasn't configured and initialized yet. See the notes in 282 | * mpv_create(). 283 | */ 284 | MPV_ERROR_UNINITIALIZED = -3, 285 | /** 286 | * Generic catch-all error if a parameter is set to an invalid or 287 | * unsupported value. This is used if there is no better error code. 288 | */ 289 | MPV_ERROR_INVALID_PARAMETER = -4, 290 | /** 291 | * Trying to set an option that doesn't exist. 292 | */ 293 | MPV_ERROR_OPTION_NOT_FOUND = -5, 294 | /** 295 | * Trying to set an option using an unsupported MPV_FORMAT. 296 | */ 297 | MPV_ERROR_OPTION_FORMAT = -6, 298 | /** 299 | * Setting the option failed. Typically this happens if the provided option 300 | * value could not be parsed. 301 | */ 302 | MPV_ERROR_OPTION_ERROR = -7, 303 | /** 304 | * The accessed property doesn't exist. 305 | */ 306 | MPV_ERROR_PROPERTY_NOT_FOUND = -8, 307 | /** 308 | * Trying to set or get a property using an unsupported MPV_FORMAT. 309 | */ 310 | MPV_ERROR_PROPERTY_FORMAT = -9, 311 | /** 312 | * The property exists, but is not available. This usually happens when the 313 | * associated subsystem is not active, e.g. querying audio parameters while 314 | * audio is disabled. 315 | */ 316 | MPV_ERROR_PROPERTY_UNAVAILABLE = -10, 317 | /** 318 | * Error setting or getting a property. 319 | */ 320 | MPV_ERROR_PROPERTY_ERROR = -11, 321 | /** 322 | * General error when running a command with mpv_command and similar. 323 | */ 324 | MPV_ERROR_COMMAND = -12, 325 | /** 326 | * Generic error on loading (usually used with mpv_event_end_file.error). 327 | */ 328 | MPV_ERROR_LOADING_FAILED = -13, 329 | /** 330 | * Initializing the audio output failed. 331 | */ 332 | MPV_ERROR_AO_INIT_FAILED = -14, 333 | /** 334 | * Initializing the video output failed. 335 | */ 336 | MPV_ERROR_VO_INIT_FAILED = -15, 337 | /** 338 | * There was no audio or video data to play. This also happens if the 339 | * file was recognized, but did not contain any audio or video streams, 340 | * or no streams were selected. 341 | */ 342 | MPV_ERROR_NOTHING_TO_PLAY = -16, 343 | /** 344 | * When trying to load the file, the file format could not be determined, 345 | * or the file was too broken to open it. 346 | */ 347 | MPV_ERROR_UNKNOWN_FORMAT = -17, 348 | /** 349 | * Generic error for signaling that certain system requirements are not 350 | * fulfilled. 351 | */ 352 | MPV_ERROR_UNSUPPORTED = -18, 353 | /** 354 | * The API function which was called is a stub only. 355 | */ 356 | MPV_ERROR_NOT_IMPLEMENTED = -19, 357 | /** 358 | * Unspecified error. 359 | */ 360 | MPV_ERROR_GENERIC = -20 361 | } mpv_error; 362 | 363 | /** 364 | * Return a string describing the error. For unknown errors, the string 365 | * "unknown error" is returned. 366 | * 367 | * @param error error number, see enum mpv_error 368 | * @return A static string describing the error. The string is completely 369 | * static, i.e. doesn't need to be deallocated, and is valid forever. 370 | */ 371 | const char *mpv_error_string(int error); 372 | 373 | /** 374 | * General function to deallocate memory returned by some of the API functions. 375 | * Call this only if it's explicitly documented as allowed. Calling this on 376 | * mpv memory not owned by the caller will lead to undefined behavior. 377 | * 378 | * @param data A valid pointer returned by the API, or NULL. 379 | */ 380 | void mpv_free(void *data); 381 | 382 | /** 383 | * Return the name of this client handle. Every client has its own unique 384 | * name, which is mostly used for user interface purposes. 385 | * 386 | * @return The client name. The string is read-only and is valid until the 387 | * mpv_handle is destroyed. 388 | */ 389 | const char *mpv_client_name(mpv_handle *ctx); 390 | 391 | /** 392 | * Create a new mpv instance and an associated client API handle to control 393 | * the mpv instance. This instance is in a pre-initialized state, 394 | * and needs to be initialized to be actually used with most other API 395 | * functions. 396 | * 397 | * Some API functions will return MPV_ERROR_UNINITIALIZED in the uninitialized 398 | * state. You can call mpv_set_property() (or mpv_set_property_string() and 399 | * other variants, and before mpv 0.21.0 mpv_set_option() etc.) to set initial 400 | * options. After this, call mpv_initialize() to start the player, and then use 401 | * e.g. mpv_command() to start playback of a file. 402 | * 403 | * The point of separating handle creation and actual initialization is that 404 | * you can configure things which can't be changed during runtime. 405 | * 406 | * Unlike the command line player, this will have initial settings suitable 407 | * for embedding in applications. The following settings are different: 408 | * - stdin/stdout/stderr and the terminal will never be accessed. This is 409 | * equivalent to setting the --no-terminal option. 410 | * (Technically, this also suppresses C signal handling.) 411 | * - No config files will be loaded. This is roughly equivalent to using 412 | * --config=no. Since libmpv 1.15, you can actually re-enable this option, 413 | * which will make libmpv load config files during mpv_initialize(). If you 414 | * do this, you are strongly encouraged to set the "config-dir" option too. 415 | * (Otherwise it will load the mpv command line player's config.) 416 | * For example: 417 | * mpv_set_option_string(mpv, "config-dir", "/my/path"); // set config root 418 | * mpv_set_option_string(mpv, "config", "yes"); // enable config loading 419 | * (call mpv_initialize() _after_ this) 420 | * - Idle mode is enabled, which means the playback core will enter idle mode 421 | * if there are no more files to play on the internal playlist, instead of 422 | * exiting. This is equivalent to the --idle option. 423 | * - Disable parts of input handling. 424 | * - Most of the different settings can be viewed with the command line player 425 | * by running "mpv --show-profile=libmpv". 426 | * 427 | * All this assumes that API users want a mpv instance that is strictly 428 | * isolated from the command line player's configuration, user settings, and 429 | * so on. You can re-enable disabled features by setting the appropriate 430 | * options. 431 | * 432 | * The mpv command line parser is not available through this API, but you can 433 | * set individual options with mpv_set_property(). Files for playback must be 434 | * loaded with mpv_command() or others. 435 | * 436 | * Note that you should avoid doing concurrent accesses on the uninitialized 437 | * client handle. (Whether concurrent access is definitely allowed or not has 438 | * yet to be decided.) 439 | * 440 | * @return a new mpv client API handle. Returns NULL on error. Currently, this 441 | * can happen in the following situations: 442 | * - out of memory 443 | * - LC_NUMERIC is not set to "C" (see general remarks) 444 | */ 445 | mpv_handle *mpv_create(void); 446 | 447 | /** 448 | * Initialize an uninitialized mpv instance. If the mpv instance is already 449 | * running, an error is returned. 450 | * 451 | * This function needs to be called to make full use of the client API if the 452 | * client API handle was created with mpv_create(). 453 | * 454 | * Only the following options are required to be set _before_ mpv_initialize(): 455 | * - options which are only read at initialization time: 456 | * - config 457 | * - config-dir 458 | * - input-conf 459 | * - load-scripts 460 | * - script 461 | * - player-operation-mode 462 | * - input-app-events (OSX) 463 | * - all encoding mode options 464 | * 465 | * @return error code 466 | */ 467 | int mpv_initialize(mpv_handle *ctx); 468 | 469 | /** 470 | * Disconnect and destroy the mpv_handle. ctx will be deallocated with this 471 | * API call. 472 | * 473 | * If the last mpv_handle is detached, the core player is destroyed. In 474 | * addition, if there are only weak mpv_handles (such as created by 475 | * mpv_create_weak_client() or internal scripts), these mpv_handles will 476 | * be sent MPV_EVENT_SHUTDOWN. This function may block until these clients 477 | * have responded to the shutdown event, and the core is finally destroyed. 478 | */ 479 | void mpv_destroy(mpv_handle *ctx); 480 | 481 | #if MPV_ENABLE_DEPRECATED 482 | /** 483 | * @deprecated use mpv_destroy(), which has exactly the same semantics (the 484 | * deprecation is a mere rename) 485 | * 486 | * Since mpv client API version 1.29: 487 | * If the last mpv_handle is detached, the core player is destroyed. In 488 | * addition, if there are only weak mpv_handles (such as created by 489 | * mpv_create_weak_client() or internal scripts), these mpv_handles will 490 | * be sent MPV_EVENT_SHUTDOWN. This function may block until these clients 491 | * have responded to the shutdown event, and the core is finally destroyed. 492 | * 493 | * Before mpv client API version 1.29: 494 | * This left the player running. If you want to be sure that the 495 | * player is terminated, send a "quit" command, and wait until the 496 | * MPV_EVENT_SHUTDOWN event is received, or use mpv_terminate_destroy(). 497 | */ 498 | void mpv_detach_destroy(mpv_handle *ctx); 499 | #endif 500 | 501 | /** 502 | * Similar to mpv_destroy(), but brings the player and all clients down 503 | * as well, and waits until all of them are destroyed. This function blocks. The 504 | * advantage over mpv_destroy() is that while mpv_destroy() merely 505 | * detaches the client handle from the player, this function quits the player, 506 | * waits until all other clients are destroyed (i.e. all mpv_handles are 507 | * detached), and also waits for the final termination of the player. 508 | * 509 | * Since mpv_destroy() is called somewhere on the way, it's not safe to 510 | * call other functions concurrently on the same context. 511 | * 512 | * Since mpv client API version 1.29: 513 | * The first call on any mpv_handle will block until the core is destroyed. 514 | * This means it will wait until other mpv_handle have been destroyed. If you 515 | * want asynchronous destruction, just run the "quit" command, and then react 516 | * to the MPV_EVENT_SHUTDOWN event. 517 | * If another mpv_handle already called mpv_terminate_destroy(), this call will 518 | * not actually block. It will destroy the mpv_handle, and exit immediately, 519 | * while other mpv_handles might still be uninitializing. 520 | * 521 | * Before mpv client API version 1.29: 522 | * If this is called on a mpv_handle that was not created with mpv_create(), 523 | * this function will merely send a quit command and then call 524 | * mpv_destroy(), without waiting for the actual shutdown. 525 | */ 526 | void mpv_terminate_destroy(mpv_handle *ctx); 527 | 528 | /** 529 | * Create a new client handle connected to the same player core as ctx. This 530 | * context has its own event queue, its own mpv_request_event() state, its own 531 | * mpv_request_log_messages() state, its own set of observed properties, and 532 | * its own state for asynchronous operations. Otherwise, everything is shared. 533 | * 534 | * This handle should be destroyed with mpv_destroy() if no longer 535 | * needed. The core will live as long as there is at least 1 handle referencing 536 | * it. Any handle can make the core quit, which will result in every handle 537 | * receiving MPV_EVENT_SHUTDOWN. 538 | * 539 | * This function can not be called before the main handle was initialized with 540 | * mpv_initialize(). The new handle is always initialized, unless ctx=NULL was 541 | * passed. 542 | * 543 | * @param ctx Used to get the reference to the mpv core; handle-specific 544 | * settings and parameters are not used. 545 | * If NULL, this function behaves like mpv_create() (ignores name). 546 | * @param name The client name. This will be returned by mpv_client_name(). If 547 | * the name is already in use, or contains non-alphanumeric 548 | * characters (other than '_'), the name is modified to fit. 549 | * If NULL, an arbitrary name is automatically chosen. 550 | * @return a new handle, or NULL on error 551 | */ 552 | mpv_handle *mpv_create_client(mpv_handle *ctx, const char *name); 553 | 554 | /** 555 | * This is the same as mpv_create_client(), but the created mpv_handle is 556 | * treated as a weak reference. If all mpv_handles referencing a core are 557 | * weak references, the core is automatically destroyed. (This still goes 558 | * through normal uninit of course. Effectively, if the last non-weak mpv_handle 559 | * is destroyed, then the weak mpv_handles receive MPV_EVENT_SHUTDOWN and are 560 | * asked to terminate as well.) 561 | * 562 | * Note if you want to use this like refcounting: you have to be aware that 563 | * mpv_terminate_destroy() _and_ mpv_destroy() for the last non-weak 564 | * mpv_handle will block until all weak mpv_handles are destroyed. 565 | */ 566 | mpv_handle *mpv_create_weak_client(mpv_handle *ctx, const char *name); 567 | 568 | /** 569 | * Load a config file. This loads and parses the file, and sets every entry in 570 | * the config file's default section as if mpv_set_option_string() is called. 571 | * 572 | * The filename should be an absolute path. If it isn't, the actual path used 573 | * is unspecified. (Note: an absolute path starts with '/' on UNIX.) If the 574 | * file wasn't found, MPV_ERROR_INVALID_PARAMETER is returned. 575 | * 576 | * If a fatal error happens when parsing a config file, MPV_ERROR_OPTION_ERROR 577 | * is returned. Errors when setting options as well as other types or errors 578 | * are ignored (even if options do not exist). You can still try to capture 579 | * the resulting error messages with mpv_request_log_messages(). Note that it's 580 | * possible that some options were successfully set even if any of these errors 581 | * happen. 582 | * 583 | * @param filename absolute path to the config file on the local filesystem 584 | * @return error code 585 | */ 586 | int mpv_load_config_file(mpv_handle *ctx, const char *filename); 587 | 588 | #if MPV_ENABLE_DEPRECATED 589 | 590 | /** 591 | * This does nothing since mpv 0.23.0 (API version 1.24). Below is the 592 | * description of the old behavior. 593 | * 594 | * Stop the playback thread. This means the core will stop doing anything, and 595 | * only run and answer to client API requests. This is sometimes useful; for 596 | * example, no new frame will be queued to the video output, so doing requests 597 | * which have to wait on the video output can run instantly. 598 | * 599 | * Suspension is reentrant and recursive for convenience. Any thread can call 600 | * the suspend function multiple times, and the playback thread will remain 601 | * suspended until the last thread resumes it. Note that during suspension, all 602 | * clients still have concurrent access to the core, which is serialized through 603 | * a single mutex. 604 | * 605 | * Call mpv_resume() to resume the playback thread. You must call mpv_resume() 606 | * for each mpv_suspend() call. Calling mpv_resume() more often than 607 | * mpv_suspend() is not allowed. 608 | * 609 | * Calling this on an uninitialized player (see mpv_create()) will deadlock. 610 | * 611 | * @deprecated This function, as well as mpv_resume(), are deprecated, and 612 | * will stop doing anything soon. Their semantics were never 613 | * well-defined, and their usefulness is extremely limited. The 614 | * calls will remain stubs in order to keep ABI compatibility. 615 | */ 616 | void mpv_suspend(mpv_handle *ctx); 617 | 618 | /** 619 | * See mpv_suspend(). 620 | */ 621 | void mpv_resume(mpv_handle *ctx); 622 | 623 | #endif 624 | 625 | /** 626 | * Return the internal time in microseconds. This has an arbitrary start offset, 627 | * but will never wrap or go backwards. 628 | * 629 | * Note that this is always the real time, and doesn't necessarily have to do 630 | * with playback time. For example, playback could go faster or slower due to 631 | * playback speed, or due to playback being paused. Use the "time-pos" property 632 | * instead to get the playback status. 633 | * 634 | * Unlike other libmpv APIs, this can be called at absolutely any time (even 635 | * within wakeup callbacks), as long as the context is valid. 636 | * 637 | * Safe to be called from mpv render API threads. 638 | */ 639 | int64_t mpv_get_time_us(mpv_handle *ctx); 640 | 641 | /** 642 | * Data format for options and properties. The API functions to get/set 643 | * properties and options support multiple formats, and this enum describes 644 | * them. 645 | */ 646 | typedef enum mpv_format { 647 | /** 648 | * Invalid. Sometimes used for empty values. 649 | */ 650 | MPV_FORMAT_NONE = 0, 651 | /** 652 | * The basic type is char*. It returns the raw property string, like 653 | * using ${=property} in input.conf (see input.rst). 654 | * 655 | * NULL isn't an allowed value. 656 | * 657 | * Warning: although the encoding is usually UTF-8, this is not always the 658 | * case. File tags often store strings in some legacy codepage, 659 | * and even filenames don't necessarily have to be in UTF-8 (at 660 | * least on Linux). If you pass the strings to code that requires 661 | * valid UTF-8, you have to sanitize it in some way. 662 | * On Windows, filenames are always UTF-8, and libmpv converts 663 | * between UTF-8 and UTF-16 when using win32 API functions. See 664 | * the "Encoding of filenames" section for details. 665 | * 666 | * Example for reading: 667 | * 668 | * char *result = NULL; 669 | * if (mpv_get_property(ctx, "property", MPV_FORMAT_STRING, &result) < 0) 670 | * goto error; 671 | * printf("%s\n", result); 672 | * mpv_free(result); 673 | * 674 | * Or just use mpv_get_property_string(). 675 | * 676 | * Example for writing: 677 | * 678 | * char *value = "the new value"; 679 | * // yep, you pass the address to the variable 680 | * // (needed for symmetry with other types and mpv_get_property) 681 | * mpv_set_property(ctx, "property", MPV_FORMAT_STRING, &value); 682 | * 683 | * Or just use mpv_set_property_string(). 684 | * 685 | */ 686 | MPV_FORMAT_STRING = 1, 687 | /** 688 | * The basic type is char*. It returns the OSD property string, like 689 | * using ${property} in input.conf (see input.rst). In many cases, this 690 | * is the same as the raw string, but in other cases it's formatted for 691 | * display on OSD. It's intended to be human readable. Do not attempt to 692 | * parse these strings. 693 | * 694 | * Only valid when doing read access. The rest works like MPV_FORMAT_STRING. 695 | */ 696 | MPV_FORMAT_OSD_STRING = 2, 697 | /** 698 | * The basic type is int. The only allowed values are 0 ("no") 699 | * and 1 ("yes"). 700 | * 701 | * Example for reading: 702 | * 703 | * int result; 704 | * if (mpv_get_property(ctx, "property", MPV_FORMAT_FLAG, &result) < 0) 705 | * goto error; 706 | * printf("%s\n", result ? "true" : "false"); 707 | * 708 | * Example for writing: 709 | * 710 | * int flag = 1; 711 | * mpv_set_property(ctx, "property", MPV_FORMAT_FLAG, &flag); 712 | */ 713 | MPV_FORMAT_FLAG = 3, 714 | /** 715 | * The basic type is int64_t. 716 | */ 717 | MPV_FORMAT_INT64 = 4, 718 | /** 719 | * The basic type is double. 720 | */ 721 | MPV_FORMAT_DOUBLE = 5, 722 | /** 723 | * The type is mpv_node. 724 | * 725 | * For reading, you usually would pass a pointer to a stack-allocated 726 | * mpv_node value to mpv, and when you're done you call 727 | * mpv_free_node_contents(&node). 728 | * You're expected not to write to the data - if you have to, copy it 729 | * first (which you have to do manually). 730 | * 731 | * For writing, you construct your own mpv_node, and pass a pointer to the 732 | * API. The API will never write to your data (and copy it if needed), so 733 | * you're free to use any form of allocation or memory management you like. 734 | * 735 | * Warning: when reading, always check the mpv_node.format member. For 736 | * example, properties might change their type in future versions 737 | * of mpv, or sometimes even during runtime. 738 | * 739 | * Example for reading: 740 | * 741 | * mpv_node result; 742 | * if (mpv_get_property(ctx, "property", MPV_FORMAT_NODE, &result) < 0) 743 | * goto error; 744 | * printf("format=%d\n", (int)result.format); 745 | * mpv_free_node_contents(&result). 746 | * 747 | * Example for writing: 748 | * 749 | * mpv_node value; 750 | * value.format = MPV_FORMAT_STRING; 751 | * value.u.string = "hello"; 752 | * mpv_set_property(ctx, "property", MPV_FORMAT_NODE, &value); 753 | */ 754 | MPV_FORMAT_NODE = 6, 755 | /** 756 | * Used with mpv_node only. Can usually not be used directly. 757 | */ 758 | MPV_FORMAT_NODE_ARRAY = 7, 759 | /** 760 | * See MPV_FORMAT_NODE_ARRAY. 761 | */ 762 | MPV_FORMAT_NODE_MAP = 8, 763 | /** 764 | * A raw, untyped byte array. Only used only with mpv_node, and only in 765 | * some very special situations. (Currently, only for the screenshot-raw 766 | * command.) 767 | */ 768 | MPV_FORMAT_BYTE_ARRAY = 9 769 | } mpv_format; 770 | 771 | /** 772 | * Generic data storage. 773 | * 774 | * If mpv writes this struct (e.g. via mpv_get_property()), you must not change 775 | * the data. In some cases (mpv_get_property()), you have to free it with 776 | * mpv_free_node_contents(). If you fill this struct yourself, you're also 777 | * responsible for freeing it, and you must not call mpv_free_node_contents(). 778 | */ 779 | typedef struct mpv_node { 780 | union { 781 | char *string; /** valid if format==MPV_FORMAT_STRING */ 782 | int flag; /** valid if format==MPV_FORMAT_FLAG */ 783 | int64_t int64; /** valid if format==MPV_FORMAT_INT64 */ 784 | double double_; /** valid if format==MPV_FORMAT_DOUBLE */ 785 | /** 786 | * valid if format==MPV_FORMAT_NODE_ARRAY 787 | * or if format==MPV_FORMAT_NODE_MAP 788 | */ 789 | struct mpv_node_list *list; 790 | /** 791 | * valid if format==MPV_FORMAT_BYTE_ARRAY 792 | */ 793 | struct mpv_byte_array *ba; 794 | } u; 795 | /** 796 | * Type of the data stored in this struct. This value rules what members in 797 | * the given union can be accessed. The following formats are currently 798 | * defined to be allowed in mpv_node: 799 | * 800 | * MPV_FORMAT_STRING (u.string) 801 | * MPV_FORMAT_FLAG (u.flag) 802 | * MPV_FORMAT_INT64 (u.int64) 803 | * MPV_FORMAT_DOUBLE (u.double_) 804 | * MPV_FORMAT_NODE_ARRAY (u.list) 805 | * MPV_FORMAT_NODE_MAP (u.list) 806 | * MPV_FORMAT_BYTE_ARRAY (u.ba) 807 | * MPV_FORMAT_NONE (no member) 808 | * 809 | * If you encounter a value you don't know, you must not make any 810 | * assumptions about the contents of union u. 811 | */ 812 | mpv_format format; 813 | } mpv_node; 814 | 815 | /** 816 | * (see mpv_node) 817 | */ 818 | typedef struct mpv_node_list { 819 | /** 820 | * Number of entries. Negative values are not allowed. 821 | */ 822 | int num; 823 | /** 824 | * MPV_FORMAT_NODE_ARRAY: 825 | * values[N] refers to value of the Nth item 826 | * 827 | * MPV_FORMAT_NODE_MAP: 828 | * values[N] refers to value of the Nth key/value pair 829 | * 830 | * If num > 0, values[0] to values[num-1] (inclusive) are valid. 831 | * Otherwise, this can be NULL. 832 | */ 833 | mpv_node *values; 834 | /** 835 | * MPV_FORMAT_NODE_ARRAY: 836 | * unused (typically NULL), access is not allowed 837 | * 838 | * MPV_FORMAT_NODE_MAP: 839 | * keys[N] refers to key of the Nth key/value pair. If num > 0, keys[0] to 840 | * keys[num-1] (inclusive) are valid. Otherwise, this can be NULL. 841 | * The keys are in random order. The only guarantee is that keys[N] belongs 842 | * to the value values[N]. NULL keys are not allowed. 843 | */ 844 | char **keys; 845 | } mpv_node_list; 846 | 847 | /** 848 | * (see mpv_node) 849 | */ 850 | typedef struct mpv_byte_array { 851 | /** 852 | * Pointer to the data. In what format the data is stored is up to whatever 853 | * uses MPV_FORMAT_BYTE_ARRAY. 854 | */ 855 | void *data; 856 | /** 857 | * Size of the data pointed to by ptr. 858 | */ 859 | size_t size; 860 | } mpv_byte_array; 861 | 862 | /** 863 | * Frees any data referenced by the node. It doesn't free the node itself. 864 | * Call this only if the mpv client API set the node. If you constructed the 865 | * node yourself (manually), you have to free it yourself. 866 | * 867 | * If node->format is MPV_FORMAT_NONE, this call does nothing. Likewise, if 868 | * the client API sets a node with this format, this function doesn't need to 869 | * be called. (This is just a clarification that there's no danger of anything 870 | * strange happening in these cases.) 871 | */ 872 | void mpv_free_node_contents(mpv_node *node); 873 | 874 | /** 875 | * Set an option. Note that you can't normally set options during runtime. It 876 | * works in uninitialized state (see mpv_create()), and in some cases in at 877 | * runtime. 878 | * 879 | * Using a format other than MPV_FORMAT_NODE is equivalent to constructing a 880 | * mpv_node with the given format and data, and passing the mpv_node to this 881 | * function. 882 | * 883 | * Note: this is semi-deprecated. For most purposes, this is not needed anymore. 884 | * Starting with mpv version 0.21.0 (version 1.23) most options can be set 885 | * with mpv_set_property() (and related functions), and even before 886 | * mpv_initialize(). In some obscure corner cases, using this function 887 | * to set options might still be required (see below, and also section 888 | * "Inconsistencies between options and properties" on the manpage). Once 889 | * these are resolved, the option setting functions might be fully 890 | * deprecated. 891 | * 892 | * The following options still need to be set either _before_ 893 | * mpv_initialize() with mpv_set_property() (or related functions), or 894 | * with mpv_set_option() (or related functions) at any time: 895 | * - options shadowed by deprecated properties: 896 | * - demuxer (property deprecated in 0.21.0) 897 | * - idle (property deprecated in 0.21.0) 898 | * - fps (property deprecated in 0.21.0) 899 | * - cache (property deprecated in 0.21.0) 900 | * - length (property deprecated in 0.10.0) 901 | * - audio-samplerate (property deprecated in 0.10.0) 902 | * - audio-channels (property deprecated in 0.10.0) 903 | * - audio-format (property deprecated in 0.10.0) 904 | * - deprecated options shadowed by properties: 905 | * - chapter (option deprecated in 0.21.0) 906 | * - playlist-pos (option deprecated in 0.21.0) 907 | * The deprecated properties were removed in mpv 0.23.0. 908 | * 909 | * @param name Option name. This is the same as on the mpv command line, but 910 | * without the leading "--". 911 | * @param format see enum mpv_format. 912 | * @param[in] data Option value (according to the format). 913 | * @return error code 914 | */ 915 | int mpv_set_option(mpv_handle *ctx, const char *name, mpv_format format, 916 | void *data); 917 | 918 | /** 919 | * Convenience function to set an option to a string value. This is like 920 | * calling mpv_set_option() with MPV_FORMAT_STRING. 921 | * 922 | * @return error code 923 | */ 924 | int mpv_set_option_string(mpv_handle *ctx, const char *name, const char *data); 925 | 926 | /** 927 | * Send a command to the player. Commands are the same as those used in 928 | * input.conf, except that this function takes parameters in a pre-split 929 | * form. 930 | * 931 | * The commands and their parameters are documented in input.rst. 932 | * 933 | * Does not use OSD and string expansion by default (unlike mpv_command_string() 934 | * and input.conf). 935 | * 936 | * @param[in] args NULL-terminated list of strings. Usually, the first item 937 | * is the command, and the following items are arguments. 938 | * @return error code 939 | */ 940 | int mpv_command(mpv_handle *ctx, const char **args); 941 | 942 | /** 943 | * Same as mpv_command(), but allows passing structured data in any format. 944 | * In particular, calling mpv_command() is exactly like calling 945 | * mpv_command_node() with the format set to MPV_FORMAT_NODE_ARRAY, and 946 | * every arg passed in order as MPV_FORMAT_STRING. 947 | * 948 | * Does not use OSD and string expansion by default. 949 | * 950 | * The args argument can have one of the following formats: 951 | * 952 | * MPV_FORMAT_NODE_ARRAY: 953 | * Positional arguments. Each entry is an argument using an arbitrary 954 | * format (the format must be compatible to the used command). Usually, 955 | * the first item is the command name (as MPV_FORMAT_STRING). The order 956 | * of arguments is as documented in each command description. 957 | * 958 | * MPV_FORMAT_NODE_MAP: 959 | * Named arguments. This requires at least an entry with the key "name" 960 | * to be present, which must be a string, and contains the command name. 961 | * The special entry "_flags" is optional, and if present, must be an 962 | * array of strings, each being a command prefix to apply. All other 963 | * entries are interpreted as arguments. They must use the argument names 964 | * as documented in each command description. Some commands do not 965 | * support named arguments at all, and must use MPV_FORMAT_NODE_ARRAY. 966 | * 967 | * @param[in] args mpv_node with format set to one of the values documented 968 | * above (see there for details) 969 | * @param[out] result Optional, pass NULL if unused. If not NULL, and if the 970 | * function succeeds, this is set to command-specific return 971 | * data. You must call mpv_free_node_contents() to free it 972 | * (again, only if the command actually succeeds). 973 | * Not many commands actually use this at all. 974 | * @return error code (the result parameter is not set on error) 975 | */ 976 | int mpv_command_node(mpv_handle *ctx, mpv_node *args, mpv_node *result); 977 | 978 | /** 979 | * This is essentially identical to mpv_command() but it also returns a result. 980 | * 981 | * Does not use OSD and string expansion by default. 982 | * 983 | * @param[in] args NULL-terminated list of strings. Usually, the first item 984 | * is the command, and the following items are arguments. 985 | * @param[out] result Optional, pass NULL if unused. If not NULL, and if the 986 | * function succeeds, this is set to command-specific return 987 | * data. You must call mpv_free_node_contents() to free it 988 | * (again, only if the command actually succeeds). 989 | * Not many commands actually use this at all. 990 | * @return error code (the result parameter is not set on error) 991 | */ 992 | int mpv_command_ret(mpv_handle *ctx, const char **args, mpv_node *result); 993 | 994 | /** 995 | * Same as mpv_command, but use input.conf parsing for splitting arguments. 996 | * This is slightly simpler, but also more error prone, since arguments may 997 | * need quoting/escaping. 998 | * 999 | * This also has OSD and string expansion enabled by default. 1000 | */ 1001 | int mpv_command_string(mpv_handle *ctx, const char *args); 1002 | 1003 | /** 1004 | * Same as mpv_command, but run the command asynchronously. 1005 | * 1006 | * Commands are executed asynchronously. You will receive a 1007 | * MPV_EVENT_COMMAND_REPLY event. This event will also have an 1008 | * error code set if running the command failed. For commands that 1009 | * return data, the data is put into mpv_event_command.result. 1010 | * 1011 | * Safe to be called from mpv render API threads. 1012 | * 1013 | * @param reply_userdata the value mpv_event.reply_userdata of the reply will 1014 | * be set to (see section about asynchronous calls) 1015 | * @param args NULL-terminated list of strings (see mpv_command()) 1016 | * @return error code (if parsing or queuing the command fails) 1017 | */ 1018 | int mpv_command_async(mpv_handle *ctx, uint64_t reply_userdata, 1019 | const char **args); 1020 | 1021 | /** 1022 | * Same as mpv_command_node(), but run it asynchronously. Basically, this 1023 | * function is to mpv_command_node() what mpv_command_async() is to 1024 | * mpv_command(). 1025 | * 1026 | * See mpv_command_async() for details. 1027 | * 1028 | * Safe to be called from mpv render API threads. 1029 | * 1030 | * @param reply_userdata the value mpv_event.reply_userdata of the reply will 1031 | * be set to (see section about asynchronous calls) 1032 | * @param args as in mpv_command_node() 1033 | * @return error code (if parsing or queuing the command fails) 1034 | */ 1035 | int mpv_command_node_async(mpv_handle *ctx, uint64_t reply_userdata, 1036 | mpv_node *args); 1037 | 1038 | /** 1039 | * Signal to all async requests with the matching ID to abort. This affects 1040 | * the following API calls: 1041 | * 1042 | * mpv_command_async 1043 | * mpv_command_node_async 1044 | * 1045 | * All of these functions take a reply_userdata parameter. This API function 1046 | * tells all requests with the matching reply_userdata value to try to return 1047 | * as soon as possible. If there are multiple requests with matching ID, it 1048 | * aborts all of them. 1049 | * 1050 | * This API function is mostly asynchronous itself. It will not wait until the 1051 | * command is aborted. Instead, the command will terminate as usual, but with 1052 | * some work not done. How this is signaled depends on the specific command (for 1053 | * example, the "subprocess" command will indicate it by "killed_by_us" set to 1054 | * true in the result). How long it takes also depends on the situation. The 1055 | * aborting process is completely asynchronous. 1056 | * 1057 | * Not all commands may support this functionality. In this case, this function 1058 | * will have no effect. The same is true if the request using the passed 1059 | * reply_userdata has already terminated, has not been started yet, or was 1060 | * never in use at all. 1061 | * 1062 | * You have to be careful of race conditions: the time during which the abort 1063 | * request will be effective is _after_ e.g. mpv_command_async() has returned, 1064 | * and before the command has signaled completion with MPV_EVENT_COMMAND_REPLY. 1065 | * 1066 | * @param reply_userdata ID of the request to be aborted (see above) 1067 | */ 1068 | void mpv_abort_async_command(mpv_handle *ctx, uint64_t reply_userdata); 1069 | 1070 | /** 1071 | * Set a property to a given value. Properties are essentially variables which 1072 | * can be queried or set at runtime. For example, writing to the pause property 1073 | * will actually pause or unpause playback. 1074 | * 1075 | * If the format doesn't match with the internal format of the property, access 1076 | * usually will fail with MPV_ERROR_PROPERTY_FORMAT. In some cases, the data 1077 | * is automatically converted and access succeeds. For example, MPV_FORMAT_INT64 1078 | * is always converted to MPV_FORMAT_DOUBLE, and access using MPV_FORMAT_STRING 1079 | * usually invokes a string parser. The same happens when calling this function 1080 | * with MPV_FORMAT_NODE: the underlying format may be converted to another 1081 | * type if possible. 1082 | * 1083 | * Using a format other than MPV_FORMAT_NODE is equivalent to constructing a 1084 | * mpv_node with the given format and data, and passing the mpv_node to this 1085 | * function. (Before API version 1.21, this was different.) 1086 | * 1087 | * Note: starting with mpv 0.21.0 (client API version 1.23), this can be used to 1088 | * set options in general. It even can be used before mpv_initialize() 1089 | * has been called. If called before mpv_initialize(), setting properties 1090 | * not backed by options will result in MPV_ERROR_PROPERTY_UNAVAILABLE. 1091 | * In some cases, properties and options still conflict. In these cases, 1092 | * mpv_set_property() accesses the options before mpv_initialize(), and 1093 | * the properties after mpv_initialize(). These conflicts will be removed 1094 | * in mpv 0.23.0. See mpv_set_option() for further remarks. 1095 | * 1096 | * @param name The property name. See input.rst for a list of properties. 1097 | * @param format see enum mpv_format. 1098 | * @param[in] data Option value. 1099 | * @return error code 1100 | */ 1101 | int mpv_set_property(mpv_handle *ctx, const char *name, mpv_format format, 1102 | void *data); 1103 | 1104 | /** 1105 | * Convenience function to set a property to a string value. 1106 | * 1107 | * This is like calling mpv_set_property() with MPV_FORMAT_STRING. 1108 | */ 1109 | int mpv_set_property_string(mpv_handle *ctx, const char *name, const char *data); 1110 | 1111 | /** 1112 | * Set a property asynchronously. You will receive the result of the operation 1113 | * as MPV_EVENT_SET_PROPERTY_REPLY event. The mpv_event.error field will contain 1114 | * the result status of the operation. Otherwise, this function is similar to 1115 | * mpv_set_property(). 1116 | * 1117 | * Safe to be called from mpv render API threads. 1118 | * 1119 | * @param reply_userdata see section about asynchronous calls 1120 | * @param name The property name. 1121 | * @param format see enum mpv_format. 1122 | * @param[in] data Option value. The value will be copied by the function. It 1123 | * will never be modified by the client API. 1124 | * @return error code if sending the request failed 1125 | */ 1126 | int mpv_set_property_async(mpv_handle *ctx, uint64_t reply_userdata, 1127 | const char *name, mpv_format format, void *data); 1128 | 1129 | /** 1130 | * Read the value of the given property. 1131 | * 1132 | * If the format doesn't match with the internal format of the property, access 1133 | * usually will fail with MPV_ERROR_PROPERTY_FORMAT. In some cases, the data 1134 | * is automatically converted and access succeeds. For example, MPV_FORMAT_INT64 1135 | * is always converted to MPV_FORMAT_DOUBLE, and access using MPV_FORMAT_STRING 1136 | * usually invokes a string formatter. 1137 | * 1138 | * @param name The property name. 1139 | * @param format see enum mpv_format. 1140 | * @param[out] data Pointer to the variable holding the option value. On 1141 | * success, the variable will be set to a copy of the option 1142 | * value. For formats that require dynamic memory allocation, 1143 | * you can free the value with mpv_free() (strings) or 1144 | * mpv_free_node_contents() (MPV_FORMAT_NODE). 1145 | * @return error code 1146 | */ 1147 | int mpv_get_property(mpv_handle *ctx, const char *name, mpv_format format, 1148 | void *data); 1149 | 1150 | /** 1151 | * Return the value of the property with the given name as string. This is 1152 | * equivalent to mpv_get_property() with MPV_FORMAT_STRING. 1153 | * 1154 | * See MPV_FORMAT_STRING for character encoding issues. 1155 | * 1156 | * On error, NULL is returned. Use mpv_get_property() if you want fine-grained 1157 | * error reporting. 1158 | * 1159 | * @param name The property name. 1160 | * @return Property value, or NULL if the property can't be retrieved. Free 1161 | * the string with mpv_free(). 1162 | */ 1163 | char *mpv_get_property_string(mpv_handle *ctx, const char *name); 1164 | 1165 | /** 1166 | * Return the property as "OSD" formatted string. This is the same as 1167 | * mpv_get_property_string, but using MPV_FORMAT_OSD_STRING. 1168 | * 1169 | * @return Property value, or NULL if the property can't be retrieved. Free 1170 | * the string with mpv_free(). 1171 | */ 1172 | char *mpv_get_property_osd_string(mpv_handle *ctx, const char *name); 1173 | 1174 | /** 1175 | * Get a property asynchronously. You will receive the result of the operation 1176 | * as well as the property data with the MPV_EVENT_GET_PROPERTY_REPLY event. 1177 | * You should check the mpv_event.error field on the reply event. 1178 | * 1179 | * Safe to be called from mpv render API threads. 1180 | * 1181 | * @param reply_userdata see section about asynchronous calls 1182 | * @param name The property name. 1183 | * @param format see enum mpv_format. 1184 | * @return error code if sending the request failed 1185 | */ 1186 | int mpv_get_property_async(mpv_handle *ctx, uint64_t reply_userdata, 1187 | const char *name, mpv_format format); 1188 | 1189 | /** 1190 | * Get a notification whenever the given property changes. You will receive 1191 | * updates as MPV_EVENT_PROPERTY_CHANGE. Note that this is not very precise: 1192 | * for some properties, it may not send updates even if the property changed. 1193 | * This depends on the property, and it's a valid feature request to ask for 1194 | * better update handling of a specific property. (For some properties, like 1195 | * ``clock``, which shows the wall clock, this mechanism doesn't make too 1196 | * much sense anyway.) 1197 | * 1198 | * Property changes are coalesced: the change events are returned only once the 1199 | * event queue becomes empty (e.g. mpv_wait_event() would block or return 1200 | * MPV_EVENT_NONE), and then only one event per changed property is returned. 1201 | * 1202 | * You always get an initial change notification. This is meant to initialize 1203 | * the user's state to the current value of the property. 1204 | * 1205 | * Normally, change events are sent only if the property value changes according 1206 | * to the requested format. mpv_event_property will contain the property value 1207 | * as data member. 1208 | * 1209 | * Warning: if a property is unavailable or retrieving it caused an error, 1210 | * MPV_FORMAT_NONE will be set in mpv_event_property, even if the 1211 | * format parameter was set to a different value. In this case, the 1212 | * mpv_event_property.data field is invalid. 1213 | * 1214 | * If the property is observed with the format parameter set to MPV_FORMAT_NONE, 1215 | * you get low-level notifications whether the property _may_ have changed, and 1216 | * the data member in mpv_event_property will be unset. With this mode, you 1217 | * will have to determine yourself whether the property really changed. On the 1218 | * other hand, this mechanism can be faster and uses less resources. 1219 | * 1220 | * Observing a property that doesn't exist is allowed. (Although it may still 1221 | * cause some sporadic change events.) 1222 | * 1223 | * Keep in mind that you will get change notifications even if you change a 1224 | * property yourself. Try to avoid endless feedback loops, which could happen 1225 | * if you react to the change notifications triggered by your own change. 1226 | * 1227 | * Only the mpv_handle on which this was called will receive the property 1228 | * change events, or can unobserve them. 1229 | * 1230 | * Safe to be called from mpv render API threads. 1231 | * 1232 | * @param reply_userdata This will be used for the mpv_event.reply_userdata 1233 | * field for the received MPV_EVENT_PROPERTY_CHANGE 1234 | * events. (Also see section about asynchronous calls, 1235 | * although this function is somewhat different from 1236 | * actual asynchronous calls.) 1237 | * If you have no use for this, pass 0. 1238 | * Also see mpv_unobserve_property(). 1239 | * @param name The property name. 1240 | * @param format see enum mpv_format. Can be MPV_FORMAT_NONE to omit values 1241 | * from the change events. 1242 | * @return error code (usually fails only on OOM or unsupported format) 1243 | */ 1244 | int mpv_observe_property(mpv_handle *mpv, uint64_t reply_userdata, 1245 | const char *name, mpv_format format); 1246 | 1247 | /** 1248 | * Undo mpv_observe_property(). This will remove all observed properties for 1249 | * which the given number was passed as reply_userdata to mpv_observe_property. 1250 | * 1251 | * Safe to be called from mpv render API threads. 1252 | * 1253 | * @param registered_reply_userdata ID that was passed to mpv_observe_property 1254 | * @return negative value is an error code, >=0 is number of removed properties 1255 | * on success (includes the case when 0 were removed) 1256 | */ 1257 | int mpv_unobserve_property(mpv_handle *mpv, uint64_t registered_reply_userdata); 1258 | 1259 | typedef enum mpv_event_id { 1260 | /** 1261 | * Nothing happened. Happens on timeouts or sporadic wakeups. 1262 | */ 1263 | MPV_EVENT_NONE = 0, 1264 | /** 1265 | * Happens when the player quits. The player enters a state where it tries 1266 | * to disconnect all clients. Most requests to the player will fail, and 1267 | * the client should react to this and quit with mpv_destroy() as soon as 1268 | * possible. 1269 | */ 1270 | MPV_EVENT_SHUTDOWN = 1, 1271 | /** 1272 | * See mpv_request_log_messages(). 1273 | */ 1274 | MPV_EVENT_LOG_MESSAGE = 2, 1275 | /** 1276 | * Reply to a mpv_get_property_async() request. 1277 | * See also mpv_event and mpv_event_property. 1278 | */ 1279 | MPV_EVENT_GET_PROPERTY_REPLY = 3, 1280 | /** 1281 | * Reply to a mpv_set_property_async() request. 1282 | * (Unlike MPV_EVENT_GET_PROPERTY, mpv_event_property is not used.) 1283 | */ 1284 | MPV_EVENT_SET_PROPERTY_REPLY = 4, 1285 | /** 1286 | * Reply to a mpv_command_async() or mpv_command_node_async() request. 1287 | * See also mpv_event and mpv_event_command. 1288 | */ 1289 | MPV_EVENT_COMMAND_REPLY = 5, 1290 | /** 1291 | * Notification before playback start of a file (before the file is loaded). 1292 | */ 1293 | MPV_EVENT_START_FILE = 6, 1294 | /** 1295 | * Notification after playback end (after the file was unloaded). 1296 | * See also mpv_event and mpv_event_end_file. 1297 | */ 1298 | MPV_EVENT_END_FILE = 7, 1299 | /** 1300 | * Notification when the file has been loaded (headers were read etc.), and 1301 | * decoding starts. 1302 | */ 1303 | MPV_EVENT_FILE_LOADED = 8, 1304 | #if MPV_ENABLE_DEPRECATED 1305 | /** 1306 | * The list of video/audio/subtitle tracks was changed. (E.g. a new track 1307 | * was found. This doesn't necessarily indicate a track switch; for this, 1308 | * MPV_EVENT_TRACK_SWITCHED is used.) 1309 | * 1310 | * @deprecated This is equivalent to using mpv_observe_property() on the 1311 | * "track-list" property. The event is redundant, and might 1312 | * be removed in the far future. 1313 | */ 1314 | MPV_EVENT_TRACKS_CHANGED = 9, 1315 | /** 1316 | * A video/audio/subtitle track was switched on or off. 1317 | * 1318 | * @deprecated This is equivalent to using mpv_observe_property() on the 1319 | * "vid", "aid", and "sid" properties. The event is redundant, 1320 | * and might be removed in the far future. 1321 | */ 1322 | MPV_EVENT_TRACK_SWITCHED = 10, 1323 | #endif 1324 | /** 1325 | * Idle mode was entered. In this mode, no file is played, and the playback 1326 | * core waits for new commands. (The command line player normally quits 1327 | * instead of entering idle mode, unless --idle was specified. If mpv 1328 | * was started with mpv_create(), idle mode is enabled by default.) 1329 | */ 1330 | MPV_EVENT_IDLE = 11, 1331 | #if MPV_ENABLE_DEPRECATED 1332 | /** 1333 | * Playback was paused. This indicates the user pause state. 1334 | * 1335 | * The user pause state is the state the user requested (changed with the 1336 | * "pause" property). There is an internal pause state too, which is entered 1337 | * if e.g. the network is too slow (the "core-idle" property generally 1338 | * indicates whether the core is playing or waiting). 1339 | * 1340 | * This event is sent whenever any pause states change, not only the user 1341 | * state. You might get multiple events in a row while these states change 1342 | * independently. But the event ID sent always indicates the user pause 1343 | * state. 1344 | * 1345 | * If you don't want to deal with this, use mpv_observe_property() on the 1346 | * "pause" property and ignore MPV_EVENT_PAUSE/UNPAUSE. Likewise, the 1347 | * "core-idle" property tells you whether video is actually playing or not. 1348 | * 1349 | * @deprecated The event is redundant with mpv_observe_property() as 1350 | * mentioned above, and might be removed in the far future. 1351 | */ 1352 | MPV_EVENT_PAUSE = 12, 1353 | /** 1354 | * Playback was unpaused. See MPV_EVENT_PAUSE for not so obvious details. 1355 | * 1356 | * @deprecated The event is redundant with mpv_observe_property() as 1357 | * explained in the MPV_EVENT_PAUSE comments, and might be 1358 | * removed in the far future. 1359 | */ 1360 | MPV_EVENT_UNPAUSE = 13, 1361 | /** 1362 | * Sent every time after a video frame is displayed. Note that currently, 1363 | * this will be sent in lower frequency if there is no video, or playback 1364 | * is paused - but that will be removed in the future, and it will be 1365 | * restricted to video frames only. 1366 | * 1367 | * @deprecated Use mpv_observe_property() with relevant properties instead 1368 | * (such as "playback-time"). 1369 | */ 1370 | MPV_EVENT_TICK = 14, 1371 | /** 1372 | * @deprecated This was used internally with the internal "script_dispatch" 1373 | * command to dispatch keyboard and mouse input for the OSC. 1374 | * It was never useful in general and has been completely 1375 | * replaced with "script-binding". 1376 | * This event never happens anymore, and is included in this 1377 | * header only for compatibility. 1378 | */ 1379 | MPV_EVENT_SCRIPT_INPUT_DISPATCH = 15, 1380 | #endif 1381 | /** 1382 | * Triggered by the script-message input command. The command uses the 1383 | * first argument of the command as client name (see mpv_client_name()) to 1384 | * dispatch the message, and passes along all arguments starting from the 1385 | * second argument as strings. 1386 | * See also mpv_event and mpv_event_client_message. 1387 | */ 1388 | MPV_EVENT_CLIENT_MESSAGE = 16, 1389 | /** 1390 | * Happens after video changed in some way. This can happen on resolution 1391 | * changes, pixel format changes, or video filter changes. The event is 1392 | * sent after the video filters and the VO are reconfigured. Applications 1393 | * embedding a mpv window should listen to this event in order to resize 1394 | * the window if needed. 1395 | * Note that this event can happen sporadically, and you should check 1396 | * yourself whether the video parameters really changed before doing 1397 | * something expensive. 1398 | */ 1399 | MPV_EVENT_VIDEO_RECONFIG = 17, 1400 | /** 1401 | * Similar to MPV_EVENT_VIDEO_RECONFIG. This is relatively uninteresting, 1402 | * because there is no such thing as audio output embedding. 1403 | */ 1404 | MPV_EVENT_AUDIO_RECONFIG = 18, 1405 | #if MPV_ENABLE_DEPRECATED 1406 | /** 1407 | * Happens when metadata (like file tags) is possibly updated. (It's left 1408 | * unspecified whether this happens on file start or only when it changes 1409 | * within a file.) 1410 | * 1411 | * @deprecated This is equivalent to using mpv_observe_property() on the 1412 | * "metadata" property. The event is redundant, and might 1413 | * be removed in the far future. 1414 | */ 1415 | MPV_EVENT_METADATA_UPDATE = 19, 1416 | #endif 1417 | /** 1418 | * Happens when a seek was initiated. Playback stops. Usually it will 1419 | * resume with MPV_EVENT_PLAYBACK_RESTART as soon as the seek is finished. 1420 | */ 1421 | MPV_EVENT_SEEK = 20, 1422 | /** 1423 | * There was a discontinuity of some sort (like a seek), and playback 1424 | * was reinitialized. Usually happens after seeking, or ordered chapter 1425 | * segment switches. The main purpose is allowing the client to detect 1426 | * when a seek request is finished. 1427 | */ 1428 | MPV_EVENT_PLAYBACK_RESTART = 21, 1429 | /** 1430 | * Event sent due to mpv_observe_property(). 1431 | * See also mpv_event and mpv_event_property. 1432 | */ 1433 | MPV_EVENT_PROPERTY_CHANGE = 22, 1434 | #if MPV_ENABLE_DEPRECATED 1435 | /** 1436 | * Happens when the current chapter changes. 1437 | * 1438 | * @deprecated This is equivalent to using mpv_observe_property() on the 1439 | * "chapter" property. The event is redundant, and might 1440 | * be removed in the far future. 1441 | */ 1442 | MPV_EVENT_CHAPTER_CHANGE = 23, 1443 | #endif 1444 | /** 1445 | * Happens if the internal per-mpv_handle ringbuffer overflows, and at 1446 | * least 1 event had to be dropped. This can happen if the client doesn't 1447 | * read the event queue quickly enough with mpv_wait_event(), or if the 1448 | * client makes a very large number of asynchronous calls at once. 1449 | * 1450 | * Event delivery will continue normally once this event was returned 1451 | * (this forces the client to empty the queue completely). 1452 | */ 1453 | MPV_EVENT_QUEUE_OVERFLOW = 24, 1454 | /** 1455 | * Triggered if a hook handler was registered with mpv_hook_add(), and the 1456 | * hook is invoked. If you receive this, you must handle it, and continue 1457 | * the hook with mpv_hook_continue(). 1458 | * See also mpv_event and mpv_event_hook. 1459 | */ 1460 | MPV_EVENT_HOOK = 25, 1461 | // Internal note: adjust INTERNAL_EVENT_BASE when adding new events. 1462 | } mpv_event_id; 1463 | 1464 | /** 1465 | * Return a string describing the event. For unknown events, NULL is returned. 1466 | * 1467 | * Note that all events actually returned by the API will also yield a non-NULL 1468 | * string with this function. 1469 | * 1470 | * @param event event ID, see see enum mpv_event_id 1471 | * @return A static string giving a short symbolic name of the event. It 1472 | * consists of lower-case alphanumeric characters and can include "-" 1473 | * characters. This string is suitable for use in e.g. scripting 1474 | * interfaces. 1475 | * The string is completely static, i.e. doesn't need to be deallocated, 1476 | * and is valid forever. 1477 | */ 1478 | const char *mpv_event_name(mpv_event_id event); 1479 | 1480 | typedef struct mpv_event_property { 1481 | /** 1482 | * Name of the property. 1483 | */ 1484 | const char *name; 1485 | /** 1486 | * Format of the data field in the same struct. See enum mpv_format. 1487 | * This is always the same format as the requested format, except when 1488 | * the property could not be retrieved (unavailable, or an error happened), 1489 | * in which case the format is MPV_FORMAT_NONE. 1490 | */ 1491 | mpv_format format; 1492 | /** 1493 | * Received property value. Depends on the format. This is like the 1494 | * pointer argument passed to mpv_get_property(). 1495 | * 1496 | * For example, for MPV_FORMAT_STRING you get the string with: 1497 | * 1498 | * char *value = *(char **)(event_property->data); 1499 | * 1500 | * Note that this is set to NULL if retrieving the property failed (the 1501 | * format will be MPV_FORMAT_NONE). 1502 | */ 1503 | void *data; 1504 | } mpv_event_property; 1505 | 1506 | /** 1507 | * Numeric log levels. The lower the number, the more important the message is. 1508 | * MPV_LOG_LEVEL_NONE is never used when receiving messages. The string in 1509 | * the comment after the value is the name of the log level as used for the 1510 | * mpv_request_log_messages() function. 1511 | * Unused numeric values are unused, but reserved for future use. 1512 | */ 1513 | typedef enum mpv_log_level { 1514 | MPV_LOG_LEVEL_NONE = 0, /// "no" - disable absolutely all messages 1515 | MPV_LOG_LEVEL_FATAL = 10, /// "fatal" - critical/aborting errors 1516 | MPV_LOG_LEVEL_ERROR = 20, /// "error" - simple errors 1517 | MPV_LOG_LEVEL_WARN = 30, /// "warn" - possible problems 1518 | MPV_LOG_LEVEL_INFO = 40, /// "info" - informational message 1519 | MPV_LOG_LEVEL_V = 50, /// "v" - noisy informational message 1520 | MPV_LOG_LEVEL_DEBUG = 60, /// "debug" - very noisy technical information 1521 | MPV_LOG_LEVEL_TRACE = 70, /// "trace" - extremely noisy 1522 | } mpv_log_level; 1523 | 1524 | typedef struct mpv_event_log_message { 1525 | /** 1526 | * The module prefix, identifies the sender of the message. As a special 1527 | * case, if the message buffer overflows, this will be set to the string 1528 | * "overflow" (which doesn't appear as prefix otherwise), and the text 1529 | * field will contain an informative message. 1530 | */ 1531 | const char *prefix; 1532 | /** 1533 | * The log level as string. See mpv_request_log_messages() for possible 1534 | * values. The level "no" is never used here. 1535 | */ 1536 | const char *level; 1537 | /** 1538 | * The log message. It consists of 1 line of text, and is terminated with 1539 | * a newline character. (Before API version 1.6, it could contain multiple 1540 | * or partial lines.) 1541 | */ 1542 | const char *text; 1543 | /** 1544 | * The same contents as the level field, but as a numeric ID. 1545 | * Since API version 1.6. 1546 | */ 1547 | mpv_log_level log_level; 1548 | } mpv_event_log_message; 1549 | 1550 | /// Since API version 1.9. 1551 | typedef enum mpv_end_file_reason { 1552 | /** 1553 | * The end of file was reached. Sometimes this may also happen on 1554 | * incomplete or corrupted files, or if the network connection was 1555 | * interrupted when playing a remote file. It also happens if the 1556 | * playback range was restricted with --end or --frames or similar. 1557 | */ 1558 | MPV_END_FILE_REASON_EOF = 0, 1559 | /** 1560 | * Playback was stopped by an external action (e.g. playlist controls). 1561 | */ 1562 | MPV_END_FILE_REASON_STOP = 2, 1563 | /** 1564 | * Playback was stopped by the quit command or player shutdown. 1565 | */ 1566 | MPV_END_FILE_REASON_QUIT = 3, 1567 | /** 1568 | * Some kind of error happened that lead to playback abort. Does not 1569 | * necessarily happen on incomplete or broken files (in these cases, both 1570 | * MPV_END_FILE_REASON_ERROR or MPV_END_FILE_REASON_EOF are possible). 1571 | * 1572 | * mpv_event_end_file.error will be set. 1573 | */ 1574 | MPV_END_FILE_REASON_ERROR = 4, 1575 | /** 1576 | * The file was a playlist or similar. When the playlist is read, its 1577 | * entries will be appended to the playlist after the entry of the current 1578 | * file, the entry of the current file is removed, and a MPV_EVENT_END_FILE 1579 | * event is sent with reason set to MPV_END_FILE_REASON_REDIRECT. Then 1580 | * playback continues with the playlist contents. 1581 | * Since API version 1.18. 1582 | */ 1583 | MPV_END_FILE_REASON_REDIRECT = 5, 1584 | } mpv_end_file_reason; 1585 | 1586 | typedef struct mpv_event_end_file { 1587 | /** 1588 | * Corresponds to the values in enum mpv_end_file_reason (the "int" type 1589 | * will be replaced with mpv_end_file_reason on the next ABI bump). 1590 | * 1591 | * Unknown values should be treated as unknown. 1592 | */ 1593 | int reason; 1594 | /** 1595 | * If reason==MPV_END_FILE_REASON_ERROR, this contains a mpv error code 1596 | * (one of MPV_ERROR_...) giving an approximate reason why playback 1597 | * failed. In other cases, this field is 0 (no error). 1598 | * Since API version 1.9. 1599 | */ 1600 | int error; 1601 | } mpv_event_end_file; 1602 | 1603 | #if MPV_ENABLE_DEPRECATED 1604 | /** @deprecated see MPV_EVENT_SCRIPT_INPUT_DISPATCH for remarks 1605 | */ 1606 | typedef struct mpv_event_script_input_dispatch { 1607 | int arg0; 1608 | const char *type; 1609 | } mpv_event_script_input_dispatch; 1610 | #endif 1611 | 1612 | typedef struct mpv_event_client_message { 1613 | /** 1614 | * Arbitrary arguments chosen by the sender of the message. If num_args > 0, 1615 | * you can access args[0] through args[num_args - 1] (inclusive). What 1616 | * these arguments mean is up to the sender and receiver. 1617 | * None of the valid items are NULL. 1618 | */ 1619 | int num_args; 1620 | const char **args; 1621 | } mpv_event_client_message; 1622 | 1623 | typedef struct mpv_event_hook { 1624 | /** 1625 | * The hook name as passed to mpv_hook_add(). 1626 | */ 1627 | const char *name; 1628 | /** 1629 | * Internal ID that must be passed to mpv_hook_continue(). 1630 | */ 1631 | uint64_t id; 1632 | } mpv_event_hook; 1633 | 1634 | // Since API version 1.102. 1635 | typedef struct mpv_event_command { 1636 | /** 1637 | * Result data of the command. Note that success/failure is signaled 1638 | * separately via mpv_event.error. This field is only for result data 1639 | * in case of success. Most commands leave it at MPV_FORMAT_NONE. Set 1640 | * to MPV_FORMAT_NONE on failure. 1641 | */ 1642 | mpv_node result; 1643 | } mpv_event_command; 1644 | 1645 | typedef struct mpv_event { 1646 | /** 1647 | * One of mpv_event. Keep in mind that later ABI compatible releases might 1648 | * add new event types. These should be ignored by the API user. 1649 | */ 1650 | mpv_event_id event_id; 1651 | /** 1652 | * This is mainly used for events that are replies to (asynchronous) 1653 | * requests. It contains a status code, which is >= 0 on success, or < 0 1654 | * on error (a mpv_error value). Usually, this will be set if an 1655 | * asynchronous request fails. 1656 | * Used for: 1657 | * MPV_EVENT_GET_PROPERTY_REPLY 1658 | * MPV_EVENT_SET_PROPERTY_REPLY 1659 | * MPV_EVENT_COMMAND_REPLY 1660 | */ 1661 | int error; 1662 | /** 1663 | * If the event is in reply to a request (made with this API and this 1664 | * API handle), this is set to the reply_userdata parameter of the request 1665 | * call. Otherwise, this field is 0. 1666 | * Used for: 1667 | * MPV_EVENT_GET_PROPERTY_REPLY 1668 | * MPV_EVENT_SET_PROPERTY_REPLY 1669 | * MPV_EVENT_COMMAND_REPLY 1670 | * MPV_EVENT_PROPERTY_CHANGE 1671 | * MPV_EVENT_HOOK 1672 | */ 1673 | uint64_t reply_userdata; 1674 | /** 1675 | * The meaning and contents of the data member depend on the event_id: 1676 | * MPV_EVENT_GET_PROPERTY_REPLY: mpv_event_property* 1677 | * MPV_EVENT_PROPERTY_CHANGE: mpv_event_property* 1678 | * MPV_EVENT_LOG_MESSAGE: mpv_event_log_message* 1679 | * MPV_EVENT_CLIENT_MESSAGE: mpv_event_client_message* 1680 | * MPV_EVENT_END_FILE: mpv_event_end_file* 1681 | * MPV_EVENT_HOOK: mpv_event_hook* 1682 | * MPV_EVENT_COMMAND_REPLY* mpv_event_command* 1683 | * other: NULL 1684 | * 1685 | * Note: future enhancements might add new event structs for existing or new 1686 | * event types. 1687 | */ 1688 | void *data; 1689 | } mpv_event; 1690 | 1691 | /** 1692 | * Enable or disable the given event. 1693 | * 1694 | * Some events are enabled by default. Some events can't be disabled. 1695 | * 1696 | * (Informational note: currently, all events are enabled by default, except 1697 | * MPV_EVENT_TICK.) 1698 | * 1699 | * Safe to be called from mpv render API threads. 1700 | * 1701 | * @param event See enum mpv_event_id. 1702 | * @param enable 1 to enable receiving this event, 0 to disable it. 1703 | * @return error code 1704 | */ 1705 | int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable); 1706 | 1707 | /** 1708 | * Enable or disable receiving of log messages. These are the messages the 1709 | * command line player prints to the terminal. This call sets the minimum 1710 | * required log level for a message to be received with MPV_EVENT_LOG_MESSAGE. 1711 | * 1712 | * @param min_level Minimal log level as string. Valid log levels: 1713 | * no fatal error warn info v debug trace 1714 | * The value "no" disables all messages. This is the default. 1715 | * An exception is the value "terminal-default", which uses the 1716 | * log level as set by the "--msg-level" option. This works 1717 | * even if the terminal is disabled. (Since API version 1.19.) 1718 | * Also see mpv_log_level. 1719 | * @return error code 1720 | */ 1721 | int mpv_request_log_messages(mpv_handle *ctx, const char *min_level); 1722 | 1723 | /** 1724 | * Wait for the next event, or until the timeout expires, or if another thread 1725 | * makes a call to mpv_wakeup(). Passing 0 as timeout will never wait, and 1726 | * is suitable for polling. 1727 | * 1728 | * The internal event queue has a limited size (per client handle). If you 1729 | * don't empty the event queue quickly enough with mpv_wait_event(), it will 1730 | * overflow and silently discard further events. If this happens, making 1731 | * asynchronous requests will fail as well (with MPV_ERROR_EVENT_QUEUE_FULL). 1732 | * 1733 | * Only one thread is allowed to call this on the same mpv_handle at a time. 1734 | * The API won't complain if more than one thread calls this, but it will cause 1735 | * race conditions in the client when accessing the shared mpv_event struct. 1736 | * Note that most other API functions are not restricted by this, and no API 1737 | * function internally calls mpv_wait_event(). Additionally, concurrent calls 1738 | * to different mpv_handles are always safe. 1739 | * 1740 | * As long as the timeout is 0, this is safe to be called from mpv render API 1741 | * threads. 1742 | * 1743 | * @param timeout Timeout in seconds, after which the function returns even if 1744 | * no event was received. A MPV_EVENT_NONE is returned on 1745 | * timeout. A value of 0 will disable waiting. Negative values 1746 | * will wait with an infinite timeout. 1747 | * @return A struct containing the event ID and other data. The pointer (and 1748 | * fields in the struct) stay valid until the next mpv_wait_event() 1749 | * call, or until the mpv_handle is destroyed. You must not write to 1750 | * the struct, and all memory referenced by it will be automatically 1751 | * released by the API on the next mpv_wait_event() call, or when the 1752 | * context is destroyed. The return value is never NULL. 1753 | */ 1754 | mpv_event *mpv_wait_event(mpv_handle *ctx, double timeout); 1755 | 1756 | /** 1757 | * Interrupt the current mpv_wait_event() call. This will wake up the thread 1758 | * currently waiting in mpv_wait_event(). If no thread is waiting, the next 1759 | * mpv_wait_event() call will return immediately (this is to avoid lost 1760 | * wakeups). 1761 | * 1762 | * mpv_wait_event() will receive a MPV_EVENT_NONE if it's woken up due to 1763 | * this call. But note that this dummy event might be skipped if there are 1764 | * already other events queued. All what counts is that the waiting thread 1765 | * is woken up at all. 1766 | * 1767 | * Safe to be called from mpv render API threads. 1768 | */ 1769 | void mpv_wakeup(mpv_handle *ctx); 1770 | 1771 | /** 1772 | * Set a custom function that should be called when there are new events. Use 1773 | * this if blocking in mpv_wait_event() to wait for new events is not feasible. 1774 | * 1775 | * Keep in mind that the callback will be called from foreign threads. You 1776 | * must not make any assumptions of the environment, and you must return as 1777 | * soon as possible (i.e. no long blocking waits). Exiting the callback through 1778 | * any other means than a normal return is forbidden (no throwing exceptions, 1779 | * no longjmp() calls). You must not change any local thread state (such as 1780 | * the C floating point environment). 1781 | * 1782 | * You are not allowed to call any client API functions inside of the callback. 1783 | * In particular, you should not do any processing in the callback, but wake up 1784 | * another thread that does all the work. The callback is meant strictly for 1785 | * notification only, and is called from arbitrary core parts of the player, 1786 | * that make no considerations for reentrant API use or allowing the callee to 1787 | * spend a lot of time doing other things. Keep in mind that it's also possible 1788 | * that the callback is called from a thread while a mpv API function is called 1789 | * (i.e. it can be reentrant). 1790 | * 1791 | * In general, the client API expects you to call mpv_wait_event() to receive 1792 | * notifications, and the wakeup callback is merely a helper utility to make 1793 | * this easier in certain situations. Note that it's possible that there's 1794 | * only one wakeup callback invocation for multiple events. You should call 1795 | * mpv_wait_event() with no timeout until MPV_EVENT_NONE is reached, at which 1796 | * point the event queue is empty. 1797 | * 1798 | * If you actually want to do processing in a callback, spawn a thread that 1799 | * does nothing but call mpv_wait_event() in a loop and dispatches the result 1800 | * to a callback. 1801 | * 1802 | * Only one wakeup callback can be set. 1803 | * 1804 | * @param cb function that should be called if a wakeup is required 1805 | * @param d arbitrary userdata passed to cb 1806 | */ 1807 | void mpv_set_wakeup_callback(mpv_handle *ctx, void (*cb)(void *d), void *d); 1808 | 1809 | /** 1810 | * Block until all asynchronous requests are done. This affects functions like 1811 | * mpv_command_async(), which return immediately and return their result as 1812 | * events. 1813 | * 1814 | * This is a helper, and somewhat equivalent to calling mpv_wait_event() in a 1815 | * loop until all known asynchronous requests have sent their reply as event, 1816 | * except that the event queue is not emptied. 1817 | * 1818 | * In case you called mpv_suspend() before, this will also forcibly reset the 1819 | * suspend counter of the given handle. 1820 | */ 1821 | void mpv_wait_async_requests(mpv_handle *ctx); 1822 | 1823 | /** 1824 | * A hook is like a synchronous event that blocks the player. You register 1825 | * a hook handler with this function. You will get an event, which you need 1826 | * to handle, and once things are ready, you can let the player continue with 1827 | * mpv_hook_continue(). 1828 | * 1829 | * Currently, hooks can't be removed explicitly. But they will be implicitly 1830 | * removed if the mpv_handle it was registered with is destroyed. This also 1831 | * continues the hook if it was being handled by the destroyed mpv_handle (but 1832 | * this should be avoided, as it might mess up order of hook execution). 1833 | * 1834 | * Hook handlers are ordered globally by priority and order of registration. 1835 | * Handlers for the same hook with same priority are invoked in order of 1836 | * registration (the handler registered first is run first). Handlers with 1837 | * lower priority are run first (which seems backward). 1838 | * 1839 | * See the "Hooks" section in the manpage to see which hooks are currently 1840 | * defined. 1841 | * 1842 | * Some hooks might be reentrant (so you get multiple MPV_EVENT_HOOK for the 1843 | * same hook). If this can happen for a specific hook type, it will be 1844 | * explicitly documented in the manpage. 1845 | * 1846 | * Only the mpv_handle on which this was called will receive the hook events, 1847 | * or can "continue" them. 1848 | * 1849 | * @param reply_userdata This will be used for the mpv_event.reply_userdata 1850 | * field for the received MPV_EVENT_HOOK events. 1851 | * If you have no use for this, pass 0. 1852 | * @param name The hook name. This should be one of the documented names. But 1853 | * if the name is unknown, the hook event will simply be never 1854 | * raised. 1855 | * @param priority See remarks above. Use 0 as a neutral default. 1856 | * @return error code (usually fails only on OOM) 1857 | */ 1858 | int mpv_hook_add(mpv_handle *ctx, uint64_t reply_userdata, 1859 | const char *name, int priority); 1860 | 1861 | /** 1862 | * Respond to a MPV_EVENT_HOOK event. You must call this after you have handled 1863 | * the event. There is no way to "cancel" or "stop" the hook. 1864 | * 1865 | * Calling this will will typically unblock the player for whatever the hook 1866 | * is responsible for (e.g. for the "on_load" hook it lets it continue 1867 | * playback). 1868 | * 1869 | * It is explicitly undefined behavior to call this more than once for each 1870 | * MPV_EVENT_HOOK, to pass an incorrect ID, or to call this on a mpv_handle 1871 | * different from the one that registered the handler and received the event. 1872 | * 1873 | * @param id This must be the value of the mpv_event_hook.id field for the 1874 | * corresponding MPV_EVENT_HOOK. 1875 | * @return error code 1876 | */ 1877 | int mpv_hook_continue(mpv_handle *ctx, uint64_t id); 1878 | 1879 | #if MPV_ENABLE_DEPRECATED 1880 | 1881 | /** 1882 | * Return a UNIX file descriptor referring to the read end of a pipe. This 1883 | * pipe can be used to wake up a poll() based processing loop. The purpose of 1884 | * this function is very similar to mpv_set_wakeup_callback(), and provides 1885 | * a primitive mechanism to handle coordinating a foreign event loop and the 1886 | * libmpv event loop. The pipe is non-blocking. It's closed when the mpv_handle 1887 | * is destroyed. This function always returns the same value (on success). 1888 | * 1889 | * This is in fact implemented using the same underlying code as for 1890 | * mpv_set_wakeup_callback() (though they don't conflict), and it is as if each 1891 | * callback invocation writes a single 0 byte to the pipe. When the pipe 1892 | * becomes readable, the code calling poll() (or select()) on the pipe should 1893 | * read all contents of the pipe and then call mpv_wait_event(c, 0) until 1894 | * no new events are returned. The pipe contents do not matter and can just 1895 | * be discarded. There is not necessarily one byte per readable event in the 1896 | * pipe. For example, the pipes are non-blocking, and mpv won't block if the 1897 | * pipe is full. Pipes are normally limited to 4096 bytes, so if there are 1898 | * more than 4096 events, the number of readable bytes can not equal the number 1899 | * of events queued. Also, it's possible that mpv does not write to the pipe 1900 | * once it's guaranteed that the client was already signaled. See the example 1901 | * below how to do it correctly. 1902 | * 1903 | * Example: 1904 | * 1905 | * int pipefd = mpv_get_wakeup_pipe(mpv); 1906 | * if (pipefd < 0) 1907 | * error(); 1908 | * while (1) { 1909 | * struct pollfd pfds[1] = { 1910 | * { .fd = pipefd, .events = POLLIN }, 1911 | * }; 1912 | * // Wait until there are possibly new mpv events. 1913 | * poll(pfds, 1, -1); 1914 | * if (pfds[0].revents & POLLIN) { 1915 | * // Empty the pipe. Doing this before calling mpv_wait_event() 1916 | * // ensures that no wakeups are missed. It's not so important to 1917 | * // make sure the pipe is really empty (it will just cause some 1918 | * // additional wakeups in unlikely corner cases). 1919 | * char unused[256]; 1920 | * read(pipefd, unused, sizeof(unused)); 1921 | * while (1) { 1922 | * mpv_event *ev = mpv_wait_event(mpv, 0); 1923 | * // If MPV_EVENT_NONE is received, the event queue is empty. 1924 | * if (ev->event_id == MPV_EVENT_NONE) 1925 | * break; 1926 | * // Process the event. 1927 | * ... 1928 | * } 1929 | * } 1930 | * } 1931 | * 1932 | * @deprecated this function will be removed in the future. If you need this 1933 | * functionality, use mpv_set_wakeup_callback(), create a pipe 1934 | * manually, and call write() on your pipe in the callback. 1935 | * 1936 | * @return A UNIX FD of the read end of the wakeup pipe, or -1 on error. 1937 | * On MS Windows/MinGW, this will always return -1. 1938 | */ 1939 | int mpv_get_wakeup_pipe(mpv_handle *ctx); 1940 | 1941 | /** 1942 | * @deprecated use render.h 1943 | */ 1944 | typedef enum mpv_sub_api { 1945 | /** 1946 | * For using mpv's OpenGL renderer on an external OpenGL context. 1947 | * mpv_get_sub_api(MPV_SUB_API_OPENGL_CB) returns mpv_opengl_cb_context*. 1948 | * This context can be used with mpv_opengl_cb_* functions. 1949 | * Will return NULL if unavailable (if OpenGL support was not compiled in). 1950 | * See opengl_cb.h for details. 1951 | * 1952 | * @deprecated use render.h 1953 | */ 1954 | MPV_SUB_API_OPENGL_CB = 1 1955 | } mpv_sub_api; 1956 | 1957 | /** 1958 | * This is used for additional APIs that are not strictly part of the core API. 1959 | * See the individual mpv_sub_api member values. 1960 | * 1961 | * @deprecated use render.h 1962 | */ 1963 | void *mpv_get_sub_api(mpv_handle *ctx, mpv_sub_api sub_api); 1964 | 1965 | #endif 1966 | 1967 | #ifdef __cplusplus 1968 | } 1969 | #endif 1970 | 1971 | #endif 1972 | -------------------------------------------------------------------------------- /framework-meta/libmpv/Headers/libmpv.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | -------------------------------------------------------------------------------- /framework-meta/libmpv/Headers/render.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018 the mpv developers 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef MPV_CLIENT_API_RENDER_H_ 17 | #define MPV_CLIENT_API_RENDER_H_ 18 | 19 | #include "client.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * Overview 27 | * -------- 28 | * 29 | * This API can be used to make mpv render using supported graphic APIs (such 30 | * as OpenGL). It can be used to handle video display. 31 | * 32 | * The renderer needs to be created with mpv_render_context_create() before 33 | * you start playback (or otherwise cause a VO to be created). Then (with most 34 | * backends) mpv_render_context_render() can be used to explicitly render the 35 | * current video frame. Use mpv_render_context_set_update_callback() to get 36 | * notified when there is a new frame to draw. 37 | * 38 | * Preferably rendering should be done in a separate thread. If you call 39 | * normal libmpv API functions on the renderer thread, deadlocks can result 40 | * (these are made non-fatal with timeouts, but user experience will obviously 41 | * suffer). See "Threading" section below. 42 | * 43 | * You can output and embed video without this API by setting the mpv "wid" 44 | * option to a native window handle (see "Embedding the video window" section 45 | * in the client.h header). In general, using the render API is recommended, 46 | * because window embedding can cause various issues, especially with GUI 47 | * toolkits and certain platforms. 48 | * 49 | * Supported backends 50 | * ------------------ 51 | * 52 | * OpenGL: via MPV_RENDER_API_TYPE_OPENGL, see render_gl.h header. 53 | * 54 | * Threading 55 | * --------- 56 | * 57 | * You are recommended to do rendering on a separate thread than normal libmpv 58 | * use. 59 | * 60 | * The mpv_render_* functions can be called from any thread, under the 61 | * following conditions: 62 | * - only one of the mpv_render_* functions can be called at the same time 63 | * (unless they belong to different mpv cores created by mpv_create()) 64 | * - never can be called from within the callbacks set with 65 | * mpv_set_wakeup_callback() or mpv_render_context_set_update_callback() 66 | * - if the OpenGL backend is used, for all functions the OpenGL context 67 | * must be "current" in the calling thread, and it must be the same OpenGL 68 | * context as the mpv_render_context was created with. Otherwise, undefined 69 | * behavior will occur. 70 | * - the thread does not call libmpv API functions other than the mpv_render_* 71 | * functions, except APIs which are declared as safe (see below). Likewise, 72 | * there must be no lock or wait dependency from the render thread to a 73 | * thread using other libmpv functions. Basically, the situation that your 74 | * render thread waits for a "not safe" libmpv API function to return must 75 | * not happen. If you ignore this requirement, deadlocks can happen, which 76 | * are made non-fatal with timeouts; then playback quality will be degraded, 77 | * and the message 78 | * mpv_render_context_render() not being called or stuck. 79 | * is logged. If you set MPV_RENDER_PARAM_ADVANCED_CONTROL, you promise that 80 | * this won't happen, and must absolutely guarantee it, or a real deadlock 81 | * will freeze the mpv core thread forever. 82 | * 83 | * libmpv functions which are safe to call from a render thread are: 84 | * - functions marked with "Safe to be called from mpv render API threads." 85 | * - client.h functions which don't have an explicit or implicit mpv_handle 86 | * parameter 87 | * - mpv_render_* functions; but only for the same mpv_render_context pointer. 88 | * If the pointer is different, mpv_render_context_free() is not safe. (The 89 | * reason is that if MPV_RENDER_PARAM_ADVANCED_CONTROL is set, it may have 90 | * to process still queued requests from the core, which it can do only for 91 | * the current context, while requests for other contexts would deadlock. 92 | * Also, it may have to wait and block for the core to terminate the video 93 | * chain to make sure no resources are used after context destruction.) 94 | * - if the mpv_handle parameter refers to a different mpv core than the one 95 | * you're rendering for (very obscure, but allowed) 96 | * 97 | * Note about old libmpv version: 98 | * 99 | * Before API version 1.105 (basically in mpv 0.29.x), simply enabling 100 | * MPV_RENDER_PARAM_ADVANCED_CONTROL could cause deadlock issues. This can 101 | * be worked around by setting the "vd-lavc-dr" option to "no". 102 | * In addition, you were required to call all mpv_render*() API functions 103 | * from the same thread on which mpv_render_context_create() was originally 104 | * run (for the same the mpv_render_context). Not honoring it led to UB 105 | * (deadlocks, use of invalid pthread_t handles), even if you moved your GL 106 | * context to a different thread correctly. 107 | * These problems were addressed in API version 1.105 (mpv 0.30.0). 108 | * 109 | * Context and handle lifecycle 110 | * ---------------------------- 111 | * 112 | * Video initialization will fail if the render context was not initialized yet 113 | * (with mpv_render_context_create()), or it will revert to a VO that creates 114 | * its own window. 115 | * 116 | * Currently, there can be only 1 mpv_render_context at a time per mpv core. 117 | * 118 | * Calling mpv_render_context_free() while a VO is using the render context is 119 | * active will disable video. 120 | * 121 | * You must free the context with mpv_render_context_free() before the mpv core 122 | * is destroyed. If this doesn't happen, undefined behavior will result. 123 | */ 124 | 125 | /** 126 | * Opaque context, returned by mpv_render_context_create(). 127 | */ 128 | typedef struct mpv_render_context mpv_render_context; 129 | 130 | /** 131 | * Parameters for mpv_render_param (which is used in a few places such as 132 | * mpv_render_context_create(). 133 | * 134 | * Also see mpv_render_param for conventions and how to use it. 135 | */ 136 | typedef enum mpv_render_param_type { 137 | /** 138 | * Not a valid value, but also used to terminate a params array. Its value 139 | * is always guaranteed to be 0 (even if the ABI changes in the future). 140 | */ 141 | MPV_RENDER_PARAM_INVALID = 0, 142 | /** 143 | * The render API to use. Valid for mpv_render_context_create(). 144 | * 145 | * Type: char* 146 | * 147 | * Defined APIs: 148 | * 149 | * MPV_RENDER_API_TYPE_OPENGL: 150 | * OpenGL desktop 2.1 or later (preferably core profile compatible to 151 | * OpenGL 3.2), or OpenGLES 2.0 or later. 152 | * Providing MPV_RENDER_PARAM_OPENGL_INIT_PARAMS is required. 153 | * It is expected that an OpenGL context is valid and "current" when 154 | * calling mpv_render_* functions (unless specified otherwise). It 155 | * must be the same context for the same mpv_render_context. 156 | */ 157 | MPV_RENDER_PARAM_API_TYPE = 1, 158 | /** 159 | * Required parameters for initializing the OpenGL renderer. Valid for 160 | * mpv_render_context_create(). 161 | * Type: mpv_opengl_init_params* 162 | */ 163 | MPV_RENDER_PARAM_OPENGL_INIT_PARAMS = 2, 164 | /** 165 | * Describes a GL render target. Valid for mpv_render_context_render(). 166 | * Type: mpv_opengl_fbo* 167 | */ 168 | MPV_RENDER_PARAM_OPENGL_FBO = 3, 169 | /** 170 | * Control flipped rendering. Valid for mpv_render_context_render(). 171 | * Type: int* 172 | * If the value is set to 0, render normally. Otherwise, render it flipped, 173 | * which is needed e.g. when rendering to an OpenGL default framebuffer 174 | * (which has a flipped coordinate system). 175 | */ 176 | MPV_RENDER_PARAM_FLIP_Y = 4, 177 | /** 178 | * Control surface depth. Valid for mpv_render_context_render(). 179 | * Type: int* 180 | * This implies the depth of the surface passed to the render function in 181 | * bits per channel. If omitted or set to 0, the renderer will assume 8. 182 | * Typically used to control dithering. 183 | */ 184 | MPV_RENDER_PARAM_DEPTH = 5, 185 | /** 186 | * ICC profile blob. Valid for mpv_render_context_set_parameter(). 187 | * Type: mpv_byte_array* 188 | * Set an ICC profile for use with the "icc-profile-auto" option. (If the 189 | * option is not enabled, the ICC data will not be used.) 190 | */ 191 | MPV_RENDER_PARAM_ICC_PROFILE = 6, 192 | /** 193 | * Ambient light in lux. Valid for mpv_render_context_set_parameter(). 194 | * Type: int* 195 | * This can be used for automatic gamma correction. 196 | */ 197 | MPV_RENDER_PARAM_AMBIENT_LIGHT = 7, 198 | /** 199 | * X11 Display, sometimes used for hwdec. Valid for 200 | * mpv_render_context_create(). The Display must stay valid for the lifetime 201 | * of the mpv_render_context. 202 | * Type: Display* 203 | */ 204 | MPV_RENDER_PARAM_X11_DISPLAY = 8, 205 | /** 206 | * Wayland display, sometimes used for hwdec. Valid for 207 | * mpv_render_context_create(). The wl_display must stay valid for the 208 | * lifetime of the mpv_render_context. 209 | * Type: struct wl_display* 210 | */ 211 | MPV_RENDER_PARAM_WL_DISPLAY = 9, 212 | /** 213 | * Better control about rendering and enabling some advanced features. Valid 214 | * for mpv_render_context_create(). 215 | * 216 | * This conflates multiple requirements the API user promises to abide if 217 | * this option is enabled: 218 | * 219 | * - The API user's render thread, which is calling the mpv_render_*() 220 | * functions, never waits for the core. Otherwise deadlocks can happen. 221 | * See "Threading" section. 222 | * - The callback set with mpv_render_context_set_update_callback() can now 223 | * be called even if there is no new frame. The API user should call the 224 | * mpv_render_context_update() function, and interpret the return value 225 | * for whether a new frame should be rendered. 226 | * - Correct functionality is impossible if the update callback is not set, 227 | * or not set soon enough after mpv_render_context_create() (the core can 228 | * block while waiting for you to call mpv_render_context_update(), and 229 | * if the update callback is not correctly set, it will deadlock, or 230 | * block for too long). 231 | * 232 | * In general, setting this option will enable the following features (and 233 | * possibly more): 234 | * 235 | * - "Direct rendering", which means the player decodes directly to a 236 | * texture, which saves a copy per video frame ("vd-lavc-dr" option 237 | * needs to be enabled, and the rendering backend as well as the 238 | * underlying GPU API/driver needs to have support for it). 239 | * - Rendering screenshots with the GPU API if supported by the backend 240 | * (instead of using a suboptimal software fallback via libswscale). 241 | * 242 | * Warning: do not just add this without reading the "Threading" section 243 | * above, and then wondering that deadlocks happen. The 244 | * requirements are tricky. But also note that even if advanced 245 | * control is disabled, not adhering to the rules will lead to 246 | * playback problems. Enabling advanced controls simply makes 247 | * violating these rules fatal. 248 | * 249 | * Type: int*: 0 for disable (default), 1 for enable 250 | */ 251 | MPV_RENDER_PARAM_ADVANCED_CONTROL = 10, 252 | /** 253 | * Return information about the next frame to render. Valid for 254 | * mpv_render_context_get_info(). 255 | * 256 | * Type: mpv_render_frame_info* 257 | * 258 | * It strictly returns information about the _next_ frame. The implication 259 | * is that e.g. mpv_render_context_update()'s return value will have 260 | * MPV_RENDER_UPDATE_FRAME set, and the user is supposed to call 261 | * mpv_render_context_render(). If there is no next frame, then the 262 | * return value will have is_valid set to 0. 263 | */ 264 | MPV_RENDER_PARAM_NEXT_FRAME_INFO = 11, 265 | /** 266 | * Enable or disable video timing. Valid for mpv_render_context_render(). 267 | * 268 | * Type: int*: 0 for disable, 1 for enable (default) 269 | * 270 | * When video is timed to audio, the player attempts to render video a bit 271 | * ahead, and then do a blocking wait until the target display time is 272 | * reached. This blocks mpv_render_context_render() for up to the amount 273 | * specified with the "video-timing-offset" global option. You can set 274 | * this parameter to 0 to disable this kind of waiting. If you do, it's 275 | * recommended to use the target time value in mpv_render_frame_info to 276 | * wait yourself, or to set the "video-timing-offset" to 0 instead. 277 | * 278 | * Disabling this without doing anything in addition will result in A/V sync 279 | * being slightly off. 280 | */ 281 | MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME = 12, 282 | /** 283 | * Use to skip rendering in mpv_render_context_render(). 284 | * 285 | * Type: int*: 0 for rendering (default), 1 for skipping 286 | * 287 | * If this is set, you don't need to pass a target surface to the render 288 | * function (and if you do, it's completely ignored). This can still call 289 | * into the lower level APIs (i.e. if you use OpenGL, the OpenGL context 290 | * must be set). 291 | * 292 | * Be aware that the render API will consider this frame as having been 293 | * rendered. All other normal rules also apply, for example about whether 294 | * you have to call mpv_render_context_report_swap(). It also does timing 295 | * in the same way. 296 | */ 297 | MPV_RENDER_PARAM_SKIP_RENDERING = 13, 298 | /** 299 | * Deprecated. Not supported. Use MPV_RENDER_PARAM_DRM_DISPLAY_V2 instead. 300 | * Type : struct mpv_opengl_drm_params* 301 | */ 302 | MPV_RENDER_PARAM_DRM_DISPLAY = 14, 303 | /** 304 | * DRM draw surface size, contains draw surface dimensions. 305 | * Valid for mpv_render_context_create(). 306 | * Type : struct mpv_opengl_drm_draw_surface_size* 307 | */ 308 | MPV_RENDER_PARAM_DRM_DRAW_SURFACE_SIZE = 15, 309 | /** 310 | * DRM display, contains drm display handles. 311 | * Valid for mpv_render_context_create(). 312 | * Type : struct mpv_opengl_drm_params_v2* 313 | */ 314 | MPV_RENDER_PARAM_DRM_DISPLAY_V2 = 16, 315 | } mpv_render_param_type; 316 | 317 | /** 318 | * For backwards compatibility with the old naming of 319 | * MPV_RENDER_PARAM_DRM_DRAW_SURFACE_SIZE 320 | */ 321 | #define MPV_RENDER_PARAM_DRM_OSD_SIZE MPV_RENDER_PARAM_DRM_DRAW_SURFACE_SIZE 322 | 323 | /** 324 | * Used to pass arbitrary parameters to some mpv_render_* functions. The 325 | * meaning of the data parameter is determined by the type, and each 326 | * MPV_RENDER_PARAM_* documents what type the value must point to. 327 | * 328 | * Each value documents the required data type as the pointer you cast to 329 | * void* and set on mpv_render_param.data. For example, if MPV_RENDER_PARAM_FOO 330 | * documents the type as Something* , then the code should look like this: 331 | * 332 | * Something foo = {...}; 333 | * mpv_render_param param; 334 | * param.type = MPV_RENDER_PARAM_FOO; 335 | * param.data = & foo; 336 | * 337 | * Normally, the data field points to exactly 1 object. If the type is char*, 338 | * it points to a 0-terminated string. 339 | * 340 | * In all cases (unless documented otherwise) the pointers need to remain 341 | * valid during the call only. Unless otherwise documented, the API functions 342 | * will not write to the params array or any data pointed to it. 343 | * 344 | * As a convention, parameter arrays are always terminated by type==0. There 345 | * is no specific order of the parameters required. The order of the 2 fields in 346 | * this struct is guaranteed (even after ABI changes). 347 | */ 348 | typedef struct mpv_render_param { 349 | enum mpv_render_param_type type; 350 | void *data; 351 | } mpv_render_param; 352 | 353 | 354 | /** 355 | * Predefined values for MPV_RENDER_PARAM_API_TYPE. 356 | */ 357 | #define MPV_RENDER_API_TYPE_OPENGL "opengl" 358 | 359 | /** 360 | * Flags used in mpv_render_frame_info.flags. Each value represents a bit in it. 361 | */ 362 | typedef enum mpv_render_frame_info_flag { 363 | /** 364 | * Set if there is actually a next frame. If unset, there is no next frame 365 | * yet, and other flags and fields that require a frame to be queued will 366 | * be unset. 367 | * 368 | * This is set for _any_ kind of frame, even for redraw requests. 369 | * 370 | * Note that when this is unset, it simply means no new frame was 371 | * decoded/queued yet, not necessarily that the end of the video was 372 | * reached. A new frame can be queued after some time. 373 | * 374 | * If the return value of mpv_render_context_render() had the 375 | * MPV_RENDER_UPDATE_FRAME flag set, this flag will usually be set as well, 376 | * unless the frame is rendered, or discarded by other asynchronous events. 377 | */ 378 | MPV_RENDER_FRAME_INFO_PRESENT = 1 << 0, 379 | /** 380 | * If set, the frame is not an actual new video frame, but a redraw request. 381 | * For example if the video is paused, and an option that affects video 382 | * rendering was changed (or any other reason), an update request can be 383 | * issued and this flag will be set. 384 | * 385 | * Typically, redraw frames will not be subject to video timing. 386 | * 387 | * Implies MPV_RENDER_FRAME_INFO_PRESENT. 388 | */ 389 | MPV_RENDER_FRAME_INFO_REDRAW = 1 << 1, 390 | /** 391 | * If set, this is supposed to reproduce the previous frame perfectly. This 392 | * is usually used for certain "video-sync" options ("display-..." modes). 393 | * Typically the renderer will blit the video from a FBO. Unset otherwise. 394 | * 395 | * Implies MPV_RENDER_FRAME_INFO_PRESENT. 396 | */ 397 | MPV_RENDER_FRAME_INFO_REPEAT = 1 << 2, 398 | /** 399 | * If set, the player timing code expects that the user thread blocks on 400 | * vsync (by either delaying the render call, or by making a call to 401 | * mpv_render_context_report_swap() at vsync time). 402 | * 403 | * Implies MPV_RENDER_FRAME_INFO_PRESENT. 404 | */ 405 | MPV_RENDER_FRAME_INFO_BLOCK_VSYNC = 1 << 3, 406 | } mpv_render_frame_info_flag; 407 | 408 | /** 409 | * Information about the next video frame that will be rendered. Can be 410 | * retrieved with MPV_RENDER_PARAM_NEXT_FRAME_INFO. 411 | */ 412 | typedef struct mpv_render_frame_info { 413 | /** 414 | * A bitset of mpv_render_frame_info_flag values (i.e. multiple flags are 415 | * combined with bitwise or). 416 | */ 417 | uint64_t flags; 418 | /** 419 | * Absolute time at which the frame is supposed to be displayed. This is in 420 | * the same unit and base as the time returned by mpv_get_time_us(). For 421 | * frames that are redrawn, or if vsync locked video timing is used (see 422 | * "video-sync" option), then this can be 0. The "video-timing-offset" 423 | * option determines how much "headroom" the render thread gets (but a high 424 | * enough frame rate can reduce it anyway). mpv_render_context_render() will 425 | * normally block until the time is elapsed, unless you pass it 426 | * MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME = 0. 427 | */ 428 | int64_t target_time; 429 | } mpv_render_frame_info; 430 | 431 | /** 432 | * Initialize the renderer state. Depending on the backend used, this will 433 | * access the underlying GPU API and initialize its own objects. 434 | * 435 | * You must free the context with mpv_render_context_free(). Not doing so before 436 | * the mpv core is destroyed may result in memory leaks or crashes. 437 | * 438 | * Currently, only at most 1 context can exists per mpv core (it represents the 439 | * main video output). 440 | * 441 | * You should pass the following parameters: 442 | * - MPV_RENDER_PARAM_API_TYPE to select the underlying backend/GPU API. 443 | * - Backend-specific init parameter, like MPV_RENDER_PARAM_OPENGL_INIT_PARAMS. 444 | * - Setting MPV_RENDER_PARAM_ADVANCED_CONTROL and following its rules is 445 | * strongly recommended. 446 | * - If you want to use hwdec, possibly hwdec interop resources. 447 | * 448 | * @param res set to the context (on success) or NULL (on failure). The value 449 | * is never read and always overwritten. 450 | * @param mpv handle used to get the core (the mpv_render_context won't depend 451 | * on this specific handle, only the core referenced by it) 452 | * @param params an array of parameters, terminated by type==0. It's left 453 | * unspecified what happens with unknown parameters. At least 454 | * MPV_RENDER_PARAM_API_TYPE is required, and most backends will 455 | * require another backend-specific parameter. 456 | * @return error code, including but not limited to: 457 | * MPV_ERROR_UNSUPPORTED: the OpenGL version is not supported 458 | * (or required extensions are missing) 459 | * MPV_ERROR_NOT_IMPLEMENTED: an unknown API type was provided, or 460 | * support for the requested API was not 461 | * built in the used libmpv binary. 462 | * MPV_ERROR_INVALID_PARAMETER: at least one of the provided parameters was 463 | * not valid. 464 | */ 465 | int mpv_render_context_create(mpv_render_context **res, mpv_handle *mpv, 466 | mpv_render_param *params); 467 | 468 | /** 469 | * Attempt to change a single parameter. Not all backends and parameter types 470 | * support all kinds of changes. 471 | * 472 | * @param ctx a valid render context 473 | * @param param the parameter type and data that should be set 474 | * @return error code. If a parameter could actually be changed, this returns 475 | * success, otherwise an error code depending on the parameter type 476 | * and situation. 477 | */ 478 | int mpv_render_context_set_parameter(mpv_render_context *ctx, 479 | mpv_render_param param); 480 | 481 | /** 482 | * Retrieve information from the render context. This is NOT a counterpart to 483 | * mpv_render_context_set_parameter(), because you generally can't read 484 | * parameters set with it, and this function is not meant for this purpose. 485 | * Instead, this is for communicating information from the renderer back to the 486 | * user. See mpv_render_param_type; entries which support this function 487 | * explicitly mention it, and for other entries you can assume it will fail. 488 | * 489 | * You pass param with param.type set and param.data pointing to a variable 490 | * of the required data type. The function will then overwrite that variable 491 | * with the returned value (at least on success). 492 | * 493 | * @param ctx a valid render context 494 | * @param param the parameter type and data that should be retrieved 495 | * @return error code. If a parameter could actually be retrieved, this returns 496 | * success, otherwise an error code depending on the parameter type 497 | * and situation. MPV_ERROR_NOT_IMPLEMENTED is used for unknown 498 | * param.type, or if retrieving it is not supported. 499 | */ 500 | int mpv_render_context_get_info(mpv_render_context *ctx, 501 | mpv_render_param param); 502 | 503 | typedef void (*mpv_render_update_fn)(void *cb_ctx); 504 | 505 | /** 506 | * Set the callback that notifies you when a new video frame is available, or 507 | * if the video display configuration somehow changed and requires a redraw. 508 | * Similar to mpv_set_wakeup_callback(), you must not call any mpv API from 509 | * the callback, and all the other listed restrictions apply (such as not 510 | * exiting the callback by throwing exceptions). 511 | * 512 | * This can be called from any thread, except from an update callback. In case 513 | * of the OpenGL backend, no OpenGL state or API is accessed. 514 | * 515 | * Calling this will raise an update callback immediately. 516 | * 517 | * @param callback callback(callback_ctx) is called if the frame should be 518 | * redrawn 519 | * @param callback_ctx opaque argument to the callback 520 | */ 521 | void mpv_render_context_set_update_callback(mpv_render_context *ctx, 522 | mpv_render_update_fn callback, 523 | void *callback_ctx); 524 | 525 | /** 526 | * The API user is supposed to call this when the update callback was invoked 527 | * (like all mpv_render_* functions, this has to happen on the render thread, 528 | * and _not_ from the update callback itself). 529 | * 530 | * This is optional if MPV_RENDER_PARAM_ADVANCED_CONTROL was not set (default). 531 | * Otherwise, it's a hard requirement that this is called after each update 532 | * callback. If multiple update callback happened, and the function could not 533 | * be called sooner, it's OK to call it once after the last callback. 534 | * 535 | * If an update callback happens during or after this function, the function 536 | * must be called again at the soonest possible time. 537 | * 538 | * If MPV_RENDER_PARAM_ADVANCED_CONTROL was set, this will do additional work 539 | * such as allocating textures for the video decoder. 540 | * 541 | * @return a bitset of mpv_render_update_flag values (i.e. multiple flags are 542 | * combined with bitwise or). Typically, this will tell the API user 543 | * what should happen next. E.g. if the MPV_RENDER_UPDATE_FRAME flag is 544 | * set, mpv_render_context_render() should be called. If flags unknown 545 | * to the API user are set, or if the return value is 0, nothing needs 546 | * to be done. 547 | */ 548 | uint64_t mpv_render_context_update(mpv_render_context *ctx); 549 | 550 | /** 551 | * Flags returned by mpv_render_context_update(). Each value represents a bit 552 | * in the function's return value. 553 | */ 554 | typedef enum mpv_render_update_flag { 555 | /** 556 | * A new video frame must be rendered. mpv_render_context_render() must be 557 | * called. 558 | */ 559 | MPV_RENDER_UPDATE_FRAME = 1 << 0, 560 | } mpv_render_context_flag; 561 | 562 | /** 563 | * Render video. 564 | * 565 | * Typically renders the video to a target surface provided via mpv_render_param 566 | * (the details depend on the backend in use). Options like "panscan" are 567 | * applied to determine which part of the video should be visible and how the 568 | * video should be scaled. You can change these options at runtime by using the 569 | * mpv property API. 570 | * 571 | * The renderer will reconfigure itself every time the target surface 572 | * configuration (such as size) is changed. 573 | * 574 | * This function implicitly pulls a video frame from the internal queue and 575 | * renders it. If no new frame is available, the previous frame is redrawn. 576 | * The update callback set with mpv_render_context_set_update_callback() 577 | * notifies you when a new frame was added. The details potentially depend on 578 | * the backends and the provided parameters. 579 | * 580 | * Generally, libmpv will invoke your update callback some time before the video 581 | * frame should be shown, and then lets this function block until the supposed 582 | * display time. This will limit your rendering to video FPS. You can prevent 583 | * this by setting the "video-timing-offset" global option to 0. (This applies 584 | * only to "audio" video sync mode.) 585 | * 586 | * You should pass the following parameters: 587 | * - Backend-specific target object, such as MPV_RENDER_PARAM_OPENGL_FBO. 588 | * - Possibly transformations, such as MPV_RENDER_PARAM_FLIP_Y. 589 | * 590 | * @param ctx a valid render context 591 | * @param params an array of parameters, terminated by type==0. Which parameters 592 | * are required depends on the backend. It's left unspecified what 593 | * happens with unknown parameters. 594 | * @return error code 595 | */ 596 | int mpv_render_context_render(mpv_render_context *ctx, mpv_render_param *params); 597 | 598 | /** 599 | * Tell the renderer that a frame was flipped at the given time. This is 600 | * optional, but can help the player to achieve better timing. 601 | * 602 | * Note that calling this at least once informs libmpv that you will use this 603 | * function. If you use it inconsistently, expect bad video playback. 604 | * 605 | * If this is called while no video is initialized, it is ignored. 606 | * 607 | * @param ctx a valid render context 608 | */ 609 | void mpv_render_context_report_swap(mpv_render_context *ctx); 610 | 611 | /** 612 | * Destroy the mpv renderer state. 613 | * 614 | * If video is still active (e.g. a file playing), video will be disabled 615 | * forcefully. 616 | * 617 | * @param ctx a valid render context. After this function returns, this is not 618 | * a valid pointer anymore. NULL is also allowed and does nothing. 619 | */ 620 | void mpv_render_context_free(mpv_render_context *ctx); 621 | 622 | #ifdef __cplusplus 623 | } 624 | #endif 625 | 626 | #endif 627 | -------------------------------------------------------------------------------- /framework-meta/libmpv/Headers/render_gl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018 the mpv developers 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef MPV_CLIENT_API_RENDER_GL_H_ 17 | #define MPV_CLIENT_API_RENDER_GL_H_ 18 | 19 | #include "render.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * OpenGL backend 27 | * -------------- 28 | * 29 | * This header contains definitions for using OpenGL with the render.h API. 30 | * 31 | * OpenGL interop 32 | * -------------- 33 | * 34 | * The OpenGL backend has some special rules, because OpenGL itself uses 35 | * implicit per-thread contexts, which causes additional API problems. 36 | * 37 | * This assumes the OpenGL context lives on a certain thread controlled by the 38 | * API user. All mpv_render_* APIs have to be assumed to implicitly use the 39 | * OpenGL context if you pass a mpv_render_context using the OpenGL backend, 40 | * unless specified otherwise. 41 | * 42 | * The OpenGL context is indirectly accessed through the OpenGL function 43 | * pointers returned by the get_proc_address callback in mpv_opengl_init_params. 44 | * Generally, mpv will not load the system OpenGL library when using this API. 45 | * 46 | * OpenGL state 47 | * ------------ 48 | * 49 | * OpenGL has a large amount of implicit state. All the mpv functions mentioned 50 | * above expect that the OpenGL state is reasonably set to OpenGL standard 51 | * defaults. Likewise, mpv will attempt to leave the OpenGL context with 52 | * standard defaults. The following state is excluded from this: 53 | * 54 | * - the glViewport state 55 | * - the glScissor state (but GL_SCISSOR_TEST is in its default value) 56 | * - glBlendFuncSeparate() state (but GL_BLEND is in its default value) 57 | * - glClearColor() state 58 | * - mpv may overwrite the callback set with glDebugMessageCallback() 59 | * - mpv always disables GL_DITHER at init 60 | * 61 | * Messing with the state could be avoided by creating shared OpenGL contexts, 62 | * but this is avoided for the sake of compatibility and interoperability. 63 | * 64 | * On OpenGL 2.1, mpv will strictly call functions like glGenTextures() to 65 | * create OpenGL objects. You will have to do the same. This ensures that 66 | * objects created by mpv and the API users don't clash. Also, legacy state 67 | * must be either in its defaults, or not interfere with core state. 68 | * 69 | * API use 70 | * ------- 71 | * 72 | * The mpv_render_* API is used. That API supports multiple backends, and this 73 | * section documents specifics for the OpenGL backend. 74 | * 75 | * Use mpv_render_context_create() with MPV_RENDER_PARAM_API_TYPE set to 76 | * MPV_RENDER_API_TYPE_OPENGL, and MPV_RENDER_PARAM_OPENGL_INIT_PARAMS provided. 77 | * 78 | * Call mpv_render_context_render() with MPV_RENDER_PARAM_OPENGL_FBO to render 79 | * the video frame to an FBO. 80 | * 81 | * Hardware decoding 82 | * ----------------- 83 | * 84 | * Hardware decoding via this API is fully supported, but requires some 85 | * additional setup. (At least if direct hardware decoding modes are wanted, 86 | * instead of copying back surface data from GPU to CPU RAM.) 87 | * 88 | * There may be certain requirements on the OpenGL implementation: 89 | * 90 | * - Windows: ANGLE is required (although in theory GL/DX interop could be used) 91 | * - Intel/Linux: EGL is required, and also the native display resource needs 92 | * to be provided (e.g. MPV_RENDER_PARAM_X11_DISPLAY for X11 and 93 | * MPV_RENDER_PARAM_WL_DISPLAY for Wayland) 94 | * - nVidia/Linux: Both GLX and EGL should work (GLX is required if vdpau is 95 | * used, e.g. due to old drivers.) 96 | * - OSX: CGL is required (CGLGetCurrentContext() returning non-NULL) 97 | * - iOS: EAGL is required (EAGLContext.currentContext returning non-nil) 98 | * 99 | * Once these things are setup, hardware decoding can be enabled/disabled at 100 | * any time by setting the "hwdec" property. 101 | */ 102 | 103 | /** 104 | * For initializing the mpv OpenGL state via MPV_RENDER_PARAM_OPENGL_INIT_PARAMS. 105 | */ 106 | typedef struct mpv_opengl_init_params { 107 | /** 108 | * This retrieves OpenGL function pointers, and will use them in subsequent 109 | * operation. 110 | * Usually, you can simply call the GL context APIs from this callback (e.g. 111 | * glXGetProcAddressARB or wglGetProcAddress), but some APIs do not always 112 | * return pointers for all standard functions (even if present); in this 113 | * case you have to compensate by looking up these functions yourself when 114 | * libmpv wants to resolve them through this callback. 115 | * libmpv will not normally attempt to resolve GL functions on its own, nor 116 | * does it link to GL libraries directly. 117 | */ 118 | void *(*get_proc_address)(void *ctx, const char *name); 119 | /** 120 | * Value passed as ctx parameter to get_proc_address(). 121 | */ 122 | void *get_proc_address_ctx; 123 | /** 124 | * This should not be used. It is deprecated and will be removed or ignored 125 | * when the opengl_cb API is removed. 126 | */ 127 | const char *extra_exts; 128 | } mpv_opengl_init_params; 129 | 130 | /** 131 | * For MPV_RENDER_PARAM_OPENGL_FBO. 132 | */ 133 | typedef struct mpv_opengl_fbo { 134 | /** 135 | * Framebuffer object name. This must be either a valid FBO generated by 136 | * glGenFramebuffers() that is complete and color-renderable, or 0. If the 137 | * value is 0, this refers to the OpenGL default framebuffer. 138 | */ 139 | int fbo; 140 | /** 141 | * Valid dimensions. This must refer to the size of the framebuffer. This 142 | * must always be set. 143 | */ 144 | int w, h; 145 | /** 146 | * Underlying texture internal format (e.g. GL_RGBA8), or 0 if unknown. If 147 | * this is the default framebuffer, this can be an equivalent. 148 | */ 149 | int internal_format; 150 | } mpv_opengl_fbo; 151 | 152 | /** 153 | * Deprecated. For MPV_RENDER_PARAM_DRM_DISPLAY. 154 | */ 155 | typedef struct mpv_opengl_drm_params { 156 | int fd; 157 | int crtc_id; 158 | int connector_id; 159 | struct _drmModeAtomicReq **atomic_request_ptr; 160 | int render_fd; 161 | } mpv_opengl_drm_params; 162 | 163 | /** 164 | * For MPV_RENDER_PARAM_DRM_DRAW_SURFACE_SIZE. 165 | */ 166 | typedef struct mpv_opengl_drm_draw_surface_size { 167 | /** 168 | * size of the draw plane surface in pixels. 169 | */ 170 | int width, height; 171 | } mpv_opengl_drm_draw_surface_size; 172 | 173 | /** 174 | * For MPV_RENDER_PARAM_DRM_DISPLAY_V2. 175 | */ 176 | typedef struct mpv_opengl_drm_params_v2 { 177 | /** 178 | * DRM fd (int). Set to -1 if invalid. 179 | */ 180 | int fd; 181 | 182 | /** 183 | * Currently used crtc id 184 | */ 185 | int crtc_id; 186 | 187 | /** 188 | * Currently used connector id 189 | */ 190 | int connector_id; 191 | 192 | /** 193 | * Pointer to a drmModeAtomicReq pointer that is being used for the renderloop. 194 | * This pointer should hold a pointer to the atomic request pointer 195 | * The atomic request pointer is usually changed at every renderloop. 196 | */ 197 | struct _drmModeAtomicReq **atomic_request_ptr; 198 | 199 | /** 200 | * DRM render node. Used for VAAPI interop. 201 | * Set to -1 if invalid. 202 | */ 203 | int render_fd; 204 | } mpv_opengl_drm_params_v2; 205 | 206 | 207 | /** 208 | * For backwards compatibility with the old naming of mpv_opengl_drm_draw_surface_size 209 | */ 210 | #define mpv_opengl_drm_osd_size mpv_opengl_drm_draw_surface_size 211 | 212 | #ifdef __cplusplus 213 | } 214 | #endif 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /framework-meta/libmpv/Headers/stream_cb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2017 the mpv developers 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef MPV_CLIENT_API_STREAM_CB_H_ 17 | #define MPV_CLIENT_API_STREAM_CB_H_ 18 | 19 | #include "client.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * Warning: this API is not stable yet. 27 | * 28 | * Overview 29 | * -------- 30 | * 31 | * This API can be used to make mpv read from a stream with a custom 32 | * implementation. This interface is inspired by funopen on BSD and 33 | * fopencookie on linux. The stream is backed by user-defined callbacks 34 | * which can implement customized open, read, seek, size and close behaviors. 35 | * 36 | * Usage 37 | * ----- 38 | * 39 | * Register your stream callbacks with the mpv_stream_cb_add_ro() function. You 40 | * have to provide a mpv_stream_cb_open_ro_fn callback to it (open_fn argument). 41 | * 42 | * Once registered, you can `loadfile myprotocol://myfile`. Your open_fn will be 43 | * invoked with the URI and you must fill out the provided mpv_stream_cb_info 44 | * struct. This includes your stream callbacks (like read_fn), and an opaque 45 | * cookie, which will be passed as the first argument to all the remaining 46 | * stream callbacks. 47 | * 48 | * Note that your custom callbacks must not invoke libmpv APIs as that would 49 | * cause a deadlock. (Unless you call a different mpv_handle than the one the 50 | * callback was registered for, and the mpv_handles refer to different mpv 51 | * instances.) 52 | * 53 | * Stream lifetime 54 | * --------------- 55 | * 56 | * A stream remains valid until its close callback has been called. It's up to 57 | * libmpv to call the close callback, and the libmpv user cannot close it 58 | * directly with the stream_cb API. 59 | * 60 | * For example, if you consider your custom stream to become suddenly invalid 61 | * (maybe because the underlying stream died), libmpv will continue using your 62 | * stream. All you can do is returning errors from each callback, until libmpv 63 | * gives up and closes it. 64 | * 65 | * Protocol registration and lifetime 66 | * ---------------------------------- 67 | * 68 | * Protocols remain registered until the mpv instance is terminated. This means 69 | * in particular that it can outlive the mpv_handle that was used to register 70 | * it, but once mpv_terminate_destroy() is called, your registered callbacks 71 | * will not be called again. 72 | * 73 | * Protocol unregistration is finished after the mpv core has been destroyed 74 | * (e.g. after mpv_terminate_destroy() has returned). 75 | * 76 | * If you do not call mpv_terminate_destroy() yourself (e.g. plugin-style code), 77 | * you will have to deal with the registration or even streams outliving your 78 | * code. Here are some possible ways to do this: 79 | * - call mpv_terminate_destroy(), which destroys the core, and will make sure 80 | * all streams are closed once this function returns 81 | * - you refcount all resources your stream "cookies" reference, so that it 82 | * doesn't matter if streams live longer than expected 83 | * - create "cancellation" semantics: after your protocol has been unregistered, 84 | * notify all your streams that are still opened, and make them drop all 85 | * referenced resources - then return errors from the stream callbacks as 86 | * long as the stream is still opened 87 | * 88 | */ 89 | 90 | /** 91 | * Read callback used to implement a custom stream. The semantics of the 92 | * callback match read(2) in blocking mode. Short reads are allowed (you can 93 | * return less bytes than requested, and libmpv will retry reading the rest 94 | * with another call). If no data can be immediately read, the callback must 95 | * block until there is new data. A return of 0 will be interpreted as final 96 | * EOF, although libmpv might retry the read, or seek to a different position. 97 | * 98 | * @param cookie opaque cookie identifying the stream, 99 | * returned from mpv_stream_cb_open_fn 100 | * @param buf buffer to read data into 101 | * @param size of the buffer 102 | * @return number of bytes read into the buffer 103 | * @return 0 on EOF 104 | * @return -1 on error 105 | */ 106 | typedef int64_t (*mpv_stream_cb_read_fn)(void *cookie, char *buf, uint64_t nbytes); 107 | 108 | /** 109 | * Seek callback used to implement a custom stream. 110 | * 111 | * Note that mpv will issue a seek to position 0 immediately after opening. This 112 | * is used to test whether the stream is seekable (since seekability might 113 | * depend on the URI contents, not just the protocol). Return 114 | * MPV_ERROR_UNSUPPORTED if seeking is not implemented for this stream. This 115 | * seek also serves to establish the fact that streams start at position 0. 116 | * 117 | * This callback can be NULL, in which it behaves as if always returning 118 | * MPV_ERROR_UNSUPPORTED. 119 | * 120 | * @param cookie opaque cookie identifying the stream, 121 | * returned from mpv_stream_cb_open_fn 122 | * @param offset target absolut stream position 123 | * @return the resulting offset of the stream 124 | * MPV_ERROR_UNSUPPORTED or MPV_ERROR_GENERIC if the seek failed 125 | */ 126 | typedef int64_t (*mpv_stream_cb_seek_fn)(void *cookie, int64_t offset); 127 | 128 | /** 129 | * Size callback used to implement a custom stream. 130 | * 131 | * Return MPV_ERROR_UNSUPPORTED if no size is known. 132 | * 133 | * This callback can be NULL, in which it behaves as if always returning 134 | * MPV_ERROR_UNSUPPORTED. 135 | * 136 | * @param cookie opaque cookie identifying the stream, 137 | * returned from mpv_stream_cb_open_fn 138 | * @return the total size in bytes of the stream 139 | */ 140 | typedef int64_t (*mpv_stream_cb_size_fn)(void *cookie); 141 | 142 | /** 143 | * Close callback used to implement a custom stream. 144 | * 145 | * @param cookie opaque cookie identifying the stream, 146 | * returned from mpv_stream_cb_open_fn 147 | */ 148 | typedef void (*mpv_stream_cb_close_fn)(void *cookie); 149 | 150 | /** 151 | * Cancel callback used to implement a custom stream. 152 | * 153 | * This callback is used to interrupt any current or future read and seek 154 | * operations. It will be called from a separate thread than the demux 155 | * thread, and should not block. 156 | * 157 | * This callback can be NULL. 158 | * 159 | * Available since API 1.106. 160 | * 161 | * @param cookie opaque cookie identifying the stream, 162 | * returned from mpv_stream_cb_open_fn 163 | */ 164 | typedef void (*mpv_stream_cb_cancel_fn)(void *cookie); 165 | 166 | /** 167 | * See mpv_stream_cb_open_ro_fn callback. 168 | */ 169 | typedef struct mpv_stream_cb_info { 170 | /** 171 | * Opaque user-provided value, which will be passed to the other callbacks. 172 | * The close callback will be called to release the cookie. It is not 173 | * interpreted by mpv. It doesn't even need to be a valid pointer. 174 | * 175 | * The user sets this in the mpv_stream_cb_open_ro_fn callback. 176 | */ 177 | void *cookie; 178 | 179 | /** 180 | * Callbacks set by the user in the mpv_stream_cb_open_ro_fn callback. Some 181 | * of them are optional, and can be left unset. 182 | * 183 | * The following callbacks are mandatory: read_fn, close_fn 184 | */ 185 | mpv_stream_cb_read_fn read_fn; 186 | mpv_stream_cb_seek_fn seek_fn; 187 | mpv_stream_cb_size_fn size_fn; 188 | mpv_stream_cb_close_fn close_fn; 189 | mpv_stream_cb_cancel_fn cancel_fn; /* since API 1.106 */ 190 | } mpv_stream_cb_info; 191 | 192 | /** 193 | * Open callback used to implement a custom read-only (ro) stream. The user 194 | * must set the callback fields in the passed info struct. The cookie field 195 | * also can be set to store state associated to the stream instance. 196 | * 197 | * Note that the info struct is valid only for the duration of this callback. 198 | * You can't change the callbacks or the pointer to the cookie at a later point. 199 | * 200 | * Each stream instance created by the open callback can have different 201 | * callbacks. 202 | * 203 | * The close_fn callback will terminate the stream instance. The pointers to 204 | * your callbacks and cookie will be discarded, and the callbacks will not be 205 | * called again. 206 | * 207 | * @param user_data opaque user data provided via mpv_stream_cb_add() 208 | * @param uri name of the stream to be opened (with protocol prefix) 209 | * @param info fields which the user should fill 210 | * @return 0 on success, MPV_ERROR_LOADING_FAILED if the URI cannot be opened. 211 | */ 212 | typedef int (*mpv_stream_cb_open_ro_fn)(void *user_data, char *uri, 213 | mpv_stream_cb_info *info); 214 | 215 | /** 216 | * Add a custom stream protocol. This will register a protocol handler under 217 | * the given protocol prefix, and invoke the given callbacks if an URI with the 218 | * matching protocol prefix is opened. 219 | * 220 | * The "ro" is for read-only - only read-only streams can be registered with 221 | * this function. 222 | * 223 | * The callback remains registered until the mpv core is registered. 224 | * 225 | * If a custom stream with the same name is already registered, then the 226 | * MPV_ERROR_INVALID_PARAMETER error is returned. 227 | * 228 | * @param protocol protocol prefix, for example "foo" for "foo://" URIs 229 | * @param user_data opaque pointer passed into the mpv_stream_cb_open_fn 230 | * callback. 231 | * @return error code 232 | */ 233 | int mpv_stream_cb_add_ro(mpv_handle *ctx, const char *protocol, void *user_data, 234 | mpv_stream_cb_open_ro_fn open_fn); 235 | 236 | #ifdef __cplusplus 237 | } 238 | #endif 239 | 240 | #endif 241 | -------------------------------------------------------------------------------- /framework-meta/libmpv/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module libmpv { 2 | umbrella "." 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /help/configure-help.txt: -------------------------------------------------------------------------------- 1 | waf [commands] [options] 2 | 3 | Main commands (example: ./waf build -j4) 4 | build : executes the build 5 | clean : cleans the project 6 | configure: configures the project 7 | dist : makes a tarball for redistributing the sources 8 | distcheck: checks if the project compiles (tarball from 'dist') 9 | distclean: removes build folders and data 10 | install : installs the targets on the system 11 | list : lists the targets to execute 12 | split : Split the string *s* using shell-like syntax. 13 | step : executes tasks in a step-by-step fashion, for debugging 14 | uninstall: removes the targets installed 15 | 16 | Options: 17 | --version show program's version number and exit 18 | -c COLORS, --color=COLORS 19 | whether to use colors (yes/no/auto) [default: auto] 20 | -j JOBS, --jobs=JOBS amount of parallel jobs (8) 21 | -k, --keep continue despite errors (-kk to try harder) 22 | -v, --verbose verbosity level -v -vv or -vvv [default: 0] 23 | --zones=ZONES debugging zones (task_gen, deps, tasks, etc) 24 | -h, --help show this help message and exit 25 | 26 | Configuration options: 27 | -o OUT, --out=OUT build dir for the project 28 | -t TOP, --top=TOP src dir for the project 29 | --check-c-compiler=CHECK_C_COMPILER 30 | list of C compilers to try [clang gcc] 31 | 32 | Build and installation options: 33 | -p, --progress -p: progress bar; -pp: ide output 34 | --targets=TARGETS task generators, e.g. "target1,target2" 35 | --variant=VARIANT variant name for saving configuration and build results 36 | --enable-lgpl enable LGPL (version 2.1 or later) build [disable] 37 | --disable-cplayer disable mpv CLI player [enable] 38 | --enable-libmpv-shared 39 | enable shared library [disable] 40 | --enable-libmpv-static 41 | enable static library [disable] 42 | --enable-static-build 43 | enable static build [disable] 44 | --disable-build-date 45 | disable whether to include binary compile time [enable] 46 | --disable-optimize disable whether to optimize [enable] 47 | --disable-debug-build 48 | disable whether to compile-in debugging information [enable] 49 | --enable-tests enable unit tests (development only) [disable] 50 | --enable-ta-leak-report 51 | enable enable ta leak report by default (development only) [disable] 52 | --disable-manpage-build 53 | disable manpage generation [autodetect] 54 | --enable-html-build 55 | enable html manual generation [disable] 56 | --enable-pdf-build enable pdf manual generation [disable] 57 | --disable-cplugins disable C plugins [autodetect] 58 | --disable-asm disable inline assembly (currently without effect) [enable] 59 | --disable-vector disable GCC vector instructions [autodetect] 60 | --enable-clang-database 61 | enable generate a clang compilation database [disable] 62 | --enable-swift-static 63 | enable static Swift linking [disable] 64 | 65 | Step options: 66 | --files=FILES files to process, by regexp, e.g. "*/main.c,*/test/main.o" 67 | 68 | Installation and uninstallation options: 69 | -f, --force force file installation 70 | --distcheck-args=ARGS 71 | arguments to pass to distcheck 72 | 73 | Installation prefix: 74 | By default, "waf install" will put the files in "/usr/local/bin", "/usr/local/lib" etc. An installation prefix other than "/usr/local" can be given using " 75 | --prefix", for example "--prefix=$HOME" 76 | 77 | --prefix=PREFIX installation prefix [default: '/usr/local/'] 78 | --destdir=DESTDIR installation root [default: ''] 79 | --exec-prefix=EXEC_PREFIX 80 | installation prefix for binaries [PREFIX] 81 | 82 | Installation directories: 83 | --bindir=BINDIR user commands [EXEC_PREFIX/bin] 84 | --sysconfdir=SYSCONFDIR 85 | host-specific configuration [PREFIX/etc] 86 | --libdir=LIBDIR object code libraries [EXEC_PREFIX/lib] 87 | --includedir=INCLUDEDIR 88 | header files [PREFIX/include] 89 | --datarootdir=DATAROOTDIR 90 | architecture-independent data root [PREFIX/share] 91 | --datadir=DATADIR architecture-independent data [DATAROOTDIR] 92 | --mandir=MANDIR manual pages [DATAROOTDIR/man] 93 | --docdir=DOCDIR documentation root [DATAROOTDIR/doc/PACKAGE] 94 | --htmldir=HTMLDIR HTML documentation [DOCDIR] 95 | --confdir=CONFDIR directory for installing configuration files [SYSCONFDIR/mpv] 96 | --zshdir=ZSHDIR directory for installing zsh completion functions [DATADIR/zsh/site-functions] 97 | --confloaddir=CONFLOADDIR 98 | directory for installing configuration files load directory [CONFDIR] 99 | --bashdir=BASHDIR directory for installing bash completion functions [DATADIR/bash-completion/completions] 100 | 101 | optional features: 102 | --disable-android disable Android environment [autodetect] 103 | --disable-tvos disable tvOS environment [autodetect] 104 | --disable-egl-android 105 | disable Android EGL support [autodetect] 106 | --disable-swift disable macOS Swift build tools [autodetect] 107 | --enable-uwp enable Universal Windows Platform [disable] 108 | --disable-win32-internal-pthreads 109 | disable internal pthread wrapper for win32 (Vista+) [autodetect] 110 | --enable-pthread-debug 111 | enable pthread runtime debugging wrappers [disable] 112 | --disable-stdatomic 113 | disable C11 stdatomic.h [autodetect] 114 | --disable-iconv disable iconv [autodetect] 115 | --disable-lua disable Lua [autodetect] 116 | --disable-javascript 117 | disable Javascript (MuJS backend) [autodetect] 118 | --disable-zlib disable zlib [autodetect] 119 | --disable-libbluray 120 | disable Bluray support [autodetect] 121 | --enable-dvdnav enable dvdnav support [disable] 122 | --enable-cdda enable cdda support (libcdio) [disable] 123 | --disable-uchardet disable uchardet support [autodetect] 124 | --disable-rubberband 125 | disable librubberband support [autodetect] 126 | --disable-zimg disable libzimg support (high quality software scaler) [autodetect] 127 | --disable-lcms2 disable LCMS2 support [autodetect] 128 | --disable-vapoursynth 129 | disable VapourSynth filter bridge [autodetect] 130 | --disable-libarchive 131 | disable libarchive wrapper for reading zip files and more [autodetect] 132 | --enable-dvbin enable DVB input module [disable] 133 | --enable-sdl2 enable SDL2 [disable] 134 | --disable-sdl2-gamepad 135 | disable SDL2 gamepad input [autodetect] 136 | --disable-libavdevice 137 | disable libavdevice [autodetect] 138 | --lua=LUA_VER select Lua package to autodetect. Choices (x is 1 or 2): luadef5x, lua5x, lua5.x, lua-5.x, luajit (luadef5x is for pkg-config name 'lua', 139 | the rest are exact pkg-config names) 140 | --swift-flags=SWIFT_FLAGS 141 | Optional Swift compiler flags 142 | 143 | audio outputs: 144 | --disable-sdl2-audio 145 | disable SDL2 audio output [autodetect] 146 | --disable-oss-audio 147 | disable OSSv4 audio output [autodetect] 148 | --disable-pipewire disable PipeWire audio output [autodetect] 149 | --enable-sndio enable sndio audio input/output [disable] 150 | --disable-pulse disable PulseAudio audio output [autodetect] 151 | --disable-jack disable JACK audio output [autodetect] 152 | --enable-openal enable OpenAL audio output [disable] 153 | --disable-opensles disable OpenSL ES audio output [autodetect] 154 | --disable-alsa disable ALSA audio output [autodetect] 155 | --disable-coreaudio 156 | disable CoreAudio audio output [autodetect] 157 | --disable-audiounit 158 | disable AudioUnit output for iOS [autodetect] 159 | --disable-wasapi disable WASAPI audio output [autodetect] 160 | 161 | video outputs: 162 | --disable-sdl2-video 163 | disable SDL2 video output [autodetect] 164 | --disable-cocoa disable Cocoa [autodetect] 165 | --disable-drm disable DRM [autodetect] 166 | --disable-gbm disable GBM [autodetect] 167 | --disable-wayland-scanner 168 | disable wayland-scanner [autodetect] 169 | --disable-wayland-protocols 170 | disable wayland-protocols [autodetect] 171 | --disable-wayland disable Wayland [autodetect] 172 | --disable-x11 disable X11 [autodetect] 173 | --disable-xv disable Xv video output [autodetect] 174 | --disable-gl-cocoa disable OpenGL Cocoa Backend [autodetect] 175 | --enable-gl-x11 enable OpenGL X11/GLX (deprecated/legacy) [disable] 176 | --enable-rpi enable Raspberry Pi support [disable] 177 | --disable-egl disable EGL 1.4 [autodetect] 178 | --disable-egl-x11 disable OpenGL X11 EGL Backend [autodetect] 179 | --disable-egl-drm disable OpenGL DRM EGL Backend [autodetect] 180 | --disable-gl-wayland 181 | disable OpenGL Wayland Backend [autodetect] 182 | --disable-gl-win32 disable OpenGL Win32 Backend [autodetect] 183 | --disable-gl-dxinterop 184 | disable OpenGL/DirectX Interop Backend [autodetect] 185 | --disable-egl-angle 186 | disable OpenGL ANGLE headers [autodetect] 187 | --disable-egl-angle-lib 188 | disable OpenGL Win32 ANGLE Library [autodetect] 189 | --disable-egl-angle-win32 190 | disable OpenGL Win32 ANGLE Backend [autodetect] 191 | --disable-vdpau disable VDPAU acceleration [autodetect] 192 | --disable-vdpau-gl-x11 193 | disable VDPAU with OpenGL/X11 [autodetect] 194 | --disable-vaapi disable VAAPI acceleration [autodetect] 195 | --disable-vaapi-x11 196 | disable VAAPI (X11 support) [autodetect] 197 | --disable-vaapi-wayland 198 | disable VAAPI (Wayland support) [autodetect] 199 | --disable-vaapi-drm 200 | disable VAAPI (DRM/EGL support) [autodetect] 201 | --disable-vaapi-x-egl 202 | disable VAAPI EGL on X11 [autodetect] 203 | --disable-caca disable CACA [autodetect] 204 | --disable-jpeg disable JPEG support [autodetect] 205 | --disable-direct3d disable Direct3D support [autodetect] 206 | --disable-shaderc disable libshaderc SPIR-V compiler [autodetect] 207 | --disable-spirv-cross 208 | disable SPIRV-Cross SPIR-V shader converter [autodetect] 209 | --disable-d3d11 disable Direct3D 11 video output [autodetect] 210 | --disable-ios-gl disable iOS OpenGL ES hardware decoding interop support [autodetect] 211 | --disable-plain-gl disable OpenGL without platform-specific code (e.g. for libmpv) [autodetect] 212 | --disable-gl disable OpenGL context support [autodetect] 213 | --disable-libplacebo 214 | disable libplacebo support [autodetect] 215 | --disable-vulkan disable Vulkan context support [autodetect] 216 | --disable-sixel disable Sixel [autodetect] 217 | 218 | hwaccels: 219 | --disable-videotoolbox-gl 220 | disable Videotoolbox with OpenGL [autodetect] 221 | --disable-d3d-hwaccel 222 | disable D3D11VA hwaccel [autodetect] 223 | --disable-d3d9-hwaccel 224 | disable DXVA2 hwaccel [autodetect] 225 | --disable-gl-dxinterop-d3d9 226 | disable OpenGL/DirectX Interop Backend DXVA2 interop [autodetect] 227 | --disable-cuda-hwaccel 228 | disable CUDA acceleration [autodetect] 229 | --disable-cuda-interop 230 | disable CUDA with graphics interop [autodetect] 231 | --disable-rpi-mmal disable Raspberry Pi MMAL hwaccel [autodetect] 232 | 233 | standalone app: 234 | --disable-macos-touchbar 235 | disable macOS Touch Bar support [autodetect] 236 | --disable-macos-10-11-features 237 | disable macOS 10.11 SDK Features [autodetect] 238 | --disable-macos-10-12-2-features 239 | disable macOS 10.12.2 SDK Features [autodetect] 240 | --disable-macos-10-14-features 241 | disable macOS 10.14 SDK Features [autodetect] 242 | --disable-macos-media-player 243 | disable macOS Media Player support [autodetect] 244 | --disable-macos-cocoa-cb 245 | disable macOS libmpv backend [autodetect] 246 | -------------------------------------------------------------------------------- /help/ffmpeg-configure-help.txt: -------------------------------------------------------------------------------- 1 | Usage: configure [options] 2 | Options: [defaults in brackets after descriptions] 3 | 4 | Help options: 5 | --help print this message 6 | --quiet Suppress showing informative output 7 | --list-decoders show all available decoders 8 | --list-encoders show all available encoders 9 | --list-hwaccels show all available hardware accelerators 10 | --list-demuxers show all available demuxers 11 | --list-muxers show all available muxers 12 | --list-parsers show all available parsers 13 | --list-protocols show all available protocols 14 | --list-bsfs show all available bitstream filters 15 | --list-indevs show all available input devices 16 | --list-outdevs show all available output devices 17 | --list-filters show all available filters 18 | 19 | Standard options: 20 | --logfile=FILE log tests and output to FILE [ffbuild/config.log] 21 | --disable-logging do not log configure debug information 22 | --fatal-warnings fail if any configure warning is generated 23 | --prefix=PREFIX install in PREFIX [/usr/local] 24 | --bindir=DIR install binaries in DIR [PREFIX/bin] 25 | --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg] 26 | --docdir=DIR install documentation in DIR [PREFIX/share/doc/ffmpeg] 27 | --libdir=DIR install libs in DIR [PREFIX/lib] 28 | --shlibdir=DIR install shared libs in DIR [LIBDIR] 29 | --incdir=DIR install includes in DIR [PREFIX/include] 30 | --mandir=DIR install man page in DIR [PREFIX/share/man] 31 | --pkgconfigdir=DIR install pkg-config files in DIR [LIBDIR/pkgconfig] 32 | --enable-rpath use rpath to allow installing libraries in paths 33 | not part of the dynamic linker search path 34 | use rpath when linking programs (USE WITH CARE) 35 | --install-name-dir=DIR Darwin directory name for installed targets 36 | 37 | Licensing options: 38 | --enable-gpl allow use of GPL code, the resulting libs 39 | and binaries will be under GPL [no] 40 | --enable-version3 upgrade (L)GPL to version 3 [no] 41 | --enable-nonfree allow use of nonfree code, the resulting libs 42 | and binaries will be unredistributable [no] 43 | 44 | Configuration options: 45 | --disable-static do not build static libraries [no] 46 | --enable-shared build shared libraries [no] 47 | --enable-small optimize for size instead of speed 48 | --disable-runtime-cpudetect disable detecting CPU capabilities at runtime (smaller binary) 49 | --enable-gray enable full grayscale support (slower color) 50 | --disable-swscale-alpha disable alpha channel support in swscale 51 | --disable-all disable building components, libraries and programs 52 | --disable-autodetect disable automatically detected external libraries [no] 53 | 54 | Program options: 55 | --disable-programs do not build command line programs 56 | --disable-ffmpeg disable ffmpeg build 57 | --disable-ffplay disable ffplay build 58 | --disable-ffprobe disable ffprobe build 59 | 60 | Documentation options: 61 | --disable-doc do not build documentation 62 | --disable-htmlpages do not build HTML documentation pages 63 | --disable-manpages do not build man documentation pages 64 | --disable-podpages do not build POD documentation pages 65 | --disable-txtpages do not build text documentation pages 66 | 67 | Component options: 68 | --disable-avdevice disable libavdevice build 69 | --disable-avcodec disable libavcodec build 70 | --disable-avformat disable libavformat build 71 | --disable-swresample disable libswresample build 72 | --disable-swscale disable libswscale build 73 | --disable-postproc disable libpostproc build 74 | --disable-avfilter disable libavfilter build 75 | --enable-avresample enable libavresample build (deprecated) [no] 76 | --disable-pthreads disable pthreads [autodetect] 77 | --disable-w32threads disable Win32 threads [autodetect] 78 | --disable-os2threads disable OS/2 threads [autodetect] 79 | --disable-network disable network support [no] 80 | --disable-dct disable DCT code 81 | --disable-dwt disable DWT code 82 | --disable-error-resilience disable error resilience code 83 | --disable-lsp disable LSP code 84 | --disable-lzo disable LZO decoder code 85 | --disable-mdct disable MDCT code 86 | --disable-rdft disable RDFT code 87 | --disable-fft disable FFT code 88 | --disable-faan disable floating point AAN (I)DCT code 89 | --disable-pixelutils disable pixel utils in libavutil 90 | 91 | Individual component options: 92 | --disable-everything disable all components listed below 93 | --disable-encoder=NAME disable encoder NAME 94 | --enable-encoder=NAME enable encoder NAME 95 | --disable-encoders disable all encoders 96 | --disable-decoder=NAME disable decoder NAME 97 | --enable-decoder=NAME enable decoder NAME 98 | --disable-decoders disable all decoders 99 | --disable-hwaccel=NAME disable hwaccel NAME 100 | --enable-hwaccel=NAME enable hwaccel NAME 101 | --disable-hwaccels disable all hwaccels 102 | --disable-muxer=NAME disable muxer NAME 103 | --enable-muxer=NAME enable muxer NAME 104 | --disable-muxers disable all muxers 105 | --disable-demuxer=NAME disable demuxer NAME 106 | --enable-demuxer=NAME enable demuxer NAME 107 | --disable-demuxers disable all demuxers 108 | --enable-parser=NAME enable parser NAME 109 | --disable-parser=NAME disable parser NAME 110 | --disable-parsers disable all parsers 111 | --enable-bsf=NAME enable bitstream filter NAME 112 | --disable-bsf=NAME disable bitstream filter NAME 113 | --disable-bsfs disable all bitstream filters 114 | --enable-protocol=NAME enable protocol NAME 115 | --disable-protocol=NAME disable protocol NAME 116 | --disable-protocols disable all protocols 117 | --enable-indev=NAME enable input device NAME 118 | --disable-indev=NAME disable input device NAME 119 | --disable-indevs disable input devices 120 | --enable-outdev=NAME enable output device NAME 121 | --disable-outdev=NAME disable output device NAME 122 | --disable-outdevs disable output devices 123 | --disable-devices disable all devices 124 | --enable-filter=NAME enable filter NAME 125 | --disable-filter=NAME disable filter NAME 126 | --disable-filters disable all filters 127 | 128 | External library support: 129 | 130 | Using any of the following switches will allow FFmpeg to link to the 131 | corresponding external library. All the components depending on that library 132 | will become enabled, if all their other dependencies are met and they are not 133 | explicitly disabled. E.g. --enable-libopus will enable linking to 134 | libopus and allow the libopus encoder to be built, unless it is 135 | specifically disabled with --disable-encoder=libopus. 136 | 137 | Note that only the system libraries are auto-detected. All the other external 138 | libraries must be explicitly enabled. 139 | 140 | Also note that the following help text describes the purpose of the libraries 141 | themselves, not all their features will necessarily be usable by FFmpeg. 142 | 143 | --disable-alsa disable ALSA support [autodetect] 144 | --disable-appkit disable Apple AppKit framework [autodetect] 145 | --disable-avfoundation disable Apple AVFoundation framework [autodetect] 146 | --enable-avisynth enable reading of AviSynth script files [no] 147 | --disable-bzlib disable bzlib [autodetect] 148 | --disable-coreimage disable Apple CoreImage framework [autodetect] 149 | --enable-chromaprint enable audio fingerprinting with chromaprint [no] 150 | --enable-frei0r enable frei0r video filtering [no] 151 | --enable-gcrypt enable gcrypt, needed for rtmp(t)e support 152 | if openssl, librtmp or gmp is not used [no] 153 | --enable-gmp enable gmp, needed for rtmp(t)e support 154 | if openssl or librtmp is not used [no] 155 | --enable-gnutls enable gnutls, needed for https support 156 | if openssl, libtls or mbedtls is not used [no] 157 | --disable-iconv disable iconv [autodetect] 158 | --enable-jni enable JNI support [no] 159 | --enable-ladspa enable LADSPA audio filtering [no] 160 | --enable-libaom enable AV1 video encoding/decoding via libaom [no] 161 | --enable-libaribb24 enable ARIB text and caption decoding via libaribb24 [no] 162 | --enable-libass enable libass subtitles rendering, 163 | needed for subtitles and ass filter [no] 164 | --enable-libbluray enable BluRay reading using libbluray [no] 165 | --enable-libbs2b enable bs2b DSP library [no] 166 | --enable-libcaca enable textual display using libcaca [no] 167 | --enable-libcelt enable CELT decoding via libcelt [no] 168 | --enable-libcdio enable audio CD grabbing with libcdio [no] 169 | --enable-libcodec2 enable codec2 en/decoding using libcodec2 [no] 170 | --enable-libdav1d enable AV1 decoding via libdav1d [no] 171 | --enable-libdavs2 enable AVS2 decoding via libdavs2 [no] 172 | --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 173 | and libraw1394 [no] 174 | --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no] 175 | --enable-libflite enable flite (voice synthesis) support via libflite [no] 176 | --enable-libfontconfig enable libfontconfig, useful for drawtext filter [no] 177 | --enable-libfreetype enable libfreetype, needed for drawtext filter [no] 178 | --enable-libfribidi enable libfribidi, improves drawtext filter [no] 179 | --enable-libglslang enable GLSL->SPIRV compilation via libglslang [no] 180 | --enable-libgme enable Game Music Emu via libgme [no] 181 | --enable-libgsm enable GSM de/encoding via libgsm [no] 182 | --enable-libiec61883 enable iec61883 via libiec61883 [no] 183 | --enable-libilbc enable iLBC de/encoding via libilbc [no] 184 | --enable-libjack enable JACK audio sound server [no] 185 | --enable-libklvanc enable Kernel Labs VANC processing [no] 186 | --enable-libkvazaar enable HEVC encoding via libkvazaar [no] 187 | --enable-liblensfun enable lensfun lens correction [no] 188 | --enable-libmodplug enable ModPlug via libmodplug [no] 189 | --enable-libmp3lame enable MP3 encoding via libmp3lame [no] 190 | --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no] 191 | --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no] 192 | --enable-libopencv enable video filtering via libopencv [no] 193 | --enable-libopenh264 enable H.264 encoding via OpenH264 [no] 194 | --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no] 195 | --enable-libopenmpt enable decoding tracked files via libopenmpt [no] 196 | --enable-libopenvino enable OpenVINO as a DNN module backend 197 | for DNN based filters like dnn_processing [no] 198 | --enable-libopus enable Opus de/encoding via libopus [no] 199 | --enable-libpulse enable Pulseaudio input via libpulse [no] 200 | --enable-librabbitmq enable RabbitMQ library [no] 201 | --enable-librav1e enable AV1 encoding via rav1e [no] 202 | --enable-librist enable RIST via librist [no] 203 | --enable-librsvg enable SVG rasterization via librsvg [no] 204 | --enable-librubberband enable rubberband needed for rubberband filter [no] 205 | --enable-librtmp enable RTMP[E] support via librtmp [no] 206 | --enable-libshine enable fixed-point MP3 encoding via libshine [no] 207 | --enable-libsmbclient enable Samba protocol via libsmbclient [no] 208 | --enable-libsnappy enable Snappy compression, needed for hap encoding [no] 209 | --enable-libsoxr enable Include libsoxr resampling [no] 210 | --enable-libspeex enable Speex de/encoding via libspeex [no] 211 | --enable-libsrt enable Haivision SRT protocol via libsrt [no] 212 | --enable-libssh enable SFTP protocol via libssh [no] 213 | --enable-libsvtav1 enable AV1 encoding via SVT [no] 214 | --enable-libtensorflow enable TensorFlow as a DNN module backend 215 | for DNN based filters like sr [no] 216 | --enable-libtesseract enable Tesseract, needed for ocr filter [no] 217 | --enable-libtheora enable Theora encoding via libtheora [no] 218 | --enable-libtls enable LibreSSL (via libtls), needed for https support 219 | if openssl, gnutls or mbedtls is not used [no] 220 | --enable-libtwolame enable MP2 encoding via libtwolame [no] 221 | --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] 222 | --enable-libv4l2 enable libv4l2/v4l-utils [no] 223 | --enable-libvidstab enable video stabilization using vid.stab [no] 224 | --enable-libvmaf enable vmaf filter via libvmaf [no] 225 | --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] 226 | --enable-libvorbis enable Vorbis en/decoding via libvorbis, 227 | native implementation exists [no] 228 | --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no] 229 | --enable-libwebp enable WebP encoding via libwebp [no] 230 | --enable-libx264 enable H.264 encoding via x264 [no] 231 | --enable-libx265 enable HEVC encoding via x265 [no] 232 | --enable-libxavs enable AVS encoding via xavs [no] 233 | --enable-libxavs2 enable AVS2 encoding via xavs2 [no] 234 | --enable-libxcb enable X11 grabbing using XCB [autodetect] 235 | --enable-libxcb-shm enable X11 grabbing shm communication [autodetect] 236 | --enable-libxcb-xfixes enable X11 grabbing mouse rendering [autodetect] 237 | --enable-libxcb-shape enable X11 grabbing shape rendering [autodetect] 238 | --enable-libxvid enable Xvid encoding via xvidcore, 239 | native MPEG-4/Xvid encoder exists [no] 240 | --enable-libxml2 enable XML parsing using the C library libxml2, needed 241 | for dash demuxing support [no] 242 | --enable-libzimg enable z.lib, needed for zscale filter [no] 243 | --enable-libzmq enable message passing via libzmq [no] 244 | --enable-libzvbi enable teletext support via libzvbi [no] 245 | --enable-lv2 enable LV2 audio filtering [no] 246 | --disable-lzma disable lzma [autodetect] 247 | --enable-decklink enable Blackmagic DeckLink I/O support [no] 248 | --enable-mbedtls enable mbedTLS, needed for https support 249 | if openssl, gnutls or libtls is not used [no] 250 | --enable-mediacodec enable Android MediaCodec support [no] 251 | --enable-mediafoundation enable encoding via MediaFoundation [auto] 252 | --enable-libmysofa enable libmysofa, needed for sofalizer filter [no] 253 | --enable-openal enable OpenAL 1.1 capture support [no] 254 | --enable-opencl enable OpenCL processing [no] 255 | --enable-opengl enable OpenGL rendering [no] 256 | --enable-openssl enable openssl, needed for https support 257 | if gnutls, libtls or mbedtls is not used [no] 258 | --enable-pocketsphinx enable PocketSphinx, needed for asr filter [no] 259 | --disable-sndio disable sndio support [autodetect] 260 | --disable-schannel disable SChannel SSP, needed for TLS support on 261 | Windows if openssl and gnutls are not used [autodetect] 262 | --disable-sdl2 disable sdl2 [autodetect] 263 | --disable-securetransport disable Secure Transport, needed for TLS support 264 | on OSX if openssl and gnutls are not used [autodetect] 265 | --enable-vapoursynth enable VapourSynth demuxer [no] 266 | --enable-vulkan enable Vulkan code [no] 267 | --disable-xlib disable xlib [autodetect] 268 | --disable-zlib disable zlib [autodetect] 269 | 270 | The following libraries provide various hardware acceleration features: 271 | --disable-amf disable AMF video encoding code [autodetect] 272 | --disable-audiotoolbox disable Apple AudioToolbox code [autodetect] 273 | --enable-cuda-nvcc enable Nvidia CUDA compiler [no] 274 | --disable-cuda-llvm disable CUDA compilation using clang [autodetect] 275 | --disable-cuvid disable Nvidia CUVID support [autodetect] 276 | --disable-d3d11va disable Microsoft Direct3D 11 video acceleration code [autodetect] 277 | --disable-dxva2 disable Microsoft DirectX 9 video acceleration code [autodetect] 278 | --disable-ffnvcodec disable dynamically linked Nvidia code [autodetect] 279 | --enable-libdrm enable DRM code (Linux) [no] 280 | --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] 281 | --enable-libnpp enable Nvidia Performance Primitives-based code [no] 282 | --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] 283 | --disable-nvdec disable Nvidia video decoding acceleration (via hwaccel) [autodetect] 284 | --disable-nvenc disable Nvidia video encoding code [autodetect] 285 | --enable-omx enable OpenMAX IL code [no] 286 | --enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no] 287 | --enable-rkmpp enable Rockchip Media Process Platform code [no] 288 | --disable-v4l2-m2m disable V4L2 mem2mem code [autodetect] 289 | --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] 290 | --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] 291 | --disable-videotoolbox disable VideoToolbox code [autodetect] 292 | 293 | Toolchain options: 294 | --arch=ARCH select architecture [] 295 | --cpu=CPU select the minimum required CPU (affects 296 | instruction selection, may crash on older CPUs) 297 | --cross-prefix=PREFIX use PREFIX for compilation tools [] 298 | --progs-suffix=SUFFIX program name suffix [] 299 | --enable-cross-compile assume a cross-compiler is used 300 | --sysroot=PATH root of cross-build tree 301 | --sysinclude=PATH location of cross-build system headers 302 | --target-os=OS compiler targets OS [] 303 | --target-exec=CMD command to run executables on target 304 | --target-path=DIR path to view of build directory on target 305 | --target-samples=DIR path to samples directory on target 306 | --tempprefix=PATH force fixed dir/prefix instead of mktemp for checks 307 | --toolchain=NAME set tool defaults according to NAME 308 | (gcc-asan, clang-asan, gcc-msan, clang-msan, 309 | gcc-tsan, clang-tsan, gcc-usan, clang-usan, 310 | valgrind-massif, valgrind-memcheck, 311 | msvc, icl, gcov, llvm-cov, hardened) 312 | --nm=NM use nm tool NM [nm -g] 313 | --ar=AR use archive tool AR [ar] 314 | --as=AS use assembler AS [] 315 | --ln_s=LN_S use symbolic link tool LN_S [ln -s -f] 316 | --strip=STRIP use strip tool STRIP [strip] 317 | --windres=WINDRES use windows resource compiler WINDRES [windres] 318 | --x86asmexe=EXE use nasm-compatible assembler EXE [nasm] 319 | --cc=CC use C compiler CC [gcc] 320 | --cxx=CXX use C compiler CXX [g++] 321 | --objcc=OCC use ObjC compiler OCC [gcc] 322 | --dep-cc=DEPCC use dependency generator DEPCC [gcc] 323 | --nvcc=NVCC use Nvidia CUDA compiler NVCC or clang [] 324 | --ld=LD use linker LD [] 325 | --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [pkg-config] 326 | --pkg-config-flags=FLAGS pass additional flags to pkgconf [] 327 | --ranlib=RANLIB use ranlib RANLIB [ranlib] 328 | --doxygen=DOXYGEN use DOXYGEN to generate API doc [doxygen] 329 | --host-cc=HOSTCC use host C compiler HOSTCC 330 | --host-cflags=HCFLAGS use HCFLAGS when compiling for host 331 | --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host 332 | --host-ld=HOSTLD use host linker HOSTLD 333 | --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host 334 | --host-extralibs=HLIBS use libs HLIBS when linking for host 335 | --host-os=OS compiler host OS [] 336 | --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [] 337 | --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [] 338 | --extra-objcflags=FLAGS add FLAGS to OBJCFLAGS [] 339 | --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [] 340 | --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [] 341 | --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [] 342 | --extra-libs=ELIBS add ELIBS [] 343 | --extra-version=STRING version string suffix [] 344 | --optflags=OPTFLAGS override optimization-related compiler flags 345 | --nvccflags=NVCCFLAGS override nvcc flags [] 346 | --build-suffix=SUFFIX library name suffix [] 347 | --enable-pic build position-independent code 348 | --enable-thumb compile for Thumb instruction set 349 | --enable-lto use link-time optimization 350 | --env="ENV=override" override the environment variables 351 | 352 | Advanced options (experts only): 353 | --malloc-prefix=PREFIX prefix malloc and related names with PREFIX 354 | --custom-allocator=NAME use a supported custom allocator 355 | --disable-symver disable symbol versioning 356 | --enable-hardcoded-tables use hardcoded tables instead of runtime generation 357 | --disable-safe-bitstream-reader 358 | disable buffer boundary checking in bitreaders 359 | (faster, but may crash) 360 | --sws-max-filter-size=N the max filter size swscale uses [256] 361 | 362 | Optimization options (experts only): 363 | --disable-asm disable all assembly optimizations 364 | --disable-altivec disable AltiVec optimizations 365 | --disable-vsx disable VSX optimizations 366 | --disable-power8 disable POWER8 optimizations 367 | --disable-amd3dnow disable 3DNow! optimizations 368 | --disable-amd3dnowext disable 3DNow! extended optimizations 369 | --disable-mmx disable MMX optimizations 370 | --disable-mmxext disable MMXEXT optimizations 371 | --disable-sse disable SSE optimizations 372 | --disable-sse2 disable SSE2 optimizations 373 | --disable-sse3 disable SSE3 optimizations 374 | --disable-ssse3 disable SSSE3 optimizations 375 | --disable-sse4 disable SSE4 optimizations 376 | --disable-sse42 disable SSE4.2 optimizations 377 | --disable-avx disable AVX optimizations 378 | --disable-xop disable XOP optimizations 379 | --disable-fma3 disable FMA3 optimizations 380 | --disable-fma4 disable FMA4 optimizations 381 | --disable-avx2 disable AVX2 optimizations 382 | --disable-avx512 disable AVX-512 optimizations 383 | --disable-aesni disable AESNI optimizations 384 | --disable-armv5te disable armv5te optimizations 385 | --disable-armv6 disable armv6 optimizations 386 | --disable-armv6t2 disable armv6t2 optimizations 387 | --disable-vfp disable VFP optimizations 388 | --disable-neon disable NEON optimizations 389 | --disable-inline-asm disable use of inline assembly 390 | --disable-x86asm disable use of standalone x86 assembly 391 | --disable-mipsdsp disable MIPS DSP ASE R1 optimizations 392 | --disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations 393 | --disable-msa disable MSA optimizations 394 | --disable-msa2 disable MSA2 optimizations 395 | --disable-mipsfpu disable floating point MIPS optimizations 396 | --disable-mmi disable Loongson SIMD optimizations 397 | --disable-fast-unaligned consider unaligned accesses slow 398 | 399 | Developer options (useful when working on FFmpeg itself): 400 | --disable-debug disable debugging symbols 401 | --enable-debug=LEVEL set the debug level [] 402 | --disable-optimizations disable compiler optimizations 403 | --enable-extra-warnings enable more compiler warnings 404 | --disable-stripping disable stripping of executables and shared libraries 405 | --assert-level=level 0(default), 1 or 2, amount of assertion testing, 406 | 2 causes a slowdown at runtime. 407 | --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data 408 | --valgrind=VALGRIND run "make fate" tests through valgrind to detect memory 409 | leaks and errors, using the specified valgrind binary. 410 | Cannot be combined with --target-exec 411 | --enable-ftrapv Trap arithmetic overflows 412 | --samples=PATH location of test samples for FATE, if not set use 413 | $FATE_SAMPLES at make invocation time. 414 | --enable-neon-clobber-test check NEON registers for clobbering (should be 415 | used only for debugging purposes) 416 | --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only; 417 | should be used only for debugging purposes) 418 | --enable-random randomly enable/disable components 419 | --disable-random 420 | --enable-random=LIST randomly enable/disable specific components or 421 | --disable-random=LIST component groups. LIST is a comma-separated list 422 | of NAME[:PROB] entries where NAME is a component 423 | (group) and PROB the probability associated with 424 | NAME (default 0.5). 425 | --random-seed=VALUE seed value for --enable/disable-random 426 | --disable-valgrind-backtrace do not print a backtrace under Valgrind 427 | (only applies to --disable-optimizations builds) 428 | --enable-ossfuzz Enable building fuzzer tool 429 | --libfuzzer=PATH path to libfuzzer 430 | --ignore-tests=TESTS comma-separated list (without "fate-" prefix 431 | in the name) of tests whose result is ignored 432 | --enable-linux-perf enable Linux Performance Monitor API 433 | --disable-large-tests disable tests that use a large amount of memory 434 | 435 | NOTE: Object files are built at the place where configure is launched. 436 | -------------------------------------------------------------------------------- /install-gas-preprocessor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | sudo git clone https://github.com/bigsen/gas-preprocessor.git /usr/local/bin/gas 4 | sudo cp /usr/local/bin/gas/gas-preprocessor.pl /usr/local/bin/gas-preprocessor.pl 5 | sudo chmod 777 /usr/local/bin/gas-preprocessor.pl 6 | sudo rm -rf /usr/local/bin/gas/ 7 | -------------------------------------------------------------------------------- /install-openssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | OPENSSL_VERSION="1.1.1w" 4 | IOS_SDK_VERSION=$(xcrun -sdk iphoneos --show-sdk-version) 5 | TVOS_SDK_VERSION=$(xcrun -sdk appletvos --show-sdk-version) 6 | 7 | IOS_FOLDER="iPhoneOS$IOS_SDK_VERSION-arm64.sdk" 8 | IOSSimulator_FOLDER="iPhoneSimulator$IOS_SDK_VERSION-arm64.sdk" 9 | TVOS_FOLDER="AppleTVOS$TVOS_SDK_VERSION-arm64.sdk" 10 | TVOSSimulator_FOLDER="AppleTVSimulator$TVOS_SDK_VERSION-arm64.sdk" 11 | 12 | # AppleTVSimulator17.0-arm64.sdk 13 | 14 | rm -rf openssl 15 | rm -rf openssl-src 16 | git clone https://github.com/jasonacox/Build-OpenSSL-cURL.git openssl-src/ 17 | cd openssl-src 18 | 19 | ./build.sh -o $OPENSSL_VERSION 20 | 21 | cd .. 22 | mkdir -p openssl/$IOS_FOLDER 23 | mkdir -p openssl/$IOSSimulator_FOLDER 24 | mkdir -p openssl/$TVOS_FOLDER 25 | mkdir -p openssl/$TVOSSimulator_FOLDER 26 | cp -r ./openssl-src/openssl/iOS/ ./openssl/$IOS_FOLDER/ 27 | cp -r ./openssl-src/openssl/iOS-simulator/ ./openssl/$IOSSimulator_FOLDER/ 28 | cp -r ./openssl-src/openssl/tvOS/ ./openssl/$TVOS_FOLDER/ 29 | cp -r ./openssl-src/openssl/tvOS-simulator/ ./openssl/$TVOSSimulator_FOLDER/ 30 | -------------------------------------------------------------------------------- /patch-ffmpeg.diff: -------------------------------------------------------------------------------- 1 | --- src/ffmpeg-5.1.3/libavfilter/metal/utils.m 2 | +++ src/ffmpeg-5.1.3/libavfilter/metal/utils.m 3 | @@ -31,7 +31,7 @@ void ff_metal_compute_encoder_dispatch(id device, 4 | BOOL fallback = YES; 5 | // MAC_OS_X_VERSION_10_15 is only defined on SDKs new enough to include its functionality (including iOS, tvOS, etc) 6 | #ifdef MAC_OS_X_VERSION_10_15 7 | - if (@available(macOS 10.15, iOS 11, tvOS 14.5, *)) { 8 | + if (@available(macOS 10.15, iOS 13, tvOS 14.5, *)) { 9 | if ([device supportsFamily:MTLGPUFamilyCommon3]) { 10 | MTLSize threadsPerGrid = MTLSizeMake(width, height, 1); 11 | [encoder dispatchThreads:threadsPerGrid threadsPerThreadgroup:threadsPerThreadgroup]; 12 | --- src/ffmpeg-5.1.3/libavcodec/videotoolbox.c 13 | +++ src/ffmpeg-5.1.3/libavcodec/videotoolbox.c 14 | @@ -1166,7 +1166,13 @@ 15 | #endif 16 | #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 17 | if (depth > 8) { 18 | - return AV_PIX_FMT_P010; 19 | + #if TARGET_OS_IPHONE 20 | + /* iOS doesn't support 10 bit textures in GLES */ 21 | + return AV_PIX_FMT_BGRA; 22 | + #else 23 | + return AV_PIX_FMT_P010; 24 | + #endif 25 | + // return AV_PIX_FMT_P010; 26 | } 27 | #endif -------------------------------------------------------------------------------- /patch-mpv.diff: -------------------------------------------------------------------------------- 1 | --- ./src/mpv-0.35.1/video/out/opengl/hwdec_ios.m 2 | +++ ./src/mpv-0.35.1/video/out/opengl/hwdec_ios.m 3 | @@ -144,7 +144,7 @@ 4 | 5 | for (int n = 0; n < p->desc.num_planes; n++) { 6 | p->desc.planes[n] = find_la_variant(mapper->ra, p->desc.planes[n]); 7 | - if (!p->desc.planes[n] || p->desc.planes[n]->ctype != RA_CTYPE_UNORM) { 8 | + if (!p->desc.planes[n]) { 9 | MP_ERR(mapper, "Format unsupported.\n"); 10 | return -1; 11 | } 12 | 13 | 14 | --- ./src/mpv-0.35.1/video/out/gpu/video.c 15 | +++ ./src/mpv-0.35.1/video/out/gpu/video.c 16 | @@ -366,6 +366,8 @@ 17 | .opts = (const m_option_t[]) { 18 | {"gpu-dumb-mode", OPT_CHOICE(dumb_mode, 19 | {"auto", 0}, {"yes", 1}, {"no", -1})}, 20 | + {"gpu-deint-shader", OPT_CHOICE(deint_shader, 21 | + {"no", 0}, {"yes", 1}, {"auto", -1})}, 22 | {"gamma-factor", OPT_FLOAT(gamma), M_RANGE(0.1, 2.0), 23 | .deprecation_message = "no replacement"}, 24 | {"gamma-auto", OPT_FLAG(gamma_auto), 25 | @@ -828,6 +830,11 @@ 26 | .padding = padding, 27 | }; 28 | 29 | + if (p->opts.deint_shader == -1) 30 | + img[n].interlaced = !!(vimg->mpi->fields & MP_IMGFIELD_INTERLACED); 31 | + else if (p->opts.deint_shader == 1) 32 | + img[n].interlaced = 1; 33 | + 34 | for (int i = 0; i < 4; i++) 35 | img[n].components += !!p->ra_format.components[n][i]; 36 | 37 | @@ -1356,8 +1363,22 @@ 38 | img.multiplier *= 1.0 / (tex_max - 1); 39 | } 40 | 41 | - GLSLF("color.%s = %f * vec4(texture(texture%d, texcoord%d)).%s;\n", 42 | - dst, img.multiplier, id, id, src); 43 | + if (img.interlaced) { 44 | + // Simple "blend" deinterlacer based on vlc's deinterlace/algo_basic.c 45 | + // The two fields are averaged together to produce one frame. 46 | + // Each line output is the input line averaged with the previous line. 47 | + // The very first line is copied exactly (albeit by averaging itself). 48 | + GLSLF("float yprev%d = texcoord%d.y == 0.0 ? 0.0 : " 49 | + "texcoord%d.y - 1.0 / texture_size%d.y;\n", 50 | + id, id, id, id); 51 | + GLSLF("vec2 prev%d = vec2(texcoord%d.x, yprev%d);\n", id, id, id); 52 | + GLSLF("color.%s = %f * mix(texture(texture%d, texcoord%d), " 53 | + "texture(texture%d, prev%d), 0.5).%s;\n", 54 | + dst, img.multiplier, id, id, id, id, src); 55 | + } else { 56 | + GLSLF("color.%s = %f * vec4(texture(texture%d, texcoord%d)).%s;\n", 57 | + dst, img.multiplier, id, id, src); 58 | + } 59 | 60 | *offset += count; 61 | } 62 | @@ -2155,7 +2176,8 @@ 63 | // If any textures are still in integer format by this point, we need 64 | // to introduce an explicit conversion pass to avoid breaking hooks/scaling 65 | for (int n = 0; n < 4; n++) { 66 | - if (img[n].tex && img[n].tex->params.format->ctype == RA_CTYPE_UINT) { 67 | + if (img[n].tex && (img[n].tex->params.format->ctype == RA_CTYPE_UINT || 68 | + img[n].interlaced)) { 69 | GLSLF("// use_integer fix for plane %d\n", n); 70 | copy_image(p, &(int){0}, img[n]); 71 | pass_describe(p, "use_integer fix"); 72 | @@ -3841,6 +3863,7 @@ 73 | .tex_pad_y = p->opts.tex_pad_y, 74 | .tone_map = p->opts.tone_map, 75 | .early_flush = p->opts.early_flush, 76 | + .deint_shader = p->opts.deint_shader, 77 | .icc_opts = p->opts.icc_opts, 78 | .hwdec_interop = p->opts.hwdec_interop, 79 | .target_trc = p->opts.target_trc, 80 | 81 | --- ./src/mpv-0.35.1/video/out/gpu/video.h 82 | +++ ./src/mpv-0.35.1/video/out/gpu/video.h 83 | @@ -171,6 +171,7 @@ 84 | int early_flush; 85 | char *shader_cache_dir; 86 | char *hwdec_interop; 87 | + int deint_shader; 88 | }; 89 | 90 | extern const struct m_sub_options gl_video_conf; 91 | 92 | --- ./src/mpv-0.35.1/video/out/gpu/video_shaders.c 93 | +++ ./src/mpv-0.35.1/video/out/gpu/video_shaders.c 94 | @@ -387,11 +387,13 @@ 95 | gl_sc_bvec(sc, 3)); 96 | break; 97 | case MP_CSP_TRC_PQ: 98 | - GLSLF("color.rgb = pow(color.rgb, vec3(1.0/%f));\n", PQ_M2); 99 | - GLSLF("color.rgb = max(color.rgb - vec3(%f), vec3(0.0)) \n" 100 | - " / (vec3(%f) - vec3(%f) * color.rgb);\n", 101 | + gl_sc_paddf(sc, "highp vec3 pq_rgb;"); 102 | + GLSLF("pq_rgb = color.rgb;\n"); 103 | + GLSLF("pq_rgb = pow(pq_rgb, vec3(%f));\n", 1.0/PQ_M2); 104 | + GLSLF("pq_rgb = max(pq_rgb - vec3(%f), vec3(0.0)) \n" 105 | + " / (vec3(%f) - vec3(%f) * pq_rgb);\n", 106 | PQ_C1, PQ_C2, PQ_C3); 107 | - GLSLF("color.rgb = pow(color.rgb, vec3(%f));\n", 1.0 / PQ_M1); 108 | + GLSLF("color.rgb = pow(pq_rgb, vec3(%f));\n", 1.0/PQ_M1); 109 | // PQ's output range is 0-10000, but we need it to be relative to 110 | // MP_REF_WHITE instead, so rescale 111 | GLSLF("color.rgb *= vec3(%f);\n", 10000 / MP_REF_WHITE); 112 | @@ -860,7 +862,8 @@ 113 | // operations needs it 114 | bool need_linear = src.gamma != dst.gamma || 115 | src.primaries != dst.primaries || 116 | - src.sig_peak != dst.sig_peak || 117 | + src.sig_peak > dst.sig_peak || 118 | + (src.sig_peak != dst.sig_peak && !mp_trc_is_hdr(dst.gamma)) || 119 | need_ootf; 120 | 121 | if (need_linear && !is_linear) { 122 | 123 | --- ./src/mpv-0.35.1/video/out/opengl/formats.c 124 | +++ ./src/mpv-0.35.1/video/out/opengl/formats.c 125 | @@ -5,6 +5,7 @@ 126 | // --- GL type aliases (for readability) 127 | T_U8 = GL_UNSIGNED_BYTE, 128 | T_U16 = GL_UNSIGNED_SHORT, 129 | + T_HFL = GL_HALF_FLOAT, 130 | T_FL = GL_FLOAT, 131 | }; 132 | 133 | @@ -85,6 +86,20 @@ 134 | {"rgb16f", GL_RGB16F, GL_RGB, T_FL, F_F16 | F_TF | F_ES3}, 135 | {"rgba16f", GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_TF | F_ES3}, 136 | 137 | + // Support GL_HALF_FLOATs as well (sans-F_F16). 138 | + {"r16f", GL_R16F, GL_RED, T_HFL, F_CF | F_GL3 | F_GL2F}, 139 | + {"rg16f", GL_RG16F, GL_RG, T_HFL, F_CF | F_GL3 | F_GL2F}, 140 | + {"rgb16f", GL_RGB16F, GL_RGB, T_HFL, F_CF | F_GL3 | F_GL2F}, 141 | + {"rgba16f", GL_RGBA16F, GL_RGBA, T_HFL, F_CF | F_GL3 | F_GL2F}, 142 | + {"r16f", GL_R16F, GL_RED, T_HFL, F_CF | F_ES32 | F_EXTF16}, 143 | + {"rg16f", GL_RG16F, GL_RG, T_HFL, F_CF | F_ES32 | F_EXTF16}, 144 | + {"rgb16f", GL_RGB16F, GL_RGB, T_HFL, F_TF | F_ES32 | F_EXTF16}, 145 | + {"rgba16f", GL_RGBA16F, GL_RGBA, T_HFL, F_CF | F_ES32 | F_EXTF16}, 146 | + {"r16f", GL_R16F, GL_RED, T_HFL, F_TF | F_ES3}, 147 | + {"rg16f", GL_RG16F, GL_RG, T_HFL, F_TF | F_ES3}, 148 | + {"rgb16f", GL_RGB16F, GL_RGB, T_HFL, F_TF | F_ES3}, 149 | + {"rgba16f", GL_RGBA16F, GL_RGBA, T_HFL, F_TF | F_ES3}, 150 | + 151 | // These might be useful as FBO formats. 152 | {"rgb10_a2",GL_RGB10_A2, GL_RGBA, 153 | GL_UNSIGNED_INT_2_10_10_10_REV, F_CF | F_GL3 | F_ES3}, 154 | @@ -123,7 +138,7 @@ 155 | { 156 | if (!format) 157 | return 0; 158 | - if (format->type == GL_FLOAT) 159 | + if (format->type == GL_FLOAT || format->type == GL_HALF_FLOAT) 160 | return MPGL_TYPE_FLOAT; 161 | if (gl_integer_format_to_base(format->format)) 162 | return MPGL_TYPE_UINT; 163 | @@ -152,6 +167,7 @@ 164 | switch (type) { 165 | case GL_UNSIGNED_BYTE: return 1; 166 | case GL_UNSIGNED_SHORT: return 2; 167 | + case GL_HALF_FLOAT: return 2; 168 | case GL_FLOAT: return 4; 169 | } 170 | return 0; 171 | 172 | --- ./src/mpv-0.35.1/waftools/fragments/ios_eagl.m 173 | +++ ./src/mpv-0.35.1/waftools/fragments/ios_eagl.m 174 | @@ -0,0 +1,3 @@ 175 | +#include 176 | +int main(int argc, char **argv) 177 | +{ (void)EAGLGetVersion; return 0; } 178 | 179 | --- ./src/mpv-0.35.1/wscript 180 | +++ ./src/mpv-0.35.1/wscript 181 | @@ -753,7 +753,11 @@ 182 | } , { 183 | 'name': '--ios-gl', 184 | 'desc': 'iOS OpenGL ES hardware decoding interop support', 185 | - 'func': check_statement('OpenGLES/ES3/glext.h', '(void)GL_RGB32F'), # arbitrary OpenGL ES 3.0 symbol 186 | + 'func': check_cc( 187 | + fragment=load_fragment('ios_eagl.m'), 188 | + framework_name=['OpenGLES'], 189 | + compile_filename='ios_eagl.m' 190 | + ) 191 | } , { 192 | 'name': '--plain-gl', 193 | 'desc': 'OpenGL without platform-specific code (e.g. for libmpv)', 194 | -------------------------------------------------------------------------------- /patch.diff: -------------------------------------------------------------------------------- 1 | --- src/mpv-0.35.1/bootstrap.py 2 | +++ src/mpv-0.35.1/bootstrap.py 3 | @@ -5,10 +5,10 @@ 4 | import os, sys, stat, hashlib, subprocess 5 | from urllib.request import urlopen, URLError 6 | 7 | -WAFRELEASE = "waf-2.0.24" 8 | +WAFRELEASE = "waf-2.0.9" 9 | WAFURLS = ["https://waf.io/" + WAFRELEASE, 10 | "https://www.freehackers.org/~tnagy/release/" + WAFRELEASE] 11 | -SHA256HASH = "93909bca823a675f9f40af7c65b24887c3a3c0efdf411ff1978ba827194bdeb0" 12 | +SHA256HASH = "2a8e0816f023995e557f79ea8940d322bec18f286917c8f9a6fa2dc3875dfa48" 13 | 14 | if os.path.exists("waf"): 15 | wafver = subprocess.check_output([sys.executable, './waf', '--version']).decode() 16 | --- src/mpv-0.35.1/wscript 17 | +++ src/mpv-0.35.1/wscript 18 | @@ -245,6 +245,12 @@ iconv support use --disable-iconv.", 19 | 'desc': 'w32/dos paths', 20 | 'deps': 'os-win32 || os-cygwin', 21 | 'func': check_true 22 | + }, { 23 | + 'name': 'posix-spawn', 24 | + 'desc': 'spawnp()/kill() POSIX support', 25 | + 'func': check_statement(['spawn.h', 'signal.h'], 26 | + 'posix_spawnp(0,0,0,0,0,0); kill(0,0)'), 27 | + 'deps': '!mingw && !tvos', 28 | }, { 29 | 'name': 'glob-posix', 30 | 'desc': 'glob() POSIX support', 31 | --- src/mpv-0.35.1/wscript_build.py 32 | +++ src/mpv-0.35.1/wscript_build.py 33 | @@ -209,7 +209,7 @@ def build(ctx): 34 | ]) 35 | 36 | subprocess_c = ctx.pick_first_matching_dep([ 37 | - ( "osdep/subprocess-posix.c", "posix" ), 38 | + ( "osdep/subprocess-posix.c", "posix-spawn" ), 39 | ( "osdep/subprocess-win.c", "win32-desktop" ), 40 | ( "osdep/subprocess-dummy.c" ), 41 | ]) 42 | --- src/uchardet-0.0.7/CMakeLists.txt 43 | +++ src/uchardet-0.0.7/CMakeLists.txt 44 | @@ -3,7 +3,7 @@ 45 | include(CheckCCompilerFlag) 46 | set (PACKAGE_NAME uchardet) 47 | project (${PACKAGE_NAME} CXX C) 48 | -enable_testing() 49 | +# enable_testing() 50 | 51 | ######## Package information 52 | set (PACKAGE_URL https://www.freedesktop.org/wiki/Software/uchardet/) 53 | @@ -71,4 +71,4 @@ 54 | 55 | add_subdirectory(src) 56 | add_subdirectory(doc) 57 | -add_subdirectory(test) 58 | +# add_subdirectory(test) 59 | -------------------------------------------------------------------------------- /scripts/ffmpeg-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | FFMPEG_OPTIONS="${COMMON_OPTIONS%% *} \ 5 | --enable-cross-compile \ 6 | --disable-lzma \ 7 | --disable-sdl2 \ 8 | --disable-debug \ 9 | --disable-programs \ 10 | --disable-doc \ 11 | --disable-audiotoolbox \ 12 | --enable-pic \ 13 | --enable-shared \ 14 | --enable-openssl \ 15 | --disable-indev=avfoundation" 16 | 17 | if [[ "$ARCH" = "x86_64" ]]; then 18 | FFMPEG_OPTIONS="${FFMPEG_OPTIONS} \ 19 | --disable-asm" 20 | fi 21 | 22 | if [[ ! `which gas-preprocessor.pl` ]]; then 23 | PREFIX="/usr/local" 24 | if [[ $(sysctl -n machdep.cpu.brand_string) =~ "Apple" ]]; then 25 | PREFIX="/opt/homebrew" 26 | fi 27 | curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl -o $PREFIX/bin/gas-preprocessor.pl \ 28 | && chmod +x $PREFIX/bin/gas-preprocessor.pl 29 | fi 30 | 31 | if [[ "$ARCH" = "arm64" ]]; then 32 | EXPORT="GASPP_FIX_XCODE5=1" 33 | fi 34 | 35 | XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'` 36 | CC="xcrun -sdk $XCRUN_SDK clang" 37 | 38 | if [[ "$ARCH" = "arm64" ]]; then 39 | AS="gas-preprocessor.pl -arch aarch64 -- $CC" 40 | else 41 | AS="gas-preprocessor.pl -- $CC" 42 | fi 43 | 44 | 45 | $SRC/ffmpeg*/configure $FFMPEG_OPTIONS \ 46 | --target-os=darwin \ 47 | --arch=$ARCH \ 48 | --cc="$CC" \ 49 | --as="$AS" \ 50 | --extra-cflags="$CFLAGS" 51 | 52 | make -j4 install $EXPORT 53 | -------------------------------------------------------------------------------- /scripts/freetype-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | $SRC/freetype*/configure $COMMON_OPTIONS \ 5 | --with-zlib=yes \ 6 | --without-png \ 7 | --with-bzip2=no \ 8 | --with-harfbuzz=no 9 | make install -------------------------------------------------------------------------------- /scripts/fribidi-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | $SRC/fribidi*/configure $COMMON_OPTIONS 5 | make install -------------------------------------------------------------------------------- /scripts/harfbuzz-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | $SRC/harfbuzz*/configure $COMMON_OPTIONS \ 5 | --with-icu=no \ 6 | --with-glib=no \ 7 | --with-fontconfig=no \ 8 | --with-coretext=no \ 9 | --with-freetype=yes \ 10 | --with-cairo=no 11 | make install -------------------------------------------------------------------------------- /scripts/libass-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | OPT="--disable-fontconfig \ 5 | --disable-require-system-font-provider \ 6 | --enable-directwrite" 7 | 8 | $SRC/libass*/configure $COMMON_OPTIONS $OPT 9 | 10 | make install -------------------------------------------------------------------------------- /scripts/mpv-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | current_path=$(dirname "$(readlink -f "$0")") 4 | echo "PATCH_PATH $current_path/patch-waf.diff" 5 | 6 | OPTS="--prefix=$SCRATCH/$ARCH \ 7 | --exec-prefix=$SCRATCH/$ARCH \ 8 | --disable-cplayer \ 9 | --disable-lcms2 \ 10 | --disable-lua \ 11 | --disable-rubberband \ 12 | --disable-zimg \ 13 | --enable-libmpv-static \ 14 | --enable-ios-gl \ 15 | --enable-gl \ 16 | --disable-javascript \ 17 | --disable-libbluray \ 18 | --disable-vapoursynth \ 19 | --enable-uchardet \ 20 | --enable-lgpl" 21 | 22 | if [[ "$ENVIRONMENT" = "development" ]]; then 23 | OPTS="$OPTS --disable-optimize" 24 | fi 25 | 26 | cd $SRC/mpv* 27 | 28 | # 刪除 waf 文件夾以免重複 patch 問題 29 | rm -rf .waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50 30 | ./bootstrap.py 31 | patch -p0 <$current_path/patch-waf.diff 32 | ./waf configure $OPTS 33 | ./waf build -j4 34 | -------------------------------------------------------------------------------- /scripts/patch-waf.diff: -------------------------------------------------------------------------------- 1 | --- .waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50/waflib/ConfigSet.py 2 | +++ .waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50/waflib/ConfigSet.py 3 | @@ -146,7 +146,7 @@ 4 | Utils.writef(filename,''.join(buf)) 5 | def load(self,filename): 6 | tbl=self.table 7 | - code=Utils.readf(filename,m='rU') 8 | + code=Utils.readf(filename,m='r') 9 | for m in re_imp.finditer(code): 10 | g=m.group 11 | tbl[g(2)]=eval(g(3)) 12 | 13 | --- .waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50/waflib/Context.py 14 | +++ .waf3-2.0.9-10a533182bd85c3f45a157fb5d62db50/waflib/Context.py 15 | @@ -346,7 +346,7 @@ 16 | pass 17 | module=imp.new_module(WSCRIPT_FILE) 18 | try: 19 | - code=Utils.readf(path,m='rU',encoding=encoding) 20 | + code=Utils.readf(path,m='r',encoding=encoding) 21 | except EnvironmentError: 22 | raise Errors.WafError('Could not read the file %r'%path) 23 | module_dir=os.path.dirname(path) 24 | 25 | -------------------------------------------------------------------------------- /scripts/uchardet-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | PREFIX="${COMMON_OPTIONS%% *}" 5 | PREFIX="${PREFIX##*=}" 6 | 7 | UCHARDET_OPTIONS="-DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=false -DCMAKE_OSX_SYSROOT=$SDKPATH" 8 | 9 | cmake $SRC/uchardet* 10 | cmake $SRC/uchardet* $UCHARDET_OPTIONS && make 11 | make install -------------------------------------------------------------------------------- /xcframework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | LIBRARIES="libuchardet libfribidi libfreetype libharfbuzz libass libmpv libavcodec libavdevice libavfilter libavformat libavutil libswresample libswscale libcrypto libssl" 4 | PLATFORMS="ios tv" 5 | ROOT="$(pwd)" 6 | LIB="$ROOT/lib" 7 | 8 | rm -rf $LIB 9 | 10 | mkdir -p $LIB 11 | 12 | for LIBRARY in $LIBRARIES; do 13 | 14 | FRAMEWORKS="" 15 | 16 | for PLATFORM in $PLATFORMS; do 17 | SCRATCH="$ROOT/scratch-$PLATFORM" 18 | 19 | if [ -d "$SCRATCH/arm64-development" ]; then 20 | ENVIRONMENTS="$ENVIRONMENTS development" 21 | mkdir -p $SCRATCH/development/$LIBRARY.framework 22 | lipo -create $SCRATCH/arm64-development/lib/$LIBRARY.a -o $SCRATCH/development/$LIBRARY.framework/$LIBRARY 23 | fi 24 | 25 | if [[ -d "$SCRATCH/arm64-distribution" ]]; then 26 | ENVIRONMENTS="$ENVIRONMENTS distribution" 27 | mkdir -p $SCRATCH/distribution/$LIBRARY.framework 28 | cp $SCRATCH/arm64-distribution/lib/$LIBRARY.a $SCRATCH/distribution/$LIBRARY.framework/$LIBRARY 29 | fi 30 | 31 | for ENVIRONMENT in $ENVIRONMENTS; do 32 | cp -a $ROOT/framework-meta/Info.plist $SCRATCH/$ENVIRONMENT/$LIBRARY.framework/Info.plist 33 | sed -i "" "s/{NAME}/$LIBRARY/g" $SCRATCH/$ENVIRONMENT/$LIBRARY.framework/Info.plist 34 | if [[ "$LIBRARY" = "libmpv" ]]; then 35 | cp -a $ROOT/framework-meta/libmpv/. $SCRATCH/$ENVIRONMENT/$LIBRARY.framework/ 36 | fi 37 | 38 | FRAMEWORKS="$FRAMEWORKS -framework $SCRATCH/$ENVIRONMENT/$LIBRARY.framework" 39 | 40 | done 41 | done 42 | 43 | xcodebuild -create-xcframework $FRAMEWORKS -output $LIB/$LIBRARY.xcframework 44 | 45 | FULL_INFO_PLIST_PATH=$LIB"/"$LIBRARY".xcframework/Info.plist" 46 | /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string 15.1" "$FULL_INFO_PLIST_PATH" 47 | done 48 | --------------------------------------------------------------------------------