Full Code of mariotaku/ihsplay for AI

main 3b382603a123 cached
150 files
351.1 KB
114.2k tokens
393 symbols
1 requests
Download .txt
Showing preview only (387K chars total). Download the full file or copy to clipboard to get everything.
Repository: mariotaku/ihsplay
Branch: main
Commit: 3b382603a123
Files: 150
Total size: 351.1 KB

Directory structure:
gitextract_wabvwvnr/

├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   └── workflows/
│       ├── build-test.yml
│       └── release.yml
├── .gitignore
├── .gitmodules
├── .run/
│   └── ihsplay.run.xml
├── CMakeLists.txt
├── LICENSE
├── README.md
├── app/
│   ├── .gitignore
│   ├── CMakeLists.txt
│   ├── app.c
│   ├── app.h
│   ├── app_events.c
│   ├── app_gamepad.c
│   ├── backend/
│   │   ├── CMakeLists.txt
│   │   ├── host_manager.c
│   │   ├── host_manager.h
│   │   ├── input_manager.c
│   │   ├── input_manager.h
│   │   ├── stream/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── stream_input.c
│   │   │   ├── stream_input.h
│   │   │   ├── stream_manager.c
│   │   │   ├── stream_manager.h
│   │   │   ├── stream_manager_internal.h
│   │   │   ├── stream_media.c
│   │   │   └── stream_media.h
│   │   └── stream_manager.h
│   ├── config.h.in
│   ├── lvgl/
│   │   ├── CMakeLists.txt
│   │   ├── display.c
│   │   ├── display.h
│   │   ├── ext/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── lv_child_group.c
│   │   │   ├── lv_child_group.h
│   │   │   ├── lv_dir_focus.c
│   │   │   ├── lv_dir_focus.h
│   │   │   ├── msgbox_ext.c
│   │   │   └── msgbox_ext.h
│   │   ├── fonts/
│   │   │   └── bootstrap-icons/
│   │   │       ├── regular.h
│   │   │       └── symbols.h
│   │   ├── keypad.c
│   │   ├── keypad.h
│   │   ├── lv_conf.h
│   │   ├── mouse.c
│   │   ├── mouse.h
│   │   ├── theme.c
│   │   └── theme.h
│   ├── main.c
│   ├── platform/
│   │   ├── CMakeLists.txt
│   │   ├── common/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── app_common.c
│   │   │   └── client_info_common.c
│   │   └── webos/
│   │       ├── CMakeLists.txt
│   │       ├── app_webos.c
│   │       └── client_info_webos.c
│   ├── settings/
│   │   ├── CMakeLists.txt
│   │   ├── app_settings.h
│   │   └── settings.c
│   ├── ui/
│   │   ├── CMakeLists.txt
│   │   ├── app_ui.c
│   │   ├── app_ui.h
│   │   ├── app_ui_font.c
│   │   ├── app_ui_font.h
│   │   ├── common/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── error_messages.c
│   │   │   ├── error_messages.h
│   │   │   ├── group_utils.c
│   │   │   ├── group_utils.h
│   │   │   ├── progress_dialog.c
│   │   │   └── progress_dialog.h
│   │   ├── connection/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── conn_error_fragment.c
│   │   │   ├── conn_error_fragment.h
│   │   │   ├── connection_fragment.c
│   │   │   ├── connection_fragment.h
│   │   │   ├── pin_fragment.c
│   │   │   └── pin_fragment.h
│   │   ├── hosts/
│   │   │   ├── hosts_fragment.c
│   │   │   └── hosts_fragment.h
│   │   ├── launcher.c
│   │   ├── launcher.h
│   │   ├── session/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── connection_progress.c
│   │   │   ├── connection_progress.h
│   │   │   ├── session.c
│   │   │   ├── session.h
│   │   │   ├── streaming_overlay.c
│   │   │   └── streaming_overlay.h
│   │   ├── settings/
│   │   │   ├── basic.c
│   │   │   ├── basic.h
│   │   │   ├── settings.c
│   │   │   ├── settings.h
│   │   │   ├── widgets.c
│   │   │   └── widgets.h
│   │   └── support/
│   │       ├── CMakeLists.txt
│   │       ├── feedback.c
│   │       ├── feedback.h
│   │       ├── support.c
│   │       ├── support.h
│   │       ├── wiki.c
│   │       └── wiki.h
│   └── util/
│       ├── CMakeLists.txt
│       ├── client_info.c
│       ├── client_info.h
│       ├── listeners_list.c
│       ├── listeners_list.h
│       ├── random.c
│       ├── random.h
│       ├── refcounter.h
│       └── video/
│           ├── CMakeLists.txt
│           └── sps/
│               ├── CMakeLists.txt
│               ├── bitstream.c
│               ├── bitstream.h
│               ├── common.c
│               ├── common.h
│               ├── include/
│               │   └── sps_util.h
│               ├── sps_util_h264.c
│               ├── sps_util_h265.c
│               └── tests/
│                   ├── CMakeLists.txt
│                   ├── sample_data.h
│                   ├── sps_parser_tests.c
│                   ├── test_dimension_h265.c
│                   └── test_nal_start_code.c
├── cmake/
│   ├── AresPackage.cmake
│   ├── CleanupNameLink.cmake
│   ├── PackageDebian.cmake
│   └── PackageWebOS.cmake
├── deploy/
│   ├── raspbian/
│   │   └── sysroot-packages.list
│   └── webos/
│       └── appinfo.in.json
├── tests/
│   ├── CMakeLists.txt
│   └── app/
│       ├── CMakeLists.txt
│       └── utils/
│           └── CMakeLists.txt
└── tools/
    ├── resource-tools/
    │   ├── .gitignore
    │   ├── .nvmrc
    │   ├── async-transform.ts
    │   ├── binheader.ts
    │   ├── codepoints.ts
    │   ├── gulp-subset-font.ts
    │   ├── gulpfile.ts
    │   ├── package.json
    │   ├── res/
    │   │   ├── bootstrap-icons.json
    │   │   └── bootstrap-icons.list
    │   ├── symheader.ts
    │   └── tsconfig.json
    └── webos/
        ├── easy_build.sh
        └── easy_install.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms

github: [mariotaku] 
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''

---

## Issue Summary

A clear and concise description of what the bug is.

## Steps to Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Select '....'
4. See error

## Expected Behavior

A clear and concise description of what you expected to happen.

## Basic Information

<!-- Please complete information below. Issue without context might get closed.-->

### IHSplay Information

<!-- Find app & system information by open :question: button, select Feedback and share the info below. -->

### Computer Setup

<!-- Describe your computer setup, like OS version, GPU model, monitor resolution etc. -->

## Additional Context

Add any other context about the problem here. For example error message on the screen, and settings in IHSplay


================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.


================================================
FILE: .github/workflows/build-test.yml
================================================
name: Build Test

on:
  push:
    # Don't run for tags
    tags-ignore:
      - '**'
    branches:
      - '**'
env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Release

jobs:
  build-webos:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          submodules: recursive

      - name: Download ares-cli-rs
        uses: robinraju/release-downloader@v1.9
        with:
          repository: "webosbrew/ares-cli-rs"
          latest: true
          fileName: "ares-package_*.deb"
          out-file-path: "temp"

      - name: Download Homebrew Toolbox
        uses: robinraju/release-downloader@v1.9
        with:
          repository: "webosbrew/dev-toolbox-cli"
          latest: true
          fileName: "webosbrew-toolbox-*.deb"
          out-file-path: "temp"

      - name: Install Tools
        run: sudo apt-get install ./temp/*.deb

      - name: Download webOS NDK
        uses: robinraju/release-downloader@v1.9
        with:
          repository: "openlgtv/buildroot-nc4"
          latest: true
          fileName: "arm-webos-linux-gnueabi_sdk-buildroot.tar.gz"
          out-file-path: "/tmp"

      - name: Extract webOS NDK
        shell: bash
        working-directory: /tmp
        run: |
          tar xzf arm-webos-linux-gnueabi_sdk-buildroot.tar.gz
          ./arm-webos-linux-gnueabi_sdk-buildroot/relocate-sdk.sh

      - name: Build
        env:
          TOOLCHAIN_FILE: /tmp/arm-webos-linux-gnueabi_sdk-buildroot/usr/share/buildroot/toolchainfile.cmake
        run: ./tools/webos/easy_build.sh -DCMAKE_BUILD_TYPE=$BUILD_TYPE

      - name: Add Commit Hash Suffix
        shell: bash
        working-directory: dist
        run: for file in *.ipk ; do mv $file ${file//_arm/-${GITHUB_SHA:0:8}_arm} ; done

      - uses: actions/upload-artifact@v4
        with:
          name: webos-snapshot
          path: dist/*.ipk

      - name: Compatibility Check
        run: webosbrew-ipk-verify -f markdown -d -o $GITHUB_STEP_SUMMARY dist/*.ipk

  build-raspi:
    runs-on: ubuntu-20.04

    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive

      - name: Run apt-get update
        shell: bash
        run: sudo apt-get -y -qq update

      - name: Prepare Sysroot
        id: pi-sysroot
        uses: mariotaku/raspbian-sysroot-action@v1.2
        with:
          release: bullseye
          packages: ${{github.workspace}}/deploy/raspbian/sysroot-packages.list

      - name: Install Build Tools
        shell: bash
        # apt-get update was implicitly called, so we don't have to call it here
        run: sudo apt-get -y -qq install crossbuild-essential-armhf cmake

      - name: Create Build Environment
        # Some projects don't allow in-source building, so create a separate build directory
        # We'll use this as our working directory for all subsequent commands
        run: cmake -E make_directory ${{github.workspace}}/build

      - name: Configure CMake
        # Use a bash shell, so we can use the same syntax for environment variable
        # access regardless of the host operating system
        shell: bash
        working-directory: ${{github.workspace}}/build
        # Note the current convention is to use the -S and -B options here to specify source
        # and build directories, but this is only available with CMake 3.13 and higher.
        # The CMake binaries on the GitHub Actions machines are (as of this writing) 3.12
        run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DTARGET_RASPI=ON
          -DCMAKE_TOOLCHAIN_FILE=${{steps.pi-sysroot.outputs.cmake-toolchain}}


      - name: Build
        working-directory: ${{github.workspace}}/build
        shell: bash
        # Execute the build.  You can specify a specific target with "--target <NAME>"
        run: |
          cmake --build . --config $BUILD_TYPE


================================================
FILE: .github/workflows/release.yml
================================================
name: Release

on:
  release:
    types: [ created ]

env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Debug

jobs:
  build-webos:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive

      - name: Download ares-cli-rs
        uses: robinraju/release-downloader@v1.9
        with:
          repository: "webosbrew/ares-cli-rs"
          latest: true
          fileName: "ares-package_*.deb"
          out-file-path: "temp"

      - name: Download Homebrew Toolbox
        uses: robinraju/release-downloader@v1.9
        with:
          repository: "webosbrew/dev-toolbox-cli"
          latest: true
          fileName: "webosbrew-toolbox-gen-manifest_*.deb"
          out-file-path: "temp"

      - name: Install Tools
        run: sudo apt-get install ./temp/*.deb

      - name: Download webOS NDK
        uses: robinraju/release-downloader@v1.9
        with:
          repository: "openlgtv/buildroot-nc4"
          latest: true
          fileName: "arm-webos-linux-gnueabi_sdk-buildroot.tar.gz"
          out-file-path: "/tmp"

      - name: Extract webOS NDK
        shell: bash
        working-directory: /tmp
        run: |
          tar xzf arm-webos-linux-gnueabi_sdk-buildroot.tar.gz
          ./arm-webos-linux-gnueabi_sdk-buildroot/relocate-sdk.sh

      - name: Build
        env:
          TOOLCHAIN_FILE: /tmp/arm-webos-linux-gnueabi_sdk-buildroot/usr/share/buildroot/toolchainfile.cmake
        run: ./tools/webos/easy_build.sh -DCMAKE_BUILD_TYPE=$BUILD_TYPE

      - name: Create Release (webOS)
        id: create_release_webos
        uses: ncipollo/release-action@v1.14.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          name: Release ${{ steps.tagName.outputs.tag }}
          allowUpdates: true
          omitNameDuringUpdate: true
          omitBodyDuringUpdate: true
          omitPrereleaseDuringUpdate: true
          artifacts: dist/*.ipk,dist/*.manifest.json


================================================
FILE: .gitignore
================================================
### C++ template
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

### C template
# Prerequisites

# Object files
*.ko
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers

# Libraries

# Shared objects (inc. Windows DLLs)
*.so.*

# Executables
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# Everything under .idea directory
.idea/

### CMake template
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
build/
dist/

================================================
FILE: .gitmodules
================================================
[submodule "third_party/lvgl"]
	path = third_party/lvgl
	url = https://github.com/lvgl/lvgl.git
[submodule "third_party/ihslib"]
	path = core
	url = https://github.com/mariotaku/ihslib.git
[submodule "cmake/sanitizers"]
	path = cmake/sanitizers
	url = https://github.com/arsenm/sanitizers-cmake.git
[submodule "third_party/ss4s"]
	path = third_party/ss4s
	url = https://github.com/mariotaku/ss4s.git
[submodule "third_party/commons"]
	path = third_party/commons
	url = https://github.com/mariotaku/commons-c.git


================================================
FILE: .run/ihsplay.run.xml
================================================
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="ihsplay" type="com.jetbrains.cidr.remote.gdbserver.type" factoryName="com.jetbrains.cidr.remote.gdbserver.factory" PROGRAM_PARAMS=":1234 ihsplay" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" WORKING_DIR="file:///media/developer/apps/usr/palm/applications/org.mariotaku.ihsplay" PASS_PARENT_ENVS_2="false" PROJECT_NAME="ihsplay" TARGET_NAME="ihsplay-install" CONFIG_NAME="webOS Debug" version="1" RUN_TARGET_PROJECT_NAME="ihsplay" RUN_TARGET_NAME="ihsplay">
    <envs>
      <env name="APPID" value="org.mariotaku.ihsplay" />
      <env name="LD_LIBRARY_PATH" value="/media/developer/apps/usr/palm/applications/org.mariotaku.ihsplay/lib" />
      <env name="HOME" value="/media/developer/apps/usr/palm/applications/org.mariotaku.ihsplay" />
      <env name="XDG_RUNTIME_DIR" value="/tmp/xdg" />
    </envs>
    <custom-gdb-server version="1" gdb-connect="um7380:1234" executable="/media/developer/bin/gdbserver" warmup-ms="0" download-type="NONE" sshConfigName="root@um7380:22 agent" uploadFile="/tmp/CLion/debug/ihsplay" defaultGdbServerArgs=":1234 /tmp/CLion/debug/ihsplay">
      <debugger toolchainName="webOS" />
    </custom-gdb-server>
    <method v="2">
      <option name="CLION.COMPOUND.BUILD" enabled="true" />
    </method>
  </configuration>
</component>

================================================
FILE: CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.16)

execute_process(COMMAND git describe --tags --abbrev=0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        OUTPUT_VARIABLE IHSPLAY_VERSION ERROR_QUIET)
if (IHSPLAY_VERSION)
    string(STRIP "${IHSPLAY_VERSION}" IHSPLAY_VERSION)
    string(SUBSTRING "${IHSPLAY_VERSION}" 1 -1 IHSPLAY_VERSION)
else ()
    set(IHSPLAY_VERSION "0.0.0")
endif ()

project(ihsplay VERSION ${IHSPLAY_VERSION} LANGUAGES C)

# To suppress warnings for MbedTLS
if (POLICY CMP0048)
    cmake_policy(SET CMP0048 NEW)
endif ()
# To suppress warnings for ExternalProject DOWNLOAD_EXTRACT_TIMESTAMP
if (POLICY CMP0135)
    cmake_policy(SET CMP0135 NEW)
endif ()

enable_testing()

# Somehow the directory containing FindMbedTLS.cmake must be in the first place
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/core/scripts ${CMAKE_SOURCE_DIR}/third_party/commons/cmake
        ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/sanitizers/cmake)

option(IHSPLAY_WIP_FEATURES "Enable Work-in-Progress Features" OFF)
option(IHSPLAY_FEATURE_FORCE_FULLSCREEN "Force full screen mode" OFF)

set(IHSPLAY_FEATURE_LIBCEC ON)

option(COMMONS_LV_SDL_IMG_USE_IMAGE "Don't use SDL_Image" OFF)

set(COMMONS_LOGGING_SDL ON)
set(COMMONS_LOGGING_LVGL ON)
set(COMMONS_LOGGING_SS4S ON)

get_filename_component(CMAKE_C_COMPILER_NAME "${CMAKE_C_COMPILER}" NAME)

if (CMAKE_C_COMPILER_NAME MATCHES "^arm-webos-linux-gnueabi-")
    set(TARGET_WEBOS TRUE)
endif ()

# Use `pkg-config` to link needed libraries.
find_package(PkgConfig REQUIRED)
find_package(Freetype REQUIRED)
find_package(Fontconfig REQUIRED)
find_package(MbedTLS)

# Use SDL2 for window creation and event handling.
if (TARGET_WEBOS)
    set(CMAKE_INSTALL_LIBDIR lib/backports)
    set(SDL2_BACKPORT_REVISION "webOS-2.30.x")
    include(ExternalSDL2BackportForWebOS)
    unset(CMAKE_INSTALL_LIBDIR)
else ()
    pkg_check_modules(SDL2 REQUIRED sdl2>=2.0.14)
endif()
pkg_check_modules(PROTOBUF_C libprotobuf-c)
pkg_check_modules(OPUS opus)

if (NOT PROTOBUF_C_FOUND)
    list(APPEND CMAKE_MESSAGE_INDENT "  ")
    message(STATUS "Including protobuf-c from source...")
    include(ExternalProtobufC)
    list(POP_BACK CMAKE_MESSAGE_INDENT)
endif ()

if (NOT OPUS_FOUND)
    list(APPEND CMAKE_MESSAGE_INDENT "  ")
    message(STATUS "Including opus from source...")
    include(ExternalOPUS)
    list(POP_BACK CMAKE_MESSAGE_INDENT)
endif ()

if (NOT MBEDTLS_FOUND)
    list(APPEND CMAKE_MESSAGE_INDENT "  ")
    message(STATUS "Including mbedtls from source...")
    include(ExternalMbedTLS)
    list(POP_BACK CMAKE_MESSAGE_INDENT)
endif ()

if (TARGET_WEBOS)
#    set(IHSLIB_SDL_TARGETVERSION "2.28.0")
    set(SS4S_MODULE_DISABLE_MMAL ON)
endif ()

add_subdirectory(core)

add_subdirectory(third_party/lvgl EXCLUDE_FROM_ALL)

target_include_directories(lvgl SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(lvgl SYSTEM PRIVATE ${FREETYPE_INCLUDE_DIRS})

target_link_libraries(lvgl PRIVATE ${SDL2_LIBRARIES} ${FREETYPE_LIBRARIES})
target_compile_definitions(lvgl PUBLIC LV_CONF_PATH=../../../app/lvgl/lv_conf.h)

add_subdirectory(third_party/ss4s)
add_subdirectory(third_party/commons)

set(CMAKE_C_STANDARD 11)

add_subdirectory(app)
target_include_directories(ihsplay PRIVATE app)

target_link_libraries(ihsplay PRIVATE lvgl ihslib ihslib-hid-sdl ss4s commons-array-list commons-os-info
        commons-logging commons-ss4s-modules-list)
target_link_libraries(ihsplay PRIVATE lv_gridview)

get_target_property(SS4S_MODULE_LIBRARY_OUTPUT_DIRECTORY ss4s SS4S_MODULE_LIBRARY_OUTPUT_DIRECTORY)

target_include_directories(ihsplay SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS} ${OPUS_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(ihsplay PRIVATE ${SDL2_LIBRARIES} ${OPUS_LIBRARIES} Fontconfig::Fontconfig Freetype::Freetype
        ${MBEDCRYPTO_LIBRARY})

if (TARGET_WEBOS)
    set(IHSPLAY_FEATURE_LIBCEC OFF)
    set(IHSPLAY_FEATURE_FORCE_FULLSCREEN ON)
    target_link_libraries(ihsplay PRIVATE commons-luna-sync)

    set_target_properties(ihsplay PROPERTIES
            BUILD_WITH_INSTALL_RPATH TRUE
            INSTALL_RPATH_USE_LINK_PATH TRUE
            INSTALL_RPATH "$ORIGIN/lib/backports:$ORIGIN")
    include(PackageWebOS)
else ()
    set(CMAKE_INSTALL_PREFIX /usr)
    include(GNUInstallDirs)
endif ()

if (IHSPLAY_FEATURE_LIBCEC AND TARGET commons-cec-sdl)
    target_link_libraries(ihsplay PRIVATE commons-cec-sdl)
else ()
    set(IHSPLAY_FEATURE_LIBCEC OFF)
endif ()

if (IHSPLAY_SANITIZE_ADDRESS)
    target_compile_options(ihsplay PRIVATE -fsanitize=address)
    target_link_options(ihsplay PRIVATE -fsanitize=address)
    target_link_libraries(ihsplay PRIVATE asan)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(IHSPLAY_IS_DEBUG ON)
endif ()

configure_file(app/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
target_include_directories(ihsplay PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

add_subdirectory(tests)

================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    {one line to give the program's name and a brief idea of what it does.}
    Copyright (C) {year}  {name of author}

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    {project}  Copyright (C) {year}  {fullname}
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
```
    ______  _______       __
   /  _/ / / / ___/____  / /___ ___  __      In-Home
   / // /_/ /\__ \/ __ \/ / __ `/ / / /     Streaming
 _/ // __  /___/ / /_/ / / /_/ / /_/ /     Player
/___/_/ /_//____/ .___/_/\__,_/\__, /     For Steam
               /_/            /____/
```

IHSplay is an SDL2 based Steam Link Client, primarily targeting webOS TV
and Raspberry Pi.

The application will be providing a TV remote / gamepad friendly UI, and
low latency video / audio output, as well as generic mouse / keyboard /
gamepad support.

---

![Home UI](https://user-images.githubusercontent.com/830358/219081008-e5eb646a-76fa-4683-9869-35e3923618ce.png)

![Streaming Overlay](https://user-images.githubusercontent.com/830358/207047480-8cc96496-4fab-4a0e-8d1a-896183c54a6e.png)


Stay tuned!


================================================
FILE: app/.gitignore
================================================
./config.h

================================================
FILE: app/CMakeLists.txt
================================================
add_executable(ihsplay
        main.c
        app.c
        app_events.c
        app_gamepad.c
        )

add_subdirectory(settings)
add_subdirectory(backend)
add_subdirectory(lvgl)
add_subdirectory(ui)
add_subdirectory(util)
add_subdirectory(platform)

================================================
FILE: app/app.c
================================================
#include <stdlib.h>
#include <assert.h>

#include "app.h"
#include "ui/app_ui.h"
#include "backend/host_manager.h"
#include "backend/stream_manager.h"
#include "backend/input_manager.h"
#include "util/client_info.h"

app_t *app_create(app_settings_t *settings, void *disp) {
    assert(settings != NULL);
    assert(disp != NULL);
    app_t *app = calloc(1, sizeof(app_t));
    app->settings = settings;
    app->main_thread_id = SDL_ThreadID();
    app->running = true;
    bool client_info_loaded = client_info_load(&app->client_info);
    assert(client_info_loaded);
    app->input_manager = input_manager_create();
    app->host_manager = host_manager_create(app);
    app->stream_manager = stream_manager_create(app);
    app->ui = app_ui_create(app, (lv_disp_t *) disp);
    app_ui_created(app->ui);
    return app;
}

void app_destroy(app_t *app) {
    app_ui_destroy(app->ui);
    stream_manager_destroy(app->stream_manager);
    host_manager_destroy(app->host_manager);
    input_manager_destroy(app->input_manager);
    client_info_clear(&app->client_info);
    free(app);
}

void app_quit(app_t *app) {
    stream_manager_stop_active(app->stream_manager);
    app->running = false;
}

void app_assert_main_thread(app_t *app) {
    assert(app->main_thread_id == SDL_ThreadID());
}

================================================
FILE: app/app.h
================================================
#pragma once

#include <stdbool.h>
#include <SDL.h>

#include "ihslib.h"
#include "ss4s.h"
#include "settings/app_settings.h"
#include "util/client_info.h"
#include "os_info.h"

typedef struct app_ui_t app_ui_t;
typedef struct stream_manager_t stream_manager_t;
typedef struct host_manager_t host_manager_t;
typedef struct input_manager_t input_manager_t;

typedef struct app_t {
    bool running;
    SDL_threadID main_thread_id;
    app_ui_t *ui;
    app_settings_t *settings;
    client_info_t client_info;
    os_info_t os_info;
    host_manager_t *host_manager;
    stream_manager_t *stream_manager;
    input_manager_t *input_manager;
} app_t;

typedef enum app_event_type_t {
    APP_EVENT_BEGIN = SDL_USEREVENT,
    APP_RUN_ON_MAIN,
    APP_UI_EVENT_BEGIN,
    APP_UI_NAV_QUIT,
    APP_UI_NAV_BACK,
    APP_UI_REQUEST_OVERLAY,
    APP_UI_CLOSE_OVERLAY,
    APP_UI_GAMEPAD_DEVICE_CHANGED,
    APP_UI_EVENT_LAST,
    APP_EVENT_LAST,
} app_event_type_t;

typedef void(*app_run_action_fn)(app_t *, void *);

void app_preinit(int argc, char *argv[]);

app_t *app_create(app_settings_t *settings, void *disp);

void app_destroy(app_t *app);

void app_quit(app_t *app);

void app_post_event(app_t *app, app_event_type_t type, void *data1, void *data2);

void app_run_on_main(app_t *app, app_run_action_fn action, void *data);

void app_run_on_main_sync(app_t *app, app_run_action_fn action, void *data);

void app_sdl_input_event(app_t *app, const SDL_Event *event);

void app_assert_main_thread(app_t *app);

void app_ihs_log(IHS_LogLevel level, const char *tag, const char *message);

================================================
FILE: app/app_events.c
================================================
#include "app.h"

typedef struct bus_blocking_action_t {
    app_run_action_fn action;

    void *data;
    SDL_mutex *mutex;
    SDL_cond *cond;
    bool done;
} bus_action_sync_t;

static void invoke_action_sync(app_t *app, void *data);

void app_post_event(app_t *app, app_event_type_t type, void *data1, void *data2) {
    (void) app;
    SDL_Event event;
    event.user.type = type;
    event.user.data1 = data1;
    event.user.data2 = data2;
    SDL_PushEvent(&event);
}

void app_run_on_main(app_t *app, app_run_action_fn action, void *data) {
    (void) app;
    app_post_event(app, APP_RUN_ON_MAIN, action, data);
}

void app_run_on_main_sync(app_t *app, app_run_action_fn action, void *data) {
    bus_action_sync_t sync = {
            .action = action,
            .data = data,
            .mutex = SDL_CreateMutex(),
            .cond = SDL_CreateCond(),
            .done = false,
    };
    app_run_on_main(app, invoke_action_sync, &sync);
    SDL_LockMutex(sync.mutex);
    while (!sync.done) {
        SDL_CondWait(sync.cond, sync.mutex);
    }
    SDL_UnlockMutex(sync.mutex);
    SDL_DestroyMutex(sync.mutex);
    SDL_DestroyCond(sync.cond);
}

static void invoke_action_sync(app_t *app, void *data) {
    (void) app;
    bus_action_sync_t *sync = data;
    SDL_LockMutex(sync->mutex);
    sync->action(app, sync->data);
    sync->done = true;
    SDL_CondSignal(sync->cond);
    SDL_UnlockMutex(sync->mutex);
}

================================================
FILE: app/app_gamepad.c
================================================
#include "ui/app_ui.h"

#include "lvgl/keypad.h"
#include "app.h"
#include "backend/input_manager.h"

void app_sdl_input_event(app_t *app, const SDL_Event *event) {
    switch (event->type) {
        case SDL_CONTROLLERDEVICEADDED: {
            input_manager_sdl_gamepad_added(app->input_manager, event->cdevice.which);
            app_post_event(app, APP_UI_GAMEPAD_DEVICE_CHANGED, NULL, NULL);
            break;
        }
        case SDL_CONTROLLERDEVICEREMOVED: {
            input_manager_sdl_gamepad_removed(app->input_manager, event->cdevice.which);
            app_post_event(app, APP_UI_GAMEPAD_DEVICE_CHANGED, NULL, NULL);
            break;
        }
        case SDL_KEYUP:
        case SDL_KEYDOWN: {
            app_indev_keypad_sdl_key_event(app->ui->indev.keypad, &event->key);
            break;
        }
        case SDL_CONTROLLERBUTTONUP:
        case SDL_CONTROLLERBUTTONDOWN: {
            app_indev_keypad_sdl_cbutton_event(app->ui->indev.keypad, &event->cbutton);
            break;
        }
    }
}

================================================
FILE: app/backend/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE host_manager.c input_manager.c)
add_subdirectory(stream)

================================================
FILE: app/backend/host_manager.c
================================================
#include <assert.h>

#include "app.h"
#include "host_manager.h"

#include "array_list.h"
#include "util/refcounter.h"
#include "util/listeners_list.h"
#include "ui/common/error_messages.h"
#include "logging.h"

struct host_manager_t {
    app_t *app;
    IHS_Client *client;
    SDL_TimerID timer;
    array_list_t *hosts;
    array_list_t *listeners;
};

typedef struct host_manager_session_error_t {
    IHS_HostInfo host;
    uint32_t result;
} host_manager_enum_error_t;

typedef struct host_manager_authorization_result_t {
    IHS_HostInfo host;
    uint64_t steam_id;
} host_manager_authorization_result_t;

typedef struct host_manager_streaming_result_t {
    IHS_HostInfo host;
    IHS_SessionInfo session;
} host_manager_streaming_result_t;

static void client_host_discovered(IHS_Client *client, const IHS_HostInfo *host, void *context);

static void client_authorization_success(IHS_Client *client, const IHS_HostInfo *host, uint64_t steamId,
                                         void *context);

static void client_authorization_failed(IHS_Client *client, const IHS_HostInfo *host,
                                        IHS_AuthorizationResult result, void *context);

static void client_streaming_success(IHS_Client *client, const IHS_HostInfo *host, const IHS_SocketAddress *address,
                                     const uint8_t *sessionKey, size_t sessionKeyLen, void *context);

static void client_streaming_failed(IHS_Client *client, const IHS_HostInfo *host, IHS_StreamingResult result,
                                    void *context);

static void client_host_discovered_main(app_t *app, void *data);

static void client_streaming_success_main(app_t *app, void *data);

static void client_streaming_failed_main(app_t *app, void *data);

static void client_authorization_success_main(app_t *app, void *data);

static void client_authorization_failed_main(app_t *app, void *data);

static int compare_host_name(const void *a, const void *b);

static const IHS_ClientDiscoveryCallbacks discovery_callbacks = {
        .discovered = client_host_discovered,
};

static const IHS_ClientAuthorizationCallbacks authorization_callbacks = {
        .success = client_authorization_success,
        .failed = client_authorization_failed,
};

static const IHS_ClientStreamingCallbacks streaming_callbacks = {
        .success = client_streaming_success,
        .failed = client_streaming_failed,
};

host_manager_t *host_manager_create(app_t *app) {
    host_manager_t *manager = SDL_calloc(1, sizeof(host_manager_t));
    manager->app = app;
    manager->client = IHS_ClientCreate(&app->client_info.config);
    manager->hosts = array_list_create(sizeof(IHS_HostInfo), 16);
    manager->listeners = listeners_list_create();
    IHS_ClientSetLogFunction(manager->client, app_ihs_log);
    IHS_ClientSetDiscoveryCallbacks(manager->client, &discovery_callbacks, manager);
    IHS_ClientSetAuthorizationCallbacks(manager->client, &authorization_callbacks, manager);
    IHS_ClientSetStreamingCallbacks(manager->client, &streaming_callbacks, manager);
    return manager;
}

void host_manager_destroy(host_manager_t *manager) {
    IHS_ClientStop(manager->client);
    IHS_ClientThreadedJoin(manager->client);
    IHS_ClientDestroy(manager->client);
    listeners_list_destroy(manager->listeners);
    array_list_destroy(manager->hosts);
    SDL_free(manager);
}

void host_manager_discovery_start(host_manager_t *manager) {
    IHS_ClientStartDiscovery(manager->client, 10000);
}

void host_manager_discovery_stop(host_manager_t *manager) {
    IHS_ClientStopDiscovery(manager->client);
}

array_list_t *host_manager_get_hosts(host_manager_t *manager) {
    return manager->hosts;
}

void host_manager_session_request(host_manager_t *manager, const IHS_HostInfo *host) {
    IHS_StreamingRequest request = {
            .audioChannelCount = 2,
            .streamingEnable.audio = true,
            .streamingEnable.video = true,
            .streamingEnable.input = true,
            .maxResolution.x = 1920,
            .maxResolution.y = 1080,
    };
    IHS_ClientStreamingRequest(manager->client, host, &request);
}

void host_manager_register_listener(host_manager_t *manager, const host_manager_listener_t *listener, void *context) {
    listeners_list_add(manager->listeners, listener, context);
}

void host_manager_unregister_listener(host_manager_t *manager, const host_manager_listener_t *listener) {
    listeners_list_remove(manager->listeners, listener);
}

void host_manager_authorization_request(host_manager_t *manager, const IHS_HostInfo *host, const char *pin) {
    IHS_ClientAuthorizationRequest(manager->client, host, pin);
}

bool host_manager_authorization_cancel(host_manager_t *manager) {
    return IHS_ClientAuthorizationCancel(manager->client);
}

static void client_host_discovered(IHS_Client *client, const IHS_HostInfo *host, void *context) {
    (void) client;
    host_manager_t *manager = context;
    IHS_HostInfo *host_copy = SDL_calloc(1, sizeof(IHS_HostInfo));
    *host_copy = *host;
    app_run_on_main(manager->app, client_host_discovered_main, host_copy);
}

static void client_authorization_success(IHS_Client *client, const IHS_HostInfo *host, uint64_t steamId,
                                         void *context) {
    (void) client;
    host_manager_t *manager = context;
    host_manager_authorization_result_t *result = SDL_calloc(1, sizeof(host_manager_authorization_result_t));
    result->host = *host;
    result->steam_id = steamId;
    app_run_on_main(manager->app, client_authorization_success_main, result);
}

static void client_authorization_failed(IHS_Client *client, const IHS_HostInfo *host, IHS_AuthorizationResult result,
                                        void *context) {
    (void) client;
    host_manager_t *manager = context;
    commons_log_error("Client", "Authorization failed: %u", result);
    host_manager_enum_error_t *error = SDL_calloc(1, sizeof(host_manager_enum_error_t));
    error->host = *host;
    error->result = result;
    app_run_on_main(manager->app, client_authorization_failed_main, error);
}

static void client_streaming_success(IHS_Client *client, const IHS_HostInfo *host, const IHS_SocketAddress *address,
                                     const uint8_t *sessionKey, size_t sessionKeyLen, void *context) {
    (void) client;
    host_manager_t *manager = context;
    host_manager_streaming_result_t *result = SDL_calloc(1, sizeof(host_manager_streaming_result_t));
    result->host = *host;
    result->session.address = *address;
    SDL_memcpy(result->session.sessionKey, sessionKey, sessionKeyLen);
    result->session.sessionKeyLen = sessionKeyLen;
    app_run_on_main(manager->app, client_streaming_success_main, result);
}

static void client_streaming_failed(IHS_Client *client, const IHS_HostInfo *host, IHS_StreamingResult result,
                                    void *context) {
    (void) client;
    host_manager_t *manager = context;
    commons_log_error("Client", "Failed to start streaming: %s", streaming_result_str(result));
    host_manager_enum_error_t *error = SDL_calloc(1, sizeof(host_manager_enum_error_t));
    error->host = *host;
    error->result = result;
    app_run_on_main(manager->app, client_streaming_failed_main, error);
}

static void client_host_discovered_main(app_t *app, void *data) {
    host_manager_t *manager = app->host_manager;
    IHS_HostInfo *host = data;
    IHS_HostInfo *info = NULL;
    array_list_t *hosts = manager->hosts;
    int insert_index = -1, update_index = -1;
    int old_size = array_list_size(hosts);
    for (int i = 0, j = old_size; i < j; ++i) {
        IHS_HostInfo *item = array_list_get(hosts, i);
        if (item->clientId == host->clientId) {
            info = item;
            update_index = i;
            break;
        } else if (compare_host_name(item, host) > 0) {
            if (insert_index == -1) {
                insert_index = i;
            }
        }
    }
    host_manager_hosts_change change_type;
    int change_index;
    if (info == NULL) {
        commons_log_debug("Hosts", "New host discovered: %s", host->hostname);
        info = array_list_add(hosts, insert_index);
        change_type = HOST_MANAGER_HOSTS_NEW;
        change_index = insert_index < 0 ? old_size : insert_index;
    } else {
        change_type = HOST_MANAGER_HOSTS_UPDATE;
        assert(update_index >= 0);
        change_index = update_index;
    }
    assert(info != NULL);
    *info = *host;
    SDL_free(host);

    listeners_list_notify(manager->listeners, host_manager_listener_t, hosts_changed, hosts, change_type,
                          change_index);
}

static void client_streaming_success_main(app_t *app, void *data) {
    host_manager_t *manager = app->host_manager;
    host_manager_streaming_result_t *result = data;

    listeners_list_notify(manager->listeners, host_manager_listener_t, session_started, &result->host, &result->session);
    SDL_free(result);
}

static void client_streaming_failed_main(app_t *app, void *data) {
    host_manager_t *manager = app->host_manager;
    host_manager_enum_error_t *error = data;

    listeners_list_notify(manager->listeners, host_manager_listener_t, session_start_failed, &error->host,
                          error->result);
    SDL_free(error);
}

static void client_authorization_success_main(app_t *app, void *data) {
    host_manager_t *manager = app->host_manager;
    host_manager_authorization_result_t *result = data;
    listeners_list_notify(manager->listeners, host_manager_listener_t, authorized, &result->host,
                          result->steam_id);
    SDL_free(result);

}

static void client_authorization_failed_main(app_t *app, void *data) {
    host_manager_t *manager = app->host_manager;
    host_manager_enum_error_t *error = data;

    listeners_list_notify(manager->listeners, host_manager_listener_t, authorization_failed, &error->host,
                          error->result);
    SDL_free(error);
}

static int compare_host_name(const void *a, const void *b) {
    const IHS_HostInfo *info1 = a;
    const IHS_HostInfo *info2 = b;
    return strncasecmp(info1->hostname, info2->hostname, 63);
}

================================================
FILE: app/backend/host_manager.h
================================================
#pragma once

#include <ihslib.h>

typedef struct app_t app_t;
typedef struct host_manager_t host_manager_t;
typedef struct array_list_t array_list_t;

typedef enum host_manager_hosts_change {
    HOST_MANAGER_HOSTS_NEW,
    HOST_MANAGER_HOSTS_UPDATE
} host_manager_hosts_change;

typedef struct host_manager_listener_t {
    void (*hosts_changed)(array_list_t *list, host_manager_hosts_change change, int index, void *context);

    void (*session_started)(const IHS_HostInfo *host, const IHS_SessionInfo *config, void *context);

    void (*session_start_failed)(const IHS_HostInfo *host, IHS_StreamingResult result, void *context);

    void (*authorized)(const IHS_HostInfo *host, uint64_t steam_id, void *context);

    void (*authorization_failed)(const IHS_HostInfo *host, IHS_AuthorizationResult result, void *context);
} host_manager_listener_t;

host_manager_t *host_manager_create(app_t *app);

void host_manager_destroy(host_manager_t *manager);

void host_manager_discovery_start(host_manager_t *manager);

void host_manager_discovery_stop(host_manager_t *manager);

array_list_t *host_manager_get_hosts(host_manager_t *manager);

void host_manager_session_request(host_manager_t *manager, const IHS_HostInfo *host);

void host_manager_register_listener(host_manager_t *manager, const host_manager_listener_t *listener, void *context);

void host_manager_unregister_listener(host_manager_t *manager, const host_manager_listener_t *listener);

void host_manager_authorization_request(host_manager_t *manager, const IHS_HostInfo *host, const char *pin);

bool host_manager_authorization_cancel(host_manager_t *manager);

================================================
FILE: app/backend/input_manager.c
================================================
#include "logging.h"
#include "input_manager.h"

#include <assert.h>

#include "ihslib/hid/sdl.h"

static void insert_controller(input_manager_t *manager, SDL_JoystickID id, SDL_GameController *controller);

static void remove_controller_at(input_manager_t *manager, size_t index);

static int manager_index(const input_manager_t *manager, SDL_JoystickID id);

static int js_count(void *context);

static int js_index(SDL_JoystickID instance_id, void *context);

static SDL_JoystickID js_instance_id(int index, void *context);

static SDL_GameController *js_controller(int index, void *context);

static int instance_id_compar(const void *id, const void *item);

static const IHS_HIDProviderSDLDeviceList hid_device_list = {
        .count = js_count,
        .index = js_index,
        .instanceId = js_instance_id,
        .controller = js_controller,
};

input_manager_t *input_manager_create() {
    input_manager_t *manager = calloc(1, sizeof(input_manager_t));
    array_list_init(&manager->controllers, sizeof(opened_controller_t), 8);
    manager->hid_provider = IHS_HIDProviderSDLCreateUnmanaged(&hid_device_list, manager);
    return manager;
}

void input_manager_destroy(input_manager_t *manager) {
    IHS_HIDProviderSDLDestroy(manager->hid_provider);
    for (int i = 0, j = array_list_size(&manager->controllers); i < j; i++) {
        opened_controller_t *controller = array_list_get(&manager->controllers, i);
        SDL_GameControllerClose(controller->controller);
    }
    array_list_deinit(&manager->controllers);
    free(manager);
}

IHS_HIDProvider *input_manager_get_hid_provider(input_manager_t *manager) {
    return manager->hid_provider;
}

void input_manager_sdl_gamepad_added(input_manager_t *manager, int which) {
    SDL_GameController *controller = SDL_GameControllerOpen(which);
    if (controller == NULL) {
        commons_log_error("Input", "Failed to open gamepad #%d: %s", which, SDL_GetError());
        return;
    }
    SDL_Joystick *joystick = SDL_GameControllerGetJoystick(controller);
    SDL_JoystickID id = SDL_JoystickInstanceID(joystick);
    insert_controller(manager, id, controller);
    commons_log_info("Input", "Gamepad #%d: %s added.", id, SDL_JoystickName(joystick));
}

void input_manager_sdl_gamepad_removed(input_manager_t *manager, SDL_JoystickID which) {
    commons_log_info("Input", "Removing gamepad, instance_id: #%d.", which);
    int index = manager_index(manager, which);
    assert(index >= 0);
    opened_controller_t *controller = array_list_get(&manager->controllers, index);
    SDL_GameControllerClose(controller->controller);
    remove_controller_at(manager, index);
    commons_log_info("Input", "Gamepad #%d removed.", which);
}

size_t input_manager_sdl_gamepad_count(const input_manager_t *manager) {
    return array_list_size(&manager->controllers);
}

void input_manager_ignore_next_mouse_movement(input_manager_t *manager) {
    manager->ignore_next_mouse_movement = true;
}

bool input_manager_get_and_reset_mouse_movement(input_manager_t *manager) {
    bool ignore = manager->ignore_next_mouse_movement;
    manager->ignore_next_mouse_movement = false;
    return ignore;
}

static void insert_controller(input_manager_t *manager, SDL_JoystickID id, SDL_GameController *controller) {
    int insert_after;
    for (insert_after = (int) (array_list_size(&manager->controllers) - 1); insert_after >= 0; insert_after--) {
        opened_controller_t *item = array_list_get(&manager->controllers, insert_after);
        if (id >= item->id) {
            break;
        }
    }
    opened_controller_t *new_item = array_list_add(&manager->controllers, insert_after + 1);
    new_item->id = id;
    new_item->controller = controller;
}

static void remove_controller_at(input_manager_t *manager, size_t index) {
    array_list_remove(&manager->controllers, (int) index);
}

static int manager_index(const input_manager_t *manager, SDL_JoystickID id) {
    return array_list_bsearch(&manager->controllers, &id, instance_id_compar);
}

static int js_count(void *context) {
    input_manager_t *manager = context;
    return (int) array_list_size(&manager->controllers);
}

static int js_index(SDL_JoystickID instance_id, void *context) {
    input_manager_t *manager = context;
    for (int i = 0, j = array_list_size(&manager->controllers); i < j; i++) {
        opened_controller_t *item = array_list_get(&manager->controllers, i);
        if (item->id == instance_id) {
            return i;
        }
    }
    return -1;
}

static SDL_JoystickID js_instance_id(int index, void *context) {
    input_manager_t *manager = context;
    opened_controller_t *item = array_list_get(&manager->controllers, index);
    if (item == NULL) {
        return -1;
    }
    return item->id;
}

static SDL_GameController *js_controller(int index, void *context) {
    input_manager_t *manager = context;
    opened_controller_t *item = array_list_get(&manager->controllers, index);
    if (item == NULL) {
        return NULL;
    }
    return item->controller;
}

static int instance_id_compar(const void *id, const void *item) {
    return *((SDL_JoystickID *) id) - ((const opened_controller_t *) item)->id;
}

================================================
FILE: app/backend/input_manager.h
================================================
#pragma once

#include <SDL2/SDL.h>
#include <stdbool.h>
#include "ihslib/hid/sdl.h"
#include "array_list.h"

typedef struct opened_controller_t {
    SDL_GameController *controller;
    SDL_JoystickID id;
} opened_controller_t;

typedef struct input_manager_t {
    array_list_t controllers;
    IHS_HIDProvider *hid_provider;
    bool ignore_next_mouse_movement;
} input_manager_t;

input_manager_t *input_manager_create();

void input_manager_destroy(input_manager_t *manager);

IHS_HIDProvider *input_manager_get_hid_provider(input_manager_t *manager);

void input_manager_sdl_gamepad_added(input_manager_t *manager, int which);

void input_manager_sdl_gamepad_removed(input_manager_t *manager, SDL_JoystickID which);

size_t input_manager_sdl_gamepad_count(const input_manager_t *manager);

/**
 * Tell the app to ignore next mouse movement, for manual moving the cursor position
 * @param manager
 */
