Skip to content

Commit

Permalink
Merge branch 'obsproject:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 authored Dec 12, 2023
2 parents 0016cc6 + 4b28631 commit c5d68ca
Show file tree
Hide file tree
Showing 26 changed files with 459 additions and 128 deletions.
4 changes: 1 addition & 3 deletions .github/scripts/.build.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,12 @@ build() {
if [[ ${GITHUB_EVENT_NAME} == push && ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]] {
run_xcodebuild ${archive_args}
run_xcodebuild ${export_args}

mv "OBS Studio.app" OBS.app
} else {
run_xcodebuild ${build_args}

rm -rf OBS.app
mkdir OBS.app
ditto "UI/${config}/OBS Studio.app" OBS.app
ditto UI/${config}/OBS.app OBS.app
}
popd
;;
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/utils.zsh/setup_linux
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ if [[ ${CPUTYPE} != ${target##*-} ]] {

sudo apt-get install -y --no-install-recommends \
build-essential \
lsb-release dh-cmake \
libcurl4-openssl-dev \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \
libswresample-dev libswscale-dev \
Expand Down
11 changes: 8 additions & 3 deletions UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8581,11 +8581,14 @@ void OBSBasic::UpdateEditMenu()
}
const bool canTransformSingle = videoCount == 1 && totalCount == 1;

OBSSceneItem curItem = GetCurrentSceneItem();
bool locked = obs_sceneitem_locked(curItem);

ui->actionCopySource->setEnabled(totalCount > 0);
ui->actionEditTransform->setEnabled(canTransformSingle);
ui->actionEditTransform->setEnabled(canTransformSingle && !locked);
ui->actionCopyTransform->setEnabled(canTransformSingle);
ui->actionPasteTransform->setEnabled(hasCopiedTransform &&
videoCount > 0);
ui->actionPasteTransform->setEnabled(
canTransformMultiple && hasCopiedTransform && videoCount > 0);
ui->actionCopyFilters->setEnabled(filter_count > 0);
ui->actionPasteFilters->setEnabled(
!obs_weak_source_expired(copyFiltersSource) && totalCount > 0);
Expand Down Expand Up @@ -8658,6 +8661,8 @@ void OBSBasic::on_actionPasteTransform_triggered()
auto func = [](obs_scene_t *, obs_sceneitem_t *item, void *data) {
if (!obs_sceneitem_selected(item))
return true;
if (obs_sceneitem_locked(item))
return true;

OBSBasic *main = reinterpret_cast<OBSBasic *>(data);

Expand Down
23 changes: 20 additions & 3 deletions UI/window-basic-transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void OBSBasicTransform::SetScene(OBSScene scene)
selectSignal.Disconnect();
deselectSignal.Disconnect();
removeSignal.Disconnect();
lockSignal.Disconnect();

if (scene) {
OBSSource source = obs_scene_get_source(scene);
Expand All @@ -139,6 +140,8 @@ void OBSBasicTransform::SetScene(OBSScene scene)
this);
deselectSignal.Connect(signal, "item_deselect",
OBSSceneItemDeselect, this);
lockSignal.Connect(signal, "item_locked", OBSSceneItemLocked,
this);
}
}

Expand All @@ -148,15 +151,20 @@ void OBSBasicTransform::SetItem(OBSSceneItem newItem)
Q_ARG(OBSSceneItem, OBSSceneItem(newItem)));
}

void OBSBasicTransform::SetEnabled(bool enable)
{
ui->container->setEnabled(enable);
ui->buttonBox->button(QDialogButtonBox::Reset)->setEnabled(enable);
}

void OBSBasicTransform::SetItemQt(OBSSceneItem newItem)
{
item = newItem;
if (item)
RefreshControls();

bool enable = !!item;
ui->container->setEnabled(enable);
ui->buttonBox->button(QDialogButtonBox::Reset)->setEnabled(enable);
bool enable = !!item && !obs_sceneitem_locked(item);
SetEnabled(enable);
}

void OBSBasicTransform::OBSChannelChanged(void *param, calldata_t *data)
Expand Down Expand Up @@ -222,6 +230,15 @@ void OBSBasicTransform::OBSSceneItemDeselect(void *param, calldata_t *data)
}
}

