-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFeedOutput.cpp
More file actions
169 lines (137 loc) · 4.1 KB
/
FeedOutput.cpp
File metadata and controls
169 lines (137 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
Vidiot id a VIDeo Input Output Transformer With a Touch of Functionality
Copyright (C) 2016 Delicode Ltd
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FeedOutput.h"
#include "predefines.h"
void FeedOutput::ensure(int width, int height)
{
if(created && width == w && height == h)
return;
w = width;
h = height;
gl->makeCurrent();
char output_name[256];
if(out_name.isEmpty())
strcpy(output_name, "Vidiot");
else
strcpy(output_name, out_name.toLocal8Bit().data());
#ifdef _WIN32
if(created) {
// The server will be ok after the next texture send
}
else {
spoutserv.SetDX9compatible(true);
created = spoutserv.CreateSender(output_name, w, h);
if(created) {
char name[256];
spoutserv.spout.GetSpoutSenderName(name, 256);
feedname = name;
}
else {
spoutserv.SetDX9(true);
created = spoutserv.CreateSender(output_name, w, h);
if(created) {
char name[256];
spoutserv.spout.GetSpoutSenderName(name, 256);
feedname = name;
}
else
std::cout << "Error creating spout server" << std::endl;
}
}
#else
GLER
if (!syphonserver)
syphonserver = new DelicodeSyphonServer();
if (!syphonserver->createServer(output_name))
{
qDebug() << "Failed creating Syphon output";
}
else
{
if (!syphonserver->startServing())
{
qDebug() << "Couldn't start syphon server";
}
else
{
created = true;
feedname = output_name;
qDebug() << "Syphon output created " << feedname;
}
}
#endif
gl->doneCurrent();
}
void FeedOutput::sendTexture(unsigned int texid, int width, int height, bool flip)
{
if(width > 0 && height > 0)
ensure(width, height);
if(!created)
return;
GLER
gl->makeCurrent();
#ifdef _WIN32
spoutserv.SendTexture(texid, GL_TEXTURE_2D, width, height, flip);
#else
// Does not work on OS X, probably due to texture rectangles being used
//syphonserver->publishTexture(texid, width, height, flip);
#endif
glFinish();
gl->doneCurrent();
}
void FeedOutput::sendFBO(unsigned int fboid, int width, int height, bool flip)
{
if(width > 0 && height > 0)
ensure(width, height);
if(!created)
return;
GLER
gl->makeCurrent();
#ifdef _WIN32
// spout has no fbo output?
#else
syphonserver->publishFBO(fboid, width, height, flip);
#endif
glFinish();
gl->doneCurrent();
}
QStringList FeedOutput::listSources(bool list_self)
{
QStringList list;
#ifdef WIN32
SpoutReceiver receiver;
int count = receiver.GetSenderCount();
char name[256];
for(int i=0; i<count; i++) {
if(receiver.GetSenderName(i, name)) {
if(name == feedname && !list_self)
continue;
list << QString("feed:///") + name + "?!*30 fps";
list << QString("feed:///") + name + "?60 fps";
}
}
#endif
#ifdef __APPLE__
char server_list[4096];
DelicodeSyphonServer::getServers(server_list);
QStringList servers = QString(server_list).split('|', QString::SkipEmptyParts);
for (int i = 0; i < servers.count(); i++)
{
list << QString("feed:///") + servers.at(i) + "?!*30 fps";
list << QString("feed:///") + servers.at(i) + "?*30 fps";
}
#endif
return list;
}