void input_manager_ignore_next_mouse_movement(input_manager_t *manager);

bool input_manager_get_and_reset_mouse_movement(input_manager_t *manager);


================================================
FILE: app/backend/stream/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE stream_manager.c stream_media.c stream_input.c)

================================================
FILE: app/backend/stream/stream_input.c
================================================
#include "app.h"
#include "ui/app_ui.h"

#include "stream_input.h"
#include "stream_manager_internal.h"
#include "backend/input_manager.h"

bool stream_input_handle_key_event(stream_manager_t *manager, const SDL_KeyboardEvent *event) {
#ifdef __WEBOS__
    SDL_Keysym keysym = event->keysym;
    switch ((int) keysym.scancode) {
        case SDL_SCANCODE_WEBOS_EXIT: {
            if (event->state == SDL_RELEASED) {
                stream_manager_set_overlay_opened(manager, true);
            }
            return true;
        }
        case SDL_SCANCODE_WEBOS_BACK: {
            // TODO: Send ESC key
            return true;
        }
    }
#endif
    if (event->keysym.sym == SDLK_ESCAPE) {
        if (event->state == SDL_RELEASED) {
            stream_manager_set_overlay_opened(manager, true);
        }
        return true;
    }
    if (!manager->app->settings->enable_input) {
        return true;
    }
    if (event->state == SDL_PRESSED) {
        IHS_SessionSendKeyDown(manager->session, event->keysym.scancode);
    } else {
        IHS_SessionSendKeyUp(manager->session, event->keysym.scancode);
    }
    return true;
}

bool stream_input_handle_mouse_event(stream_manager_t *manager, const SDL_Event *event) {
    if (!manager->app->settings->enable_input) {
        return true;
    }
    switch (event->type) {
        case SDL_MOUSEMOTION: {
            if (input_manager_get_and_reset_mouse_movement(manager->app->input_manager)) {
                break;
            }
            if (manager->app->settings->relmouse) {
                IHS_SessionSendMouseMovement(manager->session, event->motion.xrel, event->motion.yrel);
            } else {
                int w, h;
                SDL_GetWindowSize(manager->app->ui->window, &w, &h);
                IHS_SessionSendMousePosition(manager->session, (float) event->motion.x / (float) w,
                                             (float) event->motion.y / (float) h);
            }
            return true;
        }
        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP: {
            IHS_StreamInputMouseButton button = 0;
            switch (event->button.button) {
                case SDL_BUTTON_LEFT:
                    button = IHS_MOUSE_BUTTON_LEFT;
                    break;
                case SDL_BUTTON_RIGHT:
                    button = IHS_MOUSE_BUTTON_RIGHT;
                    break;
                case SDL_BUTTON_MIDDLE:
                    button = IHS_MOUSE_BUTTON_MIDDLE;
                    break;
                case SDL_BUTTON_X1:
                    button = IHS_MOUSE_BUTTON_X1;
                    break;
                case SDL_BUTTON_X2:
                    button = IHS_MOUSE_BUTTON_X2;
                    break;
            }
            if (button != 0) {
                if (event->button.state == SDL_RELEASED) {
                    IHS_SessionSendMouseUp(manager->session, button);
                } else {
                    IHS_SessionSendMouseDown(manager->session, button);
                }
            }
            return true;
        }
        case SDL_MOUSEWHEEL: {
            Sint32 x = event->wheel.x, y = event->wheel.y;
            if (event->wheel.direction == SDL_MOUSEWHEEL_FLIPPED) {
                x *= -1;
                y *= -1;
            }
            if (x != 0) {
                IHS_SessionSendMouseWheel(manager->session, x < 0 ? IHS_MOUSE_WHEEL_LEFT : IHS_MOUSE_WHEEL_RIGHT);
            }
            if (y != 0) {
                IHS_SessionSendMouseWheel(manager->session, y > 0 ? IHS_MOUSE_WHEEL_UP : IHS_MOUSE_WHEEL_DOWN);
            }
            return true;
        }
    }
    return false;
}

================================================
FILE: app/backend/stream/stream_input.h
================================================
#pragma once

#include "stream_manager.h"

bool stream_input_handle_key_event(stream_manager_t *manager, const SDL_KeyboardEvent *event);

bool stream_input_handle_mouse_event(stream_manager_t *manager, const SDL_Event *event);


================================================
FILE: app/backend/stream/stream_manager.c
================================================
#include <assert.h>
#include "stream_manager.h"
#include "stream_manager_internal.h"

#include "app.h"
#include "ui/app_ui.h"
#include "util/listeners_list.h"

#include "ihslib/hid/sdl.h"

#include "ss4s.h"

#include "stream_media.h"
#include "stream_input.h"

#include "backend/input_manager.h"
#include "logging.h"

static void session_initialized(IHS_Session *session, void *context);

static void session_finalized(IHS_Session *session, void *context);

static void session_configuring(IHS_Session *session, IHS_SessionConfig *config, void *context);

static void session_connected(IHS_Session *session, void *context);

static void session_disconnected(IHS_Session *session, void *context);

static void session_show_cursor(IHS_Session *session, float x, float y, void *context);

// Main thread callbacks

static void session_connected_main(app_t *app, void *context);

static void session_disconnected_main(app_t *app, void *context);

static void session_show_cursor_main(app_t *app, void *context);

static void destroy_session_main(app_t *app, void *context);

static void controller_back_pressed(stream_manager_t *manager);

static void controller_back_released(stream_manager_t *manager);

static Uint32 back_timer_callback(Uint32 duration, void *param);

static void back_timer_progress_main(app_t *app, void *context);

static void back_timer_finish_main(app_t *app, void *context);

static void grab_mouse(stream_manager_t *manager, bool grab);

#define BACK_COUNTER_MAX 100

typedef struct event_context_t {
    stream_manager_t *manager;
    void *arg1;
    uint32_t value1;
} event_context_t;

static const IHS_StreamSessionCallbacks session_callbacks = {
        .initialized = session_initialized,
        .configuring = session_configuring,
        .connected = session_connected,
        .disconnected = session_disconnected,
        .finalized = session_finalized,
};

static const IHS_StreamInputCallbacks input_callbacks = {
        .showCursor = session_show_cursor,
//        .hideCursor = session_hide_cursor,
//        .setCursor = session_set_cursor,
//        .cursorImage = session_cursor_image,
};

stream_manager_t *stream_manager_create(app_t *app) {
    assert(app->input_manager != NULL);
    stream_manager_t *manager = calloc(1, sizeof(stream_manager_t));
    manager->app = app;
    manager->listeners = listeners_list_create();
    return manager;
}

void stream_manager_destroy(stream_manager_t *manager) {
    switch (manager->state) {
        case STREAM_MANAGER_STATE_IDLE: {
            break;
        }
        default: {
            destroy_session_main(manager->app, manager->session);
            break;
        }
    }
    listeners_list_destroy(manager->listeners);
    free(manager);
}

void stream_manager_register_listener(stream_manager_t *manager, const stream_manager_listener_t *listener,
                                      void *context) {
    listeners_list_add(manager->listeners, listener, context);
}

void stream_manager_unregister_listener(stream_manager_t *manager, const stream_manager_listener_t *listener) {
    listeners_list_remove(manager->listeners, listener);
}

bool stream_manager_start_session(stream_manager_t *manager, const IHS_SessionInfo *info) {
    app_assert_main_thread(manager->app);
    if (manager->state != STREAM_MANAGER_STATE_IDLE) {
        return false;
    }
    // Reset all states for last session
    manager->back_counter = 0;
    manager->back_timer = 0;
    manager->overlay_opened = false;
    manager->requested_disconnect = false;

    stream_media_session_t *media = stream_media_create(manager);
    manager->media = media;
    IHS_Session *session = IHS_SessionCreate(&manager->app->client_info.config, info);
    IHS_SessionSetLogFunction(session, app_ihs_log);
    IHS_SessionSetSessionCallbacks(session, &session_callbacks, manager);
    IHS_SessionSetInputCallbacks(session, &input_callbacks, manager);
    IHS_SessionSetAudioCallbacks(session, stream_media_audio_callbacks(), media);
    IHS_SessionSetVideoCallbacks(session, stream_media_video_callbacks(), media);
    IHS_SessionHIDAddProvider(session, input_manager_get_hid_provider(manager->app->input_manager));
    manager->state = STREAM_MANAGER_STATE_CONNECTING;
    commons_log_info("StreamManager", "Change state to CONNECTING");
    manager->session = session;

    stream_media_set_viewport_size(media, manager->viewport_width, manager->viewport_height);
    stream_media_set_overlay_height(media, manager->overlay_height);

    IHS_SessionConnect(session);
    return true;
}

IHS_Session *stream_manager_active_session(const stream_manager_t *manager) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        return NULL;
    }
    return manager->session;
}

void stream_manager_stop_active(stream_manager_t *manager) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        return;
    }
    manager->requested_disconnect = true;
    IHS_SessionDisconnect(manager->session);
}

bool stream_manager_intercept_event(const stream_manager_t *manager, const SDL_Event *event) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        // Ignore events when idle
        return false;
    }
    if (manager->overlay_opened) {
        // No input event should be handled when overlay opened
        return false;
    }
    switch (event->type) {
        // Following events MUST be handled by the app too
        case SDL_CONTROLLERDEVICEADDED:
        case SDL_CONTROLLERDEVICEREMOVED:
        case SDL_CONTROLLERDEVICEREMAPPED:
            return false;
    }
    return true;
}

void stream_manager_handle_event(stream_manager_t *manager, const SDL_Event *event) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        return;
    }
    if (manager->overlay_opened) {
        switch (event->type) {
            // Following events be always handled by IHS, even with overlay opened
            case SDL_CONTROLLERDEVICEADDED:
            case SDL_CONTROLLERDEVICEREMOVED:
            case SDL_CONTROLLERDEVICEREMAPPED:
                break;
            default:
                return;
        }
    }
    switch (event->type) {
        case SDL_KEYDOWN:
        case SDL_KEYUP: {
            // Keyboard events
            stream_input_handle_key_event(manager, &event->key);
            break;
        }
        case SDL_MOUSEMOTION:
        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
        case SDL_MOUSEWHEEL: {
            stream_input_handle_mouse_event(manager, event);
            break;
        }
        case SDL_CONTROLLERBUTTONDOWN: {
            if (event->cbutton.button == SDL_CONTROLLER_BUTTON_BACK) {
                controller_back_pressed(manager);
            }
            break;
        }
        case SDL_CONTROLLERBUTTONUP: {
            if (event->cbutton.button == SDL_CONTROLLER_BUTTON_BACK) {
                controller_back_released(manager);
            }
            break;
        }
    }
    if (manager->app->settings->enable_input) {
        IHS_HIDHandleSDLEvent(manager->session, event);
    }
}

void stream_manager_set_viewport_size(stream_manager_t *manager, int width, int height) {
    manager->viewport_width = width;
    manager->viewport_height = height;
    if (manager->media != NULL) {
        stream_media_set_viewport_size(manager->media, width, height);
    }
}

bool stream_manager_is_overlay_opened(const stream_manager_t *manager) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        return false;
    }
    return manager->overlay_opened;
}

void stream_manager_set_overlay_height(stream_manager_t *manager, int height) {
    manager->overlay_height = height;
    if (manager->media != NULL) {
        stream_media_set_overlay_height(manager->media, height);
    }
}

bool stream_manager_set_overlay_opened(stream_manager_t *manager, bool opened) {
    app_assert_main_thread(manager->app);
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        return false;
    }
    manager->overlay_opened = opened;
    stream_media_set_overlay_shown(manager->media, opened);
    if (opened) {
        app_post_event(manager->app, APP_UI_REQUEST_OVERLAY, NULL, NULL);
    } else {
        app_post_event(manager->app, APP_UI_CLOSE_OVERLAY, NULL, NULL);
    }
    grab_mouse(manager, !opened);
    return true;
}

void stream_manager_set_capture_size(stream_manager_t *manager, int width, int height) {
    manager->capture_width = width;
    manager->capture_height = height;
}

bool stream_manager_is_active(const stream_manager_t *manager) {
    return manager->state == STREAM_MANAGER_STATE_STREAMING;
}

static void session_initialized(IHS_Session *session, void *context) {
    stream_manager_t *manager = (stream_manager_t *) context;
    assert (manager->state == STREAM_MANAGER_STATE_CONNECTING);
    IHS_SessionConnect(session);
}

static void session_finalized(IHS_Session *session, void *context) {
    stream_manager_t *manager = (stream_manager_t *) context;
    assert(manager->state == STREAM_MANAGER_STATE_DISCONNECTING);
    assert(manager->session == session);
    manager->state = STREAM_MANAGER_STATE_IDLE;
    commons_log_info("StreamManager", "Change state to IDLE");
    app_run_on_main(manager->app, destroy_session_main, session);
}

static void session_configuring(IHS_Session *session, IHS_SessionConfig *config, void *context) {
    (void) session;
    stream_manager_t *manager = (stream_manager_t *) context;
    assert (manager->media != NULL);
    config->enableHevc = stream_media_supports_hevc(manager->media);
}

static void session_connected(IHS_Session *session, void *context) {
    stream_manager_t *manager = (stream_manager_t *) context;
    assert(manager->state == STREAM_MANAGER_STATE_CONNECTING);
    assert(manager->session == session);
    manager->state = STREAM_MANAGER_STATE_STREAMING;
    commons_log_info("StreamManager", "Change state to STREAMING");
    event_context_t ec = {
            .manager = manager,
            .arg1 = (void *) IHS_SessionGetInfo(session),
    };
    app_run_on_main_sync(manager->app, session_connected_main, &ec);
    if (manager->app->settings->enable_input) {
        IHS_SessionHIDNotifyDeviceChange(session);
    }
}

static void session_disconnected(IHS_Session *session, void *context) {
    stream_manager_t *manager = (stream_manager_t *) context;
    assert(manager->state != STREAM_MANAGER_STATE_DISCONNECTING);
    assert(manager->session == session);
    if (manager->back_timer != 0) {
        SDL_RemoveTimer(manager->back_timer);
        manager->back_timer = 0;
    }
    bool requested = manager->requested_disconnect;
    manager->state = STREAM_MANAGER_STATE_DISCONNECTING;
    commons_log_info("StreamManager", "Change state to DISCONNECTING");
    event_context_t ec = {
            .manager = manager,
            .arg1 = (void *) IHS_SessionGetInfo(session),
            .value1 = requested
    };
    app_run_on_main_sync(manager->app, session_disconnected_main, &ec);
}

static void session_show_cursor(IHS_Session *session, float x, float y, void *context) {
    (void) session;
    stream_manager_t *manager = (stream_manager_t *) context;
    if (manager->capture_width <= 0 && manager->capture_height <= 0 || manager->viewport_width <= 0 ||
        manager->viewport_height <= 0) {
        return;
    }
    if (stream_manager_is_overlay_opened(manager)) {
        return;
    }
    float scale = SDL_min((float) manager->viewport_width / manager->capture_width,
                          (float) manager->viewport_height / manager->capture_height);
    float dst_width = (float) manager->capture_width * scale, dst_height = (float) manager->capture_height * scale;
    SDL_Point *point = calloc(1, sizeof(SDL_Point));
    point->x = (int) (((float) manager->viewport_width - dst_width) / 2.0f + dst_width * x);
    point->y = (int) (((float) manager->viewport_height - dst_height) / 2.0f + dst_height * y);
    app_run_on_main(manager->app, session_show_cursor_main, point);
}

static void session_connected_main(app_t *app, void *context) {
    (void) app;
    event_context_t *ec = context;
    stream_manager_t *manager = ec->manager;
    listeners_list_notify(manager->listeners, stream_manager_listener_t, connected, (const IHS_SessionInfo *) ec->arg1);
    grab_mouse(manager, true);
}

static void session_disconnected_main(app_t *app, void *context) {
    (void) app;
    event_context_t *ec = context;
    stream_manager_t *manager = ec->manager;
    grab_mouse(manager, false);
    listeners_list_notify(manager->listeners, stream_manager_listener_t, disconnected,
                          (const IHS_SessionInfo *) ec->arg1, ec->value1);
}

static void session_show_cursor_main(app_t *app, void *context) {
    stream_manager_t *manager = app->stream_manager;
    SDL_Point *point = context;
    input_manager_ignore_next_mouse_movement(manager->app->input_manager);
//    SDL_WarpMouseInWindow(app->ui->window, point->x, point->y);
    free(context);
}

static void destroy_session_main(app_t *app, void *context) {
    (void) app;
    IHS_Session *session = context;
    IHS_SessionThreadedJoin(session);
    IHS_SessionDestroy(session);
    stream_media_destroy(app->stream_manager->media);
    app->stream_manager->media = NULL;
}

static void controller_back_pressed(stream_manager_t *manager) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING || manager->back_timer != 0) {
        return;
    }
    manager->back_counter = 0;
    manager->back_timer = SDL_AddTimer(300, back_timer_callback, manager);
}

static void controller_back_released(stream_manager_t *manager) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING || manager->back_timer == 0) {
        return;
    }
    SDL_RemoveTimer(manager->back_timer);
    manager->back_timer = 0;
    commons_log_info("Streaming", "Overlay timer cancelled");
    // This function is expected to be called in main thread.
    app_assert_main_thread(manager->app);
    listeners_list_notify(manager->listeners, stream_manager_listener_t, overlay_progress_finished, false);
}

static void grab_mouse(stream_manager_t *manager, bool grab) {
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        SDL_SetRelativeMouseMode(SDL_FALSE);
        return;
    }
    SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE);
}


static Uint32 back_timer_callback(Uint32 duration, void *param) {
    (void) duration;
    stream_manager_t *manager = (stream_manager_t *) param;
    if (manager->state != STREAM_MANAGER_STATE_STREAMING) {
        return 0;
    }
    manager->back_counter += 1;
    if (manager->back_counter >= BACK_COUNTER_MAX) {
        manager->back_timer = 0;
        manager->back_counter = 0;
        IHS_HIDResetSDLGameControllers(manager->session);
        commons_log_info("Streaming", "Requesting overlay");
        app_run_on_main(manager->app, back_timer_finish_main, manager);
        return 0;
    } else {
        app_run_on_main(manager->app, back_timer_progress_main, manager);
    }
    return 16;
}

static void back_timer_progress_main(app_t *app, void *context) {
    (void) app;
    stream_manager_t *manager = (stream_manager_t *) context;
    listeners_list_notify(manager->listeners, stream_manager_listener_t, overlay_progress, manager->back_counter);
}

static void back_timer_finish_main(app_t *app, void *context) {
    (void) app;
    stream_manager_t *manager = (stream_manager_t *) context;
    stream_manager_set_overlay_opened(manager, true);
    listeners_list_notify(manager->listeners, stream_manager_listener_t, overlay_progress_finished, true);
}

================================================
FILE: app/backend/stream/stream_manager.h
================================================
#pragma once

#include "ihslib.h"

#include <SDL.h>

typedef struct app_t app_t;
typedef struct host_manager_t host_manager_t;

typedef struct stream_manager_t stream_manager_t;

typedef struct stream_manager_callbacks_t {
    void (*connected)(const IHS_SessionInfo *info, void *context);

    void (*disconnected)(const IHS_SessionInfo *info, bool requested, void *context);

    void (*overlay_progress)(int percentage, void *context);

    void (*overlay_progress_finished)(bool requested, void *context);
} stream_manager_listener_t;

stream_manager_t *stream_manager_create(app_t *app);

void stream_manager_destroy(stream_manager_t *manager);

void stream_manager_register_listener(stream_manager_t *manager, const stream_manager_listener_t *listener,
                                      void *context);

void stream_manager_unregister_listener(stream_manager_t *manager, const stream_manager_listener_t *listener);

bool stream_manager_start_session(stream_manager_t *manager, const IHS_SessionInfo *info);

IHS_Session *stream_manager_active_session(const stream_manager_t *manager);

void stream_manager_stop_active(stream_manager_t *manager);

/**
 * Check if an event should only be dispatched to stream manager. This method call should not change any state
 * @return true if the event should only be processed by this manager
 */
bool stream_manager_intercept_event(const stream_manager_t *manager, const SDL_Event *event);

void stream_manager_handle_event(stream_manager_t *manager, const SDL_Event *event);

void stream_manager_set_viewport_size(stream_manager_t *manager, int width, int height);

bool stream_manager_is_overlay_opened(const stream_manager_t *manager);

void stream_manager_set_overlay_height(stream_manager_t *manager, int height);

bool stream_manager_set_overlay_opened(stream_manager_t *manager, bool opened);

void stream_manager_set_capture_size(stream_manager_t *manager, int width, int height);

bool stream_manager_is_active(const stream_manager_t *manager);

================================================
FILE: app/backend/stream/stream_manager_internal.h
================================================
#pragma once

#include "stream_manager.h"
#include "stream_media.h"

#include "array_list.h"

typedef enum stream_manager_state_t {
    STREAM_MANAGER_STATE_IDLE,
    STREAM_MANAGER_STATE_CONNECTING,
    STREAM_MANAGER_STATE_STREAMING,
    STREAM_MANAGER_STATE_DISCONNECTING,
} stream_manager_state_t;

struct stream_manager_t {
    app_t *app;
    array_list_t *listeners;

    stream_manager_state_t state;

    stream_media_session_t *media;
    IHS_Session *session;
    SDL_TimerID back_timer;
    int back_counter;
    bool overlay_opened;
    bool requested_disconnect;

    int viewport_width, viewport_height;
    int capture_width, capture_height;
    int overlay_height;
};


================================================
FILE: app/backend/stream/stream_media.c
================================================
#include <stdlib.h>
#include "stream_media.h"

#include "ss4s.h"
#include "stream_manager.h"
#include "app.h"
#include "logging.h"
#include "util/video/sps/include/sps_util.h"

#include <opus_multistream.h>
#include <SDL2/SDL.h>

struct stream_media_session_t {
    stream_manager_t *manager;
    SDL_mutex *lock;
    SS4S_Player *player;
    SS4S_VideoCapabilities video_cap;

