Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <shellapi.h>
#endif

#ifndef __APPLE__
#if !defined(__ANDROID__) && !defined(__APPLE__)
// For NVENC legacy constants
#include <ffnvcodec/nvEncodeAPI.h>
#endif
Expand Down Expand Up @@ -1039,9 +1039,12 @@ namespace config {
}

void apply_config(std::unordered_map<std::string, std::string> &&vars) {
#ifndef __ANDROID__
// TODO: Android can possibly support this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I wrote a comment on this for the last review but it didn't appear for some reason.

I think we discussed this on Discord some time back, but can you explain here why it's not supported right now? In my mind this should work, but I might be missing something.

In my mind, the default "Desktop" application could be renamed to "Screen" or something along those lines. Then the user could add the commands for other applications that would launch an app. Maybe I am missing something?

For reference, these are the current three apps.json files:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I haven't decided on the form of Sunshine Android yet - whether it will be an APK, a binary launched via adb, or both options

The difference is that if it's an APK, the app will need to request screen recording permissions from users, with the readable directory being /data/data/com.xxx/files

If it's a binary launched through adb, no permissions would be needed, with the readable directory being /data/local/tmp

These two approaches have different readable directories, so I'd like to implement this when I have more time available

if (!fs::exists(stream.file_apps.c_str())) {
fs::copy_file(SUNSHINE_ASSETS_DIR "/apps.json", stream.file_apps);
}
#endif

for (auto &[name, val] : vars) {
std::cout << "["sv << name << "] -- ["sv << val << ']' << std::endl;
Expand All @@ -1066,7 +1069,7 @@ namespace config {
bool_f(vars, "nvenc_opengl_vulkan_on_dxgi", video.nv_opengl_vulkan_on_dxgi);
bool_f(vars, "nvenc_latency_over_power", video.nv_sunshine_high_power_mode);

#ifndef __APPLE__
#if !defined(__ANDROID__) && !defined(__APPLE__)
video.nv_legacy.preset = video.nv.quality_preset + 11;
video.nv_legacy.multipass = video.nv.two_pass == nvenc::nvenc_two_pass::quarter_resolution ? NV_ENC_TWO_PASS_QUARTER_RESOLUTION :
video.nv.two_pass == nvenc::nvenc_two_pass::full_resolution ? NV_ENC_TWO_PASS_FULL_RESOLUTION :
Expand Down
38 changes: 37 additions & 1 deletion src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
#include <boost/log/expressions.hpp>
#include <boost/log/sinks.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <display_device/logging.h>

// conditional includes
#ifdef __ANDROID__
#include <android/log.h>
#else
#include <display_device/logging.h>
#endif

// local includes
#include "logging.h"
Expand Down Expand Up @@ -86,6 +92,32 @@ namespace logging {
#endif
};

#ifdef __ANDROID__
android_LogPriority android_priority;
switch (log_level) {
case 0:
android_priority = ANDROID_LOG_VERBOSE;
break;
case 1:
android_priority = ANDROID_LOG_DEBUG;
break;
case 2:
android_priority = ANDROID_LOG_INFO;
break;
case 3:
android_priority = ANDROID_LOG_WARN;
break;
case 4:
android_priority = ANDROID_LOG_ERROR;
break;
case 5:
android_priority = ANDROID_LOG_FATAL;
break;
};
// get log adn input to andorid
std::string log_message = view.attribute_values()[message].extract<std::string>().get();
__android_log_print(android_priority, "Sunshine", "%s%s", log_type.data(), log_message.c_str());
#endif
auto now = std::chrono::system_clock::now();
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
now - std::chrono::time_point_cast<std::chrono::seconds>(now)
Expand All @@ -105,7 +137,9 @@ namespace logging {
}

setup_av_logging(min_log_level);
#ifndef __ANDROID__
setup_libdisplaydevice_logging(min_log_level);
#endif

sink = boost::make_shared<text_sink>();

Expand Down Expand Up @@ -153,6 +187,7 @@ namespace logging {
});
}

#ifndef __ANDROID__
void setup_libdisplaydevice_logging(int min_log_level) {
constexpr int min_level {static_cast<int>(display_device::Logger::LogLevel::verbose)};
constexpr int max_level {static_cast<int>(display_device::Logger::LogLevel::fatal)};
Expand Down Expand Up @@ -182,6 +217,7 @@ namespace logging {
}
});
}
#endif

void log_flush() {
if (sink) {
Expand Down