void OBSBasicTransform::OBSSceneItemLocked(void *param, calldata_t *data)
{
OBSBasicTransform *window =
reinterpret_cast<OBSBasicTransform *>(param);
bool locked = calldata_bool(data, "locked");

QMetaObject::invokeMethod(window, "SetEnabled", Q_ARG(bool, !locked));
}

static const uint32_t listToAlign[] = {OBS_ALIGN_TOP | OBS_ALIGN_LEFT,
OBS_ALIGN_TOP,
OBS_ALIGN_TOP | OBS_ALIGN_RIGHT,
Expand Down
3 changes: 3 additions & 0 deletions UI/window-basic-transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class OBSBasicTransform : public QDialog {
OBSSignal removeSignal;
OBSSignal selectSignal;
OBSSignal deselectSignal;
OBSSignal lockSignal;

std::string undo_data;

Expand All @@ -45,13 +46,15 @@ class OBSBasicTransform : public QDialog {
static void OBSSceneItemRemoved(void *param, calldata_t *data);
static void OBSSceneItemSelect(void *param, calldata_t *data);
static void OBSSceneItemDeselect(void *param, calldata_t *data);
static void OBSSceneItemLocked(void *param, calldata_t *data);

private slots:
void RefreshControls();
void SetItemQt(OBSSceneItem newItem);
void OnBoundsType(int index);
void OnControlChanged();
void OnCropChanged();
void SetEnabled(bool enable);

public:
OBSBasicTransform(OBSSceneItem item, OBSBasic *parent);
Expand Down
5 changes: 2 additions & 3 deletions cmake/macos/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function(set_target_properties_obs target)
if(target STREQUAL obs-studio)
set_target_properties(
${target}
PROPERTIES OUTPUT_NAME "OBS Studio"
PROPERTIES OUTPUT_NAME OBS
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/Info.plist.in"
XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY YES
Expand All @@ -62,7 +62,7 @@ function(set_target_properties_obs target)
set_target_xcode_properties(
${target}
PROPERTIES PRODUCT_BUNDLE_IDENTIFIER com.obsproject.obs-studio
PRODUCT_NAME "OBS Studio"
PRODUCT_NAME OBS
ASSETCATALOG_COMPILER_APPICON_NAME AppIcon
CURRENT_PROJECT_VERSION ${OBS_BUILD_NUMBER}
MARKETING_VERSION ${OBS_VERSION_CANONICAL}
Expand All @@ -75,7 +75,6 @@ function(set_target_properties_obs target)
INFOPLIST_KEY_NSHumanReadableCopyright "(c) 2012-${CURRENT_YEAR} Lain Bailey"
INFOPLIST_KEY_NSCameraUsageDescription "OBS needs to access the camera to enable camera sources to work."
INFOPLIST_KEY_NSMicrophoneUsageDescription "OBS needs to access the microphone to enable audio input.")

# cmake-format: on

get_property(obs_dependencies GLOBAL PROPERTY _OBS_DEPENDENCIES)
Expand Down
6 changes: 5 additions & 1 deletion deps/obs-scripting/cmake/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ option(ENABLE_SCRIPTING_PYTHON "Enable Python scripting support" ON)

if(ENABLE_SCRIPTING_PYTHON)
add_subdirectory(obspython)
find_package(Python 3.8...<3.12 COMPONENTS Interpreter Development)
if(OS_WINDOWS)
find_package(Python 3.8...<3.11 REQUIRED Interpreter Development)
else()
find_package(Python 3.8...<3.12 REQUIRED Interpreter Development)
endif()
else()
target_disable_feature(obs-scripting "Python scripting support")
endif()
Expand Down
15 changes: 9 additions & 6 deletions deps/obs-scripting/obs-scripting-python-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ bool import_python(const char *python_path, python_version_t *python_version)
}

struct dstr lib_candidate_path;
dstr_init_copy(&lib_candidate_path, lib_path.array);
dstr_init(&lib_candidate_path);

char cur_version[5];
char next_version[5];

char temp[PATH_MAX];

snprintf(cur_version, sizeof(cur_version), VERSION_PATTERN,
PY_MAJOR_VERSION_MAX, PY_MINOR_VERSION_MAX);
snprintf(temp, sizeof(temp), FILE_PATTERN, cur_version);

dstr_cat(&lib_candidate_path, temp);
struct dstr temp;
dstr_init(&temp);
dstr_printf(&temp, FILE_PATTERN, cur_version);

int minor_version = PY_MINOR_VERSION_MAX;
do {
dstr_printf(&lib_candidate_path, "%s%s", lib_path.array,
temp.array);
if (access(lib_candidate_path.array, F_OK) == 0) {
lib = os_dlopen(lib_candidate_path.array);
}
Expand All @@ -90,9 +91,10 @@ bool import_python(const char *python_path, python_version_t *python_version)
PY_MAJOR_VERSION_MAX, minor_version);
snprintf(next_version, sizeof(next_version), VERSION_PATTERN,
PY_MAJOR_VERSION_MAX, --minor_version);
dstr_replace(&lib_candidate_path, cur_version, next_version);
dstr_replace(&temp, cur_version, next_version);
} while (minor_version > 5);

dstr_free(&temp);
dstr_free(&lib_candidate_path);

if (!lib) {
Expand All @@ -116,6 +118,7 @@ bool import_python(const char *python_path, python_version_t *python_version)

IMPORT_FUNC(PyType_Ready);
IMPORT_FUNC(PyType_Modified);
IMPORT_FUNC(PyType_IsSubtype);
IMPORT_FUNC(PyObject_GenericGetAttr);
IMPORT_FUNC(PyObject_IsTrue);
IMPORT_FUNC(Py_DecRef);
Expand Down
35 changes: 33 additions & 2 deletions libobs-d3d11/d3d11-subsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,12 @@ static void PopulateMonitorIds(HMONITOR handle, char *id, char *alt_id,
}
}

static constexpr double DoubleTriangleArea(double ax, double ay, double bx,
double by, double cx, double cy)
{
return ax * (by - cy) + bx * (cy - ay) + cx * (ay - by);
}

static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter)
{
UINT i;
Expand Down Expand Up @@ -1351,13 +1357,27 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter)
UINT bits_per_color = 8;
DXGI_COLOR_SPACE_TYPE type =
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
FLOAT primaries[4][2]{};
double gamut_size = 0.;
FLOAT min_luminance = 0.f;
FLOAT max_luminance = 0.f;
FLOAT max_full_frame_luminance = 0.f;
DXGI_OUTPUT_DESC1 desc1;
if (GetOutputDesc1(output, &desc1)) {
bits_per_color = desc1.BitsPerColor;
type = desc1.ColorSpace;
primaries[0][0] = desc1.RedPrimary[0];
primaries[0][1] = desc1.RedPrimary[1];
primaries[1][0] = desc1.GreenPrimary[0];
primaries[1][1] = desc1.GreenPrimary[1];
primaries[2][0] = desc1.BluePrimary[0];
primaries[2][1] = desc1.BluePrimary[1];
primaries[3][0] = desc1.WhitePoint[0];
primaries[3][1] = desc1.WhitePoint[1];
gamut_size = DoubleTriangleArea(
desc1.RedPrimary[0], desc1.RedPrimary[1],
desc1.GreenPrimary[0], desc1.GreenPrimary[1],
desc1.BluePrimary[0], desc1.BluePrimary[1]);
min_luminance = desc1.MinLuminance;
max_luminance = desc1.MaxLuminance;
max_full_frame_luminance = desc1.MaxFullFrameLuminance;
Expand Down Expand Up @@ -1388,7 +1408,7 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter)
}