    SS4S_VideoInfo video_info;
    OpusMSDecoder *opus_decoder;
    size_t pcm_unit_size;
    int16_t *pcm_buffer;

    int pcm_buffer_size;
    int viewport_width, viewport_height;
    int overlay_height;
};

static int audio_start(IHS_Session *session, const IHS_StreamAudioConfig *config, void *context);

static void audio_stop(IHS_Session *session, void *context);

static int audio_submit(IHS_Session *session, IHS_Buffer *data, void *context);

static int video_start(IHS_Session *session, const IHS_StreamVideoConfig *config, void *context);

static void video_stop(IHS_Session *session, void *context);

static int video_submit(IHS_Session *session, IHS_Buffer *data, IHS_StreamVideoFrameFlag flags, void *context);

static int video_set_capture_size(IHS_Session *session, int width, int height, void *context);

static const IHS_StreamAudioCallbacks audio_callbacks = {
        .start = audio_start,
        .stop = audio_stop,
        .submit = audio_submit,
};

static const IHS_StreamVideoCallbacks video_callbacks = {
        .start = video_start,
        .stop = video_stop,
        .submit = video_submit,
        .setCaptureSize = video_set_capture_size,
};

stream_media_session_t *stream_media_create(stream_manager_t *manager) {
    stream_media_session_t *media_session = calloc(1, sizeof(stream_media_session_t));
    media_session->manager = manager;
    media_session->lock = SDL_CreateMutex();
    media_session->player = SS4S_PlayerOpen();
    SS4S_PlayerSetWaitAudioVideoReady(media_session->player, true);

    SS4S_GetVideoCapabilities(&media_session->video_cap);
    return media_session;
}

void stream_media_destroy(stream_media_session_t *media_session) {
    SS4S_PlayerClose(media_session->player);
    SDL_DestroyMutex(media_session->lock);
    free(media_session);
}

void stream_media_set_viewport_size(stream_media_session_t *media_session, int width, int height) {
    SDL_LockMutex(media_session->lock);
    media_session->viewport_width = width;
    media_session->viewport_height = height;
    SDL_UnlockMutex(media_session->lock);
}

void stream_media_set_overlay_height(stream_media_session_t *media_session, int height) {
    SDL_LockMutex(media_session->lock);
    media_session->overlay_height = height;
    SDL_UnlockMutex(media_session->lock);
}

void stream_media_set_overlay_shown(stream_media_session_t *media_session, bool overlay) {
    if (media_session->video_cap.transform & SS4S_VIDEO_CAP_TRANSFORM_UI_COMPOSITING) {
        return;
    }
    if (overlay) {
        SDL_LockMutex(media_session->lock);
        int ui_width = media_session->viewport_width, ui_height = media_session->viewport_height,
                overlay_height = media_session->overlay_height;
        if (ui_width <= 0 || ui_height <= 0 || overlay_height <= 0) {
            SDL_UnlockMutex(media_session->lock);
            return;
        }
        SS4S_VideoRect src = {
                .x = 0, .y = 0,
                .width = media_session->video_info.width,
                .height = media_session->video_info.height * (ui_height - overlay_height) / ui_height
        };
        SDL_UnlockMutex(media_session->lock);

        SS4S_VideoRect dest = {0, 0, ui_width, ui_height - overlay_height};
        SS4S_PlayerVideoSetDisplayArea(media_session->player, &src, &dest);
    } else {
        SS4S_PlayerVideoSetDisplayArea(media_session->player, NULL, NULL);
    }
}

bool stream_media_supports_hevc(stream_media_session_t *media_session) {
    return media_session->video_cap.codecs & SS4S_VIDEO_H265;
}

const IHS_StreamAudioCallbacks *stream_media_audio_callbacks() {
    return &audio_callbacks;
}

const IHS_StreamVideoCallbacks *stream_media_video_callbacks() {
    return &video_callbacks;
}

static int audio_start(IHS_Session *session, const IHS_StreamAudioConfig *config, void *context) {
    (void) session;
    commons_log_info("Media", "Audio start. codec=%u, channels=%u, sampleRate=%u", config->codec,
                     config->channels, config->frequency);
    if (config->codec != IHS_StreamAudioCodecOpus) {
        return -1;
    }
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    SDL_LockMutex(media_session->lock);
    int rc;
    unsigned char mapping[2] = {0, 1};
    const int samples_per_frame = 240;
    media_session->pcm_buffer_size = samples_per_frame * 64;
    media_session->pcm_unit_size = config->channels * sizeof(int16_t);

    media_session->opus_decoder = opus_multistream_decoder_create(config->frequency, config->channels,
                                                                  1, 1, mapping, &rc);
    media_session->pcm_buffer = calloc(media_session->pcm_unit_size, media_session->pcm_buffer_size);
    SS4S_AudioInfo info = {
            .codec = SS4S_AUDIO_PCM_S16LE,
            .numOfChannels = (int) config->channels,
            .sampleRate = (int) config->frequency,
            .samplesPerFrame = samples_per_frame,
            .appName = "IHSplay",
            .streamName = "Streaming",
    };
    SDL_UnlockMutex(media_session->lock);
    return SS4S_PlayerAudioOpen(media_session->player, &info);
}

static void audio_stop(IHS_Session *session, void *context) {
    (void) session;
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    SS4S_PlayerAudioClose(media_session->player);
    opus_multistream_decoder_destroy(media_session->opus_decoder);
    free(media_session->pcm_buffer);
}

static int audio_submit(IHS_Session *session, IHS_Buffer *data, void *context) {
    (void) session;
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    int decode_len = opus_multistream_decode(media_session->opus_decoder, data->data + data->offset, data->size,
                                             media_session->pcm_buffer, media_session->pcm_buffer_size, 0);
    return SS4S_PlayerAudioFeed(media_session->player, (const unsigned char *) media_session->pcm_buffer,
                                media_session->pcm_unit_size * decode_len);
}

static int video_start(IHS_Session *session, const IHS_StreamVideoConfig *config, void *context) {
    (void) session;
    SS4S_VideoCodec codec;
    switch (config->codec) {
        case IHS_StreamVideoCodecH264:
            codec = SS4S_VIDEO_H264;
            break;
        case IHS_StreamVideoCodecHEVC:
            codec = SS4S_VIDEO_H265;
            break;
        default:
            return -1;
    }
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    SDL_LockMutex(media_session->lock);
    commons_log_info("Media", "Video start. codec=%u, width=%u, height=%u", config->codec, config->width,
                     config->height);
    SS4S_VideoInfo info = {
            .codec = codec,
            .width = (int) config->width,
            .height = (int) config->height,
    };
    media_session->video_info = info;
    SDL_UnlockMutex(media_session->lock);
    return SS4S_PlayerVideoOpen(media_session->player, &info);
}

static void video_stop(IHS_Session *session, void *context) {
    (void) session;
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    SS4S_PlayerVideoClose(media_session->player);
}

static int video_submit(IHS_Session *session, IHS_Buffer *data, IHS_StreamVideoFrameFlag flags, void *context) {
    (void) session;
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    SS4S_VideoFeedFlags sflgs = 0;
    if (flags & IHS_StreamVideoFrameKeyFrame) {
        SDL_LockMutex(media_session->lock);
        sflgs = SS4S_VIDEO_FEED_DATA_KEYFRAME;
        sps_dimension_t dimension = {0, 0};
        bool dimension_parsed = false;
        switch (media_session->video_info.codec) {
            case SS4S_VIDEO_H264: {
                dimension_parsed = sps_util_parse_dimension_h264(IHS_BufferPointer(data), data->size, &dimension);
                break;
            }
            case SS4S_VIDEO_H265: {
                dimension_parsed = sps_util_parse_dimension_hevc(IHS_BufferPointer(data), data->size, &dimension);
                break;
            }
            default: {
                commons_log_fatal("Media", "Unexpected video codec %s!!",
                                  SS4S_VideoCodecName(media_session->video_info.codec));
                abort();
            }
        }
        if (!dimension_parsed) {
            commons_log_warn("Media", "Can't parse NAL Unit.");
            commons_log_hexdump(COMMONS_LOG_LEVEL_WARN, "Media", IHS_BufferPointer(data), data->size);
        }
        if (dimension_parsed && (dimension.width != media_session->video_info.width ||
                                 dimension.height != media_session->video_info.height)) {
            commons_log_info("Media", "Size change detected by NAL header. (%d*%d)=>(%d*%d)",
                             media_session->video_info.width, media_session->video_info.height, dimension.width,
                             dimension.height);
            media_session->video_info.width = dimension.width;
            media_session->video_info.height = dimension.height;
            SS4S_PlayerVideoSizeChanged(media_session->player, dimension.width, dimension.height);
        }
        SDL_UnlockMutex(media_session->lock);
    }
    return SS4S_PlayerVideoFeed(media_session->player, data->data + data->offset, data->size, sflgs);
}

static int video_set_capture_size(IHS_Session *session, int width, int height, void *context) {
    (void) session;
    stream_media_session_t *media_session = (stream_media_session_t *) context;
    stream_manager_set_capture_size(media_session->manager, width, height);
    return 0;
}

================================================
FILE: app/backend/stream/stream_media.h
================================================
#pragma once

#include "ihslib.h"

typedef struct stream_media_session_t stream_media_session_t;
typedef struct stream_manager_t stream_manager_t;

stream_media_session_t *stream_media_create(stream_manager_t *manager);

void stream_media_destroy(stream_media_session_t *media);

void stream_media_set_viewport_size(stream_media_session_t *media_session, int width, int height);

void stream_media_set_overlay_height(stream_media_session_t *media_session, int height);

void stream_media_set_overlay_shown(stream_media_session_t *media_session, bool overlay);
bool stream_media_supports_hevc(stream_media_session_t *media_session);

const IHS_StreamAudioCallbacks *stream_media_audio_callbacks();

const IHS_StreamVideoCallbacks *stream_media_video_callbacks();

================================================
FILE: app/backend/stream_manager.h
================================================
#pragma once

#include "stream/stream_manager.h"

================================================
FILE: app/config.h.in
================================================
#pragma once

#define IHSPLAY_VERSION_STRING "@PROJECT_VERSION@"
#define SS4S_MODULES_INI_PATH "@SS4S_MODULES_INI_PATH_RUNTIME@"
#cmakedefine01 IHSPLAY_IS_DEBUG
#cmakedefine01 IHSPLAY_WIP_FEATURES
#cmakedefine01 IHSPLAY_FEATURE_FORCE_FULLSCREEN
#cmakedefine01 IHSPLAY_FEATURE_LIBCEC

================================================
FILE: app/lvgl/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE
        display.c
        mouse.c
        keypad.c
        theme.c)

add_subdirectory(ext)

================================================
FILE: app/lvgl/display.c
================================================
#include "display.h"

#include <src/draw/sdl/lv_draw_sdl.h>
#include <assert.h>

static void flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *src);

lv_disp_t *app_lv_disp_init(SDL_Window *window) {
    int width, height;
    SDL_GetWindowSize(window, &width, &height);
    assert(width > 0 || height > 0);
    SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
    SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    lv_disp_draw_buf_t *draw_buf = malloc(sizeof(lv_disp_draw_buf_t));
    SDL_Texture *texture = lv_draw_sdl_create_screen_texture(renderer, width, height);
    lv_disp_draw_buf_init(draw_buf, texture, NULL, width * height);
    lv_disp_drv_t *driver = malloc(sizeof(lv_disp_drv_t));
    lv_disp_drv_init(driver);

    lv_draw_sdl_drv_param_t *param = lv_mem_alloc(sizeof(lv_draw_sdl_drv_param_t));
    param->renderer = renderer;
    param->user_data = window;
    driver->user_data = param;
    driver->draw_buf = draw_buf;
    driver->dpi = (int) (width / 5.333333);
    driver->flush_cb = flush_cb;
    driver->hor_res = width;
    driver->ver_res = height;
    SDL_SetRenderTarget(renderer, texture);
    lv_disp_t *disp = lv_disp_drv_register(driver);
    disp->bg_color = lv_color_black();
    disp->bg_opa = LV_OPA_TRANSP;
    return disp;
}

void app_lv_disp_deinit(lv_disp_t *disp) {
    lv_disp_drv_t *drv = disp->driver;

    lv_draw_ctx_t *draw_ctx = drv->draw_ctx;
    drv->draw_ctx_deinit(drv, draw_ctx);
    free(draw_ctx);

    lv_disp_draw_buf_t *draw_buf = drv->draw_buf;
    SDL_DestroyTexture(draw_buf->buf1);
    free(draw_buf);

    lv_draw_sdl_drv_param_t *param = drv->user_data;
    SDL_DestroyRenderer(param->renderer);
    free(param);

    // Set act_scr to NULL to suppress warning when we remove the display
    disp->act_scr = NULL;

    lv_disp_remove(disp);

    free(drv);
}

static void flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *src) {
    LV_UNUSED(src);
    if (area->x2 < 0 || area->y2 < 0 ||
        area->x1 > disp_drv->hor_res - 1 || area->y1 > disp_drv->ver_res - 1) {
        lv_disp_flush_ready(disp_drv);
        return;
    }

    if (lv_disp_flush_is_last(disp_drv)) {
        lv_draw_sdl_drv_param_t *param = disp_drv->user_data;
        SDL_Renderer *renderer = param->renderer;
        SDL_Texture *texture = disp_drv->draw_buf->buf1;
        SDL_SetRenderTarget(renderer, NULL);
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
        SDL_RenderClear(renderer);
        SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
        SDL_RenderCopy(renderer, texture, NULL, NULL);
        SDL_RenderPresent(renderer);
        SDL_SetRenderTarget(renderer, texture);
    }
    lv_disp_flush_ready(disp_drv);
}

================================================
FILE: app/lvgl/display.h
================================================
#pragma once

#include <lvgl.h>
#include <SDL.h>

lv_disp_t *app_lv_disp_init(SDL_Window *window);

void app_lv_disp_deinit(lv_disp_t *disp);


================================================
FILE: app/lvgl/ext/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE lv_child_group.c msgbox_ext.c lv_dir_focus.c)

================================================
FILE: app/lvgl/ext/lv_child_group.c
================================================
#include "lv_child_group.h"

void cb_child_group_add(lv_event_t *event) {
    lv_obj_t *child = lv_event_get_param(event);
    if (!child || !lv_obj_is_group_def(child)) return;
    lv_group_t *group = lv_event_get_user_data(event);
    if (lv_obj_get_group(child)) {
        lv_group_remove_obj(child);
    }
    lv_group_add_obj(group, child);
}

================================================
FILE: app/lvgl/ext/lv_child_group.h
================================================
#pragma once

#include "lvgl.h"

void cb_child_group_add(lv_event_t *event);

================================================
FILE: app/lvgl/ext/lv_dir_focus.c
================================================
#include "lv_dir_focus.h"

static lv_style_prop_t props[4] = {
        LV_STYLE_PROP_INV,
        LV_STYLE_PROP_INV,
        LV_STYLE_PROP_INV,
        LV_STYLE_PROP_INV
};

typedef enum focus_dir_index {
    DIR_INDEX_LEFT = 0,
    DIR_INDEX_RIGHT = 1,
    DIR_INDEX_TOP = 2,
    DIR_INDEX_BOTTOM = 3,
} focus_dir_index;

void lv_dir_focus_register() {
    LV_ASSERT(lv_is_initialized());
    props[DIR_INDEX_LEFT] = lv_style_register_prop(LV_STYLE_PROP_FLAG_NONE);
    props[DIR_INDEX_RIGHT] = lv_style_register_prop(LV_STYLE_PROP_FLAG_NONE);
    props[DIR_INDEX_TOP] = lv_style_register_prop(LV_STYLE_PROP_FLAG_NONE);
    props[DIR_INDEX_BOTTOM] = lv_style_register_prop(LV_STYLE_PROP_FLAG_NONE);
}

void lv_obj_set_dir_focus_obj(lv_obj_t *obj, lv_dir_t dir, const lv_obj_t *to_focus) {
    lv_style_value_t value = {.ptr = to_focus};
    if (dir & LV_DIR_LEFT) {
        lv_obj_set_local_style_prop(obj, props[DIR_INDEX_LEFT], value, 0);
    }
    if (dir & LV_DIR_RIGHT) {
        lv_obj_set_local_style_prop(obj, props[DIR_INDEX_RIGHT], value, 0);
    }
    if (dir & LV_DIR_TOP) {
        lv_obj_set_local_style_prop(obj, props[DIR_INDEX_TOP], value, 0);
    }
    if (dir & LV_DIR_BOTTOM) {
        lv_obj_set_local_style_prop(obj, props[DIR_INDEX_BOTTOM], value, 0);
    }
}

bool lv_obj_focus_dir(lv_obj_t *obj, lv_dir_t dir) {
    lv_style_value_t value;
    switch (dir) {
        case LV_DIR_LEFT:
            if (lv_obj_get_local_style_prop(obj, props[DIR_INDEX_LEFT], &value, 0) != LV_RES_OK) {
                return false;
            }
            break;
        case LV_DIR_RIGHT:
            if (lv_obj_get_local_style_prop(obj, props[DIR_INDEX_RIGHT], &value, 0) != LV_RES_OK) {
                return false;
            }
            break;
        case LV_DIR_TOP:
            if (lv_obj_get_local_style_prop(obj, props[DIR_INDEX_TOP], &value, 0) != LV_RES_OK) {
                return false;
            }
            break;
        case LV_DIR_BOTTOM:
            if (lv_obj_get_local_style_prop(obj, props[DIR_INDEX_BOTTOM], &value, 0) != LV_RES_OK) {
                return false;
            }
            break;
        default:
            return false;
    }
    lv_group_t *group = lv_obj_get_group(obj);
    lv_obj_t **group_item = NULL;
    _LV_LL_READ(&group->obj_ll, group_item) {
        if (*group_item == value.ptr) {
            break;
        }
    }
    if (group_item == NULL) {
        return false;
    }
    lv_group_focus_obj(*group_item);
    return true;
}

bool lv_obj_focus_dir_by_key(lv_obj_t *obj, lv_key_t dir) {
    switch (dir) {
        case LV_KEY_LEFT: {
            return lv_obj_focus_dir(obj, LV_DIR_LEFT);
        }
        case LV_KEY_RIGHT: {
            return lv_obj_focus_dir(obj, LV_DIR_RIGHT);
        }
        case LV_KEY_UP: {
            return lv_obj_focus_dir(obj, LV_DIR_TOP);
        }
        case LV_KEY_DOWN: {
            return lv_obj_focus_dir(obj, LV_DIR_BOTTOM);
        }
        default: {
            return false;
        }
    }
}


================================================
FILE: app/lvgl/ext/lv_dir_focus.h
================================================
#pragma once

#include "lvgl.h"


void lv_dir_focus_register();

void lv_obj_set_dir_focus_obj(lv_obj_t *obj, lv_dir_t dir, const lv_obj_t *to_focus);

bool lv_obj_focus_dir(lv_obj_t *obj, lv_dir_t dir);

bool lv_obj_focus_dir_by_key(lv_obj_t *obj, lv_key_t dir);

================================================
FILE: app/lvgl/ext/msgbox_ext.c
================================================
#include "msgbox_ext.h"
#include "ui/app_ui.h"
#include "lv_child_group.h"

static void msgbox_key(lv_event_t *event);

static void msgbox_cancel(lv_event_t *event);

static void msgbox_destroy(lv_event_t *event);

void msgbox_inject_nav(app_ui_t *ui, lv_obj_t *obj) {
    lv_group_t *group = lv_group_create();
    group->user_data = ui;
    app_ui_push_modal_group(ui, group);
    lv_obj_add_event_cb(obj, cb_child_group_add, LV_EVENT_CHILD_CREATED, group);
    lv_obj_add_event_cb(obj, msgbox_key, LV_EVENT_KEY, NULL);
    lv_obj_add_event_cb(obj, msgbox_cancel, LV_EVENT_CANCEL, NULL);
    lv_obj_add_event_cb(obj, msgbox_destroy, LV_EVENT_DELETE, group);
}

void msgbox_fix_sizes(lv_obj_t *obj, const char *btn_texts[]) {
    lv_obj_t *btns = lv_msgbox_get_btns(obj);
    if (btns != NULL) {
        int i;
        for (i = 0; btn_texts[i][0] != '\0'; i++);
        lv_obj_set_width(btns, i * LV_DPX(70) + (i - 1) * LV_DPX(10));
    }
}

static void msgbox_key(lv_event_t *event) {
    lv_obj_t *target = lv_event_get_target(event);
    lv_group_t *group = lv_obj_get_group(target);
    if (!group) return;
    switch (lv_event_get_key(event)) {
        case LV_KEY_UP: {
            lv_group_focus_prev(group);
            break;
        }
        case LV_KEY_DOWN: {
            lv_group_focus_next(group);
            break;
        }
        default: {
            break;
        }
    }
}

static void msgbox_cancel(lv_event_t *event) {
    lv_obj_t *mbox = lv_event_get_current_target(event);
    lv_obj_t *target = lv_event_get_target(event);
    lv_group_t *group = lv_obj_get_group(target);
    if (!group) return;
    lv_obj_t *btns = lv_msgbox_get_btns(mbox);
    if (btns && !lv_obj_has_flag(btns, LV_OBJ_FLAG_HIDDEN) &&
        !lv_btnmatrix_has_btn_ctrl(btns, 0, LV_BTNMATRIX_CTRL_DISABLED)) {
        lv_msgbox_close(mbox);
    }
}

static void msgbox_destroy(lv_event_t *event) {
    lv_group_t *group = lv_event_get_user_data(event);
    app_ui_remove_modal_group(group->user_data, group);
    lv_group_remove_all_objs(group);
    lv_group_del(group);
}

================================================
FILE: app/lvgl/ext/msgbox_ext.h
================================================
#pragma once

#include "lvgl.h"

typedef struct app_ui_t app_ui_t;

void msgbox_inject_nav(app_ui_t *ui, lv_obj_t *obj);

void msgbox_fix_sizes(lv_obj_t *obj, const char *btn_texts[]);

