1 /******************************************************************************
2     Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
3 
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17 
18 #pragma once
19 
20 #include "obs.h"
21 #include "graphics/matrix4.h"
22 
23 /* how obs scene! */
24 
25 struct item_action {
26 	bool visible;
27 	uint64_t timestamp;
28 };
29 
30 struct obs_scene_item {
31 	volatile long ref;
32 	volatile bool removed;
33 
34 	bool is_group;
35 	bool update_transform;
36 	bool update_group_resize;
37 
38 	int64_t id;
39 
40 	struct obs_scene *parent;
41 	struct obs_source *source;
42 	volatile long active_refs;
43 	volatile long defer_update;
44 	volatile long defer_group_resize;
45 	bool user_visible;
46 	bool visible;
47 	bool selected;
48 	bool locked;
49 
50 	gs_texrender_t *item_render;
51 	struct obs_sceneitem_crop crop;
52 
53 	struct vec2 pos;
54 	struct vec2 scale;
55 	float rot;
56 	uint32_t align;
57 
58 	/* last width/height of the source, this is used to check whether
59 	 * the transform needs updating */
60 	uint32_t last_width;
61 	uint32_t last_height;
62 
63 	struct vec2 output_scale;
64 	enum obs_scale_type scale_filter;
65 
66 	struct matrix4 box_transform;
67 	struct vec2 box_scale;
68 	struct matrix4 draw_transform;
69 
70 	enum obs_bounds_type bounds_type;
71 	uint32_t bounds_align;
72 	struct vec2 bounds;
73 
74 	obs_hotkey_pair_id toggle_visibility;
75 
76 	obs_data_t *private_settings;
77 
78 	pthread_mutex_t actions_mutex;
79 	DARRAY(struct item_action) audio_actions;
80 
81 	struct obs_source *show_transition;
82 	struct obs_source *hide_transition;
83 	uint32_t show_transition_duration;
84 	uint32_t hide_transition_duration;
85 
86 	/* would do **prev_next, but not really great for reordering */
87 	struct obs_scene_item *prev;
88 	struct obs_scene_item *next;
89 };
90 
91 struct obs_scene {
92 	struct obs_source *source;
93 
94 	bool is_group;
95 	bool custom_size;
96 	uint32_t cx;
97 	uint32_t cy;
98 
99 	int64_t id_counter;
100 
101 	pthread_mutex_t video_mutex;
102 	pthread_mutex_t audio_mutex;
103 	struct obs_scene_item *first_item;
104 };
105