const RECT &rect = desc.DesktopCoordinates;
const ULONG nits = GetSdrMaxNits(desc.Monitor);
const ULONG sdr_white_nits = GetSdrMaxNits(desc.Monitor);

char *friendly_name;
os_wcs_to_utf8_ptr(target.monitorFriendlyDeviceName, 0,
Expand All @@ -1403,6 +1423,8 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter)
"\t refresh=%u\n"
"\t bits_per_color=%u\n"
"\t space=%s\n"
"\t primaries=[r=(%f, %f), g=(%f, %f), b=(%f, %f), wp=(%f, %f)]\n"
"\t relative_gamut_area=[709=%f, P3=%f, 2020=%f]\n"
"\t sdr_white_nits=%lu\n"
"\t nit_range=[min=%f, max=%f, max_full_frame=%f]\n"
"\t dpi=%u (%u%%)\n"
Expand All @@ -1411,7 +1433,16 @@ static inline void LogAdapterMonitors(IDXGIAdapter1 *adapter)
i, friendly_name, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
desc.AttachedToDesktop ? "true" : "false", refresh,
bits_per_color, space, nits, min_luminance, max_luminance,
bits_per_color, space, primaries[0][0], primaries[0][1],
primaries[1][0], primaries[1][1], primaries[2][0],
primaries[2][1], primaries[3][0], primaries[3][1],
gamut_size /
DoubleTriangleArea(.64, .33, .3, .6, .15, .06),
gamut_size /
DoubleTriangleArea(.68, .32, .265, .69, .15, .060),
gamut_size / DoubleTriangleArea(.708, .292, .17, .797,
.131, .046),
sdr_white_nits, min_luminance, max_luminance,
max_full_frame_luminance, dpiX, scaling, id, alt_id);
bfree(friendly_name);
}
Expand Down
30 changes: 23 additions & 7 deletions libobs/obs-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,18 +542,34 @@ bool audio_callback(void *param, uint64_t start_ts_in, uint64_t end_ts_in,
#endif

/* ------------------------------------------------ */
/* build audio render order
* NOTE: these are source channels, not audio channels */
for (uint32_t i = 0; i < MAX_CHANNELS; i++) {
obs_source_t *source = obs_get_output_source(i);
if (source) {
/* build audio render order */

pthread_mutex_lock(&obs->video.mixes_mutex);
for (size_t j = 0; j < obs->video.mixes.num; j++) {
struct obs_view *view = obs->video.mixes.array[j]->view;
if (!view)
continue;

pthread_mutex_lock(&view->channels_mutex);

/* NOTE: these are source channels, not audio channels */
for (uint32_t i = 0; i < MAX_CHANNELS; i++) {
obs_source_t *source = view->channels[i];
if (!source)
continue;
if (!obs_source_active(source))
continue;

obs_source_enum_active_tree(source, push_audio_tree,
audio);
push_audio_tree(NULL, source, audio);
da_push_back(audio->root_nodes, &source);
obs_source_release(source);

if (view == &obs->data.main_view)
da_push_back(audio->root_nodes, &source);
}
pthread_mutex_unlock(&view->channels_mutex);
}
pthread_mutex_unlock(&obs->video.mixes_mutex);

pthread_mutex_lock(&data->audio_sources_mutex);

Expand Down
2 changes: 1 addition & 1 deletion libobs/obs-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* Reset to zero each major or minor version
*/
#define LIBOBS_API_PATCH_VER 0
#define LIBOBS_API_PATCH_VER 2

#define MAKE_SEMANTIC_VERSION(major, minor, patch) \
((major << 24) | (minor << 16) | patch)
Expand Down
5 changes: 5 additions & 0 deletions libobs/obs-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,11 @@ static void default_raw_video_callback(void *param, struct video_data *frame)
static bool prepare_audio(struct obs_output *output,
const struct audio_data *old, struct audio_data *new)
{
if ((output->info.flags & OBS_OUTPUT_VIDEO) == 0) {
*new = *old;
return true;
}

if (!output->video_start_ts) {
pthread_mutex_lock(&output->pause.mutex);
output->video_start_ts = output->pause.last_video_ts;
Expand Down
2 changes: 1 addition & 1 deletion libobs/obs-scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static void scene_enum_sources(void *data, obs_source_enum_proc_t enum_callback,
transition_active(item->hide_transition))
enum_callback(scene->source,
item->hide_transition, param);
else if (os_atomic_load_long(&item->active_refs) > 0)
if (os_atomic_load_long(&item->active_refs) > 0)
enum_callback(scene->source, item->source,
param);
} else {
Expand Down
Loading

0 comments on commit c5d68ca

Please sign in to comment.