================================================
FILE: app/lvgl/fonts/bootstrap-icons/regular.h
================================================
#pragma once
const unsigned char ttf_bootstrap_icons_data[] = {
  0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x80, 0x00, 0x03, 0x00, 0x30, 0x47, 0x53, 0x55, 0x42,
  0xb8, 0xfc, 0xb8, 0xea, 0x00, 0x00, 0x01, 0x68, 0x00, 0x00, 0x00, 0x28, 0x4f, 0x53, 0x2f, 0x32,
  0x3f, 0x32, 0x50, 0xfb, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x00, 0x60, 0x63, 0x6d, 0x61, 0x70,
  0xb6, 0x0c, 0xaf, 0x9e, 0x00, 0x00, 0x02, 0xb8, 0x00, 0x00, 0x00, 0x9c, 0x67, 0x6c, 0x79, 0x66,
  0xf3, 0xe0, 0xad, 0xaa, 0x00, 0x00, 0x03, 0x54, 0x00, 0x00, 0x0a, 0x54, 0x68, 0x65, 0x61, 0x64,
  0x60, 0xac, 0xa0, 0x3f, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x36, 0x68, 0x68, 0x65, 0x61,
  0x02, 0x70, 0x01, 0x12, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x24, 0x68, 0x6d, 0x74, 0x78,
  0x01, 0x29, 0xff, 0xff, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x24, 0x6c, 0x6f, 0x63, 0x61,
  0x19, 0x5a, 0x16, 0x91, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x22, 0x6d, 0x61, 0x78, 0x70,
  0x01, 0x47, 0x01, 0x31, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x20, 0x6e, 0x61, 0x6d, 0x65,
  0x06, 0xf1, 0x1f, 0x96, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, 0x90, 0x70, 0x6f, 0x73, 0x74,
  0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00,
  0x00, 0x10, 0x01, 0x25, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a,
  0x00, 0x0a, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0xd3, 0x00, 0xef, 0x01, 0x3b, 0x02, 0x06, 0x02, 0x64, 0x02, 0xe4, 0x03, 0x23, 0x03, 0x4d,
  0x03, 0x7c, 0x03, 0xd6, 0x04, 0x40, 0x04, 0x98, 0x04, 0xdf, 0x04, 0xfd, 0x05, 0x2a, 0x00, 0x00,
  0x00, 0x01, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0xff, 0xf9, 0xff, 0xe3,
  0x01, 0x49, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0xff, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x26,
  0x00, 0x26, 0x00, 0x02, 0x44, 0x46, 0x4c, 0x54, 0x00, 0x12, 0x6c, 0x61, 0x74, 0x6e, 0x00, 0x0e,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x0e, 0x4d, 0xb9, 0x5b, 0x5f, 0x0f, 0x3c, 0xf5,
  0x08, 0x0b, 0x01, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x25, 0xb0, 0x80, 0x00, 0x00, 0x00, 0x00,
  0x7c, 0x25, 0xb0, 0x80, 0xff, 0xf9, 0xff, 0xe3, 0x01, 0x49, 0x01, 0x33, 0x00, 0x00, 0x00, 0x08,
  0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x2c, 0x01, 0x90, 0x00, 0x05,
  0x00, 0x00, 0x00, 0xbe, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x2a, 0x00, 0xbe, 0x00, 0xd2, 0x00, 0x00,
  0x00, 0x90, 0x00, 0x0e, 0x00, 0x4d, 0x00, 0x00, 0x02, 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x50, 0x66, 0x45, 0x64, 0x00, 0xc0, 0xf2, 0x29, 0xf6, 0xce, 0x01, 0x2c, 0x00, 0x00,
  0x00, 0x1b, 0x01, 0x47, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x4e, 0x00, 0x03,
  0x00, 0x01, 0x04, 0x09, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x24, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
  0x00, 0x02, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x03, 0x00, 0x1e,
  0x00, 0x24, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x24, 0x00, 0x03,
  0x00, 0x01, 0x04, 0x09, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
  0x00, 0x06, 0x00, 0x1e, 0x00, 0x24, 0x00, 0x56, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x69,
  0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x52, 0x00, 0x65,
  0x00, 0x67, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x72, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x6f,
  0x00, 0x74, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00, 0x70, 0x00, 0x2d, 0x00, 0x69,
  0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x73, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03,
  0x00, 0x00, 0x00, 0x14, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x04, 0x00, 0x88,
  0x00, 0x00, 0x00, 0x1e, 0x00, 0x10, 0x00, 0x03, 0x00, 0x0e, 0xf2, 0x29, 0xf2, 0xcc, 0xf2, 0xd4,
  0xf3, 0x02, 0xf3, 0xe2, 0xf4, 0xf2, 0xf4, 0xff, 0xf5, 0x04, 0xf5, 0xed, 0xf6, 0x59, 0xf6, 0x5b,
  0xf6, 0x5e, 0xf6, 0xc1, 0xf6, 0xce, 0xff, 0xff, 0x00, 0x00, 0xf2, 0x29, 0xf2, 0xcc, 0xf2, 0xd4,
  0xf3, 0x02, 0xf3, 0xe2, 0xf4, 0xf1, 0xf4, 0xff, 0xf5, 0x04, 0xf5, 0xed, 0xf6, 0x59, 0xf6, 0x5b,
  0xf6, 0x5e, 0xf6, 0xc1, 0xf6, 0xce, 0xff, 0xff, 0x0d, 0xd9, 0x0d, 0x37, 0x0d, 0x30, 0x0d, 0x03,
  0x0c, 0x24, 0x0b, 0x16, 0x0b, 0x0a, 0x0b, 0x06, 0x0a, 0x1f, 0x09, 0xb6, 0x09, 0xa6, 0x09, 0xb0,
  0x09, 0x4a, 0x09, 0x3f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0xff, 0xfd, 0x01, 0x11, 0x01, 0x2d, 0x00, 0x11,
  0x00, 0x45, 0x00, 0x57, 0x00, 0x8b, 0x00, 0x00, 0x13, 0x26, 0x06, 0x07, 0x0e, 0x01, 0x07, 0x06,
  0x07, 0x14, 0x16, 0x36, 0x37, 0x3e, 0x01, 0x37, 0x36, 0x34, 0x17, 0x30, 0x27, 0x26, 0x27, 0x26,
  0x37, 0x36, 0x3f, 0x01, 0x34, 0x26, 0x27, 0x26, 0x2b, 0x01, 0x26, 0x0f, 0x01, 0x06, 0x22, 0x27,
  0x2e, 0x01, 0x07, 0x06, 0x07, 0x0e, 0x01, 0x17, 0x16, 0x1f, 0x01, 0x16, 0x17, 0x1e, 0x01, 0x17,
  0x1e, 0x02, 0x3e, 0x01, 0x32, 0x16, 0x17, 0x16, 0x37, 0x3e, 0x01, 0x37, 0x36, 0x27, 0x26, 0x06,
  0x07, 0x0e, 0x01, 0x07, 0x06, 0x07, 0x14, 0x16, 0x36, 0x37, 0x3e, 0x01, 0x37, 0x36, 0x34, 0x17,
  0x30, 0x27, 0x26, 0x27, 0x26, 0x37, 0x36, 0x3f, 0x01, 0x34, 0x26, 0x27, 0x26, 0x2b, 0x01, 0x26,
  0x0f, 0x01, 0x06, 0x22, 0x27, 0x2e, 0x01, 0x07, 0x06, 0x07, 0x0e, 0x01, 0x17, 0x16, 0x1f, 0x01,
  0x16, 0x17, 0x1e, 0x01, 0x17, 0x1e, 0x02, 0x3e, 0x01, 0x32, 0x16, 0x17, 0x16, 0x37, 0x3e, 0x01,
  0x37, 0x36, 0xd2, 0x01, 0x0f, 0x08, 0x0b, 0x12, 0x04, 0x03, 0x01, 0x01, 0x11, 0x09, 0x0c, 0x10,
  0x04, 0x02, 0x3e, 0x03, 0x0f, 0x08, 0x10, 0x02, 0x04, 0x1a, 0x02, 0x0f, 0x08, 0x0e, 0x10, 0x01,
  0x0a, 0x0c, 0x0f, 0x13, 0x06, 0x0b, 0x12, 0x17, 0x16, 0x0a, 0x08, 0x0d, 0x10, 0x01, 0x01, 0x05,
  0x01, 0x05, 0x04, 0x06, 0x0f, 0x0a, 0x08, 0x0b, 0x15, 0x0f, 0x15, 0x0c, 0x12, 0x09, 0x0e, 0x11,
  0x08, 0x16, 0x0c, 0x0a, 0x3f, 0x01, 0x0f, 0x08, 0x0b, 0x12, 0x04, 0x03, 0x01, 0x01, 0x11, 0x09,
  0x0c, 0x10, 0x04, 0x02, 0x3e, 0x03, 0x0f, 0x08, 0x10, 0x02, 0x04, 0x1a, 0x02, 0x0f, 0x08, 0x0e,
  0x10, 0x01, 0x0a, 0x0c, 0x0f, 0x13, 0x06, 0x0b, 0x12, 0x17, 0x16, 0x0a, 0x08, 0x0d, 0x10, 0x01,
  0x01, 0x05, 0x01, 0x05, 0x04, 0x06, 0x0f, 0x0a, 0x08, 0x0b, 0x15, 0x0f, 0x15, 0x0c, 0x12, 0x09,
  0x0e, 0x11, 0x08, 0x16, 0x0c, 0x0a, 0x01, 0x2c, 0x01, 0x03, 0x05, 0x05, 0x14, 0x0c, 0x09, 0x09,
  0x06, 0x02, 0x02, 0x05, 0x06, 0x17, 0x0b, 0x09, 0x0d, 0xdb, 0x02, 0x0a, 0x0a, 0x13, 0x17, 0x24,
  0x10, 0x02, 0x01, 0x10, 0x04, 0x08, 0x02, 0x04, 0x05, 0x06, 0x04, 0x07, 0x04, 0x09, 0x04, 0x08,
  0x0b, 0x25, 0x1e, 0x17, 0x0e, 0x02, 0x10, 0x09, 0x10, 0x16, 0x0b, 0x08, 0x08, 0x02, 0x08, 0x05,
  0x05, 0x05, 0x05, 0x07, 0x03, 0x1a, 0x17, 0x16, 0xde, 0x01, 0x03, 0x05, 0x05, 0x14, 0x0c, 0x09,
  0x09, 0x06, 0x02, 0x02, 0x05, 0x06, 0x17, 0x0b, 0x09, 0x0d, 0xdb, 0x02, 0x0a, 0x0a, 0x13, 0x17,
  0x24, 0x10, 0x02, 0x01, 0x10, 0x04, 0x08, 0x02, 0x04, 0x05, 0x06, 0x04, 0x07, 0x04, 0x09, 0x04,
  0x08, 0x0b, 0x25, 0x1e, 0x17, 0x0e, 0x02, 0x10, 0x09, 0x10, 0x16, 0x0b, 0x08, 0x08, 0x02, 0x08,
  0x05, 0x05, 0x05, 0x05, 0x07, 0x03, 0x1a, 0x17, 0x16, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  0x01, 0x04, 0x00, 0xe2, 0x00, 0x0e, 0x00, 0x00, 0x37, 0x27, 0x26, 0x3e, 0x01, 0x3b, 0x01, 0x32,
  0x1e, 0x01, 0x06, 0x0f, 0x01, 0x06, 0x22, 0x88, 0x5a, 0x05, 0x01, 0x0a, 0x08, 0xb4, 0x05, 0x0a,
  0x04, 0x01, 0x04, 0x5a, 0x05, 0x12, 0x5b, 0x67, 0x06, 0x0f, 0x0a, 0x06, 0x0a, 0x0b, 0x04, 0x67,
  0x06, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x23, 0x00, 0x0b, 0x00, 0x17,
  0x00, 0x27, 0x00, 0x37, 0x00, 0x00, 0x37, 0x22, 0x26, 0x34, 0x36, 0x3b, 0x01, 0x32, 0x16, 0x14,
  0x06, 0x23, 0x27, 0x22, 0x26, 0x34, 0x36, 0x3b, 0x01, 0x32, 0x16, 0x14, 0x06, 0x23, 0x07, 0x14,
  0x16, 0x3b, 0x01, 0x32, 0x36, 0x3d, 0x01, 0x34, 0x26, 0x2b, 0x01, 0x22, 0x06, 0x15, 0x17, 0x22,
  0x26, 0x3d, 0x01, 0x34, 0x36, 0x3b, 0x01, 0x32, 0x16, 0x1d, 0x01, 0x14, 0x06, 0x23, 0x2f, 0x04,
  0x05, 0x05, 0x04, 0xce, 0x04, 0x06, 0x06, 0x04, 0xa9, 0x04, 0x05, 0x05, 0x04, 0x84, 0x04, 0x05,
  0x05, 0x04, 0xd8, 0x10, 0x0c, 0xf4, 0x0c, 0x10, 0x10, 0x0c, 0xf4, 0x0c, 0x10, 0x1c, 0x04, 0x05,
  0x05, 0x04, 0xf4, 0x04, 0x05, 0x05, 0x04, 0xea, 0x06, 0x08, 0x05, 0x05, 0x08, 0x06, 0x26, 0x05,
  0x08, 0x06, 0x06, 0x08, 0x05, 0xd8, 0x0b, 0x11, 0x11, 0x0b, 0x84, 0x0b, 0x11, 0x11, 0x0b, 0x8d,
  0x05, 0x04, 0x84, 0x03, 0x06, 0x06, 0x03, 0x84, 0x04, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
  0x01, 0x26, 0x01, 0x06, 0x00, 0x08, 0x00, 0x12, 0x00, 0x1b, 0x00, 0x24, 0x00, 0x30, 0x00, 0x69,
  0x00, 0x8c, 0x00, 0x00, 0x37, 0x14, 0x06, 0x22, 0x26, 0x34, 0x36, 0x32, 0x16, 0x07, 0x32, 0x36,
  0x34, 0x26, 0x22, 0x06, 0x14, 0x16, 0x33, 0x37, 0x14, 0x06, 0x22, 0x26, 0x34, 0x36, 0x32, 0x16,
  0x07, 0x32, 0x36, 0x34, 0x26, 0x22, 0x06, 0x14, 0x16, 0x27, 0x33, 0x15, 0x33, 0x15, 0x23, 0x15,
  0x23, 0x35, 0x23, 0x35, 0x33, 0x27, 0x26, 0x36, 0x3f, 0x01, 0x36, 0x16, 0x17, 0x36, 0x32, 0x17,
  0x34, 0x36, 0x1f, 0x01, 0x1e, 0x01, 0x07, 0x16, 0x17, 0x1e, 0x02, 0x17, 0x16, 0x07, 0x0e, 0x01,
  0x27, 0x26, 0x27, 0x26, 0x2f, 0x01, 0x26, 0x27, 0x26, 0x22, 0x07, 0x06, 0x0f, 0x01, 0x06, 0x07,
  0x06, 0x07, 0x06, 0x26, 0x27, 0x26, 0x37, 0x3e, 0x02, 0x37, 0x36, 0x37, 0x17, 0x0e, 0x04, 0x17,
  0x16, 0x33, 0x36, 0x37, 0x36, 0x3f, 0x01, 0x36, 0x37, 0x36, 0x32, 0x17, 0x16, 0x1f, 0x01, 0x16,
  0x17, 0x16, 0x17, 0x32, 0x37, 0x36, 0x2e, 0x04, 0x22, 0xd8, 0x06, 0x08, 0x05, 0x05, 0x08, 0x06,
  0x1c, 0x03, 0x06, 0x06, 0x07, 0x06, 0x06, 0x03, 0x2f, 0x05, 0x08, 0x05, 0x05, 0x08, 0x05, 0x1c,
  0x04, 0x06, 0x06, 0x08, 0x05, 0x05, 0x76, 0x13, 0x13, 0x13, 0x13, 0x12, 0x12, 0x1b, 0x01, 0x04,
  0x04, 0x24, 0x04, 0x07, 0x01, 0x12, 0x29, 0x13, 0x07, 0x04, 0x25, 0x04, 0x04, 0x03, 0x04, 0x03,
  0x0b, 0x13, 0x0c, 0x01, 0x01, 0x07, 0x04, 0x0f, 0x08, 0x0f, 0x0e, 0x04, 0x09, 0x08, 0x0c, 0x0b,
  0x10, 0x2a, 0x10, 0x0b, 0x0c, 0x08, 0x09, 0x04, 0x0e, 0x0f, 0x08, 0x0f, 0x04, 0x07, 0x01, 0x01,
  0x0c, 0x13, 0x0b, 0x03, 0x05, 0x25, 0x18, 0x10, 0x12, 0x0a, 0x02, 0x05, 0x03, 0x05, 0x09, 0x09,
  0x04, 0x07, 0x09, 0x0e, 0x0e, 0x14, 0x34, 0x14, 0x0e, 0x0e, 0x09, 0x07, 0x04, 0x09, 0x09, 0x05,
  0x03, 0x05, 0x02, 0x0a, 0x12, 0x10, 0x30, 0x3e, 0xbb, 0x04, 0x05, 0x05, 0x08, 0x05, 0x05, 0x20,
  0x05, 0x08, 0x06, 0x06, 0x08, 0x05, 0x09, 0x04, 0x05, 0x05, 0x08, 0x06, 0x06, 0x20, 0x06, 0x07,
  0x06, 0x06, 0x07, 0x06, 0x38, 0x12, 0x13, 0x13, 0x13, 0x13, 0x3d, 0x04, 0x06, 0x01, 0x0a, 0x01,
  0x04, 0x04, 0x02, 0x02, 0x04, 0x04, 0x01, 0x0a, 0x01, 0x08, 0x04, 0x03, 0x03, 0x0b, 0x2b, 0x34,
  0x16, 0x1a, 0x10, 0x08, 0x08, 0x01, 0x01, 0x0d, 0x04, 0x0b, 0x08, 0x0e, 0x06, 0x09, 0x09, 0x06,
  0x0e, 0x08, 0x0a, 0x05, 0x0d, 0x01, 0x01, 0x08, 0x08, 0x10, 0x1a, 0x16, 0x34, 0x2b, 0x0b, 0x04,
  0x02, 0x06, 0x05, 0x10, 0x28, 0x2d, 0x2c, 0x0c, 0x05, 0x01, 0x09, 0x04, 0x08, 0x0a, 0x10, 0x08,
  0x0b, 0x0b, 0x08, 0x10, 0x09, 0x09, 0x04, 0x09, 0x01, 0x05, 0x0c, 0x2c, 0x2d, 0x28, 0x10, 0x0a,
  0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x07, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x00,
  0x35, 0x34, 0x37, 0x36, 0x37, 0x3e, 0x01, 0x3b, 0x01, 0x17, 0x16, 0x17, 0x1e, 0x01, 0x1d, 0x01,
  0x07, 0x06, 0x07, 0x0e, 0x01, 0x2b, 0x01, 0x14, 0x17, 0x33, 0x32, 0x16, 0x14, 0x06, 0x2b, 0x01,
  0x22, 0x26, 0x34, 0x36, 0x3b, 0x01, 0x36, 0x35, 0x23, 0x27, 0x26, 0x27, 0x2e, 0x01, 0x35, 0x37,
  0x0e, 0x01, 0x1d, 0x01, 0x14, 0x1e, 0x01, 0x3b, 0x01, 0x32, 0x3e, 0x01, 0x3d, 0x01, 0x34, 0x2e,
  0x01, 0x27, 0x23, 0x22, 0x01, 0x01, 0x03, 0x04, 0x10, 0x0d, 0xe1, 0x05, 0x07, 0x06, 0x08, 0x0b,
  0x01, 0x01, 0x03, 0x04, 0x10, 0x0c, 0x4b, 0x04, 0x0e, 0x04, 0x06, 0x06, 0x04, 0x70, 0x04, 0x06,
  0x06, 0x04, 0x0e, 0x05, 0x4b, 0x06, 0x07, 0x06, 0x08, 0x0b, 0x1a, 0x03, 0x04, 0x04, 0x09, 0x05,
  0xe2, 0x07, 0x07, 0x04, 0x05, 0x08, 0x06, 0xe0, 0x08, 0xe1, 0x03, 0x03, 0x07, 0x06, 0x08, 0x0b,
  0x01, 0x01, 0x03, 0x04, 0x10, 0x0d, 0x70, 0x06, 0x07, 0x06, 0x08, 0x0b, 0x13, 0x09, 0x06, 0x07,
  0x06, 0x06, 0x07, 0x06, 0x09, 0x13, 0x01, 0x01, 0x03, 0x04, 0x10, 0x0d, 0x80, 0x02, 0x09, 0x05,
  0x70, 0x08, 0x07, 0x04, 0x05, 0x08, 0x05, 0x71, 0x07, 0x07, 0x04, 0x01, 0x00, 0x02, 0xff, 0xfd,
  0xff, 0xfd, 0x01, 0x2f, 0x01, 0x2f, 0x00, 0x47, 0x00, 0x50, 0x00, 0x00, 0x13, 0x2e, 0x01, 0x06,
  0x0f, 0x01, 0x0e, 0x01, 0x2f, 0x01, 0x26, 0x0e, 0x01, 0x1f, 0x01, 0x16, 0x06, 0x0f, 0x01, 0x0e,
  0x01, 0x16, 0x1f, 0x01, 0x1e, 0x01, 0x0f, 0x01, 0x06, 0x1e, 0x01, 0x3f, 0x01, 0x36, 0x16, 0x1f,
  0x01, 0x1e, 0x01, 0x36, 0x3f, 0x01, 0x3e, 0x01, 0x1f, 0x01, 0x16, 0x3e, 0x01, 0x2f, 0x01, 0x26,
  0x36, 0x3f, 0x01, 0x3e, 0x01, 0x26, 0x2f, 0x01, 0x2e, 0x01, 0x3f, 0x01, 0x36, 0x2e, 0x01, 0x0f,
  0x01, 0x06, 0x26, 0x27, 0x07, 0x22, 0x26, 0x34, 0x36, 0x32, 0x16, 0x14, 0x06, 0xb0, 0x03, 0x17,
  0x17, 0x03, 0x02, 0x04, 0x18, 0x0c, 0x05, 0x0c, 0x17, 0x09, 0x06, 0x03, 0x07, 0x0a, 0x0d, 0x06,
  0x0d, 0x09, 0x09, 0x0d, 0x06, 0x0d, 0x0a, 0x07, 0x03, 0x06, 0x09, 0x17, 0x0b, 0x06, 0x0c, 0x18,
  0x04, 0x02, 0x03, 0x17, 0x17, 0x03, 0x02, 0x04, 0x18, 0x0c, 0x06, 0x0b, 0x17, 0x09, 0x06, 0x03,
  0x07, 0x0a, 0x0d, 0x06, 0x0d, 0x09, 0x09, 0x0d, 0x06, 0x0d, 0x0a, 0x07, 0x03, 0x06, 0x09, 0x17,
  0x0b, 0x06, 0x0c, 0x18, 0x04, 0x1c, 0x17, 0x20, 0x20, 0x2e, 0x20, 0x20, 0x01, 0x18, 0x0d, 0x09,
  0x09, 0x0d, 0x06, 0x0d, 0x0a, 0x07, 0x03, 0x06, 0x09, 0x17, 0x0b, 0x06, 0x0c, 0x18, 0x04, 0x02,
  0x03, 0x17, 0x17, 0x03, 0x02, 0x04, 0x18, 0x0c, 0x05, 0x0c, 0x17, 0x09, 0x06, 0x03, 0x07, 0x0a,
  0x0d, 0x06, 0x0d, 0x09, 0x09, 0x0d, 0x06, 0x0d, 0x0a, 0x07, 0x03, 0x06, 0x09, 0x17, 0x0b, 0x06,
  0x0c, 0x18, 0x04, 0x02, 0x03, 0x17, 0x17, 0x03, 0x02, 0x04, 0x18, 0x0c, 0x06, 0x0b, 0x17, 0x09,
  0x06, 0x03, 0x07, 0x0a, 0x0d, 0xb3, 0x20, 0x2e, 0x20, 0x20, 0x2e, 0x20, 0x00, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x01, 0x2c, 0x01, 0x07, 0x00, 0x0b, 0x00, 0x1b, 0x00, 0x2b, 0x00, 0x00, 0x37, 0x26,
  0x06, 0x1d, 0x01, 0x14, 0x16, 0x3f, 0x01, 0x36, 0x34, 0x2f, 0x01, 0x34, 0x36, 0x3b, 0x01, 0x32,
  0x16, 0x1d, 0x01, 0x14, 0x06, 0x2b, 0x01, 0x22, 0x26, 0x35, 0x25, 0x34, 0x26, 0x2b, 0x01, 0x22,
  0x06, 0x1d, 0x01, 0x14, 0x16, 0x3b, 0x01, 0x32, 0x36, 0x35, 0x7f, 0x04, 0x0a, 0x0a, 0x04, 0x42,
  0x04, 0x04, 0xc1, 0x16, 0x10, 0xe1, 0x0f, 0x16, 0x16, 0x10, 0xe0, 0x10, 0x16, 0x01, 0x19, 0x0b,
  0x07, 0xe1, 0x08, 0x0b, 0x0b, 0x08, 0xe1, 0x07, 0x0b, 0xcd, 0x03, 0x05, 0x06, 0x5e, 0x06, 0x05,
  0x03, 0x2f, 0x03, 0x0a, 0x03, 0x43, 0x10, 0x16, 0x16, 0x10, 0x96, 0x10, 0x15, 0x15, 0x10, 0x96,
  0x08, 0x0b, 0x0b, 0x08, 0x96, 0x08, 0x0b, 0x0b, 0x08, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
  0x01, 0x2c, 0x01, 0x2d, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x00, 0x25, 0x14, 0x0e, 0x01, 0x22, 0x2e,
  0x01, 0x34, 0x3e, 0x01, 0x32, 0x1e, 0x01, 0x27, 0x26, 0x06, 0x1d, 0x01, 0x14, 0x16, 0x3f, 0x01,
  0x36, 0x34, 0x27, 0x01, 0x2c, 0x28, 0x45, 0x52, 0x45, 0x28, 0x28, 0x45, 0x52, 0x45, 0x28, 0xad,
  0x04, 0x0a, 0x0a, 0x04, 0x42, 0x04, 0x04, 0x96, 0x29, 0x45, 0x28, 0x28, 0x45, 0x52, 0x45, 0x28,
  0x28, 0x45, 0x0e, 0x03, 0x05, 0x06, 0x5e, 0x06, 0x05, 0x03, 0x2f, 0x03, 0x0a, 0x03, 0x00, 0x02,
  0x00, 0x00, 0x00, 0x00, 0x01, 0x0d, 0x01, 0x1a, 0x00, 0x03, 0x00, 0x1b, 0x00, 0x00, 0x13, 0x15,
  0x33, 0x35, 0x07, 0x34, 0x36, 0x37, 0x27, 0x0e, 0x01, 0x1e, 0x02, 0x3e, 0x01, 0x26, 0x27, 0x07,
  0x1e, 0x02, 0x0e, 0x02, 0x2e, 0x02, 0x8d, 0x12, 0x67, 0x1a, 0x17, 0x0a, 0x21, 0x1e, 0x12, 0x3d,
  0x4c, 0x3d, 0x15, 0x1e, 0x21, 0x09, 0x13, 0x18, 0x06, 0x10, 0x20, 0x2a, 0x2c, 0x24, 0x14, 0x01,
  0x19, 0x83, 0x83, 0x92, 0x19, 0x2c, 0x0d, 0x10, 0x12, 0x47, 0x4a, 0x2f, 0x01, 0x2e, 0x4a, 0x47,
  0x13, 0x10, 0x0b, 0x25, 0x2c, 0x2a, 0x1f, 0x0c, 0x07, 0x1b, 0x27, 0x00, 0x00, 0x03, 0x00, 0x00,
  0x00, 0x00, 0x01, 0x2c, 0x01, 0x2d, 0x00, 0x0c, 0x00, 0x34, 0x00, 0x3d, 0x00, 0x00, 0x25, 0x14,
  0x0e, 0x01, 0x22, 0x2e, 0x01, 0x34, 0x3e, 0x01, 0x32, 0x1e, 0x01, 0x07, 0x33, 0x32, 0x36, 0x37,
  0x3e, 0x01, 0x32, 0x16, 0x15, 0x14, 0x07, 0x0e, 0x01, 0x07, 0x06, 0x1d, 0x01, 0x14, 0x16, 0x3b,
  0x01, 0x32, 0x36, 0x3d, 0x01, 0x34, 0x3e, 0x01, 0x37, 0x36, 0x35, 0x34, 0x26, 0x22, 0x07, 0x06,
  0x07, 0x06, 0x16, 0x17, 0x32, 0x36, 0x34, 0x26, 0x22, 0x06, 0x14, 0x16, 0x01, 0x2c, 0x28, 0x45,
  0x52, 0x45, 0x28, 0x28, 0x45, 0x52, 0x45, 0x28, 0xc5, 0x10, 0x01, 0x03, 0x01, 0x01, 0x0d, 0x15,
  0x0e, 0x05, 0x03, 0x15, 0x05, 0x06, 0x03, 0x02, 0x0f, 0x02, 0x03, 0x07, 0x17, 0x05, 0x07, 0x1d,
  0x29, 0x0e, 0x10, 0x01, 0x01, 0x03, 0x2e, 0x08, 0x0b, 0x0b, 0x11, 0x0a, 0x0a, 0x96, 0x29, 0x45,
  0x28, 0x28, 0x45, 0x52, 0x45, 0x28, 0x28, 0x45, 0x04, 0x03, 0x02, 0x09, 0x0c, 0x0b, 0x0b, 0x08,
  0x06, 0x04, 0x10, 0x07, 0x0a, 0x0c, 0x04, 0x02, 0x03, 0x03, 0x02, 0x02, 0x09, 0x0a, 0x11, 0x07,
  0x0a, 0x0d, 0x15, 0x15, 0x09, 0x0b, 0x16, 0x02, 0x03, 0x79, 0x0a, 0x0f, 0x0a, 0x0a, 0x0f, 0x0a,
  0x00, 0x04, 0x00, 0x00, 0xff, 0xff, 0x01, 0x2d, 0x01, 0x2d, 0x00, 0x25, 0x00, 0x34, 0x00, 0x3d,
  0x00, 0x46, 0x00, 0x00, 0x37, 0x1e, 0x02, 0x33, 0x32, 0x3e, 0x01, 0x34, 0x2e, 0x01, 0x22, 0x0e,
  0x01, 0x07, 0x17, 0x36, 0x17, 0x37, 0x35, 0x34, 0x36, 0x32, 0x16, 0x15, 0x14, 0x0e, 0x02, 0x23,
  0x07, 0x16, 0x0e, 0x02, 0x2e, 0x01, 0x27, 0x17, 0x16, 0x3e, 0x01, 0x2e, 0x01, 0x07, 0x17, 0x1e,
  0x01, 0x0e, 0x01, 0x2f, 0x01, 0x16, 0x37, 0x14, 0x16, 0x32, 0x36, 0x34, 0x26, 0x22, 0x06, 0x37,
  0x32, 0x16, 0x14, 0x06, 0x22, 0x26, 0x34, 0x36, 0x06, 0x0a, 0x2a, 0x3b, 0x21, 0x29, 0x45, 0x28,
  0x28, 0x45, 0x50, 0x43, 0x29, 0x03, 0x51, 0x0b, 0x0d, 0x25, 0x22, 0x2f, 0x21, 0x09, 0x10, 0x16,
  0x0b, 0x35, 0x01, 0x0a, 0x12, 0x15, 0x13, 0x0d, 0x02, 0x1c, 0x0c, 0x18, 0x0a, 0x09, 0x18, 0x0c,
  0x13, 0x0a, 0x07, 0x08, 0x12, 0x09, 0x12, 0x05, 0x51, 0x16, 0x20, 0x16, 0x16, 0x20, 0x16, 0x26,
  0x0c, 0x11, 0x11, 0x18, 0x10, 0x10, 0x6a, 0x1f, 0x30, 0x1b, 0x28, 0x45, 0x52, 0x45, 0x28, 0x25,
  0x40, 0x27, 0x21, 0x07, 0x01, 0x36, 0x01, 0x17, 0x22, 0x22, 0x17, 0x0c, 0x15, 0x10, 0x09, 0x25,
  0x0b, 0x12, 0x0c, 0x03, 0x08, 0x10, 0x0a, 0x15, 0x04, 0x0a, 0x18, 0x18, 0x0a, 0x04, 0x08, 0x04,
  0x12, 0x12, 0x07, 0x03, 0x08, 0x0b, 0x79, 0x10, 0x16, 0x16, 0x1f, 0x17, 0x17, 0x0d, 0x11, 0x17,
  0x11, 0x11, 0x17, 0x11, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x07, 0x00, 0x0c,
  0x00, 0x21, 0x00, 0x3d, 0x00, 0x00, 0x37, 0x34, 0x36, 0x3b, 0x01, 0x32, 0x16, 0x14, 0x06, 0x2b,
  0x01, 0x22, 0x26, 0x37, 0x33, 0x1e, 0x02, 0x1d, 0x01, 0x14, 0x0e, 0x01, 0x2b, 0x01, 0x22, 0x2e,
  0x01, 0x3d, 0x01, 0x34, 0x3e, 0x01, 0x33, 0x37, 0x23, 0x22, 0x06, 0x07, 0x06, 0x0f, 0x01, 0x15,
  0x14, 0x16, 0x17, 0x16, 0x1f, 0x01, 0x33, 0x32, 0x36, 0x37, 0x36, 0x3f, 0x01, 0x35, 0x34, 0x26,
  0x27, 0x26, 0x27, 0x2f, 0x05, 0x04, 0xbc, 0x04, 0x05, 0x05, 0x04, 0xbc, 0x04, 0x05, 0xd7, 0x01,
  0x05, 0x08, 0x05, 0x04, 0x07, 0x07, 0xe2, 0x05, 0x08, 0x05, 0x04, 0x07, 0x08, 0xe1, 0xe1, 0x0d,
  0x10, 0x04, 0x03, 0x01, 0x01, 0x0b, 0x08, 0x06, 0x07, 0x06, 0xe1, 0x0c, 0x10, 0x04, 0x03, 0x01,
  0x01, 0x0b, 0x08, 0x06, 0x07, 0x2f, 0x04, 0x05, 0x05, 0x08, 0x05, 0x05, 0xc9, 0x01, 0x04, 0x07,
  0x07, 0x71, 0x05, 0x08, 0x05, 0x04, 0x07, 0x07, 0x71, 0x06, 0x08, 0x05, 0x13, 0x0b, 0x08, 0x06,
  0x07, 0x06, 0x70, 0x0d, 0x10, 0x04, 0x03, 0x01, 0x01, 0x0b, 0x08, 0x06, 0x07, 0x06, 0x70, 0x0d,
  0x10, 0x04, 0x03, 0x01, 0x00, 0x04, 0xff, 0xff, 0x00, 0x00, 0x01, 0x2d, 0x01, 0x1a, 0x00, 0x0f,
  0x00, 0x1f, 0x00, 0x29, 0x00, 0x33, 0x00, 0x00, 0x37, 0x22, 0x06, 0x1d, 0x01, 0x14, 0x16, 0x3b,
  0x01, 0x32, 0x36, 0x3d, 0x01, 0x34, 0x26, 0x23, 0x27, 0x22, 0x06, 0x1d, 0x01, 0x14, 0x16, 0x3b,
  0x01, 0x32, 0x36, 0x3d, 0x01, 0x34, 0x26, 0x23, 0x07, 0x34, 0x36, 0x3b, 0x01, 0x36, 0x16, 0x1d,
  0x01, 0x21, 0x15, 0x21, 0x15, 0x14, 0x06, 0x2b, 0x01, 0x22, 0x26, 0x35, 0x42, 0x04, 0x06, 0x06,
  0x04, 0xa8, 0x04, 0x06, 0x06, 0x04, 0xbd, 0x13, 0x1a, 0x1a, 0x13, 0xd2, 0x13, 0x1a, 0x1a, 0x13,
  0xec, 0x0f, 0x0b, 0xd2, 0x0b, 0x0f, 0xfe, 0xfa, 0x01, 0x06, 0x0f, 0x0b, 0xd2, 0x0b, 0x0f, 0x5e,
  0x06, 0x04, 0x12, 0x04, 0x06, 0x06, 0x04, 0x12, 0x04, 0x06, 0xbb, 0x1a, 0x12, 0xae, 0x12, 0x1a,
  0x1a, 0x12, 0xae, 0x12, 0x1a, 0x2c, 0x0b, 0x0e, 0x01, 0x0f, 0x0b, 0x0c, 0x13, 0x8f, 0x0b, 0x0f,
  0x0f, 0x0b, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x00, 0x03, 0x00, 0x07,
  0x00, 0x0b, 0x00, 0x0f, 0x00, 0x00, 0x13, 0x07, 0x15, 0x33, 0x07, 0x17, 0x35, 0x23, 0x1f, 0x02,
  0x3d, 0x01, 0x07, 0x15, 0x33, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x88, 0x01, 0xa3, 0xa3, 0xa3,
  0x01, 0x12, 0x10, 0x66, 0x73, 0x11, 0x78, 0x01, 0x78, 0x17, 0x8f, 0x9d, 0x17, 0x79, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x07, 0x00, 0x1b, 0x00, 0x00, 0x37, 0x26, 0x34, 0x36,
  0x32, 0x1f, 0x01, 0x37, 0x36, 0x32, 0x16, 0x14, 0x0f, 0x01, 0x17, 0x16, 0x14, 0x06, 0x22, 0x2f,
  0x01, 0x07, 0x06, 0x22, 0x26, 0x34, 0x3f, 0x01, 0x28, 0x03, 0x06, 0x08, 0x03, 0x60, 0x60, 0x03,
  0x08, 0x06, 0x03, 0x61, 0x61, 0x03, 0x06, 0x08, 0x03, 0x60, 0x60, 0x03, 0x08, 0x06, 0x03, 0x61,
  0xf6, 0x03, 0x08, 0x06, 0x03, 0x61, 0x61, 0x03, 0x06, 0x08, 0x03, 0x60, 0x60, 0x03, 0x08, 0x06,
  0x03, 0x61, 0x61, 0x03, 0x06, 0x08, 0x03, 0x60,
};
extern const unsigned char ttf_bootstrap_icons_data[];
#define ttf_bootstrap_icons_size 3496


================================================
FILE: app/lvgl/fonts/bootstrap-icons/symbols.h
================================================
#pragma once

#define BS_SYMBOL_CARET_DOWN_FILL "\xef\x88\xa9"
#define BS_SYMBOL_COLLECTION "\xef\x8b\x8c"
#define BS_SYMBOL_CONTROLLER "\xef\x8b\x94"
#define BS_SYMBOL_DISPLAY "\xef\x8c\x82"
#define BS_SYMBOL_GEAR_FILL "\xef\x8f\xa2"
#define BS_SYMBOL_PLAY_BTN "\xef\x93\xb1"
#define BS_SYMBOL_PLAY_CIRCLE_FILL "\xef\x93\xb2"
#define BS_SYMBOL_POWER "\xef\x93\xbf"
#define BS_SYMBOL_QUESTION_CIRCLE_FILL "\xef\x94\x84"
#define BS_SYMBOL_TV "\xef\x97\xad"
#define BS_SYMBOL_X_LG "\xef\x99\x99"
#define BS_SYMBOL_APPLE "\xef\x99\x9b"
#define BS_SYMBOL_WINDOWS "\xef\x99\x9e"
#define BS_SYMBOL_STEAM "\xef\x9b\x81"
#define BS_SYMBOL_WINDOW_DESKTOP "\xef\x9b\x8e"


================================================
FILE: app/lvgl/keypad.c
================================================
#include "mouse.h"
#include "logging.h"
#include "app.h"
#include "ui/app_ui.h"

#include <SDL.h>

typedef struct keyboard_state_t {
    app_t *app;
    bool ignore_input;
    /**
     * Key code of last pressed key event, will be 0 if released
     */
    uint32_t key;
    /**
     * Key code of last key event, no matter its released or not
     */
    uint32_t ev_key;
    lv_indev_state_t state;
    bool changed;
} keyboard_state_t;

static void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data);

static void handle_esc(keyboard_state_t *state);

static uint32_t key_from_keysym(const SDL_Keysym *keysym);

static uint32_t key_from_cbutton(uint8_t button);

lv_indev_t *app_indev_keypad_init(app_t *app) {
    lv_indev_drv_t *driver = malloc(sizeof(lv_indev_drv_t));
    lv_indev_drv_init(driver);
    driver->type = LV_INDEV_TYPE_KEYPAD;
    driver->read_cb = read_cb;
    keyboard_state_t *state = calloc(1, sizeof(keyboard_state_t));
    state->app = app;
    driver->user_data = state;
    lv_indev_t *indev = lv_indev_drv_register(driver);
    lv_indev_set_group(indev, lv_group_get_default());
    return indev;
}

void app_indev_keypad_deinit(lv_indev_t *indev) {
    lv_indev_drv_t *driver = indev->driver;
    lv_indev_delete(indev);
    free(driver->user_data);
    free(driver);
}

void app_indev_keypad_set_ignore(lv_indev_t *indev, bool ignore) {
    keyboard_state_t *state = indev->driver->user_data;
    state->ignore_input = ignore;
}

void app_indev_keypad_sdl_key_event(lv_indev_t *indev, const SDL_KeyboardEvent *event) {
    keyboard_state_t *state = indev->driver->user_data;
    uint32_t key = key_from_keysym(&event->keysym);
    if (key == 0) {
#ifdef SDL_WEBOS_SCANCODE_EXIT
        if (event->state == SDL_RELEASED && event->keysym.scancode == SDL_WEBOS_SCANCODE_EXIT) {
            app_post_event(state->app, APP_UI_NAV_QUIT, NULL, NULL);
        }
#endif
        return;
    }
    if (event->state == SDL_PRESSED) {
        if (state->key == 0) {
            state->key = state->ev_key = key;
            state->state = LV_INDEV_STATE_PRESSED;
            state->changed = true;
        }
    } else if (event->state == SDL_RELEASED) {
        if (state->key == key) {
            state->ev_key = key;
            state->key = 0;
            state->state = LV_INDEV_STATE_RELEASED;
            state->changed = true;
        }
    }
}

void app_indev_keypad_sdl_cbutton_event(lv_indev_t *indev, const SDL_ControllerButtonEvent *event) {
    uint32_t key = key_from_cbutton(event->button);
    if (key == 0) {
        return;
    }
    keyboard_state_t *state = indev->driver->user_data;
    if (event->state == SDL_PRESSED) {
        if (state->key == 0) {
            state->key = state->ev_key = key;
            state->state = LV_INDEV_STATE_PRESSED;
            state->changed = true;
        }
    } else if (event->state == SDL_RELEASED) {
        if (state->key == key) {
            state->ev_key = key;
            state->key = 0;
            state->state = LV_INDEV_STATE_RELEASED;
            state->changed = true;
        }
    }
}

void app_indev_keypad_inject_key(lv_indev_t *indev, lv_key_t key, bool pressed) {
    keyboard_state_t *state = indev->driver->user_data;
    if (pressed) {
        if (state->key == 0) {
            state->key = state->ev_key = key;
            state->state = LV_INDEV_STATE_PRESSED;
            state->changed = true;
        }
    } else {
        if (state->key == key) {
            state->ev_key = key;
            state->key = 0;
            state->state = LV_INDEV_STATE_RELEASED;
            state->changed = true;
        }
    }
}

static void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {
    keyboard_state_t *state = drv->user_data;
    if (state->changed && state->ev_key == LV_KEY_ESC) {
        handle_esc(state);
    }
    state->changed = false;
    data->key = state->key;
    if (state->ignore_input) {
        data->state = false;
    } else {
        data->state = state->state;
    }
    data->continue_reading = false;
}

/**
 * Special case for esc keys
 * @param state
 */
static void handle_esc(keyboard_state_t *state) {
    lv_group_t *group = app_ui_get_input_group(state->app->ui);
    lv_obj_t *focused = lv_group_get_focused(group);
    if (focused == NULL) {
        // Next key event will not be handled by any object. Send global BACK event
        if (state->state == LV_INDEV_STATE_RELEASED) {
            app_post_event(state->app, APP_UI_NAV_BACK, NULL, NULL);
        }
        return;
    }
    // TODO: for things like dropdown, cancel event will be sent when ESC pressed.
    //  So we can compare PRESS and RELEASE event to see if it's closed or not. Send BACK event if no state change.
    if (state->state == LV_INDEV_STATE_PRESSED) {
        // Backup object state (e.g. is dropdown opened)
    } else {
        // Compare object state, and send BACK event if no change.
        app_post_event(state->app, APP_UI_NAV_BACK, NULL, NULL);
    }
}

static uint32_t key_from_keysym(const SDL_Keysym *keysym) {
    switch (keysym->sym) {
        case SDLK_UP:
            return LV_KEY_UP;
        case SDLK_DOWN:
            return LV_KEY_DOWN;
        case SDLK_LEFT:
            return LV_KEY_LEFT;
        case SDLK_RIGHT:
            return LV_KEY_RIGHT;
        case SDLK_RETURN:
        case SDLK_RETURN2:
        case SDLK_KP_ENTER:
            return LV_KEY_ENTER;
        case SDLK_ESCAPE:
            return LV_KEY_ESC;
        case SDLK_TAB:
            return keysym->mod & KMOD_SHIFT ? LV_KEY_PREV : LV_KEY_NEXT;
        default:
#ifdef SDL_WEBOS_SCANCODE_BACK
            switch ((int) keysym->scancode) {
                case SDL_WEBOS_SCANCODE_BACK:
                    return LV_KEY_ESC;
                case SDL_WEBOS_SCANCODE_CH_UP:
                    return LV_KEY_PREV;
                case SDL_WEBOS_SCANCODE_CH_DOWN:
                    return LV_KEY_NEXT;
                default:
                    break;
            }
#endif
            return 0;
    }
}

static uint32_t key_from_cbutton(uint8_t button) {
    switch (button) {
        case SDL_CONTROLLER_BUTTON_DPAD_UP:
            return LV_KEY_UP;
        case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
            return LV_KEY_DOWN;
        case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
            return LV_KEY_LEFT;
        case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
            return LV_KEY_RIGHT;
        case SDL_CONTROLLER_BUTTON_A:
            return LV_KEY_ENTER;
        case SDL_CONTROLLER_BUTTON_B:
            return LV_KEY_ESC;
        case SDL_CONTROLLER_BUTTON_BACK:
            return LV_KEY_NEXT;
        default:
            return 0;
    }
}

