├── .appveyor.yml ├── .builds ├── alpine.yml └── freebsd.yml ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── COPYING ├── README.md ├── android ├── .gitignore ├── app │ ├── .gitignore │ ├── CMakeLists.txt │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ ├── audio-decoder.c │ │ ├── audio-decoder.h │ │ ├── audio-output.cpp │ │ ├── audio-output.h │ │ ├── chiaki-jni.c │ │ ├── chiaki-jni.h │ │ ├── circular-buf.hpp │ │ ├── circular-fifo.hpp │ │ ├── log.c │ │ ├── log.h │ │ ├── video-decoder.c │ │ └── video-decoder.h │ │ ├── java │ │ └── com │ │ │ └── metallic │ │ │ └── chiaki │ │ │ ├── common │ │ │ ├── AppDatabase.kt │ │ │ ├── DisplayHost.kt │ │ │ ├── LogManager.kt │ │ │ ├── MacAddress.kt │ │ │ ├── ManualHost.kt │ │ │ ├── Preferences.kt │ │ │ ├── RegisteredHost.kt │ │ │ ├── SerializedSettings.kt │ │ │ └── ext │ │ │ │ ├── RevealActivity.kt │ │ │ │ ├── RxLiveData.kt │ │ │ │ ├── StringHex.kt │ │ │ │ ├── ViewGroupInflate.kt │ │ │ │ └── ViewModelFactory.kt │ │ │ ├── discovery │ │ │ └── DiscoveryManager.kt │ │ │ ├── lib │ │ │ └── Chiaki.kt │ │ │ ├── main │ │ │ ├── DisplayHostRecyclerViewAdapter.kt │ │ │ ├── FloatingActionButtonBackgroundBehavior.kt │ │ │ ├── FloatingActionButtonSpeedDialBehavior.kt │ │ │ ├── MainActivity.kt │ │ │ └── MainViewModel.kt │ │ │ ├── manualconsole │ │ │ ├── EditManualConsoleActivity.kt │ │ │ └── EditManualConsoleViewModel.kt │ │ │ ├── regist │ │ │ ├── ChiakiRxLog.kt │ │ │ ├── RegistActivity.kt │ │ │ ├── RegistExecuteActivity.kt │ │ │ ├── RegistExecuteViewModel.kt │ │ │ └── RegistViewModel.kt │ │ │ ├── session │ │ │ ├── StreamInput.kt │ │ │ └── StreamSession.kt │ │ │ ├── settings │ │ │ ├── ItemTouchSwipeCallback.kt │ │ │ ├── SettingsActivity.kt │ │ │ ├── SettingsFragment.kt │ │ │ ├── SettingsLogsAdapter.kt │ │ │ ├── SettingsLogsFragment.kt │ │ │ ├── SettingsLogsViewModel.kt │ │ │ ├── SettingsRegisteredHostsAdapter.kt │ │ │ ├── SettingsRegisteredHostsFragment.kt │ │ │ ├── SettingsRegisteredHostsViewModel.kt │ │ │ └── SettingsViewModel.kt │ │ │ ├── stream │ │ │ ├── StreamActivity.kt │ │ │ └── StreamViewModel.kt │ │ │ └── touchcontrols │ │ │ ├── AnalogStickView.kt │ │ │ ├── ButtonView.kt │ │ │ ├── ControlsBackgroundView.kt │ │ │ ├── DPadView.kt │ │ │ ├── TouchControlsFragment.kt │ │ │ ├── TouchTracker.kt │ │ │ ├── TouchpadOnlyFragment.kt │ │ │ └── Vector.kt │ │ └── res │ │ ├── color │ │ ├── mage_text_input_box_stroke.xml │ │ └── stream_material_button_icon_tint.xml │ │ ├── drawable │ │ ├── avd_add_to_close.xml │ │ ├── avd_close_to_add.xml │ │ ├── control_analog_stick_base.xml │ │ ├── control_analog_stick_handle.xml │ │ ├── control_button_box.xml │ │ ├── control_button_box_pressed.xml │ │ ├── control_button_cross.xml │ │ ├── control_button_cross_pressed.xml │ │ ├── control_button_home.xml │ │ ├── control_button_home_pressed.xml │ │ ├── control_button_l1.xml │ │ ├── control_button_l1_pressed.xml │ │ ├── control_button_l2.xml │ │ ├── control_button_l2_pressed.xml │ │ ├── control_button_moon.xml │ │ ├── control_button_moon_pressed.xml │ │ ├── control_button_options.xml │ │ ├── control_button_options_pressed.xml │ │ ├── control_button_pyramid.xml │ │ ├── control_button_pyramid_pressed.xml │ │ ├── control_button_r1.xml │ │ ├── control_button_r1_pressed.xml │ │ ├── control_button_r2.xml │ │ ├── control_button_r2_pressed.xml │ │ ├── control_button_share.xml │ │ ├── control_button_share_pressed.xml │ │ ├── control_button_touchpad.xml │ │ ├── control_button_touchpad_pressed.xml │ │ ├── control_dpad_idle.xml │ │ ├── control_dpad_left.xml │ │ ├── control_dpad_left_up.xml │ │ ├── ic_add.xml │ │ ├── ic_add_close.xml │ │ ├── ic_add_manual.xml │ │ ├── ic_bitrate.xml │ │ ├── ic_close.xml │ │ ├── ic_console.xml │ │ ├── ic_console_ready.xml │ │ ├── ic_console_simple.xml │ │ ├── ic_console_standby.xml │ │ ├── ic_delete_row.xml │ │ ├── ic_discover_off.xml │ │ ├── ic_discover_on.xml │ │ ├── ic_discovered_on_secondary.xml │ │ ├── ic_display_normal.xml │ │ ├── ic_display_stretch.xml │ │ ├── ic_display_zoom.xml │ │ ├── ic_export.xml │ │ ├── ic_fps.xml │ │ ├── ic_gamepad.xml │ │ ├── ic_host.xml │ │ ├── ic_import.xml │ │ ├── ic_launcher_foreground.xml │ │ ├── ic_log.xml │ │ ├── ic_overflow.xml │ │ ├── ic_pin.xml │ │ ├── ic_psn_id.xml │ │ ├── ic_regist_console.xml │ │ ├── ic_register.xml │ │ ├── ic_resolution.xml │ │ ├── ic_settings.xml │ │ ├── ic_share.xml │ │ ├── ic_triangle.xml │ │ └── selector_add_fab.xml │ │ ├── layout │ │ ├── activity_edit_manual.xml │ │ ├── activity_main.xml │ │ ├── activity_regist.xml │ │ ├── activity_regist_execute.xml │ │ ├── activity_settings.xml │ │ ├── activity_stream.xml │ │ ├── dialog_login_pin.xml │ │ ├── dropdown_menu_popup_item.xml │ │ ├── fragment_controls.xml │ │ ├── fragment_settings_logs.xml │ │ ├── fragment_settings_registered_hosts.xml │ │ ├── fragment_touchpad_only.xml │ │ ├── item_display_host.xml │ │ ├── item_log_file.xml │ │ └── item_registered_host.xml │ │ ├── menu │ │ ├── display_host.xml │ │ └── main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ ├── filepaths.xml │ │ └── preferences.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── assets ├── .gitignore ├── add_console.svg ├── chiaki.svg ├── chiaki_android_fg.svg ├── chiaki_function.svg ├── chiaki_simple.svg ├── chiaki_square.svg ├── chiaki_wide.png ├── console.svg ├── controls │ ├── buttons.svg │ ├── dpad.svg │ ├── l1.svg │ ├── l2.svg │ ├── l2_raw.svg │ ├── options_share.svg │ ├── r1.svg │ ├── r2.svg │ ├── stick.svg │ └── touchpad.svg ├── gen-icns.sh ├── ic_launcher-web.png ├── regist_console.svg ├── screenshot.png └── triangle.svg ├── cli ├── CMakeLists.txt ├── include │ └── chiaki-cli.h └── src │ ├── discover.c │ ├── main.c │ └── wakeup.c ├── cmake ├── FindArgp.cmake ├── FindFFMPEG.cmake ├── FindOpus.cmake ├── FindSDL2.cmake └── OpenSSLExternalProject.cmake ├── gui ├── CMakeLists.txt ├── MacOSXBundleInfo.plist.in ├── chiaki.desktop ├── chiaki.icns ├── chiaki.png ├── include │ ├── avopenglframeuploader.h │ ├── avopenglwidget.h │ ├── controllermanager.h │ ├── discoverymanager.h │ ├── dynamicgridwidget.h │ ├── exception.h │ ├── host.h │ ├── loginpindialog.h │ ├── mainwindow.h │ ├── manualhostdialog.h │ ├── registdialog.h │ ├── servericonwidget.h │ ├── serveritemwidget.h │ ├── sessionlog.h │ ├── settings.h │ ├── settingsdialog.h │ ├── settingskeycapturedialog.h │ ├── streamsession.h │ ├── streamwindow.h │ └── videodecoder.h ├── res │ ├── add-24px.svg │ ├── chiaki.svg │ ├── discover-24px.svg │ ├── discover-off-24px.svg │ ├── resources.qrc │ └── settings-20px.svg └── src │ ├── avopenglframeuploader.cpp │ ├── avopenglwidget.cpp │ ├── controllermanager.cpp │ ├── discoverymanager.cpp │ ├── dynamicgridwidget.cpp │ ├── host.cpp │ ├── loginpindialog.cpp │ ├── main.cpp │ ├── mainwindow.cpp │ ├── manualhostdialog.cpp │ ├── registdialog.cpp │ ├── servericonwidget.cpp │ ├── serveritemwidget.cpp │ ├── sessionlog.cpp │ ├── settings.cpp │ ├── settingsdialog.cpp │ ├── settingskeycapturedialog.cpp │ ├── streamsession.cpp │ ├── streamwindow.cpp │ └── videodecoder.cpp ├── lib ├── CMakeLists.txt ├── config.h.in ├── include │ └── chiaki │ │ ├── audio.h │ │ ├── audioreceiver.h │ │ ├── base64.h │ │ ├── common.h │ │ ├── congestioncontrol.h │ │ ├── controller.h │ │ ├── ctrl.h │ │ ├── discovery.h │ │ ├── discoveryservice.h │ │ ├── ecdh.h │ │ ├── fec.h │ │ ├── feedback.h │ │ ├── feedbacksender.h │ │ ├── frameprocessor.h │ │ ├── gkcrypt.h │ │ ├── http.h │ │ ├── launchspec.h │ │ ├── log.h │ │ ├── opusdecoder.h │ │ ├── random.h │ │ ├── regist.h │ │ ├── reorderqueue.h │ │ ├── rpcrypt.h │ │ ├── senkusha.h │ │ ├── seqnum.h │ │ ├── session.h │ │ ├── sock.h │ │ ├── stoppipe.h │ │ ├── streamconnection.h │ │ ├── takion.h │ │ ├── takionsendbuffer.h │ │ ├── thread.h │ │ ├── time.h │ │ ├── video.h │ │ └── videoreceiver.h ├── protobuf │ ├── CMakeLists.txt │ └── takion.proto └── src │ ├── audio.c │ ├── audioreceiver.c │ ├── base64.c │ ├── common.c │ ├── congestioncontrol.c │ ├── controller.c │ ├── ctrl.c │ ├── discovery.c │ ├── discoveryservice.c │ ├── ecdh.c │ ├── fec.c │ ├── feedback.c │ ├── feedbacksender.c │ ├── frameprocessor.c │ ├── gkcrypt.c │ ├── http.c │ ├── launchspec.c │ ├── log.c │ ├── opusdecoder.c │ ├── pb_utils.h │ ├── random.c │ ├── regist.c │ ├── reorderqueue.c │ ├── rpcrypt.c │ ├── senkusha.c │ ├── session.c │ ├── sock.c │ ├── stoppipe.c │ ├── streamconnection.c │ ├── takion.c │ ├── takionsendbuffer.c │ ├── thread.c │ ├── time.c │ ├── utils.h │ └── videoreceiver.c ├── scripts ├── Dockerfile ├── appveyor.sh ├── build-ffmpeg.sh ├── build-sdl2.sh ├── chiaki.rb.in ├── configure-cask.cmake ├── docker-run.sh ├── fetch-protoc.sh ├── psn-account-id.go ├── psn-account-id.py ├── travis-appimage.sh └── travis-build.sh ├── secret.tar.enc ├── test ├── CMakeLists.txt ├── fec.c ├── fec_test_cases.inl ├── gkcrypt.c ├── http.c ├── main.c ├── regist.c ├── reorderqueue.c ├── rpcrypt.c ├── seqnum.c ├── takion.c ├── takion_av_packet_parse_real_video.inl ├── test_log.c └── test_log.h └── third-party └── CMakeLists.txt /.appveyor.yml: -------------------------------------------------------------------------------- 1 | image: 'Visual Studio 2017' 2 | 3 | branches: 4 | only: 5 | - master 6 | - /^v\d.*$/ 7 | - /^deploy-test(-.*)?$/ 8 | 9 | configuration: 10 | - Release 11 | 12 | install: 13 | - git submodule update --init --recursive 14 | 15 | build_script: 16 | - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 17 | - C:\msys64\usr\bin\bash -lc "cd \"%APPVEYOR_BUILD_FOLDER%\" && scripts/appveyor.sh" 18 | 19 | artifacts: 20 | - path: Chiaki 21 | name: Chiaki 22 | - path: Chiaki-PDB 23 | name: Chiaki-PDB 24 | 25 | deploy: 26 | description: 'Chiaki Binaries' 27 | provider: GitHub 28 | draft: true 29 | auth_token: 30 | secure: Amvzm3PMM5nv+iFsqaU7TZ9fgyYt/YIrOLV0QMiCyOoUlLRIaiYxWiJ7maTpxhZ9 31 | artifact: "Chiaki" 32 | on: 33 | appveyor_repo_tag: true 34 | 35 | -------------------------------------------------------------------------------- /.builds/alpine.yml: -------------------------------------------------------------------------------- 1 | 2 | image: alpine/edge 3 | 4 | sources: 5 | - https://github.com/thestr4ng3r/chiaki.git 6 | 7 | packages: 8 | - cmake 9 | - protoc 10 | - py3-protobuf 11 | - opus-dev 12 | - qt5-qtbase-dev 13 | - qt5-qtsvg-dev 14 | - qt5-qtmultimedia-dev 15 | - ffmpeg-dev 16 | - sdl2-dev 17 | 18 | tasks: 19 | - build: | 20 | cd chiaki 21 | mkdir build && cd build 22 | cmake .. 23 | make -j4 24 | test/chiaki-unit 25 | 26 | -------------------------------------------------------------------------------- /.builds/freebsd.yml: -------------------------------------------------------------------------------- 1 | 2 | image: freebsd/latest 3 | 4 | sources: 5 | - https://github.com/thestr4ng3r/chiaki 6 | 7 | packages: 8 | - cmake 9 | - protobuf 10 | - py37-protobuf 11 | - opus 12 | - qt5-core 13 | - qt5-qmake 14 | - qt5-buildtools 15 | - qt5-gui 16 | - qt5-widgets 17 | - qt5-svg 18 | - qt5-opengl 19 | - qt5-multimedia 20 | - ffmpeg 21 | - sdl2 22 | 23 | tasks: 24 | - build: | 25 | cd chiaki 26 | mkdir build && cd build 27 | cmake .. 28 | make -j4 29 | test/chiaki-unit 30 | 31 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | /test/*.inl linguist-generated=true 2 | /lib/*.h linguist-language=C 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | .idea 4 | build 5 | cmake-build-* 6 | .DS_store 7 | *.AppImage 8 | appdir 9 | /ffmpeg* 10 | /Chiaki 11 | /SDL2-* 12 | /opus* 13 | /ffmpeg* 14 | /sdl2-* 15 | /protoc* 16 | /openssl* 17 | .vs 18 | CMakeSettings.json 19 | chiaki.rb 20 | *.jks 21 | secret.tar 22 | keystore-env.sh 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/munit"] 2 | path = test/munit 3 | url = https://github.com/nemequ/munit.git 4 | [submodule "third-party/nanopb"] 5 | path = third-party/nanopb 6 | url = https://github.com/nanopb/nanopb.git 7 | [submodule "third-party/jerasure"] 8 | path = third-party/jerasure 9 | url = https://github.com/thestr4ng3r/jerasure.git 10 | [submodule "third-party/gf-complete"] 11 | path = third-party/gf-complete 12 | url = https://github.com/thestr4ng3r/gf-complete.git 13 | [submodule "android/app/src/main/cpp/oboe"] 14 | path = android/app/src/main/cpp/oboe 15 | url = https://github.com/google/oboe 16 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.2) 3 | 4 | project(chiaki) 5 | 6 | option(CHIAKI_ENABLE_TESTS "Enable tests for Chiaki" ON) 7 | option(CHIAKI_ENABLE_CLI "Enable CLI for Chiaki" OFF) 8 | option(CHIAKI_ENABLE_GUI "Enable Qt GUI" ON) 9 | option(CHIAKI_ENABLE_ANDROID "Enable Android (Use only as part of the Gradle Project)" OFF) 10 | option(CHIAKI_LIB_ENABLE_OPUS "Use Opus as part of Chiaki Lib" ON) 11 | option(CHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT "Use OpenSSL as CMake external project" OFF) 12 | option(CHIAKI_GUI_ENABLE_QT_GAMEPAD "Use QtGamepad for Input" OFF) 13 | option(CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER "Use SDL Gamecontroller for Input" ON) 14 | option(CHIAKI_CLI_ARGP_STANDALONE "Search for standalone argp lib for CLI" OFF) 15 | 16 | set(CHIAKI_VERSION_MAJOR 1) 17 | set(CHIAKI_VERSION_MINOR 1) 18 | set(CHIAKI_VERSION_PATCH 3) 19 | set(CHIAKI_VERSION ${CHIAKI_VERSION_MAJOR}.${CHIAKI_VERSION_MINOR}.${CHIAKI_VERSION_PATCH}) 20 | 21 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 22 | 23 | add_subdirectory(third-party) 24 | 25 | add_definitions(-DCHIAKI_VERSION_MAJOR=${CHIAKI_VERSION_MAJOR} -DCHIAKI_VERSION_MINOR=${CHIAKI_VERSION_MINOR} -DCHIAKI_VERSION_PATCH=${CHIAKI_VERSION_PATCH} -DCHIAKI_VERSION=\"${CHIAKI_VERSION}\") 26 | 27 | if(CHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT) 28 | include(OpenSSLExternalProject) 29 | endif() 30 | 31 | add_subdirectory(lib) 32 | 33 | if(CHIAKI_ENABLE_CLI) 34 | add_subdirectory(cli) 35 | endif() 36 | 37 | if(CHIAKI_ENABLE_GUI) 38 | add_subdirectory(gui) 39 | endif() 40 | 41 | if(CHIAKI_ENABLE_TESTS) 42 | enable_testing() 43 | add_subdirectory(test) 44 | endif() 45 | 46 | if(CHIAKI_ENABLE_ANDROID) 47 | add_subdirectory(android/app) 48 | endif() -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | /app/release 16 | keystore.jks 17 | -------------------------------------------------------------------------------- /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.2) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_library(chiaki-jni SHARED 7 | src/main/cpp/chiaki-jni.c 8 | src/main/cpp/log.h 9 | src/main/cpp/log.c 10 | src/main/cpp/video-decoder.h 11 | src/main/cpp/video-decoder.c 12 | src/main/cpp/audio-decoder.h 13 | src/main/cpp/audio-decoder.c 14 | src/main/cpp/audio-output.h 15 | src/main/cpp/audio-output.cpp 16 | src/main/cpp/circular-fifo.hpp) 17 | target_link_libraries(chiaki-jni chiaki-lib) 18 | 19 | find_library(ANDROID_LIB_LOG log) 20 | find_library(ANDROID_LIB_MEDIANDK mediandk) 21 | find_library(ANDROID_LIB_ANDROID android) 22 | target_link_libraries(chiaki-jni "${ANDROID_LIB_LOG}" "${ANDROID_LIB_MEDIANDK}" "${ANDROID_LIB_ANDROID}") 23 | 24 | add_subdirectory(src/main/cpp/oboe) 25 | target_link_libraries(chiaki-jni oboe) -------------------------------------------------------------------------------- /android/app/src/main/cpp/audio-decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_JNI_AUDIO_DECODER_H 19 | #define CHIAKI_JNI_AUDIO_DECODER_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | typedef void (*AndroidChiakiAudioDecoderSettingsCallback)(uint32_t channels, uint32_t rate, void *user); 28 | typedef void (*AndroidChiakiAudioDecoderFrameCallback)(int16_t *buf, size_t samples_count, void *user); 29 | 30 | typedef struct android_chiaki_audio_decoder_t 31 | { 32 | ChiakiLog *log; 33 | ChiakiAudioHeader audio_header; 34 | 35 | ChiakiMutex codec_mutex; 36 | struct AMediaCodec *codec; 37 | uint64_t timestamp_cur; 38 | ChiakiThread output_thread; 39 | 40 | AndroidChiakiAudioDecoderSettingsCallback settings_cb; 41 | AndroidChiakiAudioDecoderFrameCallback frame_cb; 42 | void *cb_user; 43 | } AndroidChiakiAudioDecoder; 44 | 45 | ChiakiErrorCode android_chiaki_audio_decoder_init(AndroidChiakiAudioDecoder *decoder, ChiakiLog *log); 46 | void android_chiaki_audio_decoder_fini(AndroidChiakiAudioDecoder *decoder); 47 | void android_chiaki_audio_decoder_get_sink(AndroidChiakiAudioDecoder *decoder, ChiakiAudioSink *sink); 48 | 49 | static inline void android_chiaki_audio_decoder_set_cb(AndroidChiakiAudioDecoder *decoder, AndroidChiakiAudioDecoderSettingsCallback settings_cb, AndroidChiakiAudioDecoderFrameCallback frame_cb, void *user) 50 | { 51 | decoder->settings_cb = settings_cb; 52 | decoder->frame_cb = frame_cb; 53 | decoder->cb_user = user; 54 | } 55 | 56 | #endif -------------------------------------------------------------------------------- /android/app/src/main/cpp/audio-output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_JNI_AUDIO_OUTPUT_H 19 | #define CHIAKI_JNI_AUDIO_OUTPUT_H 20 | 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | void *android_chiaki_audio_output_new(ChiakiLog *log); 29 | void android_chiaki_audio_output_free(void *audio_output); 30 | void android_chiaki_audio_output_settings(uint32_t channels, uint32_t rate, void *audio_output); 31 | void android_chiaki_audio_output_frame(int16_t *buf, size_t samples_count, void *audio_output); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif //CHIAKI_JNI_AUDIO_OUTPUT_H 38 | -------------------------------------------------------------------------------- /android/app/src/main/cpp/chiaki-jni.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_JNI_H 19 | #define CHIAKI_JNI_H 20 | 21 | #define JNI_VERSION JNI_VERSION_1_6 22 | 23 | #define BASE_PACKAGE "com/metallic/chiaki/lib" 24 | #define JNI_FCN(name) Java_com_metallic_chiaki_lib_ChiakiNative_##name 25 | 26 | #define E (*env) 27 | 28 | JNIEnv *attach_thread_jni(); 29 | jobject jnistr_from_ascii(JNIEnv *env, const char *str); 30 | 31 | extern JavaVM *global_vm; 32 | 33 | #endif -------------------------------------------------------------------------------- /android/app/src/main/cpp/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_JNI_LOG_H 19 | #define CHIAKI_JNI_LOG_H 20 | 21 | #include 22 | 23 | #include 24 | 25 | typedef struct android_jni_chiaki_log_t 26 | { 27 | jobject java_log; 28 | jmethodID java_log_meth; 29 | ChiakiLog log; 30 | } AndroidChiakiJNILog; 31 | 32 | ChiakiErrorCode android_chiaki_file_log_init(ChiakiLog *log, uint32_t level, const char *file); 33 | void android_chiaki_file_log_fini(ChiakiLog *log); 34 | 35 | void android_chiaki_jni_log_init(AndroidChiakiJNILog *log, JNIEnv *env, jobject java_log); 36 | void android_chiaki_jni_log_fini(AndroidChiakiJNILog *log, JNIEnv *env); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /android/app/src/main/cpp/video-decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_JNI_VIDEO_DECODER_H 19 | #define CHIAKI_JNI_VIDEO_DECODER_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | typedef struct AMediaCodec AMediaCodec; 27 | typedef struct ANativeWindow ANativeWindow; 28 | 29 | typedef struct android_chiaki_video_decoder_t 30 | { 31 | ChiakiLog *log; 32 | ChiakiMutex codec_mutex; 33 | AMediaCodec *codec; 34 | ANativeWindow *window; 35 | uint64_t timestamp_cur; 36 | ChiakiThread output_thread; 37 | int32_t target_width; 38 | int32_t target_height; 39 | } AndroidChiakiVideoDecoder; 40 | 41 | ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log, int32_t target_width, int32_t target_height); 42 | void android_chiaki_video_decoder_fini(AndroidChiakiVideoDecoder *decoder); 43 | void android_chiaki_video_decoder_set_surface(AndroidChiakiVideoDecoder *decoder, JNIEnv *env, jobject surface); 44 | bool android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user); 45 | 46 | #endif -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/common/AppDatabase.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.common 19 | 20 | import android.content.Context 21 | import androidx.room.* 22 | 23 | @Database( 24 | version = 1, 25 | entities = [RegisteredHost::class, ManualHost::class]) 26 | @TypeConverters(Converters::class) 27 | abstract class AppDatabase: RoomDatabase() 28 | { 29 | abstract fun registeredHostDao(): RegisteredHostDao 30 | abstract fun manualHostDao(): ManualHostDao 31 | abstract fun importDao(): ImportDao 32 | } 33 | 34 | private var database: AppDatabase? = null 35 | fun getDatabase(context: Context): AppDatabase 36 | { 37 | val currentDb = database 38 | if(currentDb != null) 39 | return currentDb 40 | val db = Room.databaseBuilder( 41 | context.applicationContext, 42 | AppDatabase::class.java, 43 | "chiaki").build() 44 | database = db 45 | return db 46 | } 47 | 48 | private class Converters 49 | { 50 | @TypeConverter 51 | fun macFromValue(v: Long) = MacAddress(v) 52 | 53 | @TypeConverter 54 | fun macToValue(addr: MacAddress) = addr.value 55 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/common/ext/RxLiveData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.common.ext 19 | 20 | import androidx.lifecycle.LiveDataReactiveStreams 21 | import io.reactivex.BackpressureStrategy 22 | import io.reactivex.Observable 23 | import io.reactivex.Single 24 | import org.reactivestreams.Publisher 25 | 26 | fun Publisher.toLiveData() = LiveDataReactiveStreams.fromPublisher(this) 27 | fun Observable.toLiveData() = this.toFlowable(BackpressureStrategy.LATEST).toLiveData() 28 | fun Single.toLiveData() = this.toFlowable().toLiveData() -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/common/ext/StringHex.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.common.ext 19 | 20 | fun String.hexToByteArray(): ByteArray? = ByteArray(this.length / 2) { 21 | this.substring(it * 2, it * 2 + 2).toIntOrNull(16)?.toByte() ?: return null 22 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/common/ext/ViewGroupInflate.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.common.ext 19 | 20 | import android.view.LayoutInflater 21 | import android.view.View 22 | import android.view.ViewGroup 23 | import androidx.annotation.LayoutRes 24 | 25 | fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View 26 | { 27 | return LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) 28 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/common/ext/ViewModelFactory.kt: -------------------------------------------------------------------------------- 1 | package com.metallic.chiaki.common.ext 2 | 3 | import androidx.lifecycle.ViewModel 4 | import androidx.lifecycle.ViewModelProvider 5 | 6 | inline fun viewModelFactory(crossinline f: () -> T) = 7 | object : ViewModelProvider.Factory 8 | { 9 | @Suppress("UNCHECKED_CAST") 10 | override fun create(aClass: Class): T = f() as T 11 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/regist/ChiakiRxLog.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.regist 19 | 20 | import com.metallic.chiaki.lib.ChiakiLog 21 | import io.reactivex.Observable 22 | import io.reactivex.subjects.BehaviorSubject 23 | import java.util.concurrent.locks.ReentrantLock 24 | import kotlin.concurrent.withLock 25 | 26 | class ChiakiRxLog(levelMask: Int) 27 | { 28 | private val accSubject: BehaviorSubject = BehaviorSubject.create().also { 29 | it.onNext("") 30 | } 31 | private val accMutex = ReentrantLock() 32 | val logText: Observable get() = accSubject 33 | 34 | val log = ChiakiLog(levelMask, callback = { level, text -> 35 | accMutex.withLock { 36 | val cur = accSubject.value ?: "" 37 | accSubject.onNext(cur + (if(cur.isEmpty()) "" else "\n") + ChiakiLog.formatLog(level, text)) 38 | } 39 | }) 40 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/regist/RegistViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.regist 19 | 20 | import androidx.lifecycle.MutableLiveData 21 | import androidx.lifecycle.ViewModel 22 | 23 | class RegistViewModel: ViewModel() 24 | { 25 | enum class PS4Version { 26 | GE_7, 27 | LT_7 28 | } 29 | 30 | val ps4Version = MutableLiveData(PS4Version.GE_7) 31 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/settings/SettingsLogsViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.settings 19 | 20 | import androidx.lifecycle.LiveData 21 | import androidx.lifecycle.MutableLiveData 22 | import androidx.lifecycle.ViewModel 23 | import com.metallic.chiaki.common.AppDatabase 24 | import com.metallic.chiaki.common.LogFile 25 | import com.metallic.chiaki.common.LogManager 26 | import com.metallic.chiaki.common.RegisteredHost 27 | import com.metallic.chiaki.common.ext.toLiveData 28 | import io.reactivex.disposables.CompositeDisposable 29 | import io.reactivex.rxkotlin.addTo 30 | import io.reactivex.schedulers.Schedulers 31 | 32 | class SettingsLogsViewModel(val logManager: LogManager): ViewModel() 33 | { 34 | private val _sessionLogs = MutableLiveData>(logManager.files) 35 | val sessionLogs: LiveData> get() = _sessionLogs 36 | 37 | private fun updateLogs() 38 | { 39 | _sessionLogs.value = logManager.files 40 | } 41 | 42 | fun deleteLog(file: LogFile) 43 | { 44 | file.file.delete() 45 | updateLogs() 46 | } 47 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/settings/SettingsRegisteredHostsAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.settings 19 | 20 | import android.view.View 21 | import android.view.ViewGroup 22 | import androidx.recyclerview.widget.RecyclerView 23 | import com.metallic.chiaki.R 24 | import com.metallic.chiaki.common.RegisteredHost 25 | import com.metallic.chiaki.common.ext.inflate 26 | import kotlinx.android.synthetic.main.item_registered_host.view.* 27 | 28 | class SettingsRegisteredHostsAdapter: RecyclerView.Adapter() 29 | { 30 | class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) 31 | 32 | var hosts: List = listOf() 33 | set(value) 34 | { 35 | field = value 36 | notifyDataSetChanged() 37 | } 38 | 39 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(parent.inflate(R.layout.item_registered_host)) 40 | 41 | override fun getItemCount() = hosts.size 42 | 43 | override fun onBindViewHolder(holder: ViewHolder, position: Int) 44 | { 45 | val view = holder.itemView 46 | val host = hosts[position] 47 | view.nameTextView.text = host.ps4Nickname 48 | view.summaryTextView.text = host.ps4Mac.toString() 49 | } 50 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/settings/SettingsRegisteredHostsViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.settings 19 | 20 | import androidx.lifecycle.ViewModel 21 | import com.metallic.chiaki.common.AppDatabase 22 | import com.metallic.chiaki.common.RegisteredHost 23 | import com.metallic.chiaki.common.ext.toLiveData 24 | import io.reactivex.disposables.CompositeDisposable 25 | import io.reactivex.rxkotlin.addTo 26 | import io.reactivex.schedulers.Schedulers 27 | 28 | class SettingsRegisteredHostsViewModel(val database: AppDatabase): ViewModel() 29 | { 30 | private val disposable = CompositeDisposable() 31 | 32 | val registeredHosts by lazy { 33 | database.registeredHostDao().getAll().toLiveData() 34 | } 35 | 36 | fun deleteHost(host: RegisteredHost) 37 | { 38 | database.registeredHostDao() 39 | .delete(host) 40 | .subscribeOn(Schedulers.io()) 41 | .subscribe() 42 | .addTo(disposable) 43 | } 44 | 45 | override fun onCleared() 46 | { 47 | super.onCleared() 48 | disposable.dispose() 49 | } 50 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/settings/SettingsViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.settings 19 | 20 | import androidx.lifecycle.ViewModel 21 | import com.metallic.chiaki.common.AppDatabase 22 | import com.metallic.chiaki.common.Preferences 23 | import com.metallic.chiaki.common.ext.toLiveData 24 | 25 | class SettingsViewModel(val database: AppDatabase, val preferences: Preferences): ViewModel() 26 | { 27 | val registeredHostsCount by lazy { 28 | database.registeredHostDao().count().toLiveData() 29 | } 30 | 31 | val bitrateAuto by lazy { 32 | preferences.bitrateAutoObservable.toLiveData() 33 | } 34 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/touchcontrols/ControlsBackgroundView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.touchcontrols 19 | 20 | import android.content.Context 21 | import android.util.AttributeSet 22 | import android.view.MotionEvent 23 | import android.view.View 24 | 25 | class ControlsBackgroundView @JvmOverloads constructor( 26 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 27 | ) : View(context, attrs, defStyleAttr) 28 | { 29 | override fun onTouchEvent(event: MotionEvent) = true 30 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/touchcontrols/TouchTracker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.touchcontrols 19 | 20 | import android.view.MotionEvent 21 | 22 | class TouchTracker 23 | { 24 | var currentPosition: Vector? = null 25 | private set(value) 26 | { 27 | field = value 28 | positionChangedCallback?.let { it(field) } 29 | } 30 | 31 | var positionChangedCallback: ((Vector?) -> Unit)? = null 32 | 33 | private var pointerId: Int? = null 34 | 35 | fun touchEvent(event: MotionEvent) 36 | { 37 | when(event.actionMasked) 38 | { 39 | MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN -> 40 | { 41 | if(pointerId == null) 42 | { 43 | pointerId = event.getPointerId(event.actionIndex) 44 | currentPosition = Vector(event.x, event.y) 45 | } 46 | } 47 | 48 | MotionEvent.ACTION_UP, MotionEvent.ACTION_POINTER_UP -> 49 | { 50 | if(event.getPointerId(event.actionIndex) == pointerId) 51 | { 52 | pointerId = null 53 | currentPosition = null 54 | } 55 | } 56 | 57 | MotionEvent.ACTION_MOVE -> 58 | { 59 | val pointerId = pointerId 60 | if(pointerId != null) 61 | { 62 | val pointerIndex = event.findPointerIndex(pointerId) 63 | if(pointerIndex >= 0) 64 | currentPosition = Vector(event.getX(pointerIndex), event.getY(pointerIndex)) 65 | } 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /android/app/src/main/java/com/metallic/chiaki/touchcontrols/Vector.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | package com.metallic.chiaki.touchcontrols 19 | 20 | import kotlin.math.sqrt 21 | 22 | data class Vector(val x: Float, val y: Float) 23 | { 24 | operator fun plus(o: Vector) = Vector(x + o.x, y + o.y) 25 | operator fun minus(o: Vector) = Vector(x - o.x, y - o.y) 26 | operator fun plus(s: Float) = Vector(x + s, y + s) 27 | operator fun minus(s: Float) = Vector(x - s, y - s) 28 | operator fun times(s: Float) = Vector(x * s, y * s) 29 | operator fun div(s: Float) = this * (1f / s) 30 | operator fun times(o: Vector) = Vector(x * o.x, y * o.y) 31 | operator fun div(o: Vector) = this * Vector(1.0f / o.x, 1.0f / o.y) 32 | 33 | val lengthSq get() = x*x + y*y 34 | val length get() = sqrt(lengthSq) 35 | val normalized get() = this / length 36 | } -------------------------------------------------------------------------------- /android/app/src/main/res/color/mage_text_input_box_stroke.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/color/stream_material_button_icon_tint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/avd_add_to_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 14 | 15 | 16 | 17 | 19 | 20 | 25 | 26 | 27 | 28 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/avd_close_to_add.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 14 | 15 | 16 | 17 | 19 | 20 | 25 | 26 | 27 | 28 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 43 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_analog_stick_base.xml: -------------------------------------------------------------------------------- 1 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_analog_stick_handle.xml: -------------------------------------------------------------------------------- 1 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_box.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_box_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_cross.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_cross_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_home.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_home_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_l1.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_l1_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_l2.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_l2_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_moon.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_moon_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_options.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_options_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_pyramid.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_pyramid_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_r1.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_r1_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_r2.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_r2_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_button_share_pressed.xml: -------------------------------------------------------------------------------- 1 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_dpad_idle.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_dpad_left.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/control_dpad_left_up.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 27 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_add.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_add_close.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 18 | 19 | 23 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_add_manual.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 23 | 24 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_bitrate.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_close.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_console.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_console_ready.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_console_simple.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_console_standby.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_delete_row.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_discover_off.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_discover_on.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_discovered_on_secondary.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_display_normal.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_display_stretch.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_display_zoom.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_export.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_fps.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_gamepad.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_host.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_import.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 8 | 16 | 22 | 28 | 29 | 30 | 37 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_log.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_overflow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_pin.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_psn_id.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_regist_console.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_register.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_resolution.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_triangle.xml: -------------------------------------------------------------------------------- 1 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/selector_add_fab.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 11 | 12 | 13 | 17 | 18 | 19 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 23 | 24 | 25 | 31 | 32 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/dialog_login_pin.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/dropdown_menu_popup_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/fragment_settings_logs.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 25 | 26 | 37 | 38 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/fragment_touchpad_only.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 26 | 27 | -------------------------------------------------------------------------------- /android/app/src/main/res/menu/display_host.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 17 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #162d50 4 | #000128 5 | #ffaaee 6 | 7 | @android:color/white 8 | @android:color/black 9 | #77000000 10 | 11 | #fafafa 12 | #333333 13 | 14 | #22ffffff 15 | #88ffffff 16 | 17 | #B71C1C 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 48dp 4 | 48dp 5 | 32dp 6 | 48dp 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #CFFF0D 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/xml/filepaths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.61' 5 | repositories { 6 | google() 7 | jcenter() 8 | 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.5.2' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Sep 14 10:53:58 CEST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name='Chiaki' 3 | -------------------------------------------------------------------------------- /assets/.gitignore: -------------------------------------------------------------------------------- 1 | screenshots 2 | chiaki_square.png 3 | chiaki_function.png 4 | -------------------------------------------------------------------------------- /assets/chiaki_wide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/assets/chiaki_wide.png -------------------------------------------------------------------------------- /assets/controls/stick.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /assets/gen-icns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # https://gist.github.com/zlbruce/883605a635df8d5964bab11ed75e46ad 4 | 5 | if [ $# -ne 1 ]; then 6 | echo "Usage: $0 " 7 | exit 100 8 | fi 9 | filename="$1" 10 | name=${filename%.*} 11 | ext=${filename##*.} 12 | echo "processing: $name" 13 | dest="$name".iconset 14 | mkdir "$dest" 15 | 16 | convert -background none -resize '!16x16' "$1" "$dest/icon_16x16.png" 17 | convert -background none -resize '!32x32' "$1" "$dest/icon_16x16@2x.png" 18 | cp "$dest/icon_16x16@2x.png" "$dest/icon_32x32.png" 19 | convert -background none -resize '!64x64' "$1" "$dest/icon_32x32@2x.png" 20 | convert -background none -resize '!128x128' "$1" "$dest/icon_128x128.png" 21 | convert -background none -resize '!256x256' "$1" "$dest/icon_128x128@2x.png" 22 | cp "$dest/icon_128x128@2x.png" "$dest/icon_256x256.png" 23 | convert -background none -resize '!512x512' "$1" "$dest/icon_256x256@2x.png" 24 | cp "$dest/icon_256x256@2x.png" "$dest/icon_512x512.png" 25 | convert -background none -resize '!1024x1024' "$1" "$dest/icon_512x512@2x.png" 26 | 27 | iconutil -c icns "$dest" 28 | rm -R "$dest" 29 | -------------------------------------------------------------------------------- /assets/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/assets/ic_launcher-web.png -------------------------------------------------------------------------------- /assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/assets/screenshot.png -------------------------------------------------------------------------------- /assets/triangle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /cli/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE 3 | include/chiaki-cli.h 4 | src/discover.c 5 | src/wakeup.c) 6 | 7 | add_library(chiaki-cli-lib STATIC ${SOURCE}) 8 | target_include_directories(chiaki-cli-lib PUBLIC "include") 9 | target_link_libraries(chiaki-cli-lib chiaki-lib) 10 | 11 | if(CHIAKI_CLI_ARGP_STANDALONE) 12 | find_package(Argp REQUIRED) 13 | target_link_libraries(chiaki-cli-lib Argp::Argp) 14 | endif() 15 | 16 | add_executable(chiaki-cli src/main.c) 17 | target_link_libraries(chiaki-cli chiaki-cli-lib) 18 | -------------------------------------------------------------------------------- /cli/include/chiaki-cli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_CHIAKI_CLI_H 19 | #define CHIAKI_CHIAKI_CLI_H 20 | 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | CHIAKI_EXPORT int chiaki_cli_cmd_discover(ChiakiLog *log, int argc, char *argv[]); 29 | CHIAKI_EXPORT int chiaki_cli_cmd_wakeup(ChiakiLog *log, int argc, char *argv[]); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif //CHIAKI_CHIAKI_CLI_H 36 | -------------------------------------------------------------------------------- /cmake/FindArgp.cmake: -------------------------------------------------------------------------------- 1 | # FindArgp 2 | # Will define Target Argp::Argp 3 | 4 | find_path(Argp_INCLUDE_DIR 5 | NAMES argp.h) 6 | 7 | find_library(Argp_LIBRARY 8 | NAMES argp) 9 | 10 | include(FindPackageHandleStandardArgs) 11 | find_package_handle_standard_args(Argp 12 | REQUIRED_VARS Argp_LIBRARY Argp_INCLUDE_DIR) 13 | 14 | if(Argp_FOUND AND NOT TARGET Argp::Argp) 15 | add_library(Argp::Argp UNKNOWN IMPORTED) 16 | set_target_properties(Argp::Argp PROPERTIES 17 | IMPORTED_LOCATION "${Argp_LIBRARY}" 18 | INTERFACE_INCLUDE_DIRECTORIES "${Argp_INCLUDE_DIR}") 19 | endif() 20 | 21 | -------------------------------------------------------------------------------- /cmake/FindOpus.cmake: -------------------------------------------------------------------------------- 1 | # Opus_FOUND 2 | # Opus_INCLUDE_DIRS 3 | # Opus_LIBRARIES 4 | 5 | find_path(Opus_INCLUDE_DIRS 6 | NAMES opus/opus.h 7 | PATH_SUFFIXES include 8 | ) 9 | 10 | find_library(Opus_LIBRARIES NAMES opus) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(Opus 14 | DEFAULT_MSG 15 | Opus_INCLUDE_DIRS Opus_LIBRARIES 16 | ) 17 | -------------------------------------------------------------------------------- /cmake/FindSDL2.cmake: -------------------------------------------------------------------------------- 1 | 2 | find_package(SDL2 NO_MODULE QUIET) 3 | 4 | if(SDL2_FOUND AND (NOT TARGET SDL2::SDL2)) 5 | add_library(SDL2::SDL2 UNKNOWN IMPORTED GLOBAL) 6 | if(NOT SDL2_LIBDIR) 7 | set(SDL2_LIBDIR "${libdir}") 8 | endif() 9 | find_library(SDL2_LIBRARY SDL2 PATHS "${SDL2_LIBDIR}" NO_DEFAULT_PATH) 10 | if(SDL2_LIBRARY) 11 | string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) 12 | set_target_properties(SDL2::SDL2 PROPERTIES 13 | IMPORTED_LOCATION "${SDL2_LIBRARY}" 14 | IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARIES}" 15 | INTERFACE_LINK_DIRECTORIES "${SDL2_LIBDIR}" 16 | INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}") 17 | else() 18 | set(SDL2_FOUND FALSE) 19 | endif() 20 | endif() 21 | 22 | include(FindPackageHandleStandardArgs) 23 | find_package_handle_standard_args(SDL2 CONFIG_MODE) 24 | -------------------------------------------------------------------------------- /cmake/OpenSSLExternalProject.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(ExternalProject) 3 | 4 | set(OPENSSL_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/openssl-install-prefix") 5 | 6 | unset(OPENSSL_OS_COMPILER) 7 | unset(OPENSSL_CONFIG_EXTRA_ARGS) 8 | unset(OPENSSL_BUILD_ENV) 9 | 10 | if(ANDROID_ABI) 11 | if(ANDROID_ABI STREQUAL "armeabi-v7a") 12 | set(OPENSSL_OS_COMPILER "android-arm") 13 | elseif(ANDROID_ABI STREQUAL "arm64-v8a") 14 | set(OPENSSL_OS_COMPILER "android-arm64") 15 | elseif(ANDROID_ABI STREQUAL "x86") 16 | set(OPENSSL_OS_COMPILER "android-x86") 17 | elseif(ANDROID_ABI STREQUAL "x86_64") 18 | set(OPENSSL_OS_COMPILER "android-x86_64") 19 | endif() 20 | 21 | set(OPENSSL_CONFIG_EXTRA_ARGS "-D__ANDROID_API__=${ANDROID_NATIVE_API_LEVEL}") 22 | get_filename_component(ANDROID_NDK_BIN_PATH "${CMAKE_C_COMPILER}" DIRECTORY) 23 | set(OPENSSL_BUILD_ENV "ANDROID_NDK_HOME=${ANDROID_NDK}" "PATH=${ANDROID_NDK_BIN_PATH}:$ENV{PATH}") 24 | else() 25 | if(UNIX AND NOT APPLE AND CMAKE_SIZEOF_VOID_P STREQUAL "8") 26 | set(OPENSSL_OS_COMPILER "linux-x86_64") 27 | endif() 28 | endif() 29 | 30 | if(NOT OPENSSL_OS_COMPILER) 31 | message(FATAL_ERROR "Failed to match OPENSSL_OS_COMPILER") 32 | endif() 33 | 34 | find_program(MAKE_EXE NAMES gmake make) 35 | ExternalProject_Add(OpenSSL-ExternalProject 36 | URL https://www.openssl.org/source/openssl-1.1.1d.tar.gz 37 | URL_HASH SHA256=1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2 38 | INSTALL_DIR "${OPENSSL_INSTALL_DIR}" 39 | CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${OPENSSL_BUILD_ENV} 40 | "/Configure" "--prefix=" no-shared ${OPENSSL_CONFIG_EXTRA_ARGS} "${OPENSSL_OS_COMPILER}" 41 | BUILD_COMMAND ${CMAKE_COMMAND} -E env ${OPENSSL_BUILD_ENV} "${MAKE_EXE}" -j4 build_libs 42 | INSTALL_COMMAND ${CMAKE_COMMAND} -E env ${OPENSSL_BUILD_ENV} "${MAKE_EXE}" install_dev) 43 | 44 | add_library(OpenSSL_Crypto INTERFACE) 45 | add_dependencies(OpenSSL_Crypto OpenSSL-ExternalProject) 46 | if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0") 47 | target_link_directories(OpenSSL_Crypto INTERFACE "${OPENSSL_INSTALL_DIR}/lib") 48 | else() 49 | link_directories("${OPENSSL_INSTALL_DIR}/lib") 50 | endif() 51 | target_link_libraries(OpenSSL_Crypto INTERFACE crypto) 52 | target_include_directories(OpenSSL_Crypto INTERFACE "${OPENSSL_INSTALL_DIR}/include") 53 | -------------------------------------------------------------------------------- /gui/MacOSXBundleInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | ${MACOSX_BUNDLE_INFO_STRING} 11 | CFBundleIconFile 12 | ${MACOSX_BUNDLE_ICON_FILE} 13 | CFBundleIdentifier 14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${MACOSX_BUNDLE_BUNDLE_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 23 | CFBundleVersion 24 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 25 | CSResourcesFileMapped 26 | 27 | NSHumanReadableCopyright 28 | ${MACOSX_BUNDLE_COPYRIGHT} 29 | NSHighResolutionCapable 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /gui/chiaki.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=Chiaki 4 | Comment=PlayStation 4 Remote Play Client 5 | Exec=chiaki 6 | Icon=chiaki 7 | Categories=Game; -------------------------------------------------------------------------------- /gui/chiaki.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/gui/chiaki.icns -------------------------------------------------------------------------------- /gui/chiaki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/gui/chiaki.png -------------------------------------------------------------------------------- /gui/include/avopenglframeuploader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_AVOPENGLFRAMEUPLOADER_H 19 | #define CHIAKI_AVOPENGLFRAMEUPLOADER_H 20 | 21 | #include 22 | #include 23 | 24 | class AVOpenGLWidget; 25 | class VideoDecoder; 26 | class QSurface; 27 | 28 | class AVOpenGLFrameUploader: public QObject 29 | { 30 | Q_OBJECT 31 | 32 | private: 33 | VideoDecoder *decoder; 34 | AVOpenGLWidget *widget; 35 | QOpenGLContext *context; 36 | QSurface *surface; 37 | 38 | private slots: 39 | void UpdateFrame(); 40 | 41 | public: 42 | AVOpenGLFrameUploader(VideoDecoder *decoder, AVOpenGLWidget *widget, QOpenGLContext *context, QSurface *surface); 43 | }; 44 | 45 | #endif // CHIAKI_AVOPENGLFRAMEUPLOADER_H 46 | -------------------------------------------------------------------------------- /gui/include/avopenglwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_AVOPENGLWIDGET_H 19 | #define CHIAKI_AVOPENGLWIDGET_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | extern "C" 27 | { 28 | #include 29 | } 30 | 31 | class VideoDecoder; 32 | class AVOpenGLFrameUploader; 33 | 34 | struct AVOpenGLFrame 35 | { 36 | GLuint pbo[3]; 37 | GLuint tex[3]; 38 | unsigned int width; 39 | unsigned int height; 40 | 41 | bool Update(AVFrame *frame, ChiakiLog *log); 42 | }; 43 | 44 | class AVOpenGLWidget: public QOpenGLWidget 45 | { 46 | Q_OBJECT 47 | 48 | private: 49 | VideoDecoder *decoder; 50 | 51 | GLuint program; 52 | GLuint vbo; 53 | GLuint vao; 54 | 55 | AVOpenGLFrame frames[2]; 56 | int frame_fg; 57 | QMutex frames_mutex; 58 | QOpenGLContext *frame_uploader_context; 59 | AVOpenGLFrameUploader *frame_uploader; 60 | QThread *frame_uploader_thread; 61 | 62 | QTimer *mouse_timer; 63 | 64 | public: 65 | static QSurfaceFormat CreateSurfaceFormat(); 66 | 67 | explicit AVOpenGLWidget(VideoDecoder *decoder, QWidget *parent = nullptr); 68 | ~AVOpenGLWidget() override; 69 | 70 | void SwapFrames(); 71 | AVOpenGLFrame *GetBackgroundFrame() { return &frames[1 - frame_fg]; } 72 | 73 | protected: 74 | void mouseMoveEvent(QMouseEvent *event) override; 75 | 76 | void initializeGL() override; 77 | void paintGL() override; 78 | 79 | private slots: 80 | void ResetMouseTimeout(); 81 | public slots: 82 | void HideMouse(); 83 | }; 84 | 85 | #endif // CHIAKI_AVOPENGLWIDGET_H 86 | -------------------------------------------------------------------------------- /gui/include/discoverymanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_DISCOVERYMANAGER_H 19 | #define CHIAKI_DISCOVERYMANAGER_H 20 | 21 | #include 22 | 23 | #include "host.h" 24 | 25 | #include 26 | #include 27 | 28 | struct DiscoveryHost 29 | { 30 | ChiakiDiscoveryHostState state; 31 | uint16_t host_request_port; 32 | #define STRING_MEMBER(name) QString name; 33 | CHIAKI_DISCOVERY_HOST_STRING_FOREACH(STRING_MEMBER) 34 | #undef STRING_MEMBER 35 | 36 | HostMAC GetHostMAC() const; 37 | }; 38 | 39 | Q_DECLARE_METATYPE(DiscoveryHost) 40 | 41 | class DiscoveryManager : public QObject 42 | { 43 | Q_OBJECT 44 | 45 | friend class DiscoveryManagerPrivate; 46 | 47 | private: 48 | ChiakiLog log; 49 | ChiakiDiscoveryService service; 50 | bool service_active; 51 | QList hosts; 52 | 53 | private slots: 54 | void DiscoveryServiceHosts(QList hosts); 55 | 56 | public: 57 | explicit DiscoveryManager(QObject *parent = nullptr); 58 | ~DiscoveryManager(); 59 | 60 | void SetActive(bool active); 61 | 62 | void SendWakeup(const QString &host, const QByteArray ®ist_key); 63 | 64 | const QList GetHosts() const { return hosts; } 65 | 66 | signals: 67 | void HostsUpdated(); 68 | }; 69 | 70 | #endif //CHIAKI_DISCOVERYMANAGER_H 71 | -------------------------------------------------------------------------------- /gui/include/dynamicgridwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_DYNAMICGRIDWIDGET_H 19 | #define CHIAKI_DYNAMICGRIDWIDGET_H 20 | 21 | #include 22 | 23 | class QGridLayout; 24 | 25 | class DynamicGridWidget : public QWidget 26 | { 27 | Q_OBJECT 28 | 29 | private: 30 | QGridLayout *layout; 31 | QList widgets; 32 | unsigned int item_width; 33 | unsigned int columns; 34 | 35 | void UpdateLayout(); 36 | void UpdateLayoutIfNecessary(); 37 | unsigned int CalculateColumns(); 38 | 39 | protected: 40 | void resizeEvent(QResizeEvent *) override { UpdateLayoutIfNecessary(); } 41 | 42 | public: 43 | explicit DynamicGridWidget(unsigned int item_width, QWidget *parent = nullptr); 44 | 45 | void AddWidget(QWidget *widget); 46 | void AddWidgets(const QList &widgets); 47 | 48 | void RemoveWidget(QWidget *widget); 49 | void ClearWidgets(); 50 | 51 | void SetItemWidth(unsigned int item_width) { this->item_width = item_width; UpdateLayoutIfNecessary(); } 52 | 53 | }; 54 | 55 | #endif //CHIAKI_DYNAMICGRIDWIDGET_H 56 | -------------------------------------------------------------------------------- /gui/include/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_EXCEPTION_H 19 | #define CHIAKI_EXCEPTION_H 20 | 21 | #include 22 | 23 | #include 24 | 25 | class Exception : public std::exception 26 | { 27 | private: 28 | QByteArray msg; 29 | 30 | public: 31 | explicit Exception(const QString &msg) : msg(msg.toLocal8Bit()) {} 32 | const char *what() const noexcept override { return msg.constData(); } 33 | }; 34 | 35 | #endif // CHIAKI_EXCEPTION_H 36 | -------------------------------------------------------------------------------- /gui/include/loginpindialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_LOGINPINDIALOG_H 19 | #define CHIAKI_LOGINPINDIALOG_H 20 | 21 | #include 22 | 23 | class QLineEdit; 24 | class QDialogButtonBox; 25 | 26 | class LoginPINDialog : public QDialog 27 | { 28 | Q_OBJECT 29 | 30 | private: 31 | QString pin; 32 | 33 | QLineEdit *pin_edit; 34 | QDialogButtonBox *button_box; 35 | 36 | void UpdateButtons(); 37 | 38 | public: 39 | explicit LoginPINDialog(bool incorrect, QWidget *parent = nullptr); 40 | 41 | QString GetPIN() { return pin; } 42 | }; 43 | 44 | #endif // CHIAKI_LOGINPINDIALOG_H 45 | -------------------------------------------------------------------------------- /gui/include/manualhostdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_MANUALHOSTDIALOG_H 19 | #define CHIAKI_MANUALHOSTDIALOG_H 20 | 21 | #include 22 | 23 | class Settings; 24 | 25 | class QLineEdit; 26 | class QComboBox; 27 | class QDialogButtonBox; 28 | class QAbstractButton; 29 | 30 | class ManualHostDialog: public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | private: 35 | Settings *settings; 36 | int host_id; 37 | 38 | QLineEdit *host_edit; 39 | QComboBox *registered_host_combo_box; 40 | QDialogButtonBox *button_box; 41 | 42 | private slots: 43 | void ValidateInput(); 44 | 45 | void ButtonClicked(QAbstractButton *button); 46 | 47 | public: 48 | explicit ManualHostDialog(Settings *settings, int id, QWidget *parent = nullptr); 49 | 50 | public slots: 51 | void accept() override; 52 | }; 53 | 54 | #endif // CHIAKI_MANUALHOSTDIALOG_H 55 | -------------------------------------------------------------------------------- /gui/include/servericonwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SERVERICONWIDGET_H 19 | #define CHIAKI_SERVERICONWIDGET_H 20 | 21 | #include 22 | 23 | #include 24 | 25 | class ServerIconWidget : public QWidget 26 | { 27 | Q_OBJECT 28 | 29 | private: 30 | ChiakiDiscoveryHostState state = CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN; 31 | 32 | protected: 33 | void paintEvent(QPaintEvent *event) override; 34 | 35 | public: 36 | explicit ServerIconWidget(QWidget *parent = nullptr); 37 | 38 | void SetState(ChiakiDiscoveryHostState state) { this->state = state; update(); } 39 | }; 40 | 41 | #endif // CHIAKI_SERVERICONWIDGET_H 42 | -------------------------------------------------------------------------------- /gui/include/serveritemwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SERVERITEMWIDGET_H 19 | #define CHIAKI_SERVERITEMWIDGET_H 20 | 21 | #include 22 | 23 | class QLabel; 24 | 25 | class ServerIconWidget; 26 | struct DisplayServer; 27 | 28 | class ServerItemWidget : public QFrame 29 | { 30 | Q_OBJECT 31 | 32 | private: 33 | bool selected; 34 | 35 | QLabel *top_label; 36 | QLabel *bottom_label; 37 | ServerIconWidget *icon_widget; 38 | 39 | QAction *delete_action; 40 | QAction *wake_action; 41 | 42 | protected: 43 | void mousePressEvent(QMouseEvent *event) override; 44 | void mouseDoubleClickEvent(QMouseEvent *event) override; 45 | 46 | public: 47 | explicit ServerItemWidget(QWidget *parent = nullptr); 48 | 49 | bool IsSelected() { return selected; } 50 | void SetSelected(bool selected); 51 | 52 | void Update(const DisplayServer &display_server); 53 | 54 | signals: 55 | void Selected(); 56 | void Triggered(); 57 | void DeleteTriggered(); 58 | void WakeTriggered(); 59 | }; 60 | 61 | #endif //CHIAKI_CONSOLEITEMWIDGET_H 62 | -------------------------------------------------------------------------------- /gui/include/sessionlog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SESSIONLOG_H 19 | #define CHIAKI_SESSIONLOG_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class QFile; 28 | class StreamSession; 29 | 30 | class SessionLog 31 | { 32 | friend class SessionLogPrivate; 33 | 34 | private: 35 | StreamSession *session; 36 | ChiakiLog log; 37 | QFile *file; 38 | QMutex file_mutex; 39 | 40 | void Log(ChiakiLogLevel level, const char *msg); 41 | 42 | public: 43 | SessionLog(StreamSession *session, uint32_t level_mask, const QString &filename); 44 | ~SessionLog(); 45 | 46 | ChiakiLog *GetChiakiLog() { return &log; } 47 | }; 48 | 49 | QString GetLogBaseDir(); 50 | QString CreateLogFilename(); 51 | 52 | #endif //CHIAKI_SESSIONLOG_H 53 | -------------------------------------------------------------------------------- /gui/include/settingsdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SETTINGSDIALOG_H 19 | #define CHIAKI_SETTINGSDIALOG_H 20 | 21 | #include 22 | 23 | class Settings; 24 | class QListWidget; 25 | class QComboBox; 26 | class QCheckBox; 27 | class QLineEdit; 28 | 29 | class SettingsDialog : public QDialog 30 | { 31 | Q_OBJECT 32 | 33 | private: 34 | Settings *settings; 35 | 36 | QCheckBox *log_verbose_check_box; 37 | 38 | QComboBox *resolution_combo_box; 39 | QComboBox *fps_combo_box; 40 | QLineEdit *bitrate_edit; 41 | QLineEdit *audio_buffer_size_edit; 42 | 43 | QListWidget *registered_hosts_list_widget; 44 | QPushButton *delete_registered_host_button; 45 | 46 | void UpdateBitratePlaceholder(); 47 | 48 | private slots: 49 | void LogVerboseChanged(); 50 | 51 | void ResolutionSelected(); 52 | void FPSSelected(); 53 | void BitrateEdited(); 54 | void AudioBufferSizeEdited(); 55 | 56 | void UpdateRegisteredHosts(); 57 | void UpdateRegisteredHostsButtons(); 58 | void RegisterNewHost(); 59 | void DeleteRegisteredHost(); 60 | 61 | public: 62 | SettingsDialog(Settings *settings, QWidget *parent = nullptr); 63 | }; 64 | 65 | #endif // CHIAKI_SETTINGSDIALOG_H 66 | -------------------------------------------------------------------------------- /gui/include/settingskeycapturedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SETTINGSKEYCAPTUREDIALOG_H 19 | #define CHIAKI_SETTINGSKEYCAPTUREDIALOG_H 20 | 21 | #include 22 | 23 | class SettingsKeyCaptureDialog : public QDialog 24 | { 25 | Q_OBJECT 26 | 27 | signals: 28 | void KeyCaptured(Qt::Key); 29 | 30 | protected: 31 | void keyReleaseEvent(QKeyEvent *event) override; 32 | 33 | public: 34 | explicit SettingsKeyCaptureDialog(QWidget *parent = nullptr); 35 | }; 36 | 37 | #endif // CHIAKI_SETTINGSKEYCAPTUREDIALOG_H 38 | -------------------------------------------------------------------------------- /gui/include/streamwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_GUI_STREAMWINDOW_H 19 | #define CHIAKI_GUI_STREAMWINDOW_H 20 | 21 | #include 22 | 23 | #include "streamsession.h" 24 | 25 | class QLabel; 26 | class AVOpenGLWidget; 27 | 28 | class StreamWindow: public QMainWindow 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | explicit StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent = nullptr); 34 | ~StreamWindow() override; 35 | 36 | private: 37 | StreamSession *session; 38 | 39 | AVOpenGLWidget *av_widget; 40 | 41 | void Init(const StreamSessionConnectInfo &connect_info); 42 | 43 | protected: 44 | void keyPressEvent(QKeyEvent *event) override; 45 | void keyReleaseEvent(QKeyEvent *event) override; 46 | void closeEvent(QCloseEvent *event) override; 47 | void mousePressEvent(QMouseEvent *event) override; 48 | void mouseReleaseEvent(QMouseEvent *event) override; 49 | 50 | private slots: 51 | void SessionQuit(ChiakiQuitReason reason, const QString &reason_str); 52 | void LoginPINRequested(bool incorrect); 53 | void ToggleFullscreen(); 54 | }; 55 | 56 | #endif // CHIAKI_GUI_STREAMWINDOW_H 57 | -------------------------------------------------------------------------------- /gui/include/videodecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_VIDEODECODER_H 19 | #define CHIAKI_VIDEODECODER_H 20 | 21 | #include 22 | 23 | #include "exception.h" 24 | 25 | #include 26 | #include 27 | 28 | extern "C" 29 | { 30 | #include 31 | } 32 | 33 | #include 34 | 35 | class VideoDecoderException: public Exception 36 | { 37 | public: 38 | explicit VideoDecoderException(const QString &msg) : Exception(msg) {}; 39 | }; 40 | 41 | class VideoDecoder: public QObject 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | VideoDecoder(ChiakiLog *log); 47 | ~VideoDecoder(); 48 | 49 | void PushFrame(uint8_t *buf, size_t buf_size); 50 | AVFrame *PullFrame(); 51 | 52 | ChiakiLog *GetChiakiLog() { return log; } 53 | 54 | signals: 55 | void FramesAvailable(); 56 | 57 | private: 58 | ChiakiLog *log; 59 | QMutex mutex; 60 | 61 | AVCodec *codec; 62 | AVCodecContext *codec_context; 63 | }; 64 | 65 | #endif // CHIAKI_VIDEODECODER_H 66 | -------------------------------------------------------------------------------- /gui/res/add-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gui/res/discover-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gui/res/discover-off-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gui/res/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | settings-20px.svg 4 | add-24px.svg 5 | discover-24px.svg 6 | discover-off-24px.svg 7 | chiaki.svg 8 | 9 | 10 | -------------------------------------------------------------------------------- /gui/res/settings-20px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gui/src/avopenglframeuploader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | AVOpenGLFrameUploader::AVOpenGLFrameUploader(VideoDecoder *decoder, AVOpenGLWidget *widget, QOpenGLContext *context, QSurface *surface) 26 | : QObject(nullptr), 27 | decoder(decoder), 28 | widget(widget), 29 | context(context), 30 | surface(surface) 31 | { 32 | connect(decoder, SIGNAL(FramesAvailable()), this, SLOT(UpdateFrame())); 33 | } 34 | 35 | void AVOpenGLFrameUploader::UpdateFrame() 36 | { 37 | if(QOpenGLContext::currentContext() != context) 38 | context->makeCurrent(surface); 39 | 40 | AVFrame *next_frame = decoder->PullFrame(); 41 | if(!next_frame) 42 | return; 43 | 44 | bool success = widget->GetBackgroundFrame()->Update(next_frame, decoder->GetChiakiLog()); 45 | av_frame_free(&next_frame); 46 | 47 | if(success) 48 | widget->SwapFrames(); 49 | } -------------------------------------------------------------------------------- /gui/src/loginpindialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #define PIN_LENGTH 4 29 | 30 | static const QRegularExpression pin_re(QString("[0-9]").repeated(PIN_LENGTH)); 31 | 32 | LoginPINDialog::LoginPINDialog(bool incorrect, QWidget *parent) : QDialog(parent) 33 | { 34 | setWindowTitle(tr("Console Login PIN")); 35 | 36 | auto layout = new QVBoxLayout(this); 37 | setLayout(layout); 38 | 39 | if(incorrect) 40 | layout->addWidget(new QLabel(tr("Entered PIN was incorrect!"), this)); 41 | 42 | pin_edit = new QLineEdit(this); 43 | pin_edit->setPlaceholderText(tr("Login PIN")); 44 | pin_edit->setValidator(new QRegularExpressionValidator(pin_re, pin_edit)); 45 | layout->addWidget(pin_edit); 46 | connect(pin_edit, &QLineEdit::textChanged, this, [this](const QString &text) { 47 | this->pin = text; 48 | UpdateButtons(); 49 | }); 50 | 51 | button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 52 | layout->addWidget(button_box); 53 | 54 | connect(button_box, &QDialogButtonBox::accepted, this, &QDialog::accept); 55 | connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); 56 | 57 | UpdateButtons(); 58 | } 59 | 60 | void LoginPINDialog::UpdateButtons() 61 | { 62 | button_box->button(QDialogButtonBox::Ok)->setEnabled(pin_edit->text().length() == PIN_LENGTH); 63 | } -------------------------------------------------------------------------------- /gui/src/settingskeycapturedialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include "settingskeycapturedialog.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | SettingsKeyCaptureDialog::SettingsKeyCaptureDialog(QWidget* parent) 26 | { 27 | setWindowTitle(tr("Key Capture")); 28 | 29 | auto root_layout = new QVBoxLayout(this); 30 | setLayout(root_layout); 31 | 32 | auto label = new QLabel(tr("Press any key to configure button or click close.")); 33 | root_layout->addWidget(label); 34 | 35 | auto button = new QPushButton(tr("Close"), this); 36 | root_layout->addWidget(button); 37 | button->setAutoDefault(false); 38 | connect(button, &QPushButton::clicked, this, &QDialog::accept); 39 | } 40 | 41 | void SettingsKeyCaptureDialog::keyReleaseEvent(QKeyEvent* event) 42 | { 43 | KeyCaptured(Qt::Key(event->key())); 44 | accept(); 45 | } 46 | -------------------------------------------------------------------------------- /lib/config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_CONFIG_H 19 | #define CHIAKI_CONFIG_H 20 | 21 | #cmakedefine01 CHIAKI_LIB_ENABLE_OPUS 22 | 23 | #endif // CHIAKI_CONFIG_H 24 | -------------------------------------------------------------------------------- /lib/include/chiaki/audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_AUDIO_H 19 | #define CHIAKI_AUDIO_H 20 | 21 | #include 22 | #ifndef _WIN32 23 | #include 24 | #endif 25 | 26 | #include "common.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #define CHIAKI_AUDIO_HEADER_SIZE 0xe 33 | 34 | typedef struct chiaki_audio_header_t 35 | { 36 | uint8_t channels; 37 | uint8_t bits; 38 | uint32_t rate; 39 | uint32_t frame_size; 40 | uint32_t unknown; 41 | } ChiakiAudioHeader; 42 | 43 | CHIAKI_EXPORT void chiaki_audio_header_load(ChiakiAudioHeader *audio_header, const uint8_t *buf); 44 | CHIAKI_EXPORT void chiaki_audio_header_save(ChiakiAudioHeader *audio_header, uint8_t *buf); 45 | 46 | static inline size_t chiaki_audio_header_frame_buf_size(ChiakiAudioHeader *audio_header) 47 | { 48 | return audio_header->frame_size * audio_header->channels * sizeof(int16_t); 49 | } 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif // CHIAKI_AUDIO_H 56 | -------------------------------------------------------------------------------- /lib/include/chiaki/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_BASE64_H 19 | #define CHIAKI_BASE64_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_size, char *out, size_t out_size); 32 | CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_size, uint8_t *out, size_t *out_size); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif // CHIAKI_BASE64_H 39 | -------------------------------------------------------------------------------- /lib/include/chiaki/congestioncontrol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_CONGESTIONCONTROL_H 19 | #define CHIAKI_CONGESTIONCONTROL_H 20 | 21 | #include "takion.h" 22 | #include "thread.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct chiaki_congestion_control_t 29 | { 30 | ChiakiTakion *takion; 31 | ChiakiThread thread; 32 | ChiakiBoolPredCond stop_cond; 33 | } ChiakiCongestionControl; 34 | 35 | CHIAKI_EXPORT ChiakiErrorCode chiaki_congestion_control_start(ChiakiCongestionControl *control, ChiakiTakion *takion); 36 | 37 | /** 38 | * Stop control and join the thread 39 | */ 40 | CHIAKI_EXPORT ChiakiErrorCode chiaki_congestion_control_stop(ChiakiCongestionControl *control); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif // CHIAKI_CONGESTIONCONTROL_H 47 | -------------------------------------------------------------------------------- /lib/include/chiaki/ctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_CTRL_H 19 | #define CHIAKI_CTRL_H 20 | 21 | #include "common.h" 22 | #include "thread.h" 23 | #include "stoppipe.h" 24 | 25 | #include 26 | #include 27 | 28 | #if _WIN32 29 | #include 30 | #endif 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | typedef struct chiaki_ctrl_t 37 | { 38 | struct chiaki_session_t *session; 39 | ChiakiThread thread; 40 | 41 | bool should_stop; 42 | bool login_pin_entered; 43 | uint8_t *login_pin; 44 | size_t login_pin_size; 45 | ChiakiStopPipe notif_pipe; 46 | ChiakiMutex notif_mutex; 47 | 48 | bool login_pin_requested; 49 | 50 | chiaki_socket_t sock; 51 | 52 | #ifdef __GNUC__ 53 | __attribute__((aligned(__alignof__(uint32_t)))) 54 | #endif 55 | uint8_t recv_buf[512]; 56 | 57 | size_t recv_buf_size; 58 | uint64_t crypt_counter_local; 59 | uint64_t crypt_counter_remote; 60 | } ChiakiCtrl; 61 | 62 | CHIAKI_EXPORT ChiakiErrorCode chiaki_ctrl_start(ChiakiCtrl *ctrl, struct chiaki_session_t *session); 63 | CHIAKI_EXPORT void chiaki_ctrl_stop(ChiakiCtrl *ctrl); 64 | CHIAKI_EXPORT ChiakiErrorCode chiaki_ctrl_join(ChiakiCtrl *ctrl); 65 | CHIAKI_EXPORT void chiaki_ctrl_set_login_pin(ChiakiCtrl *ctrl, const uint8_t *pin, size_t pin_size); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif // CHIAKI_CTRL_H 72 | -------------------------------------------------------------------------------- /lib/include/chiaki/discoveryservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | 19 | #ifndef CHIAKI_DISCOVERYSERVICE_H 20 | #define CHIAKI_DISCOVERYSERVICE_H 21 | 22 | #include "discovery.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef void (*ChiakiDiscoveryServiceCb)(ChiakiDiscoveryHost *hosts, size_t hosts_count, void *user); 29 | 30 | typedef struct chiaki_discovery_service_options_t 31 | { 32 | size_t hosts_max; 33 | uint64_t host_drop_pings; 34 | uint64_t ping_ms; 35 | struct sockaddr *send_addr; 36 | size_t send_addr_size; 37 | ChiakiDiscoveryServiceCb cb; 38 | void *cb_user; 39 | } ChiakiDiscoveryServiceOptions; 40 | 41 | typedef struct chiaki_discovery_service_host_discovery_info_t 42 | { 43 | uint64_t last_ping_index; 44 | } ChiakiDiscoveryServiceHostDiscoveryInfo; 45 | 46 | typedef struct chiaki_discovery_service_t 47 | { 48 | ChiakiLog *log; 49 | ChiakiDiscoveryServiceOptions options; 50 | ChiakiDiscovery discovery; 51 | 52 | uint64_t ping_index; 53 | ChiakiDiscoveryHost *hosts; 54 | ChiakiDiscoveryServiceHostDiscoveryInfo *host_discovery_infos; 55 | size_t hosts_count; 56 | ChiakiMutex state_mutex; 57 | 58 | ChiakiThread thread; 59 | ChiakiBoolPredCond stop_cond; 60 | } ChiakiDiscoveryService; 61 | 62 | CHIAKI_EXPORT ChiakiErrorCode chiaki_discovery_service_init(ChiakiDiscoveryService *service, ChiakiDiscoveryServiceOptions *options, ChiakiLog *log); 63 | CHIAKI_EXPORT void chiaki_discovery_service_fini(ChiakiDiscoveryService *service); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif //CHIAKI_DISCOVERYSERVICE_H 70 | -------------------------------------------------------------------------------- /lib/include/chiaki/ecdh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_ECDH_H 19 | #define CHIAKI_ECDH_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define CHIAKI_ECDH_SECRET_SIZE 32 31 | 32 | typedef struct chiaki_ecdh_t 33 | { 34 | struct ec_group_st *group; 35 | struct ec_key_st *key_local; 36 | } ChiakiECDH; 37 | 38 | CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_init(ChiakiECDH *ecdh); 39 | CHIAKI_EXPORT void chiaki_ecdh_fini(ChiakiECDH *ecdh); 40 | CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_get_local_pub_key(ChiakiECDH *ecdh, uint8_t *key_out, size_t *key_out_size, const uint8_t *handshake_key, uint8_t *sig_out, size_t *sig_out_size); 41 | CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_derive_secret(ChiakiECDH *ecdh, uint8_t *secret_out, const uint8_t *remote_key, size_t remote_key_size, const uint8_t *handshake_key, const uint8_t *remote_sig, size_t remote_sig_size); 42 | CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const uint8_t *private_key, size_t private_key_size, const uint8_t *public_key, size_t public_key_size); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // CHIAKI_ECDH_H 49 | -------------------------------------------------------------------------------- /lib/include/chiaki/fec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_FEC_H 19 | #define CHIAKI_FEC_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #ifndef _WIN32 25 | #include 26 | #endif 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #define CHIAKI_FEC_WORDSIZE 8 33 | 34 | CHIAKI_EXPORT ChiakiErrorCode chiaki_fec_decode(uint8_t *frame_buf, size_t unit_size, unsigned int k, unsigned int m, const unsigned int *erasures, size_t erasures_count); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif //CHIAKI_FEC_H 41 | -------------------------------------------------------------------------------- /lib/include/chiaki/feedbacksender.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_FEEDBACKSENDER_H 19 | #define CHIAKI_FEEDBACKSENDER_H 20 | 21 | #include "controller.h" 22 | #include "takion.h" 23 | #include "thread.h" 24 | #include "common.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef struct chiaki_feedback_sender_t 31 | { 32 | ChiakiLog *log; 33 | ChiakiTakion *takion; 34 | ChiakiThread thread; 35 | 36 | ChiakiSeqNum16 state_seq_num; 37 | 38 | ChiakiSeqNum16 history_seq_num; 39 | ChiakiFeedbackHistoryBuffer history_buf; 40 | 41 | bool should_stop; 42 | ChiakiControllerState controller_state_prev; 43 | ChiakiControllerState controller_state; 44 | bool controller_state_changed; 45 | ChiakiMutex state_mutex; 46 | ChiakiCond state_cond; 47 | } ChiakiFeedbackSender; 48 | 49 | CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_sender_init(ChiakiFeedbackSender *feedback_sender, ChiakiTakion *takion); 50 | CHIAKI_EXPORT void chiaki_feedback_sender_fini(ChiakiFeedbackSender *feedback_sender); 51 | CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_sender_set_controller_state(ChiakiFeedbackSender *feedback_sender, ChiakiControllerState *state); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif // CHIAKI_FEEDBACKSENDER_H 58 | -------------------------------------------------------------------------------- /lib/include/chiaki/http.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_HTTP_H 19 | #define CHIAKI_HTTP_H 20 | 21 | #include "common.h" 22 | #include "stoppipe.h" 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef struct chiaki_http_header_t 31 | { 32 | const char *key; 33 | const char *value; 34 | struct chiaki_http_header_t *next; 35 | } ChiakiHttpHeader; 36 | 37 | typedef struct chiaki_http_response_t 38 | { 39 | int code; 40 | ChiakiHttpHeader *headers; 41 | } ChiakiHttpResponse; 42 | 43 | CHIAKI_EXPORT void chiaki_http_header_free(ChiakiHttpHeader *header); 44 | CHIAKI_EXPORT ChiakiErrorCode chiaki_http_header_parse(ChiakiHttpHeader **header, char *buf, size_t buf_size); 45 | 46 | CHIAKI_EXPORT void chiaki_http_response_fini(ChiakiHttpResponse *response); 47 | CHIAKI_EXPORT ChiakiErrorCode chiaki_http_response_parse(ChiakiHttpResponse *response, char *buf, size_t buf_size); 48 | 49 | /** 50 | * @param stop_pipe optional 51 | * @param timeout_ms only used if stop_pipe is not NULL 52 | */ 53 | CHIAKI_EXPORT ChiakiErrorCode chiaki_recv_http_header(int sock, char *buf, size_t buf_size, size_t *header_size, size_t *received_size, ChiakiStopPipe *stop_pipe, uint64_t timeout_ms); 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif // CHIAKI_HTTP_H 61 | -------------------------------------------------------------------------------- /lib/include/chiaki/launchspec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_LAUNCHSPEC_H 19 | #define CHIAKI_LAUNCHSPEC_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef struct chiaki_launch_spec_t 31 | { 32 | unsigned int mtu; 33 | unsigned int rtt; 34 | uint8_t *handshake_key; 35 | unsigned int width; 36 | unsigned int height; 37 | unsigned int max_fps; 38 | unsigned int bw_kbps_sent; 39 | } ChiakiLaunchSpec; 40 | 41 | CHIAKI_EXPORT int chiaki_launchspec_format(char *buf, size_t buf_size, ChiakiLaunchSpec *launch_spec); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // CHIAKI_LAUNCHSPEC_H 48 | -------------------------------------------------------------------------------- /lib/include/chiaki/opusdecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_OPUSDECODER_H 19 | #define CHIAKI_OPUSDECODER_H 20 | 21 | #include 22 | #if CHIAKI_LIB_ENABLE_OPUS 23 | 24 | #include "audioreceiver.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef void (*ChiakiOpusDecoderSettingsCallback)(uint32_t channels, uint32_t rate, void *user); 31 | typedef void (*ChiakiOpusDecoderFrameCallback)(int16_t *buf, size_t samples_count, void *user); 32 | 33 | typedef struct chiaki_opus_decoder_t 34 | { 35 | ChiakiLog *log; 36 | struct OpusDecoder *opus_decoder; 37 | ChiakiAudioHeader audio_header; 38 | int16_t *pcm_buf; 39 | size_t pcm_buf_size; 40 | 41 | ChiakiOpusDecoderSettingsCallback settings_cb; 42 | ChiakiOpusDecoderFrameCallback frame_cb; 43 | void *cb_user; 44 | } ChiakiOpusDecoder; 45 | 46 | CHIAKI_EXPORT void chiaki_opus_decoder_init(ChiakiOpusDecoder *decoder, ChiakiLog *log); 47 | CHIAKI_EXPORT void chiaki_opus_decoder_fini(ChiakiOpusDecoder *decoder); 48 | CHIAKI_EXPORT void chiaki_opus_decoder_get_sink(ChiakiOpusDecoder *decoder, ChiakiAudioSink *sink); 49 | 50 | static inline void chiaki_opus_decoder_set_cb(ChiakiOpusDecoder *decoder, ChiakiOpusDecoderSettingsCallback settings_cb, ChiakiOpusDecoderFrameCallback frame_cb, void *user) 51 | { 52 | decoder->settings_cb = settings_cb; 53 | decoder->frame_cb = frame_cb; 54 | decoder->cb_user = user; 55 | } 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | 63 | #endif // CHIAKI_OPUSDECODER_H 64 | -------------------------------------------------------------------------------- /lib/include/chiaki/random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_RANDOM_H 19 | #define CHIAKI_RANDOM_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** 31 | * Random for cryptography 32 | */ 33 | CHIAKI_EXPORT ChiakiErrorCode chiaki_random_bytes_crypt(uint8_t *buf, size_t buf_size); 34 | 35 | CHIAKI_EXPORT uint32_t chiaki_random_32(); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif // CHIAKI_RANDOM_H 42 | -------------------------------------------------------------------------------- /lib/include/chiaki/rpcrypt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_RPCRYPT_H 19 | #define CHIAKI_RPCRYPT_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define CHIAKI_RPCRYPT_KEY_SIZE 0x10 31 | 32 | typedef struct chiaki_rpcrypt_t 33 | { 34 | uint8_t bright[CHIAKI_RPCRYPT_KEY_SIZE]; 35 | uint8_t ambassador[CHIAKI_RPCRYPT_KEY_SIZE]; 36 | } ChiakiRPCrypt; 37 | 38 | CHIAKI_EXPORT void chiaki_rpcrypt_bright_ambassador(uint8_t *bright, uint8_t *ambassador, const uint8_t *nonce, const uint8_t *morning); 39 | CHIAKI_EXPORT void chiaki_rpcrypt_aeropause(uint8_t *aeropause, const uint8_t *ambassador); 40 | 41 | CHIAKI_EXPORT void chiaki_rpcrypt_init_auth(ChiakiRPCrypt *rpcrypt, const uint8_t *nonce, const uint8_t *morning); 42 | CHIAKI_EXPORT void chiaki_rpcrypt_init_regist(ChiakiRPCrypt *rpcrypt, const uint8_t *ambassador, uint32_t pin); 43 | CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt, uint8_t *iv, uint64_t counter); 44 | CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_encrypt(ChiakiRPCrypt *rpcrypt, uint64_t counter, const uint8_t *in, uint8_t *out, size_t sz); 45 | CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_decrypt(ChiakiRPCrypt *rpcrypt, uint64_t counter, const uint8_t *in, uint8_t *out, size_t sz); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif // CHIAKI_RPCRYPT_H 52 | -------------------------------------------------------------------------------- /lib/include/chiaki/senkusha.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SENKUSHA_H 19 | #define CHIAKI_SENKUSHA_H 20 | 21 | #include "takion.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef struct chiaki_session_t ChiakiSession; 28 | 29 | typedef struct senkusha_t 30 | { 31 | ChiakiSession *session; 32 | ChiakiLog *log; 33 | ChiakiTakion takion; 34 | 35 | int state; 36 | bool state_finished; 37 | bool state_failed; 38 | bool should_stop; 39 | ChiakiSeqNum32 data_ack_seq_num_expected; 40 | uint64_t pong_time_us; 41 | uint16_t ping_test_index; 42 | uint16_t ping_index; 43 | uint32_t ping_tag; 44 | uint32_t mtu_id; 45 | 46 | /** 47 | * signaled on change of state_finished or should_stop 48 | */ 49 | ChiakiCond state_cond; 50 | 51 | /** 52 | * protects state, state_finished, state_failed and should_stop 53 | */ 54 | ChiakiMutex state_mutex; 55 | } ChiakiSenkusha; 56 | 57 | CHIAKI_EXPORT ChiakiErrorCode chiaki_senkusha_init(ChiakiSenkusha *senkusha, ChiakiSession *session); 58 | CHIAKI_EXPORT void chiaki_senkusha_fini(ChiakiSenkusha *senkusha); 59 | CHIAKI_EXPORT ChiakiErrorCode chiaki_senkusha_run(ChiakiSenkusha *senkusha, uint32_t *mtu_in, uint32_t *mtu_out, uint64_t *rtt_us); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif // CHIAKI_SENKUSHA_H 66 | -------------------------------------------------------------------------------- /lib/include/chiaki/seqnum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SEQNUM_H 19 | #define CHIAKI_SEQNUM_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | // RFC 1982 31 | 32 | #define CHIAKI_DEFINE_SEQNUM(bits, greater_sint) \ 33 | \ 34 | typedef uint##bits##_t ChiakiSeqNum##bits; \ 35 | \ 36 | static inline bool chiaki_seq_num_##bits##_lt(ChiakiSeqNum##bits a, ChiakiSeqNum##bits b) \ 37 | { \ 38 | if(a == b) \ 39 | return false; \ 40 | greater_sint d = (greater_sint)b - (greater_sint)a; \ 41 | return (a < b && d < ((ChiakiSeqNum##bits)1 << (bits - 1))) \ 42 | || ((a > b) && -d > ((ChiakiSeqNum##bits)1 << (bits - 1))); \ 43 | } \ 44 | \ 45 | static inline bool chiaki_seq_num_##bits##_gt(ChiakiSeqNum##bits a, ChiakiSeqNum##bits b) \ 46 | { \ 47 | if(a == b) \ 48 | return false; \ 49 | greater_sint d = (greater_sint)b - (greater_sint)a; \ 50 | return (a < b && d > ((ChiakiSeqNum##bits)1 << (bits - 1))) \ 51 | || ((a > b) && -d < ((ChiakiSeqNum##bits)1 << (bits - 1))); \ 52 | } 53 | 54 | CHIAKI_DEFINE_SEQNUM(16, int32_t) 55 | CHIAKI_DEFINE_SEQNUM(32, int64_t) 56 | #undef CHIAKI_DEFINE_SEQNUM 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif // CHIAKI_SEQNUM_H 63 | -------------------------------------------------------------------------------- /lib/include/chiaki/sock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_SOCK_H 19 | #define CHIAKI_SOCK_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #ifdef _WIN32 30 | #include 31 | typedef SOCKET chiaki_socket_t; 32 | #define CHIAKI_SOCKET_IS_INVALID(s) ((s) == INVALID_SOCKET) 33 | #define CHIAKI_INVALID_SOCKET INVALID_SOCKET 34 | #define CHIAKI_SOCKET_CLOSE(s) closesocket(s) 35 | #define CHIAKI_SOCKET_ERROR_FMT "%d" 36 | #define CHIAKI_SOCKET_ERROR_VALUE (WSAGetLastError()) 37 | #define CHIAKI_SOCKET_EINPROGRESS (WSAGetLastError() == WSAEWOULDBLOCK) 38 | #else 39 | #include 40 | #include 41 | typedef int chiaki_socket_t; 42 | #define CHIAKI_SOCKET_IS_INVALID(s) ((s) < 0) 43 | #define CHIAKI_INVALID_SOCKET (-1) 44 | #define CHIAKI_SOCKET_CLOSE(s) close(s) 45 | #define CHIAKI_SOCKET_ERROR_FMT "%s" 46 | #define CHIAKI_SOCKET_ERROR_VALUE (strerror(errno)) 47 | #define CHIAKI_SOCKET_EINPROGRESS (errno == EINPROGRESS) 48 | #endif 49 | 50 | CHIAKI_EXPORT ChiakiErrorCode chiaki_socket_set_nonblock(chiaki_socket_t sock, bool nonblock); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif //CHIAKI_SOCK_H 57 | -------------------------------------------------------------------------------- /lib/include/chiaki/stoppipe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_STOPPIPE_H 19 | #define CHIAKI_STOPPIPE_H 20 | 21 | #include "sock.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifdef _WIN32 28 | #include 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | typedef struct chiaki_stop_pipe_t 36 | { 37 | #ifdef _WIN32 38 | WSAEVENT event; 39 | #else 40 | int fds[2]; 41 | #endif 42 | } ChiakiStopPipe; 43 | 44 | struct sockaddr; 45 | 46 | CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_init(ChiakiStopPipe *stop_pipe); 47 | CHIAKI_EXPORT void chiaki_stop_pipe_fini(ChiakiStopPipe *stop_pipe); 48 | CHIAKI_EXPORT void chiaki_stop_pipe_stop(ChiakiStopPipe *stop_pipe); 49 | CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_select_single(ChiakiStopPipe *stop_pipe, chiaki_socket_t fd, bool write, uint64_t timeout_ms); 50 | /** 51 | * Like connect(), but can be canceled by the stop pipe. Only makes sense with a non-blocking socket. 52 | */ 53 | CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_connect(ChiakiStopPipe *stop_pipe, chiaki_socket_t fd, struct sockaddr *addr, size_t addrlen); 54 | static inline ChiakiErrorCode chiaki_stop_pipe_sleep(ChiakiStopPipe *stop_pipe, uint64_t timeout_ms) { return chiaki_stop_pipe_select_single(stop_pipe, CHIAKI_INVALID_SOCKET, false, timeout_ms); } 55 | CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_reset(ChiakiStopPipe *stop_pipe); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif // CHIAKI_STOPPIPE_H 62 | -------------------------------------------------------------------------------- /lib/include/chiaki/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_TIME_H 19 | #define CHIAKI_TIME_H 20 | 21 | #include "common.h" 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | CHIAKI_EXPORT uint64_t chiaki_time_now_monotonic_us(); 30 | 31 | static inline uint64_t chiaki_time_now_monotonic_ms() { return chiaki_time_now_monotonic_us() / 1000; } 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // CHIAKI_TIME_H 38 | -------------------------------------------------------------------------------- /lib/include/chiaki/video.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_VIDEO_H 19 | #define CHIAKI_VIDEO_H 20 | 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct chiaki_video_profile_t 29 | { 30 | unsigned int width; 31 | unsigned int height; 32 | size_t header_sz; 33 | uint8_t *header; 34 | } ChiakiVideoProfile; 35 | 36 | /** 37 | * Padding for FFMPEG 38 | */ 39 | #define CHIAKI_VIDEO_BUFFER_PADDING_SIZE 64 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // CHIAKI_VIDEO_H 46 | -------------------------------------------------------------------------------- /lib/protobuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_program(PROTOC protoc) 3 | if(NOT PROTOC) 4 | message(FATAL_ERROR "Could not find protoc") 5 | endif() 6 | 7 | add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/takion.pb" 8 | COMMAND "${PROTOC}" "-o${CMAKE_CURRENT_BINARY_DIR}/takion.pb" "${CMAKE_CURRENT_SOURCE_DIR}/takion.proto" "-I${CMAKE_CURRENT_SOURCE_DIR}" 9 | MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/takion.proto") 10 | 11 | set(SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/takion.pb.c") 12 | set(HEADER_FILES "${CMAKE_CURRENT_BINARY_DIR}/takion.pb.h") 13 | 14 | add_custom_command(OUTPUT ${SOURCE_FILES} ${HEADER_FILES} 15 | COMMAND "${PYTHON_EXECUTABLE}" "${NANOPB_GENERATOR_PY}" "${CMAKE_CURRENT_BINARY_DIR}/takion.pb" 16 | MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/takion.pb") 17 | 18 | set(CHIAKI_LIB_PROTO_SOURCE_FILES "${SOURCE_FILES}" PARENT_SCOPE) 19 | set(CHIAKI_LIB_PROTO_HEADER_FILES "${HEADER_FILES}" PARENT_SCOPE) 20 | set(CHIAKI_LIB_PROTO_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) 21 | 22 | add_custom_target(chiaki-pb DEPENDS ${SOURCE_FILES} ${HEADER_FILES}) 23 | -------------------------------------------------------------------------------- /lib/src/audio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #ifdef _WIN32 21 | #include 22 | #else 23 | #include 24 | #endif 25 | 26 | 27 | void chiaki_audio_header_load(ChiakiAudioHeader *audio_header, const uint8_t *buf) 28 | { 29 | audio_header->channels = buf[0]; 30 | audio_header->bits = buf[1]; 31 | audio_header->rate = ntohl(*((chiaki_unaligned_uint32_t *)(buf + 2))); 32 | audio_header->frame_size = ntohl(*((chiaki_unaligned_uint32_t *)(buf + 6))); 33 | audio_header->unknown = ntohl(*((chiaki_unaligned_uint32_t *)(buf + 0xa))); 34 | } 35 | 36 | void chiaki_audio_header_save(ChiakiAudioHeader *audio_header, uint8_t *buf) 37 | { 38 | buf[0] = audio_header->bits; 39 | buf[1] = audio_header->channels; 40 | *((chiaki_unaligned_uint32_t *)(buf + 2)) = htonl(audio_header->rate); 41 | *((chiaki_unaligned_uint32_t *)(buf + 6)) = htonl(audio_header->frame_size); 42 | *((chiaki_unaligned_uint32_t *)(buf + 0xa)) = htonl(audio_header->unknown); 43 | } 44 | -------------------------------------------------------------------------------- /lib/src/controller.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | CHIAKI_EXPORT void chiaki_controller_state_set_idle(ChiakiControllerState *state) 21 | { 22 | state->buttons = 0; 23 | state->left_x = 0; 24 | state->left_y = 0; 25 | state->right_x = 0; 26 | state->right_y = 0; 27 | } 28 | 29 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 30 | #define ABS(a) ((a) > 0 ? (a) : -(a)) 31 | #define MAX_ABS(a, b) (ABS(a) > ABS(b) ? (a) : (b)) 32 | 33 | CHIAKI_EXPORT void chiaki_controller_state_or(ChiakiControllerState *out, ChiakiControllerState *a, ChiakiControllerState *b) 34 | { 35 | out->buttons = a->buttons | b->buttons; 36 | out->l2_state = MAX(a->l2_state, b->l2_state); 37 | out->r2_state = MAX(a->r2_state, b->r2_state); 38 | out->left_x = MAX_ABS(a->left_x, b->left_x); 39 | out->left_y = MAX_ABS(a->left_y, b->left_y); 40 | out->right_x = MAX_ABS(a->right_x, b->right_x); 41 | out->right_y = MAX_ABS(a->right_y, b->right_y); 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/random.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | CHIAKI_EXPORT ChiakiErrorCode chiaki_random_bytes_crypt(uint8_t *buf, size_t buf_size) 23 | { 24 | int r = RAND_bytes(buf, (int)buf_size); 25 | if(!r) 26 | return CHIAKI_ERR_UNKNOWN; 27 | return CHIAKI_ERR_SUCCESS; 28 | } 29 | 30 | CHIAKI_EXPORT uint32_t chiaki_random_32() 31 | { 32 | return rand() % UINT32_MAX; 33 | } -------------------------------------------------------------------------------- /lib/src/sock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | CHIAKI_EXPORT ChiakiErrorCode chiaki_socket_set_nonblock(chiaki_socket_t sock, bool nonblock) 22 | { 23 | #ifdef _WIN32 24 | u_long nbio = nonblock ? 1 : 0; 25 | if(ioctlsocket(sock, FIONBIO, &nbio) != NO_ERROR) 26 | return CHIAKI_ERR_UNKNOWN; 27 | #else 28 | int flags = fcntl(sock, F_GETFL, 0); 29 | if(flags == -1) 30 | return CHIAKI_ERR_UNKNOWN; 31 | flags = nonblock ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK); 32 | if(fcntl(sock, F_SETFL, flags) == -1) 33 | return CHIAKI_ERR_UNKNOWN; 34 | #endif 35 | return CHIAKI_ERR_SUCCESS; 36 | } -------------------------------------------------------------------------------- /lib/src/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #ifdef _WIN32 23 | #include 24 | #endif 25 | 26 | CHIAKI_EXPORT uint64_t chiaki_time_now_monotonic_us() 27 | { 28 | #if _WIN32 29 | LARGE_INTEGER f; 30 | if(!QueryPerformanceFrequency(&f)) 31 | return 0; 32 | LARGE_INTEGER v; 33 | if(!QueryPerformanceCounter(&v)) 34 | return 0; 35 | v.QuadPart *= 1000000; 36 | v.QuadPart /= f.QuadPart; 37 | return v.QuadPart; 38 | #else 39 | struct timespec time; 40 | clock_gettime(CLOCK_MONOTONIC, &time); 41 | return time.tv_sec * 1000000 + time.tv_nsec / 1000; 42 | #endif 43 | } 44 | -------------------------------------------------------------------------------- /scripts/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM utensils/opengl:19.0.8 AS builder 3 | LABEL maintainer="chiaki-docker@florianmaerkl.de" 4 | WORKDIR /app 5 | RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ 6 | && apk update \ 7 | && apk --no-cache add \ 8 | build-base \ 9 | cmake \ 10 | ffmpeg-dev \ 11 | git \ 12 | openssl \ 13 | opus-dev \ 14 | protobuf \ 15 | # py3-protobuf@testing \ # Enable this when the OpenGL image updates alpine 16 | qt5-qtbase \ 17 | qt5-qtmultimedia-dev \ 18 | qt5-qtsvg-dev \ 19 | sdl2-dev \ 20 | && pip3 install protobuf \ 21 | && git clone https://github.com/thestr4ng3r/chiaki.git /app \ 22 | && git submodule update --init \ 23 | && mkdir build \ 24 | && cd build \ 25 | && cmake .. \ 26 | && make \ 27 | && ./test/chiaki-unit \ 28 | && rm -rf /var/cache/apk/* 29 | 30 | FROM utensils/opengl:19.0.8 31 | RUN apk update \ 32 | && apk --no-cache add \ 33 | ffmpeg \ 34 | qt5-qtbase \ 35 | qt5-qtmultimedia \ 36 | qt5-qtsvg \ 37 | sdl2 \ 38 | && rm -rf /var/cache/apk/* \ 39 | && addgroup ps4 && adduser -D -G ps4 ps4 \ 40 | && chown -R ps4: /home/ps4 41 | WORKDIR /home/ps4 42 | COPY --from=builder /app/build/gui/chiaki . 43 | USER ps4 44 | VOLUME /home/ps4/.local/share/Chiaki 45 | CMD ["/home/ps4/chiaki"] 46 | 47 | -------------------------------------------------------------------------------- /scripts/build-ffmpeg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd $(dirname "${BASH_SOURCE[0]}")/.. 4 | ROOT="`pwd`" 5 | 6 | TAG=n4.2 7 | 8 | git clone https://git.ffmpeg.org/ffmpeg.git --depth 1 -b $TAG && cd ffmpeg || exit 1 9 | 10 | ./configure --disable-all --enable-avcodec --enable-decoder=h264 --prefix="$ROOT/ffmpeg-prefix" "$@" || exit 1 11 | make -j4 || exit 1 12 | make install || exit 1 -------------------------------------------------------------------------------- /scripts/build-sdl2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd $(dirname "${BASH_SOURCE[0]}")/.. 4 | ROOT="`pwd`" 5 | 6 | URL=https://www.libsdl.org/release/SDL2-2.0.10.tar.gz 7 | FILE=SDL2-2.0.10.tar.gz 8 | DIR=SDL2-2.0.10 9 | 10 | if [ ! -d "$DIR" ]; then 11 | wget "$URL" || exit 1 12 | tar -xf "$FILE" || exit 1 13 | fi 14 | 15 | cd "$DIR" || exit 1 16 | 17 | mkdir -p build && cd build || exit 1 18 | cmake \ 19 | -DCMAKE_INSTALL_PREFIX="$ROOT/sdl2-prefix" \ 20 | -DSDL_ATOMIC=OFF \ 21 | -DSDL_AUDIO=OFF \ 22 | -DSDL_CPUINFO=OFF \ 23 | -DSDL_EVENTS=ON \ 24 | -DSDL_FILE=OFF \ 25 | -DSDL_FILESYSTEM=OFF \ 26 | -DSDL_HAPTIC=ON \ 27 | -DSDL_JOYSTICK=ON \ 28 | -DSDL_LOADSO=OFF \ 29 | -DSDL_RENDER=OFF \ 30 | -DSDL_SHARED=ON \ 31 | -DSDL_STATIC=OFF \ 32 | -DSDL_TEST=OFF \ 33 | -DSDL_THREADS=ON \ 34 | -DSDL_TIMERS=OFF \ 35 | -DSDL_VIDEO=OFF \ 36 | .. || exit 1 37 | # SDL_THREADS is not needed, but it doesn't compile without 38 | 39 | make -j4 || exit 1 40 | make install || exit 1 41 | 42 | -------------------------------------------------------------------------------- /scripts/chiaki.rb.in: -------------------------------------------------------------------------------- 1 | cask 'chiaki' do 2 | version '@CHIAKI_VERSION@' 3 | sha256 '@CHIAKI_DMG_SHA256@' 4 | 5 | url "https://github.com/thestr4ng3r/chiaki/releases/download/v#{version}/Chiaki-v#{version}-macOS-x86_64.dmg" 6 | appcast 'https://github.com/thestr4ng3r/chiaki/releases.atom' 7 | name 'Chiaki' 8 | homepage 'https://github.com/thestr4ng3r/chiaki' 9 | 10 | app 'Chiaki.app' 11 | 12 | zap trash: [ 13 | '~/Library/Application Support/Chiaki', 14 | '~/Library/Preferences/com.chiaki.Chiaki.plist', 15 | ] 16 | end 17 | -------------------------------------------------------------------------------- /scripts/configure-cask.cmake: -------------------------------------------------------------------------------- 1 | 2 | if(NOT CHIAKI_VERSION OR NOT CHIAKI_DMG OR NOT CHIAKI_CASK_OUT) 3 | message(FATAL_ERROR "CHIAKI_VERSION, CHIAKI_DMG and CHIAKI_CASK_OUT must be set.") 4 | endif() 5 | 6 | if(CHIAKI_VERSION MATCHES "^v([0-9].*)$") 7 | set(CHIAKI_VERSION "${CMAKE_MATCH_1}") 8 | endif() 9 | 10 | file(SHA256 "${CHIAKI_DMG}" CHIAKI_DMG_SHA256) 11 | configure_file("${CMAKE_CURRENT_LIST_DIR}/chiaki.rb.in" "${CHIAKI_CASK_OUT}") 12 | -------------------------------------------------------------------------------- /scripts/docker-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker run \ 4 | -v $HOME/.local/share/Chiaki:/home/ps4/.local/share/Chiaki \ 5 | -v $HOME/.config/Chiaki:/home/ps4/.config/Chiaki \ 6 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 7 | --net host \ 8 | -e DISPLAY=$DISPLAY \ 9 | --device /dev/snd \ 10 | --name chiaki \ 11 | --rm \ 12 | thestr4ng3r/chiaki 13 | 14 | -------------------------------------------------------------------------------- /scripts/fetch-protoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd $(dirname "${BASH_SOURCE[0]}")/.. 4 | ROOT="`pwd`" 5 | 6 | URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip 7 | 8 | wget "$URL" -O protoc.zip || exit 1 9 | unzip protoc.zip -d protoc || exit 1 10 | 11 | -------------------------------------------------------------------------------- /scripts/travis-appimage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd build && make install DESTDIR=../appdir && cd .. || exit 1 4 | wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod +x linuxdeploy-x86_64.AppImage || exit 1 5 | wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage && chmod +x linuxdeploy-plugin-qt-x86_64.AppImage || exit 1 6 | source /opt/qt512/bin/qt512-env.sh || exit 1 7 | 8 | if [ -n "$SDL2_FROM_SRC" ]; then 9 | export LD_LIBRARY_PATH="$TRAVIS_BUILD_DIR/sdl2-prefix/lib:$LD_LIBRARY_PATH" || exit 1 10 | fi 11 | 12 | export EXTRA_QT_PLUGINS=opengl 13 | 14 | ./linuxdeploy-x86_64.AppImage --appdir=appdir -e appdir/usr/bin/chiaki -d appdir/usr/share/applications/chiaki.desktop --plugin qt --output appimage || exit 1 15 | export DEPLOY_FILE="Chiaki-${CHIAKI_VERSION}-Linux-x86_64.AppImage" || exit 1 16 | mv Chiaki-*-x86_64.AppImage "$DEPLOY_FILE" || exit 1 -------------------------------------------------------------------------------- /scripts/travis-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir build && cd build || exit 1 4 | cmake \ 5 | -DCMAKE_BUILD_TYPE=Release \ 6 | -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \ 7 | -DCHIAKI_ENABLE_TESTS=ON \ 8 | -DCHIAKI_ENABLE_CLI=OFF \ 9 | -DCHIAKI_GUI_ENABLE_QT_GAMEPAD=OFF \ 10 | -DCHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER=ON \ 11 | $CMAKE_EXTRA_ARGS \ 12 | .. || exit 1 13 | make -j4 || exit 1 14 | test/chiaki-unit || exit 1 -------------------------------------------------------------------------------- /secret.tar.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peidaqi/chiaki/b0b8bac984b3b13ffc162c2eedbebebc1c1f0be9/secret.tar.enc -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(munit "${CMAKE_CURRENT_SOURCE_DIR}/munit/munit.c") 3 | target_include_directories(munit PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/munit") 4 | 5 | add_executable(chiaki-unit 6 | main.c 7 | http.c 8 | rpcrypt.c 9 | gkcrypt.c 10 | takion.c 11 | seqnum.c 12 | reorderqueue.c 13 | fec.c 14 | test_log.c 15 | test_log.h 16 | regist.c) 17 | 18 | target_link_libraries(chiaki-unit chiaki-lib munit) 19 | 20 | add_test(unit chiaki-unit) 21 | -------------------------------------------------------------------------------- /test/test_log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #include "test_log.h" 19 | 20 | #include 21 | 22 | static bool initialized = false; 23 | static ChiakiLog log_quiet; 24 | 25 | ChiakiLog *get_test_log() 26 | { 27 | if(!initialized) 28 | chiaki_log_init(&log_quiet, 0, NULL, NULL); 29 | return &log_quiet; 30 | } -------------------------------------------------------------------------------- /test/test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Chiaki. 3 | * 4 | * Chiaki is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * Chiaki is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with Chiaki. If not, see . 16 | */ 17 | 18 | #ifndef CHIAKI_TEST_LOG_H 19 | #define CHIAKI_TEST_LOG_H 20 | 21 | #include 22 | 23 | ChiakiLog *get_test_log(); 24 | 25 | #endif // CHIAKI_LOG_QUIET_H 26 | -------------------------------------------------------------------------------- /third-party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ################## 3 | # nanopb 4 | ################## 5 | 6 | find_package(PythonInterp 3 REQUIRED) # Make sure nanopb doesn't find Python 2.7 because Python 2 should just die. 7 | 8 | add_subdirectory(nanopb EXCLUDE_FROM_ALL) 9 | set(NANOPB_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nanopb") 10 | set(NANOPB_SOURCE_DIR "${NANOPB_SOURCE_DIR}" PARENT_SCOPE) 11 | set(NANOPB_GENERATOR_PY "${NANOPB_SOURCE_DIR}/generator/nanopb_generator.py" PARENT_SCOPE) 12 | 13 | ################## 14 | # gf-complete 15 | ################## 16 | 17 | set(GF_COMPLETE_SOURCE 18 | gf-complete/src/gf.c 19 | gf-complete/src/gf_wgen.c 20 | gf-complete/src/gf_w4.c 21 | gf-complete/src/gf_w8.c 22 | gf-complete/src/gf_w16.c 23 | gf-complete/src/gf_w32.c 24 | gf-complete/src/gf_w64.c 25 | gf-complete/src/gf_w128.c 26 | gf-complete/src/gf_rand.c 27 | gf-complete/src/gf_general.c 28 | gf-complete/src/gf_cpu.c) 29 | 30 | # TODO: support NEON 31 | 32 | add_library(gf_complete STATIC ${GF_COMPLETE_SOURCE}) 33 | target_include_directories(gf_complete PUBLIC gf-complete/include) 34 | 35 | ################## 36 | # jerasure 37 | ################## 38 | 39 | set(JERASURE_SOURCE 40 | jerasure/src/galois.c 41 | jerasure/src/jerasure.c 42 | jerasure/src/reed_sol.c 43 | jerasure/src/cauchy.c 44 | jerasure/src/liberation.c) 45 | 46 | add_library(jerasure STATIC ${JERASURE_SOURCE}) 47 | target_include_directories(jerasure PUBLIC jerasure/include) 48 | target_link_libraries(jerasure gf_complete) 49 | --------------------------------------------------------------------------------