2 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
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 3 of the License, or
7 // (at your option) any later version.
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.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "gnashconfig.h"
32 #include "gst/VideoInputGst.h"
36 using namespace gnash
;
37 using namespace media
;
41 static TestState runtest
;
47 LogFile
& dbglogfile
= LogFile::getDefaultInstance();
59 std::vector
<std::string
> names
;
60 VideoInputGst::getNames(names
);
63 runtest
.fail("the video vector was not created by find_vid_devs");
65 runtest
.pass("the video vector was created");
69 if (names
.at(0) != "videotest") {
70 runtest
.fail("the zeroth element doesn't contain the right product name info");
72 runtest
.pass("the zeroth vid_vect element contains the right product name info");
77 int devselect
= vig
.makeWebcamDeviceSelection();
79 bool ret
= vig
.setWebcam(devselect
);
81 runtest
.fail("the transferToPrivate function didn't return anything");
83 runtest
.pass("the transferToPrivate function returned a GnashWebcamPrivate ptr");
86 if (vig
.name() != "videotest") {
87 runtest
.fail("webcam doesn't have the right _deviceName value");
89 runtest
.pass("webcam has the right _deviceName value");
92 //real camera source tests
93 if (vig
.name().empty()) {
94 runtest
.fail("_deviceName isn't set in GnashWebcamPrivate class");
96 runtest
.pass("_deviceName is set in GnashWebcamPrivate class");
100 bool result
= vig
.init();
101 if (result
!= true) {
102 runtest
.fail("Webcam inititalization");
104 runtest
.pass("Webcam initialization was okay");
108 result
= vig
.webcamCreateSaveBin();
109 if (result
!= true) {
110 runtest
.fail("webcamCreateSaveBin() reported an error");
112 runtest
.pass("webcamCreateSaveBin() didn't report any errors");
115 result
= vig
.webcamMakeVideoSaveLink();
116 if (result
!= true) {
117 runtest
.fail("webcamMakeVideoSaveLink() reported an error");
119 runtest
.pass("webcamMakeVideoSaveLink() didn't report errors");
122 //end of setup tests, now startup the webcamPipeline, run for a few seconds
123 //and then make sure there is a file present after running
125 if (result
!= true) {
126 runtest
.fail("play() function reported an error");
128 runtest
.pass("play() function reported no errors");
131 g_print(" NOTE: the output window will close automatically\n");
135 if (result
!= true) {
136 runtest
.fail("webcamStop() function reported an error");
138 runtest
.pass("webcamStop() function reported no errors");
142 std::string file
= "./vidoutput.ogg";
144 if (stat(file
.c_str(), &st
) == 0) {
145 runtest
.pass("vidoutput.ogg file is in testsuite/libmedia.all");
146 if (st
.st_blocks
== 0) {
147 runtest
.fail("the output file is there, but there's no information in it!");
149 runtest
.pass("the output file has data in it");
152 runtest
.fail("there's no output video file in testsuite/libmedia.all");
155 //delete the old vidoutput.ogg file
156 if (unlink(file
.c_str()) == 0) {
157 g_print(" NOTE: deleting output file...\n");
160 result
= vig
.webcamBreakVideoDisplayLink();
161 if (result
!= true) {
162 runtest
.fail("the webcamBreakVideoDisplayLink() function reported an error");
164 runtest
.pass("the webcamBreakVideoDisplayLink() function reported no errors");
168 if (result
!= true) {
169 runtest
.fail("play() reported errors after breaking display link");
171 runtest
.pass("play() still works after breaking display link");
173 g_print(" NOTE: sleeping for 5 seconds here....\n");
177 if (result
!= true) {
178 runtest
.fail("webcamStop() reported errors after breaking display link");
180 runtest
.pass("webcamStop() reported success after breaking display link");
183 if (stat(file
.c_str(), &st
) == 0) {
184 runtest
.pass("the a new vidoput.ogg file was created");
186 runtest
.fail("there's no new vidoutput.ogg file!");
189 //delete the old vidoutput.ogg file
190 if (unlink(file
.c_str()) == 0) {
191 g_print(" NOTE: deleting output file...\n");
194 result
= vig
.webcamBreakVideoSaveLink();
195 if (result
!= true) {
196 runtest
.fail("breaking the videoSaveLink failed");
198 runtest
.pass("breaking the videoSaveLink was successful");
201 result
= vig
.webcamMakeVideoDisplayLink();
202 if (result
!= true) {
203 runtest
.fail("making videosrc -> display link failed");
205 runtest
.pass("making videosrc -> display link succeeded");
209 if (result
!= true) {
210 runtest
.fail("play() reported errors after relinking display");
212 runtest
.pass("play() still works after relinking display");
214 g_print(" NOTE: sleeping for 5 seconds here....\n");
218 if (result
!= true) {
219 runtest
.fail("webcamStop() reported errors after breaking display link");
221 runtest
.pass("webcamStop() reported success after breaking display link");
224 if (stat(file
.c_str(), &st
) == 0) {
225 runtest
.fail("a vidoutput.ogg file was created, and it shouldn't be");
227 runtest
.pass("no vidoutput.ogg file wasn't created");
230 result
= vig
.webcamMakeVideoSaveLink();
231 if (result
!= true) {
232 runtest
.fail("webcamMakeVideoSaveLink() reported an error");
234 runtest
.pass("webcamMakeVideoSaveLink() reported no errors");
238 if (result
!= true) {
239 runtest
.fail("play() reported errors");
241 runtest
.pass("play() reported no errors");
244 g_print(" NOTE: sleeping for 5 seconds here....\n");
248 if (result
!= true) {
249 runtest
.fail("webcamStop() reported errors after breaking display link");
251 runtest
.pass("webcamStop() reported success after breaking display link");
254 if (stat(file
.c_str(), &st
) == 0) {
255 runtest
.pass("the a new vidoput.ogg file was created");
257 runtest
.fail("there's no new vidoutput.ogg file!");
259 //delete the old vidoutput.ogg file
260 if (unlink(file
.c_str()) == 0) {
261 g_print(" NOTE: deleting output file...\n");
266 //tests more similar to execution flow
267 gst::VideoInputGst
* video
= new VideoInputGst
;
269 runtest
.fail("new VideoInputGst didn't work");
271 runtest
.pass("new VideoInputGst returned a value");
274 //get global webcam reference for use below
275 result
= video
->webcamMakeVideoDisplayLink();
276 if (result
!= true) {
277 runtest
.fail("webcamMakeVideoDisplayLink reported errors");
279 runtest
.pass("webcamMakeVideoDisplayLink reported no errors");
282 result
= video
->play();
283 if (result
!= true) {
284 runtest
.fail("play reported errors");
286 runtest
.pass("play reported no errors");
289 g_print(" NOTE: sleeping for 5 seconds here....\n");
292 result
= video
->stop();
293 if (result
!= true) {
294 runtest
.fail("webcamStop reported errors");
296 runtest
.pass("webcamStop reported no errors");
299 g_print(" NOTE: changing values (display window should be bigger)....\n");
301 video
->requestMode(800, 600, 30, true);
303 result
= video
->play();
304 if (result
!= true) {
305 runtest
.fail("play reported errors");
307 runtest
.pass("play reported no errors");
310 g_print(" NOTE: sleeping for 5 seconds here....\n");
313 result
= video
->stop();
314 if (result
!= true) {
315 runtest
.fail("webcamStop reported errors");
317 runtest
.pass("webcamStop reported no errors");
320 result
= video
->webcamMakeVideoSaveLink();
321 if (result
!= true) {
322 runtest
.fail("webcamMakeVideoSaveLink reported errors");
324 runtest
.pass("webcamMakeVideoSaveLink reported no errors");
327 result
= video
->play();
328 if (result
!= true) {
329 runtest
.fail("play reported errors");
331 runtest
.pass("play reported no errors");
334 g_print(" NOTE: sleeping for 5 seconds here....\n");
337 result
= video
->stop();
338 if (result
!= true) {
339 runtest
.fail("webcamStop reported errors");
341 runtest
.pass("webcamStop reported no errors");
343 if (stat(file
.c_str(), &st
) == 0) {
344 runtest
.pass("the a new vidoput.ogg file was created");
346 runtest
.fail("there's no new vidoutput.ogg file!");
348 //delete the old vidoutput.ogg file
349 if (unlink(file
.c_str()) == 0) {
350 g_print(" NOTE: deleting output file...\n");
353 result
= video
->webcamBreakVideoDisplayLink();
354 if (result
!= true) {
355 runtest
.fail("webcamBreakVideoDisplayLink reported errors");
357 runtest
.pass("webcamBreakVideoDisplayLink reported no errors");
360 result
= video
->play();
361 if (result
!= true) {
362 runtest
.fail("play reported errors");
364 runtest
.pass("play reported no errors");
367 g_print(" NOTE: sleeping for 5 seconds here....\n");
370 result
= video
->stop();
371 if (result
!= true) {
372 runtest
.fail("webcamStop reported errors");
374 runtest
.pass("webcamStop reported no errors");
376 if (stat(file
.c_str(), &st
) == 0) {
377 runtest
.pass("the a new vidoput.ogg file was created");
379 runtest
.fail("there's no new vidoutput.ogg file!");
382 //delete the old vidoutput.ogg file
383 if (unlink(file
.c_str()) == 0) {
384 g_print(" NOTE: deleting output file...\n");
387 result
= video
->webcamMakeVideoDisplayLink();
388 if (result
!= true) {
389 runtest
.fail("webcamMakeVideoDisplayLink failed after breaking the link");
391 runtest
.pass("webcamMakeVideoDisplayLink reported no errors");
394 result
= video
->webcamBreakVideoSaveLink();
395 if (result
!= true) {
396 runtest
.fail("webcamBreakVideoSaveLink function reported errors");
398 runtest
.pass("webcamBreakVideoSaveLink function reported no errors");
401 result
= video
->play();
402 if (result
!= true) {
403 runtest
.fail("play reported errors");
405 runtest
.pass("play reported no errors");
408 g_print(" NOTE: sleeping for 5 seconds here....\n");
411 result
= video
->stop();
412 if (result
!= true) {
413 runtest
.fail("webcamStop reported errors");
415 runtest
.pass("webcamStop reported no errors");
418 if (stat(file
.c_str(), &st
) == 0) {
419 runtest
.fail("a vidoutput.ogg file was created, and it shouldn't be");
421 runtest
.pass("no vidoutput.ogg file wasn't created");
430 main(int /*argc*/, char /* *argv[]*/)
433 cerr
<< "This program needs to have DejaGnu installed!" << endl
;