diff --git a/CMakeLists.txt b/CMakeLists.txt index 8acf604..f11195a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,7 +358,7 @@ endif() if (APPLE) set(XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC OFF) - target_link_libraries(${PROJECT_NAME} PRIVATE "-framework CoreMedia" "-framework VideoToolbox") + target_link_libraries(${PROJECT_NAME} PRIVATE "-framework CoreMedia" "-framework VideoToolbox" "-framework AVKit") elseif (PLATFORM_PSV) target_link_libraries(${PROJECT_NAME} PRIVATE mp3lame libGLESv2_stub) endif () \ No newline at end of file diff --git a/README.md b/README.md index 8d37771..2ad9a9d 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ make -C build/pc -j$(nproc) Also, please note that the `resources` folder must be available in the working directory, otherwise the program will fail to find the shaders. -### iOS: +### iOS / tvOS: ```shell # build libromfs generator @@ -145,22 +145,13 @@ Also, please note that the `resources` folder must be available in the working d # prepare vcpkg ./extern/vcpkg/bootstrap-vcpkg.sh - -# install packages -./extern/vcpkg/vcpkg install --triplet arm64-ios mbedtls -./extern/vcpkg/vcpkg install --triplet arm64-ios jansson -./extern/vcpkg/vcpkg install --triplet arm64-ios ffmpeg -./extern/vcpkg/vcpkg install --triplet arm64-ios "curl[mbedtls]" -./extern/vcpkg/vcpkg install --triplet arm64-ios libpng -./extern/vcpkg/vcpkg install --triplet arm64-ios opus ``` -#### 1. Build for arm64 iphoneOS +#### 1. Build for arm64 iphoneOS / tvOS ```shell # 1. Generate a Xcode project -# IOS_CODE_SIGN_IDENTITY: code is not signed when IOS_CODE_SIGN_IDENTITY is empty -# IOS_GUI_IDENTIFIER: optional, default is com.borealis.demo +# Replace `PLATFORM_IOS` with `PLATFORM_TVOS` to build for tvOS platform cmake -B build/ios -G Xcode -DPLATFORM_IOS=ON # 2. open project in Xcode diff --git a/app/platforms/ios/apple_display.mm b/app/platforms/ios/apple_display.mm new file mode 100644 index 0000000..f882261 --- /dev/null +++ b/app/platforms/ios/apple_display.mm @@ -0,0 +1,41 @@ +#ifdef PLATFORM_TVOS + +#import +#import +#import +#import +#include "Limelight.h" +#include "Settings.hpp" + +@interface AVDisplayCriteria() +@property(readonly) int videoDynamicRange; +@property(readonly, nonatomic) float refreshRate; +- (id)initWithRefreshRate:(float)arg1 videoDynamicRange:(int)arg2; +@end + +void updatePreferredDisplayMode(bool streamActive) { + UIWindow* window = [[[UIApplication sharedApplication] delegate] window]; + AVDisplayManager* displayManager = [window avDisplayManager]; + + // This logic comes from Kodi and MrMC + if (streamActive) { + int dynamicRange; + + if (LiGetCurrentHostDisplayHdrMode()) { + dynamicRange = 2; // HDR10 + } + else { + dynamicRange = 0; // SDR + } + + AVDisplayCriteria* displayCriteria = [[AVDisplayCriteria alloc] initWithRefreshRate:Settings::instance().fps() + videoDynamicRange:dynamicRange]; + displayManager.preferredDisplayCriteria = displayCriteria; + } + else { + // Switch back to the default display mode + displayManager.preferredDisplayCriteria = nil; + } +} + +#endif diff --git a/app/src/streaming_view.cpp b/app/src/streaming_view.cpp index 93244db..061cd19 100644 --- a/app/src/streaming_view.cpp +++ b/app/src/streaming_view.cpp @@ -18,9 +18,17 @@ using namespace brls; +#ifdef PLATFORM_TVOS +extern void updatePreferredDisplayMode(bool streamActive); +#endif + StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host), app(app) { Application::getPlatform()->disableScreenDimming(true); +#ifdef PLATFORM_TVOS + updatePreferredDisplayMode(true); +#endif + setFocusable(true); setHideHighlight(true); loader = new LoadingOverlay(this); @@ -439,6 +447,10 @@ void StreamingView::onLayout() { } StreamingView::~StreamingView() { +#ifdef PLATFORM_TVOS + updatePreferredDisplayMode(false); +#endif + Application::getPlatform()->disableScreenDimming(false); Application::getPlatform() ->getInputManager()