================================================
FILE: app/lvgl/keypad.h
================================================
#pragma once

#include <lvgl.h>
#include <SDL2/SDL.h>

typedef struct app_t app_t;

lv_indev_t *app_indev_keypad_init(app_t *app);

void app_indev_keypad_deinit(lv_indev_t *indev);

void app_indev_keypad_set_ignore(lv_indev_t *indev, bool ignore);

void app_indev_keypad_sdl_key_event(lv_indev_t *indev, const SDL_KeyboardEvent *event);

void app_indev_keypad_sdl_cbutton_event(lv_indev_t *indev, const SDL_ControllerButtonEvent *event);

void app_indev_keypad_inject_key(lv_indev_t *indev, lv_key_t key, bool pressed);

================================================
FILE: app/lvgl/lv_conf.h
================================================
#ifndef LV_CONF_H
#define LV_CONF_H

#include <stdint.h>

/* Use 32-bit color depth */
#define LV_COLOR_DEPTH     32

#define LV_DPI_DEF         360

/* Use stdlib to allocate/free memory */
#define LV_MEM_CUSTOM      1
#define LV_MEM_CUSTOM_INCLUDE   <string.h>   /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC     malloc
#define LV_MEM_CUSTOM_FREE      free
#define LV_MEM_CUSTOM_REALLOC   realloc

/* Use the standard `memcpy` and `memset` instead of LVGL's own functions. */
#define LV_MEMCPY_MEMSET_STD    1

#define LV_DISP_DEF_REFR_PERIOD 17
#define LV_INDEV_DEF_READ_PERIOD 5

#define LV_USE_REFR_DEBUG 0

/* Let LVGL call SDL_GetTicks automatically so we can skip creating a separate timer thread. */
#define LV_TICK_CUSTOM     1
#define LV_TICK_CUSTOM_INCLUDE  <SDL.h>
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (SDL_GetTicks())

#define LV_DRAW_COMPLEX 1
#define LV_SHADOW_CACHE_SIZE    0
#define LV_IMG_CACHE_DEF_SIZE       0

#define LV_GRADIENT_MAX_STOPS 8

/* Use SDL draw backend */
#define LV_USE_GPU_SDL    1
#define LV_GPU_SDL_INCLUDE_PATH <SDL.h>
#define LV_GPU_SDL_CUSTOM_BLEND_MODE 0

/*Change the built in (v)snprintf functions*/
#define LV_SPRINTF_CUSTOM   1
#if LV_SPRINTF_CUSTOM
#  define LV_SPRINTF_INCLUDE <stdio.h>
#  define lv_snprintf     snprintf
#  define lv_vsnprintf    vsnprintf
#else   /*LV_SPRINTF_CUSTOM*/
#  define LV_SPRINTF_USE_FLOAT 0
#endif  /*LV_SPRINTF_CUSTOM*/

/*Enable the log module*/
#define LV_USE_LOG      1
#if LV_USE_LOG

/*How important log should be added:
 *LV_LOG_LEVEL_TRACE       A lot of logs to give detailed information
 *LV_LOG_LEVEL_INFO        Log important events
 *LV_LOG_LEVEL_WARN        Log if something unwanted happened but didn't cause a problem
 *LV_LOG_LEVEL_ERROR       Only critical issue, when the system may fail
 *LV_LOG_LEVEL_USER        Only logs added by the user
 *LV_LOG_LEVEL_NONE        Do not log anything*/
#  define LV_LOG_LEVEL    LV_LOG_LEVEL_WARN

/*1: Print the log with 'printf';
 *0: User need to register a callback with `lv_log_register_print_cb()`*/
#  define LV_LOG_PRINTF   0

/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
#  define LV_LOG_TRACE_MEM            1
#  define LV_LOG_TRACE_TIMER          1
#  define LV_LOG_TRACE_INDEV          1
#  define LV_LOG_TRACE_DISP_REFR      1
#  define LV_LOG_TRACE_EVENT          1
#  define LV_LOG_TRACE_OBJ_CREATE     1
#  define LV_LOG_TRACE_LAYOUT         1
#  define LV_LOG_TRACE_ANIM           1

#endif  /*LV_USE_LOG*/

/* Abort on assertion failure */
#define LV_ASSERT_HANDLER_INCLUDE   <stdlib.h>
#define LV_ASSERT_HANDLER   abort();

#define LV_USE_USER_DATA      1

/* Use 32bit coordinates */
#define LV_USE_LARGE_COORD  1

#define LV_USE_FREETYPE 1

#define LV_FONT_UNSCII_16    1

#define LV_FONT_DEFAULT &lv_font_unscii_16

#define LV_TXT_ENC LV_TXT_ENC_UTF8


/*==================
 *  WIDGET USAGE
 *================*/

/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/

#define LV_USE_ARC          1

#define LV_USE_ANIMIMG        0

#define LV_USE_BAR          1

#define LV_USE_BTN          1

#define LV_USE_BTNMATRIX    1

#define LV_USE_CANVAS       1

#define LV_USE_CHECKBOX     1


#define LV_USE_DROPDOWN     1   /*Requires: lv_label*/

#define LV_USE_IMG          1   /*Requires: lv_label*/

#define LV_USE_LABEL        1
#if LV_USE_LABEL
#  define LV_LABEL_TEXT_SELECTION         1   /*Enable selecting text of the label*/
#  define LV_LABEL_LONG_TXT_HINT    1   /*Store some extra info in labels to speed up drawing of very long texts*/
#endif

#define LV_USE_LINE         1

#define LV_USE_ROLLER       0   /*Requires: lv_label*/
#if LV_USE_ROLLER
#  define LV_ROLLER_INF_PAGES       7   /*Number of extra "pages" when the roller is infinite*/
#endif

#define LV_USE_SLIDER       1   /*Requires: lv_bar*/

#define LV_USE_SWITCH    0

#define LV_USE_TEXTAREA   0     /*Requires: lv_label*/
#if LV_USE_TEXTAREA != 0
#  define LV_TEXTAREA_DEF_PWD_SHOW_TIME     1500    /*ms*/
#endif

#define LV_USE_TABLE  0

/*==================
 * EXTRA COMPONENTS
 *==================*/

/*-----------
 * Widgets
 *----------*/
#define LV_USE_CALENDAR     0
#if LV_USE_CALENDAR
# define LV_CALENDAR_WEEK_STARTS_MONDAY 0
# if LV_CALENDAR_WEEK_STARTS_MONDAY
#  define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}
# else
#  define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
# endif

# define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March",  "April", "May",  "June", "July", "August", "September", "October", "November", "December"}
# define LV_USE_CALENDAR_HEADER_ARROW       1
# define LV_USE_CALENDAR_HEADER_DROPDOWN    1
#endif  /*LV_USE_CALENDAR*/

#define LV_USE_CHART        0

#define LV_USE_COLORWHEEL   0

#define LV_USE_GRIDVIEW     1

#define LV_USE_IMGBTN       1

#define LV_USE_KEYBOARD     0

#define LV_USE_LED          1

#define LV_USE_LIST         1

#define LV_USE_METER        0

#define LV_USE_MSGBOX       1

#define LV_USE_SPINBOX      0

#define LV_USE_SPINNER      1

#define LV_USE_TABVIEW      1

#define LV_USE_TILEVIEW     0

#define LV_USE_WIN          1

#define LV_USE_SPAN         1
#if LV_USE_SPAN
/*A line text can contain maximum num of span descriptor */
#  define LV_SPAN_SNIPPET_STACK_SIZE   64
#endif

/*-----------
 * Themes
 *----------*/
/*A simple, impressive and very complete theme*/
#define LV_USE_THEME_DEFAULT    0
#if LV_USE_THEME_DEFAULT

/*0: Light mode; 1: Dark mode*/
# define LV_THEME_DEFAULT_DARK     0

/*1: Enable grow on press*/
# define LV_THEME_DEFAULT_GROW              0

/*Default transition time in [ms]*/
# define LV_THEME_DEFAULT_TRANSITON_TIME    80
#endif /*LV_USE_THEME_DEFAULT*/

/*An very simple them that is a good starting point for a custom theme*/
#define LV_USE_THEME_BASIC    1

/*A theme designed for monochrome displays*/
#define LV_USE_THEME_MONO       0

/*-----------
 * Layouts
 *----------*/

/*A layout similar to Flexbox in CSS.*/
#define LV_USE_FLEX     1

/*A layout similar to Grid in CSS.*/
#define LV_USE_GRID     1

/*-----------
 * Extras
 *----------*/

#define LV_USE_FRAGMENT  1
#define LV_USE_QRCODE    1

/*----------
 * Icon font symbol overrides
 *---------*/
#define LV_SYMBOL_DOWN "\xef\x88\xa9" /*BS_SYMBOL_CARET_DOWN_FILL*/

#endif /*LV_CONF_H*/

================================================
FILE: app/lvgl/mouse.c
================================================
#include "mouse.h"

#include <SDL.h>

static void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data);

lv_indev_t *app_lv_mouse_indev_init() {
    lv_indev_drv_t *driver = malloc(sizeof(lv_indev_drv_t));
    lv_indev_drv_init(driver);
    driver->type = LV_INDEV_TYPE_POINTER;
    driver->read_cb = read_cb;
    lv_indev_t *indev = lv_indev_drv_register(driver);
    lv_indev_set_group(indev, lv_group_get_default());
    return indev;
}


void app_lv_mouse_indev_deinit(lv_indev_t *indev) {
    lv_indev_drv_t *driver = indev->driver;
    lv_indev_delete(indev);
    free(driver);
}

static void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {
    int x, y;
    Uint32 buttons = SDL_GetMouseState(&x, &y);
    data->state = (buttons & SDL_BUTTON_LEFT) ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
    data->point.x = x;
    data->point.y = y;
    data->continue_reading = false;
}

================================================
FILE: app/lvgl/mouse.h
================================================
#pragma once

#include <lvgl.h>

lv_indev_t *app_lv_mouse_indev_init();

void app_lv_mouse_indev_deinit(lv_indev_t *indev);

================================================
FILE: app/lvgl/theme.c
================================================
#include "theme.h"
#include "config.h"

#include "ui/app_ui.h"

#include "ext/msgbox_ext.h"

static void apply_cb(lv_theme_t *theme, lv_obj_t *obj);

typedef struct theme_context_t {
    app_ui_t *ui;

    lv_style_t scr;

    lv_style_t obj;

    lv_style_t focused;

    lv_style_t label;

    lv_style_t btn;
    lv_style_t btn_focused;
    lv_style_t btn_pressed;

    lv_style_t dropdown_list;

    lv_style_t modal_bg;

    lv_style_t msgbox;
    lv_style_t msgbox_backdrop;
    lv_style_t msgbox_title;
    lv_style_t msgbox_text;
    lv_style_t msgbox_btns;
    lv_style_t msgbox_btns_item;
    lv_style_t msgbox_btns_item_focused;
    lv_style_t msgbox_btns_item_pressed;

    lv_style_t win_title;
    lv_style_t win_btn;
    lv_style_t win_header;
    lv_style_t win_content;

    lv_style_t arc_indic;
    lv_style_t arc_indic_primary;

} theme_context_t;

void app_theme_init(lv_theme_t *theme, app_ui_t *ui) {
    theme_context_t *styles = lv_mem_alloc(sizeof(theme_context_t));
    lv_memset_00(styles, sizeof(theme_context_t));
    styles->ui = ui;

    theme->font_small = ui->font.small;
    theme->font_normal = ui->font.body;
    theme->font_large = ui->font.heading3;

    lv_color_t primary_color = lv_color_hex(0x1387b8);
    lv_color_t accent_color = lv_color_lighten(primary_color, 1);
    lv_color_t focus_color = lv_color_make(31, 169, 255);

    theme->color_primary = primary_color;

    lv_style_init(&styles->scr);

    const static lv_grad_dsc_t grad = {
            .dir = LV_GRAD_DIR_VER,
            .stops = {
                    {.color = {.ch = {.red = 0x11, .green = 0x1d, .blue = 0x2e, .alpha = 255}}, .frac = 0},
                    {.color = {.ch = {.red = 0x05, .green = 0x18, .blue = 0x39, .alpha = 255}}, .frac = 63},
                    {.color = {.ch = {.red = 0x0a, .green = 0x1b, .blue = 0x48, .alpha = 255}}, .frac = 119},
                    {.color = {.ch = {.red = 0x13, .green = 0x2e, .blue = 0x62, .alpha = 255}}, .frac = 172},
                    {.color = {.ch = {.red = 0x14, .green = 0x4b, .blue = 0x7e, .alpha = 255}}, .frac = 216},
                    {.color = {.ch = {.red = 0x13, .green = 0x64, .blue = 0x97, .alpha = 255}}, .frac = 255},
            },
            .stops_count = 6,
    };
    lv_style_set_bg_grad(&styles->scr, &grad);
    lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER);

    lv_style_init(&styles->obj);
    lv_style_set_text_color(&styles->obj, lv_color_white());
    lv_style_set_pad_gap(&styles->obj, LV_DPX(10));

    lv_style_init(&styles->focused);
    lv_style_set_outline_width(&styles->focused, LV_DPX(2));
    lv_style_set_outline_opa(&styles->focused, LV_OPA_COVER);
    lv_style_set_outline_color(&styles->focused, primary_color);
    lv_style_set_outline_pad(&styles->focused, LV_DPX(5));
    lv_style_set_radius(&styles->focused, LV_DPX(5));

    lv_style_init(&styles->label);
    lv_style_set_text_font(&styles->label, ui->font.body);

    lv_style_init(&styles->btn);
    lv_style_set_pad_all(&styles->btn, LV_DPX(10));
    lv_style_set_bg_color(&styles->btn, lv_color_white());
    lv_style_set_bg_opa(&styles->btn, LV_OPA_20);

    lv_style_init(&styles->btn_focused);
    lv_style_set_bg_color(&styles->btn_focused, focus_color);
    lv_style_set_bg_opa(&styles->btn_focused, LV_OPA_COVER);

    lv_style_init(&styles->btn_pressed);
    lv_style_set_bg_color(&styles->btn_pressed, lv_color_darken(focus_color, LV_OPA_20));
    lv_style_set_bg_opa(&styles->btn_pressed, LV_OPA_COVER);

    lv_style_init(&styles->dropdown_list);
    lv_style_set_pad_ver(&styles->dropdown_list, LV_DPX(20));
    lv_style_set_pad_hor(&styles->dropdown_list, LV_DPX(15));
    lv_style_set_text_line_space(&styles->dropdown_list, LV_DPX(20));

    lv_style_init(&styles->modal_bg);
    lv_style_set_bg_color(&styles->modal_bg, lv_color_hex(0x25282e));
    lv_style_set_bg_opa(&styles->modal_bg, LV_OPA_COVER);
    lv_style_set_shadow_color(&styles->modal_bg, lv_color_black());
    lv_style_set_shadow_opa(&styles->modal_bg, LV_OPA_30);
    lv_style_set_shadow_width(&styles->modal_bg, LV_DPX(20));
    lv_style_set_shadow_ofs_y(&styles->modal_bg, LV_DPX(10));
    lv_style_set_radius(&styles->modal_bg, LV_DPX(5));
    lv_style_set_min_width(&styles->modal_bg, LV_DPX(480));
    lv_style_set_max_width(&styles->modal_bg, LV_DPX(576));

    lv_style_init(&styles->msgbox);
    lv_style_set_pad_top(&styles->msgbox, LV_DPX(16));
    lv_style_set_pad_bottom(&styles->msgbox, LV_DPX(8));
    lv_style_set_pad_hor(&styles->msgbox, LV_DPX(8));
    lv_style_set_flex_main_place(&styles->msgbox, LV_FLEX_ALIGN_END);

    lv_style_init(&styles->msgbox_backdrop);
    lv_style_set_bg_color(&styles->msgbox_backdrop, lv_color_black());
    lv_style_set_bg_opa(&styles->msgbox_backdrop, LV_OPA_30);

    lv_style_init(&styles->msgbox_title);
    lv_style_set_text_font(&styles->msgbox_title, ui->font.heading2);
    lv_style_set_text_letter_space(&styles->msgbox_title, LV_DPX(1));
    lv_style_set_pad_hor(&styles->msgbox_title, LV_DPX(16));

    lv_style_init(&styles->msgbox_text);
    lv_style_set_text_font(&styles->msgbox_text, ui->font.body);
    lv_style_set_pad_top(&styles->msgbox_text, LV_DPX(8));
    lv_style_set_pad_hor(&styles->msgbox_text, LV_DPX(16));
    lv_style_set_pad_bottom(&styles->msgbox_text, LV_DPX(16));

    lv_style_init(&styles->msgbox_btns);

    lv_style_init(&styles->msgbox_btns_item);
    lv_style_set_radius(&styles->msgbox_btns_item, LV_DPX(2));
    lv_style_set_text_font(&styles->msgbox_btns_item, ui->font.small);
    lv_style_set_text_color(&styles->msgbox_btns_item, accent_color);

    lv_style_init(&styles->msgbox_btns_item_focused);
    lv_style_set_bg_color(&styles->msgbox_btns_item_focused, primary_color);
    lv_style_set_bg_opa(&styles->msgbox_btns_item_focused, LV_OPA_10);

    lv_style_init(&styles->msgbox_btns_item_pressed);
    lv_style_set_bg_color(&styles->msgbox_btns_item_pressed, primary_color);
    lv_style_set_bg_opa(&styles->msgbox_btns_item_pressed, LV_OPA_20);

    lv_style_init(&styles->win_title);
    lv_style_set_text_font(&styles->win_title, ui->font.heading2);

    lv_style_init(&styles->win_btn);
    lv_style_set_text_font(&styles->win_btn, ui->iconfont.heading3);
    lv_style_set_radius(&styles->win_btn, LV_RADIUS_CIRCLE);
    lv_style_set_min_height(&styles->win_btn, LV_DPX(40));
    lv_style_set_max_height(&styles->win_btn, LV_DPX(40));

    lv_style_init(&styles->win_header);
    lv_style_set_min_height(&styles->win_header, LV_DPX(60));
    lv_style_set_pad_hor(&styles->win_header, LV_DPX(30));
    lv_style_set_pad_top(&styles->win_header, LV_DPX(20));
    lv_style_set_pad_bottom(&styles->win_header, LV_DPX(10));

    lv_style_init(&styles->win_content);
    lv_style_set_pad_hor(&styles->win_content, LV_DPX(30));
    lv_style_set_pad_top(&styles->win_content, LV_DPX(10));
    lv_style_set_pad_bottom(&styles->win_content, LV_DPX(15));

    lv_style_init(&styles->arc_indic);
    lv_style_set_arc_color(&styles->arc_indic, lv_color_lighten(accent_color, LV_OPA_80));
    lv_style_set_arc_opa(&styles->arc_indic, LV_OPA_20);
    lv_style_set_arc_width(&styles->arc_indic, LV_DPX(15));
    lv_style_set_arc_rounded(&styles->arc_indic, true);

    lv_style_init(&styles->arc_indic_primary);
    lv_style_set_arc_color(&styles->arc_indic_primary, accent_color);
    lv_style_set_arc_opa(&styles->arc_indic_primary, LV_OPA_COVER);

    theme->user_data = styles;

    lv_theme_set_apply_cb(theme, apply_cb);
}

void app_theme_deinit(lv_theme_t *theme) {
    theme_context_t *styles = theme->user_data;
    lv_style_reset(&styles->arc_indic_primary);
    lv_style_reset(&styles->arc_indic);

    lv_style_reset(&styles->win_content);
    lv_style_reset(&styles->win_header);
    lv_style_reset(&styles->win_btn);
    lv_style_reset(&styles->win_title);

    lv_style_reset(&styles->msgbox_btns_item_pressed);
    lv_style_reset(&styles->msgbox_btns_item_focused);
    lv_style_reset(&styles->msgbox_btns_item);
    lv_style_reset(&styles->msgbox_btns);
    lv_style_reset(&styles->msgbox_text);
    lv_style_reset(&styles->msgbox_title);
    lv_style_reset(&styles->msgbox_backdrop);
    lv_style_reset(&styles->msgbox);

    lv_style_reset(&styles->modal_bg);

    lv_style_reset(&styles->dropdown_list);

    lv_style_reset(&styles->btn_focused);
    lv_style_reset(&styles->btn_pressed);
    lv_style_reset(&styles->btn);

    lv_style_reset(&styles->focused);
    lv_style_reset(&styles->obj);
    lv_style_reset(&styles->scr);

    free(styles);
}

lv_coord_t app_win_header_size(lv_theme_t *theme) {
    if (theme->apply_cb != apply_cb) {
        return LV_SIZE_CONTENT;
    }
    theme_context_t *styles = theme->user_data;
    lv_style_value_t value;
    if (lv_style_get_prop(&styles->win_header, LV_STYLE_MIN_HEIGHT, &value) != LV_RES_OK) {
        return LV_SIZE_CONTENT;
    }
    return value.num;
}

lv_obj_t *app_lv_win_create(lv_obj_t *parent) {
    lv_theme_t *theme = lv_disp_get_theme(lv_obj_get_disp(parent));
    lv_obj_t *win = lv_win_create(parent, app_win_header_size(theme));
    lv_obj_t *header = lv_win_get_header(win);
    lv_obj_clear_flag(header, LV_OBJ_FLAG_SCROLLABLE);

#if IHSPLAY_WIP_FEATURES
    lv_obj_t *footer = lv_obj_create(win);
    lv_obj_set_style_bg_opa(footer, LV_OPA_30, 0);
    lv_obj_set_style_bg_color(footer, lv_color_black(), 0);
    lv_obj_set_style_pad_hor(footer, lv_obj_get_style_pad_left(header, 0), 0);
    lv_obj_set_size(footer, LV_PCT(100), LV_DPX(40));
    lv_obj_set_flex_flow(footer, LV_FLEX_FLOW_ROW);
    lv_obj_set_flex_align(footer, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);

    lv_obj_t *prompt_a = lv_label_create(footer);
    lv_label_set_text(prompt_a, "(A) Open");

    lv_obj_t *prompt_b = lv_label_create(footer);
    lv_label_set_text(prompt_b, "(B) Back");
#endif
    return win;
}

static void apply_cb(lv_theme_t *theme, lv_obj_t *obj) {
    theme_context_t *styles = theme->user_data;
    lv_obj_t *parent = lv_obj_get_parent(obj);
    if (parent == NULL) {
        lv_obj_add_style(obj, &styles->scr, 0);
        return;
    }
    lv_obj_add_style(obj, &styles->obj, 0);
    if (lv_obj_has_class(obj, &lv_btn_class)) {
        lv_obj_add_style(obj, &styles->btn, 0);
        lv_obj_add_style(obj, &styles->btn_pressed, LV_STATE_PRESSED);
        lv_obj_add_style(obj, &styles->btn_focused, LV_STATE_FOCUS_KEY);
        if (parent->parent != NULL && lv_obj_check_type(parent->parent, &lv_win_class)) {
            if (lv_win_get_header(parent->parent) == obj->parent) {
                lv_obj_add_style(obj, &styles->win_btn, 0);
            }
        }
    } else if (lv_obj_has_class(obj, &lv_label_class)) {
        lv_obj_add_style(obj, &styles->label, 0);
        if (lv_obj_check_type(parent, &lv_msgbox_class)) {
            if (lv_msgbox_get_title(parent) == NULL && lv_msgbox_get_content(parent) == NULL) {
                // Title was not assigned, and the content was not created either. Assume this is the title
                lv_obj_add_style(obj, &styles->msgbox_title, 0);
            }
        } else if (parent->parent != NULL) {
            if (lv_obj_check_type(parent->parent, &lv_msgbox_class)) {
                if (lv_msgbox_get_content(parent->parent) == lv_obj_get_parent(obj)) {
                    lv_obj_add_style(obj, &styles->msgbox_text, 0);
                }
            } else if (lv_obj_check_type(parent->parent, &lv_win_class)) {
                if (lv_win_get_header(parent->parent) == lv_obj_get_parent(obj)) {
                    lv_obj_add_style(obj, &styles->win_title, 0);
                }
            }
        }
    } else if (lv_obj_has_class(obj, &lv_dropdown_class)) {
        lv_obj_add_style(obj, &styles->label, 0);
        lv_obj_add_style(obj, &styles->focused, LV_STATE_FOCUS_KEY);
    } else if (lv_obj_has_class(obj, &lv_dropdownlist_class)) {
        lv_obj_add_style(obj, &styles->modal_bg, 0);
        lv_obj_add_style(obj, &styles->modal_bg, 0);
        lv_obj_add_style(obj, &styles->label, LV_PART_SELECTED);
        lv_obj_add_style(obj, &styles->dropdown_list, 0);
        lv_obj_add_style(obj, &styles->dropdown_list, LV_PART_SELECTED);
    } else if (lv_obj_has_class(obj, &lv_btnmatrix_class)) {
        if (lv_obj_check_type(parent, &lv_msgbox_class)) {
            lv_obj_add_style(obj, &styles->msgbox_btns, 0);
            lv_obj_add_style(obj, &styles->msgbox_btns_item, LV_PART_ITEMS);
            lv_obj_add_style(obj, &styles->msgbox_btns_item_focused, LV_PART_ITEMS | LV_STATE_FOCUSED);
            lv_obj_add_style(obj, &styles->msgbox_btns_item_pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
        }
    } else if (lv_obj_check_type(obj, &lv_msgbox_class)) {
        lv_obj_add_style(obj, &styles->modal_bg, 0);
        lv_obj_add_style(obj, &styles->msgbox, 0);
        msgbox_inject_nav(styles->ui, obj);
    } else if (lv_obj_check_type(obj, &lv_msgbox_backdrop_class)) {
        lv_obj_add_style(obj, &styles->msgbox_backdrop, 0);
    } else if (lv_obj_check_type(obj, &lv_spinner_class)) {
        lv_obj_add_style(obj, &styles->arc_indic, 0);
        lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR);
        lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR);
    } else if (lv_obj_check_type(obj, &lv_arc_class)) {
        lv_obj_add_style(obj, &styles->arc_indic, 0);
        lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR);
        lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR);
    } else if (lv_obj_check_type(parent, &lv_win_class)) {
        if (obj == lv_win_get_header(parent)) {
            lv_obj_add_style(obj, &styles->win_header, 0);
        } else if (obj == lv_win_get_content(parent)) {
            lv_obj_add_style(obj, &styles->win_content, 0);
        }
    }
}


================================================
FILE: app/lvgl/theme.h
================================================
#pragma once

#include <lvgl.h>

typedef struct app_ui_t app_ui_t;

void app_theme_init(lv_theme_t *theme, app_ui_t *ui);

void app_theme_deinit(lv_theme_t *theme);

lv_coord_t app_win_header_size(lv_theme_t *theme);

lv_obj_t *app_lv_win_create(lv_obj_t *parent);

================================================
FILE: app/main.c
================================================
#include <SDL.h>
#include <lvgl.h>

#include "app.h"
#include "config.h"

#include "ui/app_ui.h"

#include "lvgl/display.h"
#include "lvgl/ext/lv_dir_focus.h"

#include "ss4s.h"

#include "backend/host_manager.h"
#include "backend/stream_manager.h"
#include "backend/input_manager.h"

#include "logging.h"
#include "logging_ext_ss4s.h"
#include "logging_ext_sdl.h"
#include "logging_ext_lvgl.h"
#include "os_info.h"

#if IHSPLAY_FEATURE_LIBCEC

#include "cec_sdl.h"

#endif

static void process_events();

static void logging_init();

static app_t *app = NULL;

static bool use_windowed();

int main(int argc, char *argv[]) {
    logging_init();
    app_preinit(argc, argv);
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC);

    os_info_t os_info;
    if (os_info_get(&os_info) == 0) {
        char *str = os_info_str(&os_info);
        commons_log_info("APP", "System: %s", str);
        free(str);
    }

    app_settings_t settings;
    app_settings_init(&settings, &os_info);

    SS4S_Config ss4s_config = {
            .audioDriver = settings.audio_driver,
            .videoDriver = settings.video_driver,
            .loggingFunction = commons_ss4s_logf,
    };
    SS4S_Init(argc, argv, &ss4s_config);
    IHS_Init();
    SDL_RegisterEvents((APP_EVENT_LAST - APP_EVENT_BEGIN) + 1);
    lv_init();
    lv_dir_focus_register();

    int w = 1920, h = 1080;
    SDL_DisplayMode mode;
    SDL_GetDisplayMode(0, 0, &mode);
    /* Get display size. Fallback to 1920x1080 if failed. */
    if (mode.w > 0 && mode.h > 0) {
        w = mode.w;
        h = mode.h;
    }
    Uint32 fullscreen_flag;
#ifdef TARGET_WEBOS
    fullscreen_flag = SDL_WINDOW_FULLSCREEN;
#elif IHSPLAY_FEATURE_FORCE_FULLSCREEN
    fullscreen_flag = SDL_WINDOW_FULLSCREEN_DESKTOP;
#else
    bool windowed = use_windowed();
    if (windowed) {
        w = 1920;
        h = 1080;
        fullscreen_flag = SDL_WINDOW_RESIZABLE;
    } else {
        fullscreen_flag = SDL_WINDOW_FULLSCREEN_DESKTOP;
    }
#endif
    /* Caveat: Don't use SDL_WINDOW_FULLSCREEN_DESKTOP on webOS. On older platforms it's not supported. */
    SDL_Window *window = SDL_CreateWindow("IHSplay", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h,
                                          SDL_WINDOW_ALLOW_HIGHDPI | fullscreen_flag);
    SS4S_PostInit(argc, argv);

    lv_disp_t *disp = app_lv_disp_init(window);
    lv_disp_set_default(disp);

    app = app_create(&settings, disp);
    app->os_info = os_info;

#if IHSPLAY_FEATURE_LIBCEC
    cec_sdl_ctx_t cec;
    cec_sdl_init(&cec, "IHSplay");
#endif

    while (app->running) {
        process_events();
        uint32_t next_delay = lv_task_handler();
        SDL_Delay(stream_manager_is_active(app->stream_manager) ? 1 : next_delay);
    }
    // Drain remaining events
    process_events();

#if IHSPLAY_FEATURE_LIBCEC
    cec_sdl_deinit(&cec);
#endif

    app_destroy(app);

    app_lv_disp_deinit(disp);

    app_settings_deinit(&settings);

    SDL_DestroyWindow(window);
    IHS_Quit();

    SS4S_Quit();

    SDL_Quit();
    commons_logging_deinit();
    os_info_clear(&os_info);
    return 0;
}

static void process_events() {
    SDL_Event event;
    while (SDL_PollEvent(&event)) {
        switch (event.type) {
            case SDL_KEYUP:
            case SDL_KEYDOWN:
            case SDL_MOUSEMOTION:
            case SDL_MOUSEBUTTONDOWN:
            case SDL_MOUSEBUTTONUP:
            case SDL_CONTROLLERAXISMOTION:
            case SDL_CONTROLLERBUTTONDOWN:
            case SDL_CONTROLLERBUTTONUP:
            case SDL_CONTROLLERDEVICEADDED:
            case SDL_CONTROLLERDEVICEREMOVED: {
                bool intercept_by_stream = stream_manager_intercept_event(app->stream_manager, &event);
                if (!intercept_by_stream) {
                    app_sdl_input_event(app, &event);
                }
                stream_manager_handle_event(app->stream_manager, &event);
                break;
            }
            case SDL_APP_WILLENTERBACKGROUND: {
#if IHSPLAY_FEATURE_FORCE_FULLSCREEN
                stream_manager_stop_active(app->stream_manager);
#endif
                break;
            }
            case SDL_APP_DIDENTERFOREGROUND: {
                lv_obj_invalidate(lv_scr_act());
                break;
            }
            case SDL_QUIT: {
                app_quit(app);
                break;
            }
            case APP_RUN_ON_MAIN: {
                void (*action)(app_t *, void *) = event.user.data1;
                void *data = event.user.data2;
                action(app, data);
                break;
            }
            default: {
                if (event.type > APP_UI_EVENT_BEGIN && event.type < APP_UI_EVENT_LAST) {
                    app_ui_event_data_t data = {.data1 = event.user.data1, .data2 = event.user.data2};
                    if (!app_ui_dispatch_event(app->ui, event.type, &data)) {
                        commons_log_debug("UI", "Unhandled UI event 0x%x", event.type);
                    }
                }
                break;
            }
        }
    }
}

static void logging_init() {
    commons_logging_init("ihsplay");
    lv_log_register_print_cb(commons_lv_log);
    SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
    SDL_LogSetOutputFunction(commons_sdl_log, NULL);
}

static bool use_windowed() {
    const char *v = SDL_getenv("IHSPLAY_WINDOWED");
    if (v == NULL) {
        return false;
    }
    return strcmp(v, "1") == 0 || strcmp(v, "true") == 0;
}

void app_ihs_log(IHS_LogLevel level, const char *tag, const char *message) {
    char app_tag[32] = "IHS.";
    strncpy(app_tag + 4, tag, 28);
    commons_log_printf((commons_log_level) level, app_tag, "%s", message);
}

================================================
FILE: app/platform/CMakeLists.txt
================================================
if (TARGET_WEBOS)
    add_subdirectory(webos)
else()
    add_subdirectory(common)
endif ()

================================================
FILE: app/platform/common/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE app_common.c client_info_common.c)

================================================
FILE: app/platform/common/app_common.c
================================================
#include "app.h"

void app_preinit(int argc, char *argv[]) {

}

void app_ui_set_handle_nav_back(app_ui_t *ui, bool handle) {
}

================================================
FILE: app/platform/common/client_info_common.c
================================================
#include "util/client_info.h"

bool client_info_load(client_info_t *info) {
    client_info_load_default(info);
    return true;
}

================================================
FILE: app/platform/webos/CMakeLists.txt
================================================
pkg_check_modules(PBNJSON_C REQUIRED pbnjson_c)
target_sources(ihsplay PRIVATE app_webos.c client_info_webos.c)
target_include_directories(ihsplay PRIVATE ${PBNJSON_C_INCLUDE_DIRS})
target_link_libraries(ihsplay PRIVATE ${PBNJSON_C_LIBRARIES})

