Skip to content

Commit 6221633

Browse files
committed
multitrack: mac support for enhanced broadcasting
* enable for Apple Silicon (not Intel macs since those are not supported)
1 parent 61f53ee commit 6221633

File tree

7 files changed

+89
-2
lines changed

7 files changed

+89
-2
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ if(NOT libcurl_POPULATED)
136136
set(USE_LIBIDN2 OFF CACHE BOOL "" FORCE)
137137
set(USE_LIBPSL OFF CACHE BOOL "" FORCE)
138138
set(CURL_ZLIB OFF CACHE BOOL "" FORCE)
139+
140+
if(APPLE)
141+
# Enable Secure Transport on Apple platforms
142+
set(CURL_USE_SECTRANSP ON CACHE BOOL "" FORCE)
143+
set(CMAKE_USE_SCHANNEL OFF CACHE BOOL "" FORCE)
144+
else()
139145
set(CMAKE_USE_SCHANNEL ON CACHE BOOL "" FORCE)
146+
endif()
140147

141148
FetchContent_Populate(libcurl)
142149
add_subdirectory(${libcurl_SOURCE_DIR} ${libcurl_BINARY_DIR} EXCLUDE_FROM_ALL)

obs-studio-server/source/osn-multitrack-video-configuration.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Config DownloadGoLiveConfig(std::string url, const PostData &post_data)
174174
5); // timeout in seconds
175175

176176
if (!encodeConfigDownloadedOk) {
177+
blog(LOG_ERROR, "Go live error: %s", libraryError.c_str());
177178
throw std::runtime_error("Failed to start stream. Config request failed");
178179
}
179180

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,65 @@
11
#include "osn-multitrack-video-system-info.hpp"
2+
#include "shared.hpp"
3+
#include "util/platform.h"
4+
5+
#import <Foundation/Foundation.h>
6+
#import <Foundation/NSProcessInfo.h>
27

38
namespace osn {
49

5-
// This feature is currently unused on Mac
6-
void system_info(Capabilities &capabilities) {}
10+
void fillSystemInfo(System &sysinfo)
11+
{
12+
NSProcessInfo *procInfo = [NSProcessInfo processInfo];
13+
NSOperatingSystemVersion versionObj = [procInfo operatingSystemVersion];
14+
15+
sysinfo.name = "macOS";
16+
sysinfo.bits = 64; // 32-bit macOS is long deprecated.
17+
sysinfo.version = [[procInfo operatingSystemVersionString] UTF8String];
18+
19+
switch (versionObj.majorVersion) {
20+
case 11:
21+
sysinfo.release = "Big Sur";
22+
break;
23+
case 12:
24+
sysinfo.release = "Monterey";
25+
break;
26+
case 13:
27+
sysinfo.release = "Ventura";
28+
break;
29+
case 14:
30+
sysinfo.release = "Sonoma";
31+
break;
32+
case 15:
33+
sysinfo.release = "Sequoia";
34+
break;
35+
default:
36+
sysinfo.release = "unknown";
37+
}
38+
39+
sysinfo.arm = true;
40+
sysinfo.armEmulation = false;
41+
}
42+
43+
void system_info(Capabilities &capabilities)
44+
{
45+
capabilities.cpu.name = g_util_osx->getCpuName();
46+
// Getting the frequency is not supported on Apple Silicon.
47+
capabilities.cpu.physical_cores = os_get_physical_cores();
48+
capabilities.cpu.logical_cores = os_get_logical_cores();
49+
50+
capabilities.memory.total = os_get_sys_total_size();
51+
capabilities.memory.free = os_get_sys_free_size();
52+
53+
// Apple Silicon- there's only going to be gpu
54+
Gpu gpu;
55+
gpu.model = capabilities.cpu.name.value_or("Unknown");
56+
gpu.vendor_id = 0x106b; // Always Apple
57+
gpu.device_id = 0; // Always 0 for Apple Silicon
58+
59+
std::vector<Gpu> gpus;
60+
gpus.push_back(std::move(gpu));
61+
capabilities.gpu = gpus;
62+
fillSystemInfo(capabilities.system);
63+
}
764

865
} // namespace osn

obs-studio-server/source/util-osx-impl.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ @implementation UtilImplObj
214214
return physical_cores;
215215
}
216216

217+
std::string UtilObjCInt::getCpuName(void)
218+
{
219+
char buffer[256];
220+
size_t size = sizeof(buffer);
221+
std::string name;
222+
223+
if (sysctlbyname("machdep.cpu.brand_string", buffer, &size, nullptr, 0) == 0) {
224+
name = std::string(buffer);
225+
} else if (sysctlbyname("hw.model", buffer, &size, nullptr, 0) == 0) {
226+
name = std::string(buffer);
227+
}
228+
229+
return name;
230+
}
231+
217232
void UtilObjCInt::nextState(void)
218233
{
219234
if (state + 1 < UtilObjCInt::EState::Max) {

obs-studio-server/source/util-osx-int.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class UtilObjCInt {
4040
std::string getWorkingDirectory(void);
4141
std::string getComputerName(void);
4242
int getPhysicalCores(void);
43+
std::string getCpuName(void);
4344
void wait_terminate(void);
4445
void nextState(void);
4546
bool hasInitApi(void);

obs-studio-server/source/util-osx.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ int UtilInt::getPhysicalCores(void)
8989
return _impl->getPhysicalCores();
9090
}
9191

92+
std::string UtilInt::getCpuName(void)
93+
{
94+
return _impl->getCpuName();
95+
}
96+
9297
void UtilInt::nextState(void)
9398
{
9499
_impl->nextState();

obs-studio-server/source/util-osx.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class UtilInt {
4141
std::string getWorkingDirectory(void);
4242
std::string getComputerName(void);
4343
int getPhysicalCores(void);
44+
std::string getCpuName(void);
4445
void nextState(void);
4546
bool hasInitApi(void);
4647
bool hasInitCef(void);

0 commit comments

Comments
 (0)