Jelajahi Sumber

libobs: Add obs_view_get_video_info

Exeldro 2 tahun lalu
induk
melakukan
a5e9c94e4b
2 mengubah file dengan 23 tambahan dan 0 penghapusan
  1. 19 0
      libobs/obs-view.c
  2. 4 0
      libobs/obs.h

+ 19 - 0
libobs/obs-view.c

@@ -198,3 +198,22 @@ void obs_view_remove(obs_view_t *view)
 	set_main_mix();
 	pthread_mutex_unlock(&obs->video.mixes_mutex);
 }
+
+bool obs_view_get_video_info(obs_view_t *view, struct obs_video_info *ovi)
+{
+	if (!view)
+		return false;
+
+	pthread_mutex_lock(&obs->video.mixes_mutex);
+
+	size_t idx = find_mix_for_view(view);
+	if (idx != DARRAY_INVALID) {
+		*ovi = obs->video.mixes.array[idx]->ovi;
+		pthread_mutex_unlock(&obs->video.mixes_mutex);
+		return true;
+	}
+
+	pthread_mutex_unlock(&obs->video.mixes_mutex);
+
+	return false;
+}

+ 4 - 0
libobs/obs.h

@@ -930,6 +930,10 @@ EXPORT video_t *obs_view_add2(obs_view_t *view, struct obs_video_info *ovi);
 /** Removes a view from the main render loop */
 EXPORT void obs_view_remove(obs_view_t *view);
 
+/** Gets the video settings currently in use for this view context, returns false if no video */
+EXPORT bool obs_view_get_video_info(obs_view_t *view,
+				    struct obs_video_info *ovi);
+
 /* ------------------------------------------------------------------------- */
 /* Display context */