================================================
FILE: app/platform/webos/app_webos.c
================================================
#include "app.h"

void app_preinit(int argc, char *argv[]) {
    (void) argc;
    (void) argv;

    SDL_SetHint(SDL_HINT_WEBOS_ACCESS_POLICY_KEYS_EXIT, "true");
    SDL_SetHint(SDL_HINT_WEBOS_CURSOR_SLEEP_TIME, "5000");
}

void app_ui_set_handle_nav_back(app_ui_t *ui, bool handle) {
    (void) ui;
    SDL_SetHint(SDL_HINT_WEBOS_ACCESS_POLICY_KEYS_BACK, handle ? "true" : "false");
}

================================================
FILE: app/platform/webos/client_info_webos.c
================================================
#include "util/client_info.h"

#include <string.h>
#include <stdio.h>
#include <pbnjson.h>

#include "lunasynccall.h"
#include "logging.h"

#include <mbedtls/sha1.h>
#include <mbedtls/sha256.h>

bool client_info_load(client_info_t *info) {
    memset(info, 0, sizeof(*info));
    char *payload = NULL;
    const char *uri = "luna://com.webos.service.config/getConfigs";
    if (!HLunaServiceCallSync(uri, "{\"configNames\":[\"tv.model.serialnumber\", \"tv.model.modelname\"]}", true,
                              &payload) || !payload) {
        commons_log_warn("OSInfo", "Failed to call %s", uri);
        return client_info_load_default(info);
    }

    JSchemaInfo schemaInfo;
    jschema_info_init(&schemaInfo, jschema_all(), NULL, NULL);
    jdomparser_ref parser = jdomparser_create(&schemaInfo, 0);
    jdomparser_feed(parser, payload, (int) strlen(payload));
    jdomparser_end(parser);
    jvalue_ref body = jdomparser_get_result(parser);
    jvalue_ref configs = jobject_get(body, j_cstr_to_buffer("configs"));
    if (jis_null(configs)) {
        jdomparser_release(&parser);
        return client_info_load_default(info);
    }
    jvalue_ref serial_number = jobject_get(configs, j_cstr_to_buffer("tv.model.serialnumber"));
    jvalue_ref module_name = jobject_get(configs, j_cstr_to_buffer("tv.model.modelname"));
    if (!jis_string(serial_number) || !jis_string(module_name)) {
        jdomparser_release(&parser);
        return client_info_load_default(info);
    }
    raw_buffer serial_number_buf = jstring_get(serial_number);
    raw_buffer module_name_buf = jstring_get(module_name);

    unsigned char sha1[20];
    mbedtls_sha1((const unsigned char *) serial_number_buf.m_str, serial_number_buf.m_len, sha1);
    memcpy(&info->device_id, &sha1[4], 16);

    mbedtls_sha256((const unsigned char *) serial_number_buf.m_str, serial_number_buf.m_len, info->secret_key, 0);

    char name[64];
    snprintf(name, 64, "webOS TV %.*s", module_name_buf.m_len, module_name_buf.m_str);
    info->name = strndup(name, 64);

    jdomparser_release(&parser);

    info->config.deviceId = info->device_id;
    info->config.secretKey = info->secret_key;
    info->config.deviceName = info->name;

    return true;
}

================================================
FILE: app/settings/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE settings.c)

================================================
FILE: app/settings/app_settings.h
================================================
#pragma once

#include <stdbool.h>
#include <stdint.h>

#include "array_list.h"

typedef struct os_info_t os_info_t;

typedef struct app_settings_t {
    bool enable_input;
    bool relmouse;
    /** The pointer references to modules */
    const char *audio_driver;
    /** The pointer references to modules */
    const char *video_driver;
    array_list_t modules;
    uint64_t selected_client_id;
} app_settings_t;

void app_settings_init(app_settings_t *settings, const os_info_t *os_info);

void app_settings_deinit(app_settings_t *settings);

================================================
FILE: app/settings/settings.c
================================================
#include <string.h>

#include "app_settings.h"

#include "ss4s_modules.h"

#include "array_list.h"
#include "os_info.h"
#include "logging.h"

void app_settings_init(app_settings_t *settings, const os_info_t *os_info) {
    memset(settings, 0, sizeof(app_settings_t));
    int errno;
    if ((errno = SS4S_ModulesList(&settings->modules, os_info)) != 0) {
        commons_log_error("SS4S", "Can't load modules list: %s", strerror(errno));
    }
    settings->enable_input = true;
    settings->relmouse = true;

    SS4S_ModulePreferences preferences = {.audio_module = NULL, .video_module = NULL};
    SS4S_ModuleSelection selection = {.audio_module = NULL, .video_module = NULL};
    // TODO: check result
    SS4S_ModulesSelect(&settings->modules, &preferences, &selection, true);
    settings->video_driver = SS4S_ModuleInfoGetId(selection.video_module);
    settings->audio_driver = SS4S_ModuleInfoGetId(selection.audio_module);
}

void app_settings_deinit(app_settings_t *settings) {
    SS4S_ModulesListClear(&settings->modules);
}


================================================
FILE: app/ui/CMakeLists.txt
================================================
target_sources(ihsplay PRIVATE
        app_ui.c
        app_ui_font.c
        launcher.c
        hosts/hosts_fragment.c
        settings/settings.c
        settings/basic.c
        settings/widgets.c)

add_subdirectory(common)
add_subdirectory(connection)
add_subdirectory(session)
add_subdirectory(support)


================================================
FILE: app/ui/app_ui.c
================================================
#include <stdlib.h>

#include <lvgl.h>
#include <src/draw/sdl/lv_draw_sdl.h>

#include "app_ui.h"
#include "launcher.h"
#include "lvgl/fonts/bootstrap-icons/regular.h"
#include "lvgl/keypad.h"
#include "lvgl/mouse.h"
#include "lvgl/theme.h"
#include "backend/stream_manager.h"

static void app_input_populate_group(app_ui_t *ui);

static void app_ui_focus_cb(lv_group_t *group);

app_ui_t *app_ui_create(app_t *app, lv_disp_t *disp) {
    lv_draw_sdl_drv_param_t *param = disp->driver->user_data;
    app_ui_t *ui = calloc(1, sizeof(app_ui_t));
    ui->app = app;
    ui->window = param->user_data;
    ui->root = lv_disp_get_scr_act(disp);
    ui->fm = lv_fragment_manager_create(NULL);

    lv_group_t *group = lv_group_create();
    group->user_data = ui;
    lv_group_set_editing(group, 0);
    lv_group_set_default(group);
    lv_group_set_focus_cb(group, app_ui_focus_cb);
    ui->group = group;
    _lv_ll_init(&ui->modal_groups, sizeof(lv_group_t *));

    ui->indev.mouse = app_lv_mouse_indev_init();
    ui->indev.keypad = app_indev_keypad_init(app);

    app_ui_fontset_set_default_size(ui, &ui->font);
    app_ui_fontset_set_default_size(ui, &ui->iconfont);

    app_ui_fontset_init_fc(&ui->font, "sans-serif");
    app_ui_fontset_init_mem(&ui->iconfont, "bootstrap-icons", ttf_bootstrap_icons_data,
                            ttf_bootstrap_icons_size);
    app_ui_fontset_apply_fallback(&ui->font, &ui->iconfont);

    lv_obj_set_style_bg_opa(ui->root, LV_OPA_0, 0);

    lv_style_init(&ui->styles.action_btn_label);
    lv_style_set_text_font(&ui->styles.action_btn_label, ui->iconfont.heading2);

    lv_theme_set_parent(&ui->theme, lv_disp_get_theme(disp));
    app_theme_init(&ui->theme, ui);
    lv_disp_set_theme(disp, &ui->theme);
    return ui;
}

void app_ui_created(app_ui_t *ui) {
    app_ui_push_fragment(ui, &launcher_fragment_class, NULL);
    app_ui_resized(ui, lv_obj_get_width(ui->root), lv_obj_get_height(ui->root));
}

void app_ui_destroy(app_ui_t *ui) {
    lv_group_set_default(NULL);
    lv_group_del(ui->group);
    _lv_ll_clear(&ui->modal_groups);

    lv_style_reset(&ui->styles.action_btn_label);

    app_ui_fontset_deinit(&ui->iconfont);
    app_ui_fontset_deinit(&ui->font);
    lv_fragment_manager_del(ui->fm);

    app_indev_keypad_deinit(ui->indev.keypad);
    app_lv_mouse_indev_deinit(ui->indev.mouse);

    app_theme_deinit(&ui->theme);

    free(ui);
}

void app_ui_resized(app_ui_t *ui, int width, int height) {
    stream_manager_set_viewport_size(ui->app->stream_manager, width, height);
}

void app_ui_set_ignore_keys(app_ui_t *ui, bool ignore) {
    app_indev_keypad_set_ignore(ui->indev.keypad, ignore);
}

lv_fragment_t *app_ui_create_fragment(app_ui_t *ui, const lv_fragment_class_t *cls, void *args) {
    app_ui_fragment_args_t fargs = {ui->app, args};
    return lv_fragment_create(cls, &fargs);
}

void app_ui_push_fragment(app_ui_t *ui, const lv_fragment_class_t *cls, void *args) {
    lv_fragment_t *f = app_ui_create_fragment(ui, cls, args);
    lv_fragment_manager_push(ui->fm, f, &ui->root);
    app_ui_update_nav_back(ui);
}

void app_ui_remove_fragment(app_ui_t *ui, lv_fragment_t *f) {
    lv_fragment_manager_remove(ui->fm, f);
    app_ui_update_nav_back(ui);
}

void app_ui_pop_top_fragment(app_ui_t *ui) {
    lv_fragment_manager_pop(ui->fm);
    app_ui_update_nav_back(ui);
}

bool app_ui_dispatch_event(app_ui_t *ui, app_event_type_t type, app_ui_event_data_t *data) {
    bool handled = lv_fragment_manager_send_event(ui->fm, type, data);
    if (type == APP_UI_NAV_QUIT && !handled) {
        app_quit(ui->app);
        return true;
    }
    return handled;
}

void app_ui_push_modal_group(app_ui_t *ui, lv_group_t *group) {
    LV_ASSERT_NULL(group);
    lv_group_t **tail = _lv_ll_ins_tail(&ui->modal_groups);
    *tail = group;
    app_input_populate_group(ui);
}

void app_ui_remove_modal_group(app_ui_t *ui, lv_group_t *group) {
    lv_group_t **node = NULL;
    _LV_LL_READ_BACK(&ui->modal_groups, node) {
        if (*node == group) break;
    }
    if (node) {
        _lv_ll_remove(&ui->modal_groups, node);
        lv_mem_free(node);
    }
    app_input_populate_group(ui);
}

lv_group_t *app_ui_get_input_group(app_ui_t *ui) {
    return ui->indev.keypad->group;
}

void app_ui_update_nav_back(app_ui_t *ui) {
    size_t stack_size = lv_fragment_manager_get_stack_size(ui->fm);
    LV_ASSERT(stack_size > 0);
    app_ui_set_handle_nav_back(ui, stack_size > 1);
}

static void app_input_populate_group(app_ui_t *ui) {
    lv_group_t *group = NULL;
    lv_group_t *const *tail = _lv_ll_get_tail(&ui->modal_groups);
    if (tail) {
        group = *tail;
    }
    if (!group) {
        group = ui->group;
    }
    if (!group) {
        group = lv_group_get_default();
    }
    lv_indev_set_group(ui->indev.keypad, group);
    lv_indev_set_group(ui->indev.mouse, group);
}

static void app_ui_focus_cb(lv_group_t *group) {

}

================================================
FILE: app/ui/app_ui.h
================================================
#pragma once

#include <lvgl.h>
#include <SDL.h>
#include "app.h"
#include "app_ui_font.h"

typedef struct app_t app_t;


typedef struct app_ui_t {
    app_t *app;
    lv_theme_t theme;
    lv_obj_t *root;
    lv_fragment_manager_t *fm;
    SDL_Window *window;
    app_ui_fontset_t font;
    app_ui_fontset_t iconfont;
    lv_group_t *group;
    lv_ll_t modal_groups;
    struct {
        lv_indev_t *mouse;
        lv_indev_t *keypad;
    } indev;
    struct {
        lv_style_t action_btn_label;
    } styles;
} app_ui_t;

typedef struct app_ui_fragment_args_t {
    app_t *app;
    void *data;
} app_ui_fragment_args_t;

typedef struct app_ui_event_data_t {
    void *data1;
    void *data2;
} app_ui_event_data_t;

app_ui_t *app_ui_create(app_t *app, lv_disp_t *disp);

void app_ui_created(app_ui_t *ui);

void app_ui_destroy(app_ui_t *ui);

void app_ui_resized(app_ui_t *ui, int width, int height);

void app_ui_set_ignore_keys(app_ui_t *ui, bool ignore);

lv_fragment_t *app_ui_create_fragment(app_ui_t *ui, const lv_fragment_class_t *cls, void *args);

void app_ui_push_fragment(app_ui_t *ui, const lv_fragment_class_t *cls, void *args);

void app_ui_remove_fragment(app_ui_t *ui, lv_fragment_t *f);

void app_ui_pop_top_fragment(app_ui_t *ui);

/**
 * @warning DO NOT call this directly!
 * @return true if this event has been handled by someone
 */
bool app_ui_dispatch_event(app_ui_t *ui, app_event_type_t type, app_ui_event_data_t *data);

void app_ui_push_modal_group(app_ui_t *ui, lv_group_t *group);

void app_ui_remove_modal_group(app_ui_t *ui, lv_group_t *group);

lv_group_t *app_ui_get_input_group(app_ui_t *ui);

void app_ui_update_nav_back(app_ui_t *ui);

void app_ui_set_handle_nav_back(app_ui_t *ui, bool handle);

================================================
FILE: app/ui/app_ui_font.c
================================================
#include "app_ui.h"
#include "app_ui_font.h"

#include <fontconfig/fontconfig.h>
#include <assert.h>

static lv_font_t *load_font(const lv_ft_info_t *info, lv_coord_t size);

static bool fontset_load_fc(app_ui_fontset_t *set, FcPattern *font);

void app_ui_fontset_set_default_size(const app_ui_t *ui, app_ui_fontset_t *set) {
    set->sizes.heading1 = LV_DPX(42);
    set->sizes.heading2 = LV_DPX(28);
    set->sizes.heading3 = LV_DPX(21);
    set->sizes.body = LV_DPX(16);
    set->sizes.small = LV_DPX(14);
    set->sizes.huge = LV_DPX(96);
}


void app_ui_fontset_init_mem(app_ui_fontset_t *set, const char *name, const void *mem, size_t size) {
    lv_ft_info_t ft_info = {.name = name, .mem = mem, .mem_size = size, .style = FT_FONT_STYLE_NORMAL};
    set->body = load_font(&ft_info, set->sizes.body);
    set->heading1 = load_font(&ft_info, set->sizes.heading1);
    set->heading2 = load_font(&ft_info, set->sizes.heading2);
    set->heading3 = load_font(&ft_info, set->sizes.heading3);
    set->small = load_font(&ft_info, set->sizes.small);
    set->huge = load_font(&ft_info, set->sizes.huge);
}

void app_ui_fontset_init_fc(app_ui_fontset_t *set, const char *name) {
    //does not necessarily have to be a specific name.  You could put anything here and Fontconfig WILL find a font for you
    FcPattern *pattern = FcNameParse((const FcChar8 *) name);
    assert(pattern != NULL);

    FcConfigSubstitute(NULL, pattern, FcMatchPattern);
    FcDefaultSubstitute(pattern);

    FcResult result;

    FcPattern *font = FcFontMatch(NULL, pattern, &result);

    fontset_load_fc(set, font);

    if (font) {
        FcPatternDestroy(font);
        font = NULL;
    }
    FcPatternDestroy(pattern);
    pattern = NULL;
#ifdef FONT_FAMILY_FALLBACK
    const i18n_entry_t *loc_entry = i18n_entry(i18n_locale());
    pattern = FcNameParse((const FcChar8 *) ((loc_entry && loc_entry->font) ? loc_entry->font : FONT_FAMILY_FALLBACK));
    if (pattern) {
        FcLangSet *ls = FcLangSetCreate();
        if (loc_entry) {
            FcLangSetAdd(ls, (const FcChar8 *) loc_entry->locale);
            FcPatternAddLangSet(pattern, FC_LANG, ls);
        }

        FcConfigSubstitute(NULL, pattern, FcMatchPattern);
        FcDefaultSubstitute(pattern);

        font = FcFontMatch(NULL, pattern, &result);
        if (font) {
            fontset.fallback = calloc(1, sizeof(app_fontset_t));
            if (fontset_load_fc(fontset.fallback, font)) {
                fontset.normal->fallback = fontset.fallback->normal;
                fontset.large->fallback = fontset.fallback->large;
                fontset.small->fallback = fontset.fallback->small;
            } else {
                free(fontset.fallback);
                fontset.fallback = NULL;
            }
            FcPatternDestroy(font);
            font = NULL;
        }
        FcLangSetDestroy(ls);
        FcPatternDestroy(pattern);
        pattern = NULL;
    }
#endif
}

void app_ui_fontset_apply_fallback(app_ui_fontset_t *set, const app_ui_fontset_t *fallback) {
    set->small->fallback = fallback->small;
    set->body->fallback = fallback->body;
    set->heading3->fallback = fallback->heading3;
    set->heading2->fallback = fallback->heading2;
    set->heading1->fallback = fallback->heading1;
    set->huge->fallback = fallback->huge;
}

void app_ui_fontset_deinit(app_ui_fontset_t *set) {
    lv_ft_font_destroy(set->small);
    lv_ft_font_destroy(set->body);
    lv_ft_font_destroy(set->heading3);
    lv_ft_font_destroy(set->heading2);
    lv_ft_font_destroy(set->heading1);
    lv_ft_font_destroy(set->huge);
}

static lv_font_t *load_font(const lv_ft_info_t *info, lv_coord_t size) {
    lv_ft_info_t ft_info = *info;
    ft_info.font = NULL;
    ft_info.weight = size;
    if (!lv_ft_font_init(&ft_info)) {
        LV_LOG_ERROR("Failed to load font");
    }
    return ft_info.font;
}


static bool fontset_load_fc(app_ui_fontset_t *set, FcPattern *font) {
    //The pointer stored in 'file' is tied to 'font'; therefore, when 'font' is freed, this pointer is freed automatically.
    //If you want to return the filename of the selected font, pass a buffer and copy the file name into that buffer
    FcChar8 *file = NULL;

    if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
        lv_ft_info_t ft_info = {.name = (char *) file, .style = FT_FONT_STYLE_NORMAL};
        set->body = load_font(&ft_info, set->sizes.body);
        set->heading1 = load_font(&ft_info, set->sizes.heading1);
        set->heading2 = load_font(&ft_info, set->sizes.heading2);
        set->heading3 = load_font(&ft_info, set->sizes.heading3);
        set->small = load_font(&ft_info, set->sizes.small);
        set->huge = load_font(&ft_info, set->sizes.huge);
        return true;
    }
    return false;
}

================================================
FILE: app/ui/app_ui_font.h
================================================
#pragma once
Download .txt
gitextract_wabvwvnr/

├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   └── workflows/
│       ├── build-test.yml
│       └── release.yml
├── .gitignore
├── .gitmodules
├── .run/
│   └── ihsplay.run.xml
├── CMakeLists.txt
├── LICENSE
├── README.md
├── app/
│   ├── .gitignore
│   ├── CMakeLists.txt
│   ├── app.c
│   ├── app.h
│   ├── app_events.c
│   ├── app_gamepad.c
│   ├── backend/
│   │   ├── CMakeLists.txt
│   │   ├── host_manager.c
│   │   ├── host_manager.h
│   │   ├── input_manager.c
│   │   ├── input_manager.h
│   │   ├── stream/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── stream_input.c
│   │   │   ├── stream_input.h
│   │   │   ├── stream_manager.c
│   │   │   ├── stream_manager.h
│   │   │   ├── stream_manager_internal.h
│   │   │   ├── stream_media.c
│   │   │   └── stream_media.h
│   │   └── stream_manager.h
│   ├── config.h.in
│   ├── lvgl/
│   │   ├── CMakeLists.txt
│   │   ├── display.c
│   │   ├── display.h
│   │   ├── ext/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── lv_child_group.c
│   │   │   ├── lv_child_group.h
│   │   │   ├── lv_dir_focus.c
│   │   │   ├── lv_dir_focus.h
│   │   │   ├── msgbox_ext.c
│   │   │   └── msgbox_ext.h
│   │   ├── fonts/
│   │   │   └── bootstrap-icons/
│   │   │       ├── regular.h
│   │   │       └── symbols.h
│   │   ├── keypad.c
│   │   ├── keypad.h
│   │   ├── lv_conf.h
│   │   ├── mouse.c
│   │   ├── mouse.h
│   │   ├── theme.c
│   │   └── theme.h
│   ├── main.c
│   ├── platform/
│   │   ├── CMakeLists.txt
│   │   ├── common/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── app_common.c
│   │   │   └── client_info_common.c
│   │   └── webos/
│   │       ├── CMakeLists.txt
│   │       ├── app_webos.c
│   │       └── client_info_webos.c
│   ├── settings/
│   │   ├── CMakeLists.txt
│   │   ├── app_settings.h
│   │   └── settings.c
│   ├── ui/
│   │   ├── CMakeLists.txt
│   │   ├── app_ui.c
│   │   ├── app_ui.h
│   │   ├── app_ui_font.c
│   │   ├── app_ui_font.h
│   │   ├── common/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── error_messages.c
│   │   │   ├── error_messages.h
│   │   │   ├── group_utils.c
│   │   │   ├── group_utils.h
│   │   │   ├── progress_dialog.c
│   │   │   └── progress_dialog.h
│   │   ├── connection/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── conn_error_fragment.c
│   │   │   ├── conn_error_fragment.h
│   │   │   ├── connection_fragment.c
│   │   │   ├── connection_fragment.h
│   │   │   ├── pin_fragment.c
│   │   │   └── pin_fragment.h
│   │   ├── hosts/
│   │   │   ├── hosts_fragment.c
│   │   │   └── hosts_fragment.h
│   │   ├── launcher.c
│   │   ├── launcher.h
│   │   ├── session/
│   │   │   ├── CMakeLists.txt
│   │   │   ├── connection_progress.c
│   │   │   ├── connection_progress.h
│   │   │   ├── session.c
│   │   │   ├── session.h
│   │   │   ├── streaming_overlay.c
│   │   │   └── streaming_overlay.h
│   │   ├── settings/
│   │   │   ├── basic.c
│   │   │   ├── basic.h
│   │   │   ├── settings.c
│   │   │   ├── settings.h
│   │   │   ├── widgets.c
│   │   │   └── widgets.h
│   │   └── support/
│   │       ├── CMakeLists.txt
│   │       ├── feedback.c
│   │       ├── feedback.h
│   │       ├── support.c
│   │       ├── support.h
│   │       ├── wiki.c
│   │       └── wiki.h
│   └── util/
│       ├── CMakeLists.txt
│       ├── client_info.c
│       ├── client_info.h
│       ├── listeners_list.c
│       ├── listeners_list.h
│       ├── random.c
│       ├── random.h
│       ├── refcounter.h
│       └── video/
│           ├── CMakeLists.txt
│           └── sps/
│               ├── CMakeLists.txt
│               ├── bitstream.c
│               ├── bitstream.h
│               ├── common.c
│               ├── common.h
│               ├── include/
│               │   └── sps_util.h
│               ├── sps_util_h264.c
│               ├── sps_util_h265.c
│               └── tests/
│                   ├── CMakeLists.txt
│                   ├── sample_data.h
│                   ├── sps_parser_tests.c
│                   ├── test_dimension_h265.c
│                   └── test_nal_start_code.c
├── cmake/
│   ├── AresPackage.cmake
│   ├── CleanupNameLink.cmake
│   ├── PackageDebian.cmake
│   └── PackageWebOS.cmake
├── deploy/
│   ├── raspbian/
│   │   └── sysroot-packages.list
│   └── webos/
│       └── appinfo.in.json
├── tests/
│   ├── CMakeLists.txt
│   └── app/
│       ├── CMakeLists.txt
│       └── utils/
│           └── CMakeLists.txt
└── tools/
    ├── resource-tools/
    │   ├── .gitignore
    │   ├── .nvmrc
    │   ├── async-transform.ts
    │   ├── binheader.ts
    │   ├── codepoints.ts
    │   ├── gulp-subset-font.ts
    │   ├── gulpfile.ts
    │   ├── package.json
    │   ├── res/
    │   │   ├── bootstrap-icons.json
    │   │   └── bootstrap-icons.list
    │   ├── symheader.ts
    │   └── tsconfig.json
    └── webos/
        ├── easy_build.sh
        └── easy_install.sh
Download .txt
SYMBOL INDEX (393 symbols across 74 files)

FILE: app/app.c
  function app_t (line 11) | app_t *app_create(app_settings_t *settings, void *disp) {
  function app_destroy (line 28) | void app_destroy(app_t *app) {
  function app_quit (line 37) | void app_quit(app_t *app) {
  function app_assert_main_thread (line 42) | void app_assert_main_thread(app_t *app) {

FILE: app/app.h
  type app_ui_t (line 12) | typedef struct app_ui_t app_ui_t;
  type stream_manager_t (line 13) | typedef struct stream_manager_t stream_manager_t;
  type host_manager_t (line 14) | typedef struct host_manager_t host_manager_t;
  type input_manager_t (line 15) | typedef struct input_manager_t input_manager_t;
  type app_t (line 17) | typedef struct app_t {
  type app_event_type_t (line 29) | typedef enum app_event_type_t {

FILE: app/app_events.c
  type bus_action_sync_t (line 3) | typedef struct bus_blocking_action_t {
  function app_post_event (line 14) | void app_post_event(app_t *app, app_event_type_t type, void *data1, void...
  function app_run_on_main (line 23) | void app_run_on_main(app_t *app, app_run_action_fn action, void *data) {
  function app_run_on_main_sync (line 28) | void app_run_on_main_sync(app_t *app, app_run_action_fn action, void *da...
  function invoke_action_sync (line 46) | static void invoke_action_sync(app_t *app, void *data) {

FILE: app/app_gamepad.c
  function app_sdl_input_event (line 7) | void app_sdl_input_event(app_t *app, const SDL_Event *event) {

FILE: app/backend/host_manager.c
  type host_manager_t (line 12) | struct host_manager_t {
  type host_manager_enum_error_t (line 20) | typedef struct host_manager_session_error_t {
  type host_manager_authorization_result_t (line 25) | typedef struct host_manager_authorization_result_t {
  type host_manager_streaming_result_t (line 30) | typedef struct host_manager_streaming_result_t {
  function host_manager_t (line 75) | host_manager_t *host_manager_create(app_t *app) {
  function host_manager_destroy (line 88) | void host_manager_destroy(host_manager_t *manager) {
  function host_manager_discovery_start (line 97) | void host_manager_discovery_start(host_manager_t *manager) {
  function host_manager_discovery_stop (line 101) | void host_manager_discovery_stop(host_manager_t *manager) {
  function array_list_t (line 105) | array_list_t *host_manager_get_hosts(host_manager_t *manager) {
  function host_manager_session_request (line 109) | void host_manager_session_request(host_manager_t *manager, const IHS_Hos...
  function host_manager_register_listener (line 121) | void host_manager_register_listener(host_manager_t *manager, const host_...
  function host_manager_unregister_listener (line 125) | void host_manager_unregister_listener(host_manager_t *manager, const hos...
  function host_manager_authorization_request (line 129) | void host_manager_authorization_request(host_manager_t *manager, const I...
  function host_manager_authorization_cancel (line 133) | bool host_manager_authorization_cancel(host_manager_t *manager) {
  function client_host_discovered (line 137) | static void client_host_discovered(IHS_Client *client, const IHS_HostInf...
  function client_authorization_success (line 145) | static void client_authorization_success(IHS_Client *client, const IHS_H...
  function client_authorization_failed (line 155) | static void client_authorization_failed(IHS_Client *client, const IHS_Ho...
  function client_streaming_success (line 166) | static void client_streaming_success(IHS_Client *client, const IHS_HostI...
  function client_streaming_failed (line 178) | static void client_streaming_failed(IHS_Client *client, const IHS_HostIn...
  function client_host_discovered_main (line 189) | static void client_host_discovered_main(app_t *app, void *data) {
  function client_streaming_success_main (line 228) | static void client_streaming_success_main(app_t *app, void *data) {
  function client_streaming_failed_main (line 236) | static void client_streaming_failed_main(app_t *app, void *data) {
  function client_authorization_success_main (line 245) | static void client_authorization_success_main(app_t *app, void *data) {
  function client_authorization_failed_main (line 254) | static void client_authorization_failed_main(app_t *app, void *data) {
  function compare_host_name (line 263) | static int compare_host_name(const void *a, const void *b) {

FILE: app/backend/host_manager.h
  type app_t (line 5) | typedef struct app_t app_t;
  type host_manager_t (line 6) | typedef struct host_manager_t host_manager_t;
  type array_list_t (line 7) | typedef struct array_list_t array_list_t;
  type host_manager_hosts_change (line 9) | typedef enum host_manager_hosts_change {
  type host_manager_listener_t (line 14) | typedef struct host_manager_listener_t {

FILE: app/backend/input_manager.c
  function input_manager_t (line 31) | input_manager_t *input_manager_create() {
  function input_manager_destroy (line 38) | void input_manager_destroy(input_manager_t *manager) {
  function IHS_HIDProvider (line 48) | IHS_HIDProvider *input_manager_get_hid_provider(input_manager_t *manager) {
  function input_manager_sdl_gamepad_added (line 52) | void input_manager_sdl_gamepad_added(input_manager_t *manager, int which) {
  function input_manager_sdl_gamepad_removed (line 64) | void input_manager_sdl_gamepad_removed(input_manager_t *manager, SDL_Joy...
  function input_manager_sdl_gamepad_count (line 74) | size_t input_manager_sdl_gamepad_count(const input_manager_t *manager) {
  function input_manager_ignore_next_mouse_movement (line 78) | void input_manager_ignore_next_mouse_movement(input_manager_t *manager) {
  function input_manager_get_and_reset_mouse_movement (line 82) | bool input_manager_get_and_reset_mouse_movement(input_manager_t *manager) {
  function insert_controller (line 88) | static void insert_controller(input_manager_t *manager, SDL_JoystickID i...
  function remove_controller_at (line 101) | static void remove_controller_at(input_manager_t *manager, size_t index) {
  function manager_index (line 105) | static int manager_index(const input_manager_t *manager, SDL_JoystickID ...
  function js_count (line 109) | static int js_count(void *context) {
  function js_index (line 114) | static int js_index(SDL_JoystickID instance_id, void *context) {
  function SDL_JoystickID (line 125) | static SDL_JoystickID js_instance_id(int index, void *context) {
  function SDL_GameController (line 134) | static SDL_GameController *js_controller(int index, void *context) {
  function instance_id_compar (line 143) | static int instance_id_compar(const void *id, const void *item) {

FILE: app/backend/input_manager.h
  type opened_controller_t (line 8) | typedef struct opened_controller_t {
  type input_manager_t (line 13) | typedef struct input_manager_t {

FILE: app/backend/stream/stream_input.c
  function stream_input_handle_key_event (line 8) | bool stream_input_handle_key_event(stream_manager_t *manager, const SDL_...
  function stream_input_handle_mouse_event (line 41) | bool stream_input_handle_mouse_event(stream_manager_t *manager, const SD...

FILE: app/backend/stream/stream_manager.c
  type event_context_t (line 55) | typedef struct event_context_t {
  function stream_manager_t (line 76) | stream_manager_t *stream_manager_create(app_t *app) {
  function stream_manager_destroy (line 84) | void stream_manager_destroy(stream_manager_t *manager) {
  function stream_manager_register_listener (line 98) | void stream_manager_register_listener(stream_manager_t *manager, const s...
  function stream_manager_unregister_listener (line 103) | void stream_manager_unregister_listener(stream_manager_t *manager, const...
  function stream_manager_start_session (line 107) | bool stream_manager_start_session(stream_manager_t *manager, const IHS_S...
  function IHS_Session (line 138) | IHS_Session *stream_manager_active_session(const stream_manager_t *manag...
  function stream_manager_stop_active (line 145) | void stream_manager_stop_active(stream_manager_t *manager) {
  function stream_manager_intercept_event (line 153) | bool stream_manager_intercept_event(const stream_manager_t *manager, con...
  function stream_manager_handle_event (line 172) | void stream_manager_handle_event(stream_manager_t *manager, const SDL_Ev...
  function stream_manager_set_viewport_size (line 219) | void stream_manager_set_viewport_size(stream_manager_t *manager, int wid...
  function stream_manager_is_overlay_opened (line 227) | bool stream_manager_is_overlay_opened(const stream_manager_t *manager) {
  function stream_manager_set_overlay_height (line 234) | void stream_manager_set_overlay_height(stream_manager_t *manager, int he...
  function stream_manager_set_overlay_opened (line 241) | bool stream_manager_set_overlay_opened(stream_manager_t *manager, bool o...
  function stream_manager_set_capture_size (line 257) | void stream_manager_set_capture_size(stream_manager_t *manager, int widt...
  function stream_manager_is_active (line 262) | bool stream_manager_is_active(const stream_manager_t *manager) {
  function session_initialized (line 266) | static void session_initialized(IHS_Session *session, void *context) {
  function session_finalized (line 272) | static void session_finalized(IHS_Session *session, void *context) {
  function session_configuring (line 281) | static void session_configuring(IHS_Session *session, IHS_SessionConfig ...
  function session_connected (line 288) | static void session_connected(IHS_Session *session, void *context) {
  function session_disconnected (line 304) | static void session_disconnected(IHS_Session *session, void *context) {
  function session_show_cursor (line 323) | static void session_show_cursor(IHS_Session *session, float x, float y, ...
  function session_connected_main (line 342) | static void session_connected_main(app_t *app, void *context) {
  function session_disconnected_main (line 350) | static void session_disconnected_main(app_t *app, void *context) {
  function session_show_cursor_main (line 359) | static void session_show_cursor_main(app_t *app, void *context) {
  function destroy_session_main (line 367) | static void destroy_session_main(app_t *app, void *context) {
  function controller_back_pressed (line 376) | static void controller_back_pressed(stream_manager_t *manager) {
  function controller_back_released (line 384) | static void controller_back_released(stream_manager_t *manager) {
  function grab_mouse (line 396) | static void grab_mouse(stream_manager_t *manager, bool grab) {
  function Uint32 (line 405) | static Uint32 back_timer_callback(Uint32 duration, void *param) {
  function back_timer_progress_main (line 425) | static void back_timer_progress_main(app_t *app, void *context) {
  function back_timer_finish_main (line 431) | static void back_timer_finish_main(app_t *app, void *context) {

FILE: app/backend/stream/stream_manager.h
  type app_t (line 7) | typedef struct app_t app_t;
  type host_manager_t (line 8) | typedef struct host_manager_t host_manager_t;
  type stream_manager_t (line 10) | typedef struct stream_manager_t stream_manager_t;
  type stream_manager_listener_t (line 12) | typedef struct stream_manager_callbacks_t {

FILE: app/backend/stream/stream_manager_internal.h
  type stream_manager_state_t (line 8) | typedef enum stream_manager_state_t {
  type stream_manager_t (line 15) | struct stream_manager_t {

FILE: app/backend/stream/stream_media.c
  type stream_media_session_t (line 13) | struct stream_media_session_t {
  function stream_media_session_t (line 56) | stream_media_session_t *stream_media_create(stream_manager_t *manager) {
  function stream_media_destroy (line 67) | void stream_media_destroy(stream_media_session_t *media_session) {
  function stream_media_set_viewport_size (line 73) | void stream_media_set_viewport_size(stream_media_session_t *media_sessio...
  function stream_media_set_overlay_height (line 80) | void stream_media_set_overlay_height(stream_media_session_t *media_sessi...
  function stream_media_set_overlay_shown (line 86) | void stream_media_set_overlay_shown(stream_media_session_t *media_sessio...
  function stream_media_supports_hevc (line 112) | bool stream_media_supports_hevc(stream_media_session_t *media_session) {
  function IHS_StreamAudioCallbacks (line 116) | const IHS_StreamAudioCallbacks *stream_media_audio_callbacks() {
  function IHS_StreamVideoCallbacks (line 120) | const IHS_StreamVideoCallbacks *stream_media_video_callbacks() {
  function audio_start (line 124) | static int audio_start(IHS_Session *session, const IHS_StreamAudioConfig...
  function audio_stop (line 154) | static void audio_stop(IHS_Session *session, void *context) {
  function audio_submit (line 162) | static int audio_submit(IHS_Session *session, IHS_Buffer *data, void *co...
  function video_start (line 171) | static int video_start(IHS_Session *session, const IHS_StreamVideoConfig...
  function video_stop (line 198) | static void video_stop(IHS_Session *session, void *context) {
  function video_submit (line 204) | static int video_submit(IHS_Session *session, IHS_Buffer *data, IHS_Stre...
  function video_set_capture_size (line 246) | static int video_set_capture_size(IHS_Session *session, int width, int h...

FILE: app/backend/stream/stream_media.h
  type stream_media_session_t (line 5) | typedef struct stream_media_session_t stream_media_session_t;
  type stream_manager_t (line 6) | typedef struct stream_manager_t stream_manager_t;

FILE: app/lvgl/display.c
  function lv_disp_t (line 8) | lv_disp_t *app_lv_disp_init(SDL_Window *window) {
  function app_lv_disp_deinit (line 36) | void app_lv_disp_deinit(lv_disp_t *disp) {
  function flush_cb (line 59) | static void flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_...

FILE: app/lvgl/ext/lv_child_group.c
  function cb_child_group_add (line 3) | void cb_child_group_add(lv_event_t *event) {

FILE: app/lvgl/ext/lv_dir_focus.c
  type focus_dir_index (line 10) | typedef enum focus_dir_index {
  function lv_dir_focus_register (line 17) | void lv_dir_focus_register() {
  function lv_obj_set_dir_focus_obj (line 25) | void lv_obj_set_dir_focus_obj(lv_obj_t *obj, lv_dir_t dir, const lv_obj_...
  function lv_obj_focus_dir (line 41) | bool lv_obj_focus_dir(lv_obj_t *obj, lv_dir_t dir) {
  function lv_obj_focus_dir_by_key (line 81) | bool lv_obj_focus_dir_by_key(lv_obj_t *obj, lv_key_t dir) {

FILE: app/lvgl/ext/msgbox_ext.c
  function msgbox_inject_nav (line 11) | void msgbox_inject_nav(app_ui_t *ui, lv_obj_t *obj) {
  function msgbox_fix_sizes (line 21) | void msgbox_fix_sizes(lv_obj_t *obj, const char *btn_texts[]) {
  function msgbox_key (line 30) | static void msgbox_key(lv_event_t *event) {
  function msgbox_cancel (line 49) | static void msgbox_cancel(lv_event_t *event) {
  function msgbox_destroy (line 61) | static void msgbox_destroy(lv_event_t *event) {

FILE: app/lvgl/ext/msgbox_ext.h
  type app_ui_t (line 5) | typedef struct app_ui_t app_ui_t;

FILE: app/lvgl/keypad.c
  type keyboard_state_t (line 8) | typedef struct keyboard_state_t {
  function lv_indev_t (line 31) | lv_indev_t *app_indev_keypad_init(app_t *app) {
  function app_indev_keypad_deinit (line 44) | void app_indev_keypad_deinit(lv_indev_t *indev) {
  function app_indev_keypad_set_ignore (line 51) | void app_indev_keypad_set_ignore(lv_indev_t *indev, bool ignore) {
  function app_indev_keypad_sdl_key_event (line 56) | void app_indev_keypad_sdl_key_event(lv_indev_t *indev, const SDL_Keyboar...
  function app_indev_keypad_sdl_cbutton_event (line 83) | void app_indev_keypad_sdl_cbutton_event(lv_indev_t *indev, const SDL_Con...
  function app_indev_keypad_inject_key (line 105) | void app_indev_keypad_inject_key(lv_indev_t *indev, lv_key_t key, bool p...
  function read_cb (line 123) | static void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {
  function handle_esc (line 142) | static void handle_esc(keyboard_state_t *state) {
  function key_from_keysym (line 162) | static uint32_t key_from_keysym(const SDL_Keysym *keysym) {
  function key_from_cbutton (line 197) | static uint32_t key_from_cbutton(uint8_t button) {

FILE: app/lvgl/keypad.h
  type app_t (line 6) | typedef struct app_t app_t;

FILE: app/lvgl/mouse.c
  function lv_indev_t (line 7) | lv_indev_t *app_lv_mouse_indev_init() {
  function app_lv_mouse_indev_deinit (line 18) | void app_lv_mouse_indev_deinit(lv_indev_t *indev) {
  function read_cb (line 24) | static void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) {

FILE: app/lvgl/theme.c
  type theme_context_t (line 10) | typedef struct theme_context_t {
  function app_theme_init (line 48) | void app_theme_init(lv_theme_t *theme, app_ui_t *ui) {
  function app_theme_deinit (line 194) | void app_theme_deinit(lv_theme_t *theme) {
  function lv_coord_t (line 228) | lv_coord_t app_win_header_size(lv_theme_t *theme) {
  function lv_obj_t (line 240) | lv_obj_t *app_lv_win_create(lv_obj_t *parent) {
  function apply_cb (line 264) | static void apply_cb(lv_theme_t *theme, lv_obj_t *obj) {

FILE: app/lvgl/theme.h
  type app_ui_t (line 5) | typedef struct app_ui_t app_ui_t;

FILE: app/main.c
  function main (line 38) | int main(int argc, char *argv[]) {
  function process_events (line 132) | static void process_events() {
  function logging_init (line 186) | static void logging_init() {
  function use_windowed (line 193) | static bool use_windowed() {
  function app_ihs_log (line 201) | void app_ihs_log(IHS_LogLevel level, const char *tag, const char *messag...

FILE: app/platform/common/app_common.c
  function app_preinit (line 3) | void app_preinit(int argc, char *argv[]) {
  function app_ui_set_handle_nav_back (line 7) | void app_ui_set_handle_nav_back(app_ui_t *ui, bool handle) {

FILE: app/platform/common/client_info_common.c
  function client_info_load (line 3) | bool client_info_load(client_info_t *info) {

FILE: app/platform/webos/app_webos.c
  function app_preinit (line 3) | void app_preinit(int argc, char *argv[]) {
  function app_ui_set_handle_nav_back (line 11) | void app_ui_set_handle_nav_back(app_ui_t *ui, bool handle) {

FILE: app/platform/webos/client_info_webos.c
  function client_info_load (line 13) | bool client_info_load(client_info_t *info) {

FILE: app/settings/app_settings.h
  type os_info_t (line 8) | typedef struct os_info_t os_info_t;
  type app_settings_t (line 10) | typedef struct app_settings_t {

FILE: app/settings/settings.c
  function app_settings_init (line 11) | void app_settings_init(app_settings_t *settings, const os_info_t *os_inf...
  function app_settings_deinit (line 28) | void app_settings_deinit(app_settings_t *settings) {

FILE: app/ui/app_ui.c
  function app_ui_t (line 18) | app_ui_t *app_ui_create(app_t *app, lv_disp_t *disp) {
  function app_ui_created (line 56) | void app_ui_created(app_ui_t *ui) {
  function app_ui_destroy (line 61) | void app_ui_destroy(app_ui_t *ui) {
  function app_ui_resized (line 80) | void app_ui_resized(app_ui_t *ui, int width, int height) {
  function app_ui_set_ignore_keys (line 84) | void app_ui_set_ignore_keys(app_ui_t *ui, bool ignore) {
  function lv_fragment_t (line 88) | lv_fragment_t *app_ui_create_fragment(app_ui_t *ui, const lv_fragment_cl...
  function app_ui_push_fragment (line 93) | void app_ui_push_fragment(app_ui_t *ui, const lv_fragment_class_t *cls, ...
  function app_ui_remove_fragment (line 99) | void app_ui_remove_fragment(app_ui_t *ui, lv_fragment_t *f) {
  function app_ui_pop_top_fragment (line 104) | void app_ui_pop_top_fragment(app_ui_t *ui) {
  function app_ui_dispatch_event (line 109) | bool app_ui_dispatch_event(app_ui_t *ui, app_event_type_t type, app_ui_e...
  function app_ui_push_modal_group (line 118) | void app_ui_push_modal_group(app_ui_t *ui, lv_group_t *group) {
  function app_ui_remove_modal_group (line 125) | void app_ui_remove_modal_group(app_ui_t *ui, lv_group_t *group) {
  function lv_group_t (line 137) | lv_group_t *app_ui_get_input_group(app_ui_t *ui) {
  function app_ui_update_nav_back (line 141) | void app_ui_update_nav_back(app_ui_t *ui) {
  function app_input_populate_group (line 147) | static void app_input_populate_group(app_ui_t *ui) {
  function app_ui_focus_cb (line 163) | static void app_ui_focus_cb(lv_group_t *group) {

FILE: app/ui/app_ui.h
  type app_t (line 8) | typedef struct app_t app_t;
  type app_ui_t (line 11) | typedef struct app_ui_t {
  type app_ui_fragment_args_t (line 30) | typedef struct app_ui_fragment_args_t {
  type app_ui_event_data_t (line 35) | typedef struct app_ui_event_data_t {

FILE: app/ui/app_ui_font.c
  function app_ui_fontset_set_default_size (line 11) | void app_ui_fontset_set_default_size(const app_ui_t *ui, app_ui_fontset_...
  function app_ui_fontset_init_mem (line 21) | void app_ui_fontset_init_mem(app_ui_fontset_t *set, const char *name, co...
  function app_ui_fontset_init_fc (line 31) | void app_ui_fontset_init_fc(app_ui_fontset_t *set, const char *name) {
  function app_ui_fontset_apply_fallback (line 85) | void app_ui_fontset_apply_fallback(app_ui_fontset_t *set, const app_ui_f...
  function app_ui_fontset_deinit (line 94) | void app_ui_fontset_deinit(app_ui_fontset_t *set) {
  function lv_font_t (line 103) | static lv_font_t *load_font(const lv_ft_info_t *info, lv_coord_t size) {
  function fontset_load_fc (line 114) | static bool fontset_load_fc(app_ui_fontset_t *set, FcPattern *font) {

FILE: app/ui/app_ui_font.h
  type app_t (line 6) | typedef struct app_t app_t;
  type app_ui_t (line 7) | typedef struct app_ui_t app_ui_t;
  type app_ui_font_sizes_t (line 9) | typedef struct app_ui_font_sizes_t {
  type app_ui_fontset_t (line 17) | typedef struct app_ui_fontset_t {

FILE: app/ui/common/group_utils.c
  function lv_obj_t (line 4) | lv_obj_t *ui_group_first_in_parent(lv_group_t *group, lv_obj_t *parent) {

FILE: app/ui/common/progress_dialog.c
  function lv_obj_t (line 3) | lv_obj_t *progress_dialog_create(const char *message) {
  function progress_dialog_set_message (line 23) | void progress_dialog_set_message(lv_obj_t *obj, const char *message) {

FILE: app/ui/connection/conn_error_fragment.c
  type conn_error_fragment_t (line 4) | typedef struct conn_error_fragment_t {
  function conn_error_ctor (line 26) | static void conn_error_ctor(lv_fragment_t *self, void *arg) {
  function conn_error_dtor (line 34) | static void conn_error_dtor(lv_fragment_t *self) {
  function lv_obj_t (line 39) | static lv_obj_t *conn_error_create_obj(lv_fragment_t *self, lv_obj_t *co...
  function conn_error_obj_created (line 51) | static void conn_error_obj_created(lv_fragment_t *self, lv_obj_t *obj) {

FILE: app/ui/connection/conn_error_fragment.h
  type conn_error_fragment_data (line 5) | typedef struct conn_error_fragment_data {

FILE: app/ui/connection/connection_fragment.c
  type connection_fragment_t (line 14) | typedef struct connection_fragment_t {
  function conn_ctor (line 57) | static void conn_ctor(lv_fragment_t *self, void *arg) {
  function lv_obj_t (line 65) | static lv_obj_t *conn_create_obj(lv_fragment_t *self, lv_obj_t *containe...
  function conn_obj_created (line 73) | static void conn_obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function conn_obj_will_del (line 80) | static void conn_obj_will_del(lv_fragment_t *self, lv_obj_t *obj) {
  function connection_fragment_set_title (line 86) | void connection_fragment_set_title(lv_fragment_t *self, const char *titl...
  function session_started (line 91) | static void session_started(const IHS_HostInfo *host, const IHS_SessionI...
  function session_start_failed (line 101) | static void session_start_failed(const IHS_HostInfo *host, IHS_Streaming...
  function authorized (line 113) | static void authorized(const IHS_HostInfo *host, uint64_t steam_id, void...
  function authorization_failed (line 123) | static void authorization_failed(const IHS_HostInfo *host, IHS_Authoriza...
  function open_authorization (line 132) | static void open_authorization(connection_fragment_t *fragment, const IH...
  function conn_show_page (line 139) | static void conn_show_page(connection_fragment_t *fragment, const lv_fra...

FILE: app/ui/connection/pin_fragment.c
  type pin_fragment_t (line 5) | typedef struct pin_fragment_t {
  function pin_ctor (line 24) | static void pin_ctor(lv_fragment_t *self, void *arg) {
  function lv_obj_t (line 31) | static lv_obj_t *pin_create_obj(lv_fragment_t *self, lv_obj_t *container) {
  function pin_obj_created (line 47) | static void pin_obj_created(lv_fragment_t *self, lv_obj_t *obj) {

FILE: app/ui/hosts/hosts_fragment.c
  type hosts_fragment (line 17) | typedef struct hosts_fragment {
  type host_obj_holder (line 25) | typedef struct host_obj_holder {
  function hosts_fragment_focus_hosts (line 98) | void hosts_fragment_focus_hosts(lv_fragment_t *self) {
  function constructor (line 107) | static void constructor(lv_fragment_t *self, void *arg) {
  function destructor (line 114) | static void destructor(lv_fragment_t *self) {
  function lv_obj_t (line 118) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *container) {
  function obj_created (line 147) | static void obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_will_delete (line 161) | static void obj_will_delete(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_deleted (line 167) | static void obj_deleted(lv_fragment_t *self, lv_obj_t *obj) {
  function hosts_changed (line 173) | static void hosts_changed(array_list_t *list, host_manager_hosts_change ...
  function lv_obj_t (line 194) | static lv_obj_t *open_msgbox(hosts_fragment *fragment, const char *title...
  function close_msgbox (line 203) | static void close_msgbox(hosts_fragment *fragment) {
  function msgbox_confirm_cb (line 211) | static void msgbox_confirm_cb(lv_event_t *e) {
  function msgbox_del_cb (line 217) | static void msgbox_del_cb(lv_event_t *e) {
  function authorization_cancel_cb (line 225) | static void authorization_cancel_cb(lv_event_t *e) {
  function host_item_count (line 233) | static int host_item_count(lv_obj_t *grid, void *data) {
  function lv_obj_t (line 238) | static lv_obj_t *host_item_create(lv_obj_t *grid) {
  function host_item_delete (line 273) | static void host_item_delete(lv_event_t *e) {
  function host_item_bind (line 277) | static void host_item_bind(lv_obj_t *grid, lv_obj_t *item_view, void *da...
  function grid_size_populate (line 291) | static void grid_size_populate(hosts_fragment *fragment) {
  function host_item_clicked (line 302) | static void host_item_clicked(lv_event_t *e) {
  function size_changed_cb (line 315) | static void size_changed_cb(lv_event_t *e) {
  function grid_focused (line 320) | static void grid_focused(lv_event_t *e) {
  function grid_unfocused (line 338) | static void grid_unfocused(lv_event_t *e) {
  function grid_key_cb (line 343) | static void grid_key_cb(lv_event_t *e) {
  function event_cb (line 353) | static bool event_cb(lv_fragment_t *self, int code, void *data) {

FILE: app/ui/launcher.c
  type launcher_fragment (line 22) | typedef struct launcher_fragment {
  function constructor (line 94) | static void constructor(lv_fragment_t *self, void *arg) {
  function destructor (line 118) | static void destructor(lv_fragment_t *self) {
  function lv_obj_t (line 124) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *container) {
  function obj_created (line 201) | static void obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_will_delete (line 213) | static void obj_will_delete(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_deleted (line 219) | static void obj_deleted(lv_fragment_t *self, lv_obj_t *obj) {
  function launcher_fragment_set_selected_host (line 223) | void launcher_fragment_set_selected_host(lv_fragment_t *self, uint64_t c...
  function hosts_changed (line 228) | static void hosts_changed(array_list_t *list, host_manager_hosts_change ...
  function launcher_gamepads_changed (line 237) | static void launcher_gamepads_changed(launcher_fragment *fragment) {
  function event_cb (line 250) | static bool event_cb(lv_fragment_t *self, int type, void *data) {
  function lv_obj_t (line 264) | static lv_obj_t *launch_option_create_label_action(launcher_fragment *fr...
  function lv_obj_t (line 286) | static lv_obj_t *launch_option_get_label(lv_obj_t *obj) {
  function launch_option_set_text (line 290) | static void launch_option_set_text(lv_obj_t *obj, const char *label) {
  function focus_content (line 294) | static void focus_content(lv_event_t *e) {
  function open_settings (line 303) | static void open_settings(lv_event_t *e) {
  function open_support (line 308) | static void open_support(lv_event_t *e) {
  function select_host (line 313) | static void select_host(lv_event_t *e) {
  function request_session (line 318) | static void request_session(lv_event_t *e) {
  function launcher_quit (line 329) | static void launcher_quit(lv_event_t *e) {
  function hosts_update (line 333) | static void hosts_update(launcher_fragment *fragment) {
  function IHS_HostInfo (line 342) | static const IHS_HostInfo *get_selected_host(launcher_fragment *fragment) {

FILE: app/ui/session/connection_progress.c
  type connection_progress_fragment (line 6) | typedef struct connection_progress_fragment {
  function constructor (line 12) | void constructor(lv_fragment_t *self, void *args) {
  function lv_obj_t (line 17) | lv_obj_t *create_obj_cb(lv_fragment_t *self, lv_obj_t *container) {

FILE: app/ui/session/session.c
  type session_fragment_t (line 16) | typedef struct session_fragment_t {
  type cursor_t (line 36) | typedef struct cursor_t {
  function constructor (line 95) | static void constructor(lv_fragment_t *self, void *args) {
  function destructor (line 130) | static void destructor(lv_fragment_t *self) {
  function lv_obj_t (line 137) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *container) {
  function obj_created (line 177) | static void obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_will_delete (line 195) | static void obj_will_delete(lv_fragment_t *self, lv_obj_t *obj) {
  function event_cb (line 205) | static bool event_cb(lv_fragment_t *self, int code, void *userdata) {
  function session_connected_main (line 234) | static void session_connected_main(const IHS_SessionInfo *info, void *co...
  function session_disconnected_main (line 244) | static void session_disconnected_main(const IHS_SessionInfo *info, bool ...
  function session_overlay_progress (line 257) | static void session_overlay_progress(int percentage, void *context) {
  function session_overlay_progress_finished (line 265) | static void session_overlay_progress_finished(bool requested, void *cont...
  function session_show_cursor (line 270) | static void session_show_cursor(IHS_Session *session, float x, float y, ...
  function session_set_cursor (line 283) | static bool session_set_cursor(IHS_Session *session, uint64_t cursorId, ...
  function session_hide_cursor (line 296) | static void session_hide_cursor(IHS_Session *session, void *context) {
  function cursor_t (line 304) | static const cursor_t *session_current_cursor(session_fragment_t *fragme...
  function session_cursor_image (line 316) | static void session_cursor_image(IHS_Session *session, const IHS_StreamI...
  function disconnected_dialog_cb (line 342) | static void disconnected_dialog_cb(lv_event_t *e) {
  function screen_clicked_cb (line 347) | static void screen_clicked_cb(lv_event_t *e) {
  function set_overlay_visible (line 356) | static void set_overlay_visible(session_fragment_t *fragment, bool visib...
  function lv_style_t (line 371) | lv_style_t *session_fragment_get_overlay_style(lv_fragment_t *fragment) {

FILE: app/ui/session/session.h
  type session_fragment_args_t (line 6) | typedef struct session_fragment_args_t {

FILE: app/ui/session/streaming_overlay.c
  type streaming_overlay_fragment_t (line 9) | typedef struct streaming_overlay_fragment_t {
  function constructor_cb (line 34) | static void constructor_cb(lv_fragment_t *self, void *args) {
  function destructor_cb (line 40) | static void destructor_cb(lv_fragment_t *self) {
  function lv_obj_t (line 43) | static lv_obj_t *create_obj_cb(lv_fragment_t *self, lv_obj_t *container) {
  function obj_created_cb (line 64) | static void obj_created_cb(lv_fragment_t *self, lv_obj_t *obj) {
  function quit_clicked_cb (line 68) | static void quit_clicked_cb(lv_event_t *e) {

FILE: app/ui/settings/basic.c
  type basic_fragment (line 7) | typedef struct basic_fragment {
  function constructor (line 12) | static void constructor(lv_fragment_t *self, void *arg) {
  function destructor (line 16) | static void destructor(lv_fragment_t *self) {
  function lv_obj_t (line 20) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *container) {
  function obj_created (line 40) | static void obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_will_delete (line 44) | static void obj_will_delete(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_deleted (line 48) | static void obj_deleted(lv_fragment_t *self, lv_obj_t *obj) {

FILE: app/ui/settings/settings.c
  type settings_fragment (line 9) | typedef struct settings_fragment {
  function constructor (line 40) | static void constructor(lv_fragment_t *self, void *arg) {
  function destructor (line 45) | static void destructor(lv_fragment_t *self) {
  function lv_obj_t (line 48) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *container) {
  function obj_created (line 56) | static void obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_will_delete (line 62) | static void obj_will_delete(lv_fragment_t *self, lv_obj_t *obj) {
  function obj_deleted (line 66) | static void obj_deleted(lv_fragment_t *self, lv_obj_t *obj) {
  function event_cb (line 70) | static bool event_cb(lv_fragment_t *self, int code, void *data) {

FILE: app/ui/settings/widgets.c
  function lv_obj_t (line 3) | lv_obj_t *settings_select_create(lv_obj_t *parent, const char *name) {

FILE: app/ui/support/feedback.c
  type feedback_fragment_t (line 6) | typedef struct feedback_fragment_t {
  function feedback_ctor (line 21) | static void feedback_ctor(lv_fragment_t *self, void *arg) {
  function lv_obj_t (line 25) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *parent) {

FILE: app/ui/support/support.c
  type support_fragment_t (line 8) | typedef struct support_fragment_t {
  function constructor (line 41) | static void constructor(lv_fragment_t *self, void *args) {
  function lv_obj_t (line 54) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *parent) {
  function obj_created (line 74) | static void obj_created(lv_fragment_t *self, lv_obj_t *obj) {
  function event_cb (line 78) | static bool event_cb(lv_fragment_t *self, int code, void *data) {
  function lv_obj_t (line 88) | static lv_obj_t *add_btn(support_fragment_t *fragment, lv_obj_t *parent,...
  function show_page (line 100) | static void show_page(lv_fragment_t *self, const lv_fragment_class_t *cl...
  function btn_click_cb (line 107) | static void btn_click_cb(lv_event_t *e) {
  function btn_key_cb (line 117) | static void btn_key_cb(lv_event_t *e) {

FILE: app/ui/support/wiki.c
  function lv_obj_t (line 10) | static lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *parent) {

FILE: app/util/client_info.c
  function client_info_load_default (line 12) | bool client_info_load_default(client_info_t *info) {
  function client_info_clear (line 21) | void client_info_clear(client_info_t *info) {

FILE: app/util/client_info.h
  type client_info_t (line 5) | typedef struct client_info_t {

FILE: app/util/listeners_list.c
  function array_list_t (line 3) | array_list_t *listeners_list_create() {
  function listeners_list_destroy (line 7) | void listeners_list_destroy(array_list_t *list) {
  function listeners_list_add (line 17) | void listeners_list_add(array_list_t *list, const void *listener, void *...
  function listeners_list_remove (line 25) | void listeners_list_remove(array_list_t *list, const void *listener) {

FILE: app/util/listeners_list.h
  type registered_listener_t (line 6) | typedef struct registered_listener_t {

FILE: app/util/random.c
  function random_pin (line 6) | void random_pin(char *pin) {

FILE: app/util/refcounter.h
  type refcounter_t (line 6) | typedef struct refcounter_t {
  function refcounter_init (line 11) | static inline void refcounter_init(refcounter_t *counter) {
  function refcounter_destroy (line 16) | static inline void refcounter_destroy(refcounter_t *counter) {
  function refcounter_ref (line 22) | static inline void refcounter_ref(refcounter_t *counter) {
  function refcounter_unref (line 29) | static inline bool refcounter_unref(refcounter_t *counter) {

FILE: app/util/video/sps/bitstream.c
  function bitstream_init (line 5) | void bitstream_init(bitstream_t *buf, const unsigned char *data, size_t ...
  function bitstream_read_bits (line 12) | bool bitstream_read_bits(bitstream_t *buf, uint32_t size, uint32_t *valu...
  function bitstream_skip_bits (line 48) | bool bitstream_skip_bits(bitstream_t *buf, uint32_t size) {
  function bitstream_read_ueg (line 56) | bool bitstream_read_ueg(bitstream_t *buf, uint32_t *value) {
  function bitstream_read_eg (line 82) | bool bitstream_read_eg(bitstream_t *buf, int32_t *value) {
  function bitstream_skip_scaling_list (line 95) | bool bitstream_skip_scaling_list(bitstream_t *buf, uint8_t count) {

FILE: app/util/video/sps/bitstream.h
  type bitstream_t (line 7) | typedef struct bitstream_t {
  function bitstream_read1 (line 26) | static inline bool bitstream_read1(bitstream_t *buf, bool *value) {
  function bitstream_read2 (line 33) | static inline bool bitstream_read2(bitstream_t *buf, uint8_t *value) {
  function bitstream_read3 (line 40) | static inline bool bitstream_read3(bitstream_t *buf, uint8_t *value) {
  function bitstream_read4 (line 47) | static inline bool bitstream_read4(bitstream_t *buf, uint8_t *value) {
  function bitstream_read8 (line 54) | static inline bool bitstream_read8(bitstream_t *buf, uint8_t *value) {

FILE: app/util/video/sps/common.c
  function sps_util_nal_skip_start_code (line 3) | int sps_util_nal_skip_start_code(const unsigned char *data, size_t size,...

FILE: app/util/video/sps/include/sps_util.h
  type sps_dimension_t (line 7) | typedef struct sps_dimension_t {

FILE: app/util/video/sps/sps_util_h264.c
  function sps_util_parse_dimension_h264 (line 11) | bool sps_util_parse_dimension_h264(const unsigned char *data, size_t siz...
  function skip_vui_parameters (line 164) | static bool skip_vui_parameters(bitstream_t *buf) {
  function skip_hrd_parameters (line 263) | static bool skip_hrd_parameters(bitstream_t *buf) {

FILE: app/util/video/sps/sps_util_h265.c
  function sps_util_parse_dimension_hevc (line 15) | bool sps_util_parse_dimension_hevc(const unsigned char *data, size_t siz...
  function parse_profile_info (line 90) | static bool parse_profile_info(bitstream_t *buf) {
  function parse_profile_tier_level (line 116) | static bool parse_profile_tier_level(bitstream_t *buf, uint8_t max_sub_l...

FILE: app/util/video/sps/tests/sps_parser_tests.c
  function test_sps_parse_dimension_h264 (line 23) | void test_sps_parse_dimension_h264(void) {
  function test_sps_parse_dimension_hevc (line 30) | void test_sps_parse_dimension_hevc(void) {
  function main (line 38) | int main() {

FILE: app/util/video/sps/tests/test_dimension_h265.c
  function main (line 5) | int main() {

FILE: app/util/video/sps/tests/test_nal_start_code.c
  function main (line 4) | int main() {

FILE: tools/resource-tools/async-transform.ts
  type File (line 5) | type File = BufferFile | StreamFile;
  function asyncTransform (line 7) | function asyncTransform(fn: (file: BufferFile | StreamFile) => Promise<F...

FILE: tools/resource-tools/binheader.ts
  type Case (line 5) | type Case = 'camelCase' | 'PascalCase' | 'snake_case' | 'UPPER_CASE';
  type Option (line 7) | interface Option {
  function joinWithCase (line 12) | function joinWithCase(segments: string[], naming: Case): string {
  function binHeader (line 29) | function binHeader(option?: Partial<Option>) {

FILE: tools/resource-tools/codepoints.ts
  function codepointsList (line 6) | async function codepointsList(path: string, type: string, filter: ((name...
  function selectedList (line 26) | async function selectedList(path: string): Promise<string[]> {
  function codepoints (line 31) | function codepoints() {

FILE: tools/resource-tools/gulp-subset-font.ts
  function subsetFont (line 5) | function subsetFont(text: string | ((file: File) => string)) {

FILE: tools/resource-tools/gulpfile.ts
  function codepointsMetadata (line 10) | function codepointsMetadata(file: any): Record<string, number> {
  function iconfont (line 14) | async function iconfont() {
  function symlist (line 25) | async function symlist() {

FILE: tools/resource-tools/symheader.ts
  type Option (line 3) | interface Option {
  function codepointsMetadata (line 7) | function codepointsMetadata(file: any): Record<string, number> {
  function symheader (line 11) | function symheader(option?: Partial<Option>) {
Condensed preview — 150 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (384K chars).
[
  {
    "path": ".github/FUNDING.yml",
    "chars": 646,
    "preview": "# These are supported funding model platforms\n\ngithub: [mariotaku] \npatreon: # Replace with a single Patreon username\nop"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "chars": 875,
    "preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: \"[BUG]\"\nlabels: ''\nassignees: ''\n\n---\n\n## Issue Su"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "chars": 595,
    "preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Is your fea"
  },
  {
    "path": ".github/workflows/build-test.yml",
    "chars": 3946,
    "preview": "name: Build Test\n\non:\n  push:\n    # Don't run for tags\n    tags-ignore:\n      - '**'\n    branches:\n      - '**'\nenv:\n  #"
  },
  {
    "path": ".github/workflows/release.yml",
    "chars": 2023,
    "preview": "name: Release\n\non:\n  release:\n    types: [ created ]\n\nenv:\n  # Customize the CMake build type here (Release, Debug, RelW"
  },
  {
    "path": ".gitignore",
    "chars": 890,
    "preview": "### C++ template\n# Prerequisites\n*.d\n\n# Compiled Object files\n*.slo\n*.lo\n*.o\n*.obj\n\n# Precompiled Headers\n*.gch\n*.pch\n\n#"
  },
  {
    "path": ".gitmodules",
    "chars": 512,
    "preview": "[submodule \"third_party/lvgl\"]\n\tpath = third_party/lvgl\n\turl = https://github.com/lvgl/lvgl.git\n[submodule \"third_party/"
  },
  {
    "path": ".run/ihsplay.run.xml",
    "chars": 1378,
    "preview": "<component name=\"ProjectRunConfigurationManager\">\n  <configuration default=\"false\" name=\"ihsplay\" type=\"com.jetbrains.ci"
  },
  {
    "path": "CMakeLists.txt",
    "chars": 4905,
    "preview": "cmake_minimum_required(VERSION 3.16)\n\nexecute_process(COMMAND git describe --tags --abbrev=0 WORKING_DIRECTORY ${CMAKE_S"
  },
  {
    "path": "LICENSE",
    "chars": 35141,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 793,
    "preview": "```\n    ______  _______       __\n   /  _/ / / / ___/____  / /___ ___  __      In-Home\n   / // /_/ /\\__ \\/ __ \\/ / __ `/ "
  },
  {
    "path": "app/.gitignore",
    "chars": 10,
    "preview": "./config.h"
  },
  {
    "path": "app/CMakeLists.txt",
    "chars": 252,
    "preview": "add_executable(ihsplay\n        main.c\n        app.c\n        app_events.c\n        app_gamepad.c\n        )\n\nadd_subdirecto"
  },
  {
    "path": "app/app.c",
    "chars": 1290,
    "preview": "#include <stdlib.h>\n#include <assert.h>\n\n#include \"app.h\"\n#include \"ui/app_ui.h\"\n#include \"backend/host_manager.h\"\n#incl"
  },
  {
    "path": "app/app.h",
    "chars": 1586,
    "preview": "#pragma once\n\n#include <stdbool.h>\n#include <SDL.h>\n\n#include \"ihslib.h\"\n#include \"ss4s.h\"\n#include \"settings/app_settin"
  },
  {
    "path": "app/app_events.c",
    "chars": 1431,
    "preview": "#include \"app.h\"\n\ntypedef struct bus_blocking_action_t {\n    app_run_action_fn action;\n\n    void *data;\n    SDL_mutex *m"
  },
  {
    "path": "app/app_gamepad.c",
    "chars": 1027,
    "preview": "#include \"ui/app_ui.h\"\n\n#include \"lvgl/keypad.h\"\n#include \"app.h\"\n#include \"backend/input_manager.h\"\n\nvoid app_sdl_input"
  },
  {
    "path": "app/backend/CMakeLists.txt",
    "chars": 87,
    "preview": "target_sources(ihsplay PRIVATE host_manager.c input_manager.c)\nadd_subdirectory(stream)"
  },
  {
    "path": "app/backend/host_manager.c",
    "chars": 10207,
    "preview": "#include <assert.h>\n\n#include \"app.h\"\n#include \"host_manager.h\"\n\n#include \"array_list.h\"\n#include \"util/refcounter.h\"\n#i"
  },
  {
    "path": "app/backend/host_manager.h",
    "chars": 1630,
    "preview": "#pragma once\n\n#include <ihslib.h>\n\ntypedef struct app_t app_t;\ntypedef struct host_manager_t host_manager_t;\ntypedef str"
  },
  {
    "path": "app/backend/input_manager.c",
    "chars": 5184,
    "preview": "#include \"logging.h\"\n#include \"input_manager.h\"\n\n#include <assert.h>\n\n#include \"ihslib/hid/sdl.h\"\n\nstatic void insert_co"
  },
  {
    "path": "app/backend/input_manager.h",
    "chars": 1056,
    "preview": "#pragma once\n\n#include <SDL2/SDL.h>\n#include <stdbool.h>\n#include \"ihslib/hid/sdl.h\"\n#include \"array_list.h\"\n\ntypedef st"
  },
  {
    "path": "app/backend/stream/CMakeLists.txt",
    "chars": 78,
    "preview": "target_sources(ihsplay PRIVATE stream_manager.c stream_media.c stream_input.c)"
  },
  {
    "path": "app/backend/stream/stream_input.c",
    "chars": 3671,
    "preview": "#include \"app.h\"\n#include \"ui/app_ui.h\"\n\n#include \"stream_input.h\"\n#include \"stream_manager_internal.h\"\n#include \"backen"
  },
  {
    "path": "app/backend/stream/stream_input.h",
    "chars": 228,
    "preview": "#pragma once\n\n#include \"stream_manager.h\"\n\nbool stream_input_handle_key_event(stream_manager_t *manager, const SDL_Keybo"
  },
  {
    "path": "app/backend/stream/stream_manager.c",
    "chars": 15612,
    "preview": "#include <assert.h>\n#include \"stream_manager.h\"\n#include \"stream_manager_internal.h\"\n\n#include \"app.h\"\n#include \"ui/app_"
  },
  {
    "path": "app/backend/stream/stream_manager.h",
    "chars": 2003,
    "preview": "#pragma once\n\n#include \"ihslib.h\"\n\n#include <SDL.h>\n\ntypedef struct app_t app_t;\ntypedef struct host_manager_t host_mana"
  },
  {
    "path": "app/backend/stream/stream_manager_internal.h",
    "chars": 685,
    "preview": "#pragma once\n\n#include \"stream_manager.h\"\n#include \"stream_media.h\"\n\n#include \"array_list.h\"\n\ntypedef enum stream_manage"
  },
  {
    "path": "app/backend/stream/stream_media.c",
    "chars": 10061,
    "preview": "#include <stdlib.h>\n#include \"stream_media.h\"\n\n#include \"ss4s.h\"\n#include \"stream_manager.h\"\n#include \"app.h\"\n#include \""
  },
  {
    "path": "app/backend/stream/stream_media.h",
    "chars": 761,
    "preview": "#pragma once\n\n#include \"ihslib.h\"\n\ntypedef struct stream_media_session_t stream_media_session_t;\ntypedef struct stream_m"
  },
  {
    "path": "app/backend/stream_manager.h",
    "chars": 48,
    "preview": "#pragma once\n\n#include \"stream/stream_manager.h\""
  },
  {
    "path": "app/config.h.in",
    "chars": 282,
    "preview": "#pragma once\n\n#define IHSPLAY_VERSION_STRING \"@PROJECT_VERSION@\"\n#define SS4S_MODULES_INI_PATH \"@SS4S_MODULES_INI_PATH_R"
  },
  {
    "path": "app/lvgl/CMakeLists.txt",
    "chars": 121,
    "preview": "target_sources(ihsplay PRIVATE\n        display.c\n        mouse.c\n        keypad.c\n        theme.c)\n\nadd_subdirectory(ext"
  },
  {
    "path": "app/lvgl/display.c",
    "chars": 2760,
    "preview": "#include \"display.h\"\n\n#include <src/draw/sdl/lv_draw_sdl.h>\n#include <assert.h>\n\nstatic void flush_cb(lv_disp_drv_t *dis"
  },
  {
    "path": "app/lvgl/display.h",
    "chars": 142,
    "preview": "#pragma once\n\n#include <lvgl.h>\n#include <SDL.h>\n\nlv_disp_t *app_lv_disp_init(SDL_Window *window);\n\nvoid app_lv_disp_dei"
  },
  {
    "path": "app/lvgl/ext/CMakeLists.txt",
    "chars": 76,
    "preview": "target_sources(ihsplay PRIVATE lv_child_group.c msgbox_ext.c lv_dir_focus.c)"
  },
  {
    "path": "app/lvgl/ext/lv_child_group.c",
    "chars": 347,
    "preview": "#include \"lv_child_group.h\"\n\nvoid cb_child_group_add(lv_event_t *event) {\n    lv_obj_t *child = lv_event_get_param(event"
  },
  {
    "path": "app/lvgl/ext/lv_child_group.h",
    "chars": 76,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nvoid cb_child_group_add(lv_event_t *event);"
  },
  {
    "path": "app/lvgl/ext/lv_dir_focus.c",
    "chars": 3022,
    "preview": "#include \"lv_dir_focus.h\"\n\nstatic lv_style_prop_t props[4] = {\n        LV_STYLE_PROP_INV,\n        LV_STYLE_PROP_INV,\n   "
  },
  {
    "path": "app/lvgl/ext/lv_dir_focus.h",
    "chars": 263,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\n\nvoid lv_dir_focus_register();\n\nvoid lv_obj_set_dir_focus_obj(lv_obj_t *obj, lv_dir_t d"
  },
  {
    "path": "app/lvgl/ext/msgbox_ext.c",
    "chars": 2075,
    "preview": "#include \"msgbox_ext.h\"\n#include \"ui/app_ui.h\"\n#include \"lv_child_group.h\"\n\nstatic void msgbox_key(lv_event_t *event);\n\n"
  },
  {
    "path": "app/lvgl/ext/msgbox_ext.h",
    "chars": 184,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\ntypedef struct app_ui_t app_ui_t;\n\nvoid msgbox_inject_nav(app_ui_t *ui, lv_obj_t *obj);"
  },
  {
    "path": "app/lvgl/fonts/bootstrap-icons/regular.h",
    "chars": 21574,
    "preview": "#pragma once\nconst unsigned char ttf_bootstrap_icons_data[] = {\n  0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x80, 0x00, "
  },
  {
    "path": "app/lvgl/fonts/bootstrap-icons/symbols.h",
    "chars": 661,
    "preview": "#pragma once\n\n#define BS_SYMBOL_CARET_DOWN_FILL \"\\xef\\x88\\xa9\"\n#define BS_SYMBOL_COLLECTION \"\\xef\\x8b\\x8c\"\n#define BS_SY"
  },
  {
    "path": "app/lvgl/keypad.c",
    "chars": 6663,
    "preview": "#include \"mouse.h\"\n#include \"logging.h\"\n#include \"app.h\"\n#include \"ui/app_ui.h\"\n\n#include <SDL.h>\n\ntypedef struct keyboa"
  },
  {
    "path": "app/lvgl/keypad.h",
    "chars": 519,
    "preview": "#pragma once\n\n#include <lvgl.h>\n#include <SDL2/SDL.h>\n\ntypedef struct app_t app_t;\n\nlv_indev_t *app_indev_keypad_init(ap"
  },
  {
    "path": "app/lvgl/lv_conf.h",
    "chars": 6371,
    "preview": "#ifndef LV_CONF_H\n#define LV_CONF_H\n\n#include <stdint.h>\n\n/* Use 32-bit color depth */\n#define LV_COLOR_DEPTH     32\n\n#d"
  },
  {
    "path": "app/lvgl/mouse.c",
    "chars": 895,
    "preview": "#include \"mouse.h\"\n\n#include <SDL.h>\n\nstatic void read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data);\n\nlv_indev_t *app_"
  },
  {
    "path": "app/lvgl/mouse.h",
    "chars": 123,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nlv_indev_t *app_lv_mouse_indev_init();\n\nvoid app_lv_mouse_indev_deinit(lv_indev_t *inde"
  },
  {
    "path": "app/lvgl/theme.c",
    "chars": 13800,
    "preview": "#include \"theme.h\"\n#include \"config.h\"\n\n#include \"ui/app_ui.h\"\n\n#include \"ext/msgbox_ext.h\"\n\nstatic void apply_cb(lv_the"
  },
  {
    "path": "app/lvgl/theme.h",
    "chars": 264,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\ntypedef struct app_ui_t app_ui_t;\n\nvoid app_theme_init(lv_theme_t *theme, app_ui_t *ui)"
  },
  {
    "path": "app/main.c",
    "chars": 5728,
    "preview": "#include <SDL.h>\n#include <lvgl.h>\n\n#include \"app.h\"\n#include \"config.h\"\n\n#include \"ui/app_ui.h\"\n\n#include \"lvgl/display"
  },
  {
    "path": "app/platform/CMakeLists.txt",
    "chars": 90,
    "preview": "if (TARGET_WEBOS)\n    add_subdirectory(webos)\nelse()\n    add_subdirectory(common)\nendif ()"
  },
  {
    "path": "app/platform/common/CMakeLists.txt",
    "chars": 65,
    "preview": "target_sources(ihsplay PRIVATE app_common.c client_info_common.c)"
  },
  {
    "path": "app/platform/common/app_common.c",
    "chars": 127,
    "preview": "#include \"app.h\"\n\nvoid app_preinit(int argc, char *argv[]) {\n\n}\n\nvoid app_ui_set_handle_nav_back(app_ui_t *ui, bool hand"
  },
  {
    "path": "app/platform/common/client_info_common.c",
    "chars": 130,
    "preview": "#include \"util/client_info.h\"\n\nbool client_info_load(client_info_t *info) {\n    client_info_load_default(info);\n    retu"
  },
  {
    "path": "app/platform/webos/CMakeLists.txt",
    "chars": 243,
    "preview": "pkg_check_modules(PBNJSON_C REQUIRED pbnjson_c)\ntarget_sources(ihsplay PRIVATE app_webos.c client_info_webos.c)\ntarget_i"
  },
  {
    "path": "app/platform/webos/app_webos.c",
    "chars": 384,
    "preview": "#include \"app.h\"\n\nvoid app_preinit(int argc, char *argv[]) {\n    (void) argc;\n    (void) argv;\n\n    SDL_SetHint(SDL_HINT"
  },
  {
    "path": "app/platform/webos/client_info_webos.c",
    "chars": 2226,
    "preview": "#include \"util/client_info.h\"\n\n#include <string.h>\n#include <stdio.h>\n#include <pbnjson.h>\n\n#include \"lunasynccall.h\"\n#i"
  },
  {
    "path": "app/settings/CMakeLists.txt",
    "chars": 42,
    "preview": "target_sources(ihsplay PRIVATE settings.c)"
  },
  {
    "path": "app/settings/app_settings.h",
    "chars": 548,
    "preview": "#pragma once\n\n#include <stdbool.h>\n#include <stdint.h>\n\n#include \"array_list.h\"\n\ntypedef struct os_info_t os_info_t;\n\nty"
  },
  {
    "path": "app/settings/settings.c",
    "chars": 1038,
    "preview": "#include <string.h>\n\n#include \"app_settings.h\"\n\n#include \"ss4s_modules.h\"\n\n#include \"array_list.h\"\n#include \"os_info.h\"\n"
  },
  {
    "path": "app/ui/CMakeLists.txt",
    "chars": 308,
    "preview": "target_sources(ihsplay PRIVATE\n        app_ui.c\n        app_ui_font.c\n        launcher.c\n        hosts/hosts_fragment.c\n"
  },
  {
    "path": "app/ui/app_ui.c",
    "chars": 4914,
    "preview": "#include <stdlib.h>\n\n#include <lvgl.h>\n#include <src/draw/sdl/lv_draw_sdl.h>\n\n#include \"app_ui.h\"\n#include \"launcher.h\"\n"
  },
  {
    "path": "app/ui/app_ui.h",
    "chars": 1736,
    "preview": "#pragma once\n\n#include <lvgl.h>\n#include <SDL.h>\n#include \"app.h\"\n#include \"app_ui_font.h\"\n\ntypedef struct app_t app_t;\n"
  },
  {
    "path": "app/ui/app_ui_font.c",
    "chars": 4792,
    "preview": "#include \"app_ui.h\"\n#include \"app_ui_font.h\"\n\n#include <fontconfig/fontconfig.h>\n#include <assert.h>\n\nstatic lv_font_t *"
  },
  {
    "path": "app/ui/app_ui_font.h",
    "chars": 1054,
    "preview": "#pragma once\n\n#include <stdint.h>\n#include \"lvgl.h\"\n\ntypedef struct app_t app_t;\ntypedef struct app_ui_t app_ui_t;\n\ntype"
  },
  {
    "path": "app/ui/common/CMakeLists.txt",
    "chars": 113,
    "preview": "target_sources(ihsplay PRIVATE\n        error_messages.c\n        progress_dialog.c\n        group_utils.c\n        )"
  },
  {
    "path": "app/ui/common/error_messages.c",
    "chars": 1264,
    "preview": "#include \"error_messages.h\"\n\nconst char *authorization_result_str(IHS_AuthorizationResult result) {\n    switch (result) "
  },
  {
    "path": "app/ui/common/error_messages.h",
    "chars": 168,
    "preview": "#pragma once\n\n#include \"ihslib.h\"\n\nconst char *authorization_result_str(IHS_AuthorizationResult result);\n\nconst char *st"
  },
  {
    "path": "app/ui/common/group_utils.c",
    "chars": 442,
    "preview": "\n#include \"group_utils.h\"\n\nlv_obj_t *ui_group_first_in_parent(lv_group_t *group, lv_obj_t *parent) {\n    lv_obj_t **obj "
  },
  {
    "path": "app/ui/common/group_utils.h",
    "chars": 105,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nlv_obj_t * ui_group_first_in_parent(lv_group_t *group, lv_obj_t*parent);"
  },
  {
    "path": "app/ui/common/progress_dialog.c",
    "chars": 1312,
    "preview": "#include \"progress_dialog.h\"\n\nlv_obj_t *progress_dialog_create(const char *message) {\n    lv_obj_t *dialog = lv_msgbox_c"
  },
  {
    "path": "app/ui/common/progress_dialog.h",
    "chars": 158,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nlv_obj_t *progress_dialog_create(const char *message);\n\nvoid progress_dialog_set_messag"
  },
  {
    "path": "app/ui/connection/CMakeLists.txt",
    "chars": 90,
    "preview": "target_sources(ihsplay PRIVATE connection_fragment.c pin_fragment.c conn_error_fragment.c)"
  },
  {
    "path": "app/ui/connection/conn_error_fragment.c",
    "chars": 1835,
    "preview": "#include \"conn_error_fragment.h\"\n#include \"ui/app_ui.h\"\n\ntypedef struct conn_error_fragment_t {\n    lv_fragment_t base;\n"
  },
  {
    "path": "app/ui/connection/conn_error_fragment.h",
    "chars": 188,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\ntypedef struct conn_error_fragment_data {\n    const char *message;\n} conn_error_fragmen"
  },
  {
    "path": "app/ui/connection/connection_fragment.c",
    "chars": 5560,
    "preview": "#include \"connection_fragment.h\"\n\n#include \"backend/host_manager.h\"\n\n#include \"lvgl/theme.h\"\n#include \"ui/app_ui.h\"\n#inc"
  },
  {
    "path": "app/ui/connection/connection_fragment.h",
    "chars": 170,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nextern const lv_fragment_class_t connection_fragment_class;\n\nvoid connection_fragment_s"
  },
  {
    "path": "app/ui/connection/pin_fragment.c",
    "chars": 1746,
    "preview": "#include \"pin_fragment.h\"\n#include \"ui/app_ui.h\"\n#include \"connection_fragment.h\"\n\ntypedef struct pin_fragment_t {\n    l"
  },
  {
    "path": "app/ui/connection/pin_fragment.h",
    "chars": 85,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nextern const lv_fragment_class_t pin_fragment_class;"
  },
  {
    "path": "app/ui/hosts/hosts_fragment.c",
    "chars": 12978,
    "preview": "#include \"hosts_fragment.h\"\n\n#include \"app.h\"\n#include \"backend/host_manager.h\"\n#include \"lv_gridview.h\"\n#include \"ui/ap"
  },
  {
    "path": "app/ui/hosts/hosts_fragment.h",
    "chars": 142,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t hosts_fragment_class;\n\nvoid hosts_fragment_focus_hosts"
  },
  {
    "path": "app/ui/launcher.c",
    "chars": 13069,
    "preview": "#include <assert.h>\n#include \"app.h\"\n#include \"app_ui.h\"\n#include \"config.h\"\n\n#include \"launcher.h\"\n\n#include \"hosts/hos"
  },
  {
    "path": "app/ui/launcher.h",
    "chars": 174,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t launcher_fragment_class;\n\nvoid launcher_fragment_set_s"
  },
  {
    "path": "app/ui/session/CMakeLists.txt",
    "chars": 116,
    "preview": "target_sources(ihsplay PRIVATE\n        session.c\n        connection_progress.c\n        streaming_overlay.c\n        )"
  },
  {
    "path": "app/ui/session/connection_progress.c",
    "chars": 2400,
    "preview": "#include \"connection_progress.h\"\n#include \"session.h\"\n#include \"app.h\"\n#include \"ui/app_ui.h\"\n\ntypedef struct connection"
  },
  {
    "path": "app/ui/session/connection_progress.h",
    "chars": 92,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nextern const lv_fragment_class_t connection_progress_class;"
  },
  {
    "path": "app/ui/session/session.c",
    "chars": 13929,
    "preview": "#include <assert.h>\n#include \"session.h\"\n#include \"ihslib.h\"\n#include \"ui/app_ui.h\"\n#include \"app.h\"\n#include \"ui/common"
  },
  {
    "path": "app/ui/session/session.h",
    "chars": 374,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n#include \"ihslib.h\"\n\ntypedef struct session_fragment_args_t {\n    IHS_HostInfo host;\n   "
  },
  {
    "path": "app/ui/session/streaming_overlay.c",
    "chars": 2318,
    "preview": "#include \"streaming_overlay.h\"\n#include \"lvgl/fonts/bootstrap-icons/symbols.h\"\n\n#include \"app.h\"\n#include \"ui/app_ui.h\"\n"
  },
  {
    "path": "app/ui/session/streaming_overlay.h",
    "chars": 90,
    "preview": "#pragma once\n\n#include \"lvgl.h\"\n\nextern const lv_fragment_class_t streaming_overlay_class;"
  },
  {
    "path": "app/ui/settings/basic.c",
    "chars": 1588,
    "preview": "#include \"app.h\"\n#include \"basic.h\"\n#include \"widgets.h\"\n\n#include \"config.h\"\n\ntypedef struct basic_fragment {\n    lv_fr"
  },
  {
    "path": "app/ui/settings/basic.h",
    "chars": 96,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t settings_basic_fragment_class;"
  },
  {
    "path": "app/ui/settings/settings.c",
    "chars": 2321,
    "preview": "#include \"settings.h\"\n\n#include \"app.h\"\n#include \"ui/launcher.h\"\n#include \"lvgl/theme.h\"\n#include \"basic.h\"\n#include \"ui"
  },
  {
    "path": "app/ui/settings/settings.h",
    "chars": 90,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t settings_fragment_class;"
  },
  {
    "path": "app/ui/settings/widgets.c",
    "chars": 384,
    "preview": "#include \"widgets.h\"\n\nlv_obj_t *settings_select_create(lv_obj_t *parent, const char *name) {\n    lv_obj_t *item = lv_lab"
  },
  {
    "path": "app/ui/settings/widgets.h",
    "chars": 102,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nlv_obj_t *settings_select_create(lv_obj_t *parent, const char *name);"
  },
  {
    "path": "app/ui/support/CMakeLists.txt",
    "chars": 59,
    "preview": "target_sources(ihsplay PRIVATE support.c wiki.c feedback.c)"
  },
  {
    "path": "app/ui/support/feedback.c",
    "chars": 2168,
    "preview": "#include \"wiki.h\"\n#include \"ss4s.h\"\n#include \"config.h\"\n#include \"app.h\"\n\ntypedef struct feedback_fragment_t {\n    lv_fr"
  },
  {
    "path": "app/ui/support/feedback.h",
    "chars": 90,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t feedback_fragment_class;"
  },
  {
    "path": "app/ui/support/support.c",
    "chars": 4984,
    "preview": "#include \"support.h\"\n#include \"wiki.h\"\n#include \"feedback.h\"\n#include \"app.h\"\n#include \"lvgl/theme.h\"\n#include \"ui/app_u"
  },
  {
    "path": "app/ui/support/support.h",
    "chars": 89,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t support_fragment_class;"
  },
  {
    "path": "app/ui/support/wiki.c",
    "chars": 1078,
    "preview": "#include \"wiki.h\"\n\nstatic lv_obj_t *create_obj(lv_fragment_t *self, lv_obj_t *parent);\n\nconst lv_fragment_class_t wiki_f"
  },
  {
    "path": "app/ui/support/wiki.h",
    "chars": 86,
    "preview": "#pragma once\n\n#include <lvgl.h>\n\nextern const lv_fragment_class_t wiki_fragment_class;"
  },
  {
    "path": "app/util/CMakeLists.txt",
    "chars": 96,
    "preview": "target_sources(ihsplay PRIVATE listeners_list.c random.c client_info.c)\n\nadd_subdirectory(video)"
  },
  {
    "path": "app/util/client_info.c",
    "chars": 688,
    "preview": "#include <stdlib.h>\n#include <string.h>\n#include \"client_info.h\"\n\nstatic const uint8_t secretKey[32] = {\n        11, 45,"
  },
  {
    "path": "app/util/client_info.h",
    "chars": 324,
    "preview": "#pragma once\n\n#include \"ihslib.h\"\n\ntypedef struct client_info_t {\n    uint64_t device_id;\n    uint8_t secret_key[32];\n  "
  },
  {
    "path": "app/util/listeners_list.c",
    "chars": 1341,
    "preview": "#include \"listeners_list.h\"\n\narray_list_t *listeners_list_create() {\n    return array_list_create(sizeof(registered_list"
  },
  {
    "path": "app/util/listeners_list.h",
    "chars": 1747,
    "preview": "#pragma once\n\n#include \"array_list.h\"\n#include \"refcounter.h\"\n\ntypedef struct registered_listener_t {\n    const void *li"
  },
  {
    "path": "app/util/random.c",
    "chars": 237,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n#include \"random.h\"\n\nvoid random_pin(char *pin) {\n    srand(tim"
  },
  {
    "path": "app/util/random.h",
    "chars": 41,
    "preview": "#pragma once\n\nvoid random_pin(char *pin);"
  },
  {
    "path": "app/util/refcounter.h",
    "chars": 881,
    "preview": "#pragma once\n\n#include <SDL.h>\n#include <stdbool.h>\n\ntypedef struct refcounter_t {\n    int counter;\n    SDL_mutex *lock;"
  },
  {
    "path": "app/util/video/CMakeLists.txt",
    "chars": 69,
    "preview": "add_subdirectory(sps)\ntarget_link_libraries(ihsplay PRIVATE sps_util)"
  },
  {
    "path": "app/util/video/sps/CMakeLists.txt",
    "chars": 194,
    "preview": "add_library(sps_util STATIC sps_util_h264.c sps_util_h265.c common.c bitstream.c)\ntarget_include_directories(sps_util PU"
  },
  {
    "path": "app/util/video/sps/bitstream.c",
    "chars": 2980,
    "preview": "\n#include \"bitstream.h\"\n\n\nvoid bitstream_init(bitstream_t *buf, const unsigned char *data, size_t size) {\n    buf->data "
  },
  {
    "path": "app/util/video/sps/bitstream.h",
    "chars": 1554,
    "preview": "#pragma once\n\n#include <stdint.h>\n#include <stdbool.h>\n#include <stddef.h>\n\ntypedef struct bitstream_t {\n    const unsig"
  },
  {
    "path": "app/util/video/sps/common.c",
    "chars": 546,
    "preview": "#include \"common.h\"\n\nint sps_util_nal_skip_start_code(const unsigned char *data, size_t size, size_t begin) {\n    int co"
  },
  {
    "path": "app/util/video/sps/common.h",
    "chars": 1080,
    "preview": "#pragma once\n\n#include <stddef.h>\n#include <stdint.h>\n\n#include \"bitstream.h\"\n\n#define bitstream_skip_bits_checked(s, v)"
  },
  {
    "path": "app/util/video/sps/include/sps_util.h",
    "chars": 378,
    "preview": "#pragma once\n\n#include <stdint.h>\n#include <stdbool.h>\n#include <stddef.h>\n\ntypedef struct sps_dimension_t {\n    uint16_"
  },
  {
    "path": "app/util/video/sps/sps_util_h264.c",
    "chars": 9979,
    "preview": "#include \"sps_util.h\"\n#include \"bitstream.h\"\n#include \"common.h\"\n\n#define EXTENDED_SAR 255\n\nstatic bool skip_vui_paramet"
  },
  {
    "path": "app/util/video/sps/sps_util_h265.c",
    "chars": 4684,
    "preview": "/**\n * @see https://www.itu.int/rec/T-REC-H.265\n */\n#include <stdio.h>\n#include \"sps_util.h\"\n#include \"bitstream.h\"\n#inc"
  },
  {
    "path": "app/util/video/sps/tests/CMakeLists.txt",
    "chars": 557,
    "preview": "add_executable(test_dimension_h265 test_dimension_h265.c)\ntarget_link_libraries(test_dimension_h265 sps_util)\n\nadd_test("
  },
  {
    "path": "app/util/video/sps/tests/sample_data.h",
    "chars": 431,
    "preview": "#pragma once\n\n#include <stdint.h>\n\nstatic const uint8_t sample_data_sps_h265_1[] = {\n        0x00, 0x00, 0x00, 0x01,\n   "
  },
  {
    "path": "app/util/video/sps/tests/sps_parser_tests.c",
    "chars": 1421,
    "preview": "#include \"sps_util.h\"\n\n#include <assert.h>\n\nstatic const unsigned char h264_test_data[] = {\n        0x00, 0x00, 0x00, 0x"
  },
  {
    "path": "app/util/video/sps/tests/test_dimension_h265.c",
    "chars": 313,
    "preview": "#include <assert.h>\n#include \"sample_data.h\"\n#include \"sps_util.h\"\n\nint main() {\n    sps_dimension_t dimension;\n    asse"
  },
  {
    "path": "app/util/video/sps/tests/test_nal_start_code.c",
    "chars": 539,
    "preview": "#include <assert.h>\n#include \"common.h\"\n\nint main() {\n    unsigned char data1[] = {0x00, 0x00, 0x00, 0x01, 0x33};\n    as"
  },
  {
    "path": "cmake/AresPackage.cmake",
    "chars": 766,
    "preview": "execute_process(COMMAND ares-package \"${CPACK_TEMPORARY_DIRECTORY}\" -o \"${CPACK_PACKAGE_DIRECTORY}\"\n        -e include\n "
  },
  {
    "path": "cmake/CleanupNameLink.cmake",
    "chars": 975,
    "preview": "file(GLOB_RECURSE FOUND_LIBS \"${CPACK_TEMPORARY_INSTALL_DIRECTORY}/**/*.so*\")\n\nfunction(get_soname PATH)\n    set(SONAME "
  },
  {
    "path": "cmake/PackageDebian.cmake",
    "chars": 15,
    "preview": "include(CPack)\n"
  },
  {
    "path": "cmake/PackageWebOS.cmake",
    "chars": 1780,
    "preview": "get_filename_component(CMAKE_C_COMPILER_NAME \"${CMAKE_C_COMPILER}\" NAME)\nif (CMAKE_C_COMPILER_NAME MATCHES \"^arm-webos-l"
  },
  {
    "path": "deploy/raspbian/sysroot-packages.list",
    "chars": 121,
    "preview": "libsdl2-dev\nlibopus-dev\nlibmbedtls-dev\nlibraspberrypi-dev\nlibprotobuf-c-dev\nlibfreetype6-dev\nlibfontconfig-dev\nlibcec-de"
  },
  {
    "path": "deploy/webos/appinfo.in.json",
    "chars": 316,
    "preview": "{\n  \"id\": \"@CPACK_PACKAGE_NAME@\",\n  \"type\": \"native\",\n  \"main\": \"ihsplay\",\n  \"icon\": \"icon.png\",\n  \"largeIcon\": \"largeIc"
  },
  {
    "path": "tests/CMakeLists.txt",
    "chars": 892,
    "preview": "enable_testing()\n\nfunction(ihsplay_add_test NAME)\n    cmake_parse_arguments(TEST \"\" \"\" \"SOURCES;ARGS;INCLUDES;LIBRARIES\""
  },
  {
    "path": "tests/app/CMakeLists.txt",
    "chars": 23,
    "preview": "add_subdirectory(utils)"
  },
  {
    "path": "tests/app/utils/CMakeLists.txt",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "tools/resource-tools/.gitignore",
    "chars": 13,
    "preview": "node_modules/"
  },
  {
    "path": "tools/resource-tools/.nvmrc",
    "chars": 2,
    "preview": "16"
  },
  {
    "path": "tools/resource-tools/async-transform.ts",
    "chars": 396,
    "preview": "import {BufferFile, StreamFile} from \"vinyl\";\nimport through2 from \"through2\";\nimport * as stream from \"stream\";\n\ntype F"
  },
  {
    "path": "tools/resource-tools/binheader.ts",
    "chars": 2038,
    "preview": "import {BufferFile} from \"vinyl\";\nimport {camelCase, constantCase, pascalCase, snakeCase} from \"change-case\";\nimport asy"
  },
  {
    "path": "tools/resource-tools/codepoints.ts",
    "chars": 1743,
    "preview": "import fs from \"fs/promises\";\nimport asyncTransform from \"./async-transform\";\nimport {R_OK} from \"constants\";\nimport {pi"
  },
  {
    "path": "tools/resource-tools/gulp-subset-font.ts",
    "chars": 589,
    "preview": "import asyncTransform from \"./async-transform\";\nimport sf from 'subset-font';\nimport {BufferFile} from \"vinyl\";\n\nexport "
  },
  {
    "path": "tools/resource-tools/gulpfile.ts",
    "chars": 1070,
    "preview": "import {dest, parallel, src} from \"gulp\";\nimport binheader from \"./binheader\";\nimport codepoints from \"./codepoints\";\nim"
  },
  {
    "path": "tools/resource-tools/package.json",
    "chars": 694,
    "preview": "{\n  \"name\": \"ihsplay-tools\",\n  \"version\": \"1.0.0\",\n  \"private\": true,\n  \"description\": \"\",\n  \"scripts\": {\n    \"iconfonts"
  },
  {
    "path": "tools/resource-tools/res/bootstrap-icons.json",
    "chars": 51087,
    "preview": "{\n  \"123\": 63103,\n  \"alarm-fill\": 61697,\n  \"alarm\": 61698,\n  \"align-bottom\": 61699,\n  \"align-center\": 61700,\n  \"align-en"
  },
  {
    "path": "tools/resource-tools/res/bootstrap-icons.list",
    "chars": 151,
    "preview": "apple\ncaret-down-fill\ncollection\ncontroller\ndisplay\ngear-fill\nplay-btn\nplay-circle-fill\npower\nquestion-circle-fill\nsteam"
  },
  {
    "path": "tools/resource-tools/symheader.ts",
    "chars": 930,
    "preview": "import asyncTransform from \"./async-transform\";\n\nexport interface Option {\n    prefix: string;\n}\n\nfunction codepointsMet"
  },
  {
    "path": "tools/resource-tools/tsconfig.json",
    "chars": 317,
    "preview": "{\n  // these options are overrides used only by ts-node\n  \"ts-node\": {\n    \"compilerOptions\": {\n      \"module\": \"commonj"
  },
  {
    "path": "tools/webos/easy_build.sh",
    "chars": 1121,
    "preview": "#!/usr/bin/env bash\n\nif [ ! -d app ] || [ ! -f CMakeLists.txt ]; then\n  echo \"Please invoke this script in project root "
  },
  {
    "path": "tools/webos/easy_install.sh",
    "chars": 112,
    "preview": "#!/bin/sh\n\nTARGET=\"$1\"\nARES_DEVICE=$(ares-device -d | xargs) cmake --build .. --target \"webos-launch-${TARGET}\"\n"
  }
]

About this extraction

This page contains the full source code of the mariotaku/ihsplay GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 150 files (351.1 KB), approximately 114.2k tokens, and a symbol index with 393 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!