[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11309: updated the audio and video
From: |
Ben Limmer |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11309: updated the audio and video input testcases and the findwebcams utility |
Date: |
Thu, 23 Jul 2009 16:55:40 -0600 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11309
committer: Ben Limmer <address@hidden>
branch nick: trunk
timestamp: Thu 2009-07-23 16:55:40 -0600
message:
updated the audio and video input testcases and the findwebcams utility
modified:
libmedia/gst/AudioInputGst.cpp
libmedia/gst/AudioInputGst.h
libmedia/gst/VideoInputGst.cpp
libmedia/gst/VideoInputGst.h
testsuite/libmedia.all/test_audioinput.cpp
testsuite/libmedia.all/test_videoinput.cpp
utilities/findwebcams.cpp
------------------------------------------------------------
revno: 11306.1.1
committer: Ben Limmer <address@hidden>
branch nick: cam_mic_impl_2
timestamp: Thu 2009-07-23 16:54:22 -0600
message:
updated the audio and video input testcases and the findwebcams utility
modified:
libmedia/gst/AudioInputGst.cpp
libmedia/gst/AudioInputGst.h
libmedia/gst/VideoInputGst.cpp
libmedia/gst/VideoInputGst.h
testsuite/libmedia.all/test_audioinput.cpp
testsuite/libmedia.all/test_videoinput.cpp
utilities/findwebcams.cpp
=== modified file 'libmedia/gst/AudioInputGst.cpp'
--- a/libmedia/gst/AudioInputGst.cpp 2009-07-22 16:56:41 +0000
+++ b/libmedia/gst/AudioInputGst.cpp 2009-07-23 22:54:22 +0000
@@ -134,6 +134,10 @@
void
AudioInputGst::getSelectedCaps(int devselect) {
+ if (devselect > (_audioVect.size() - 1) || devselect < 0) {
+ log_error("%s: passed an invalid devselect argument",
__FUNCTION__);
+ exit(EXIT_FAILURE);
+ }
GstElement *pipeline;
gchar *command;
GError *error = NULL;
@@ -513,7 +517,7 @@
g_print(("Execution ended after %" G_GUINT64_FORMAT " ns.\n"), diff);
}
- void
+ int
AudioInputGst::makeAudioDevSelection() {
int devselect = -1;
devselect = rcfile.getAudioInputDevice();
@@ -528,53 +532,12 @@
getSelectedCaps(devselect);
- GnashAudioPrivate *audio = NULL;
- audio = transferToPrivate(devselect);
- if (audio == NULL) {
- log_error("%s: Couldn't transferToPrivate structure",
__FUNCTION__);
- }
-
- bool ok = false;
- ok = audioCreateMainBin(audio);
- if (ok != true) {
- log_error("%s: Couldn't make the audioMainBin", __FUNCTION__);
- } else {
- ok = false;
- }
-
- ok = audioCreatePlaybackBin(audio);
- if (ok != true) {
- log_error("%s: Couldn't make the audioPlaybackBin", __FUNCTION__);
- } else {
- ok = false;
- }
-
- ok = audioCreateSaveBin(audio);
- if (ok != true) {
- log_error("%s: Couldn't make the audioSaveBin", __FUNCTION__);
- } else {
- ok = false;
- }
-
- ok = makeAudioSourcePlaybackLink(audio);
- if (ok != true) {
- log_error("%s: Couldn't make the Source-Playback link",
__FUNCTION__);
- } else {
- ok = false;
- }
-
- ok = makeAudioSourceSaveLink(audio);
- if (ok != true) {
- log_error("%s: Couldn't make the Source-Save link", __FUNCTION__);
- } else {
- ok = false;
- }
-
+ return devselect;
+ } /*
//debug
//g_print("starting pipeline....\n");
audioPlay(audio);
-
- }
+ } */
} //gst namespace
} //media namespace
=== modified file 'libmedia/gst/AudioInputGst.h'
--- a/libmedia/gst/AudioInputGst.h 2009-07-22 16:56:41 +0000
+++ b/libmedia/gst/AudioInputGst.h 2009-07-23 22:54:22 +0000
@@ -273,7 +273,7 @@
/// If one is not selected, the audiotestsrc is used by default. This
function
/// also currently calls the functions to make the GstBins, pipelines and
/// element connections.
- void makeAudioDevSelection();
+ int makeAudioDevSelection();
/// \brief This function grabs information about the selected audio input
/// device. It also calls checkSupportedFormats to make sure that Gnash
@@ -379,6 +379,8 @@
/// AudioInputGst class.
std::vector<GnashAudio*>* getAudioVect() {return &_audioVect;}
+ GnashAudioPrivate* getGlobalAudio() {return _globalAudio;}
+
private:
/// \var _numdevs
=== modified file 'libmedia/gst/VideoInputGst.cpp'
--- a/libmedia/gst/VideoInputGst.cpp 2009-07-22 21:40:18 +0000
+++ b/libmedia/gst/VideoInputGst.cpp 2009-07-23 22:54:22 +0000
@@ -300,9 +300,15 @@
log_trace("Camera %d specified in gnashrc file, using that one.\n",
dev_select);
}
- //now that a selection has been made, get capabilities of that device
- getSelectedCaps(rcfile.getWebcamDevice());
- return rcfile.getWebcamDevice();
+ //make sure that the device selected is actually valid
+ if ((rcfile.getWebcamDevice() > (_vidVect.size() - 1)) ||
rcfile.getWebcamDevice() < 0) {
+ log_error("You have an invalid camera selected. Please check your
gnashrc file");
+ exit(EXIT_FAILURE);
+ } else {
+ //now that a selection has been made, get capabilities of that
device
+ getSelectedCaps(rcfile.getWebcamDevice());
+ return rcfile.getWebcamDevice();
+ }
}
//called after a device selection, this starts enumerating the device's
@@ -325,6 +331,10 @@
if (dev_select == 0) {
command = g_strdup_printf ("%s name=src ! fakesink",
data_struct->getGstreamerSrc());
+ } else if ((dev_select > (_vidVect.size() - 1)) || dev_select < 0) {
+ log_error("%s: Passed an invalid argument (not a valid dev_select
value)",
+ __FUNCTION__);
+ exit(EXIT_FAILURE);
} else {
command = g_strdup_printf ("%s name=src device=%s ! fakesink",
data_struct->getGstreamerSrc(), data_struct->getDevLocation());
@@ -473,6 +483,11 @@
GnashWebcamPrivate*
VideoInputGst::transferToPrivate(gint dev_select)
{
+ if ((dev_select > (_vidVect.size() - 1)) || dev_select < 0) {
+ log_error("%s: Passed an invalid argument (bad dev_select value)",
+ __FUNCTION__);
+ exit(EXIT_FAILURE);
+ }
GnashWebcamPrivate *webcam = new GnashWebcamPrivate;
if (webcam != NULL) {
webcam->setWebcamDevice(_vidVect[dev_select]);
@@ -905,17 +920,23 @@
tfthen = gst_util_get_timestamp ();
state = gst_element_set_state (webcam->_pipeline,
GST_STATE_PLAYING);
- if (state == GST_STATE_CHANGE_SUCCESS) {
+ if (state != GST_STATE_CHANGE_FAILURE) {
webcam->_pipelineIsPlaying = true;
}
- loop = webcam->_loop;
- log_trace("running (ctrl-c in terminal to quit).....\n");
- g_main_loop_run(loop);
- log_trace("main loop done...\n");
- tfnow = gst_util_get_timestamp ();
- diff = GST_CLOCK_DIFF (tfthen, tfnow);
- log_trace(("Execution ended after %" G_GUINT64_FORMAT " ns.\n"),
diff);
+ //loop = webcam->_loop;
+ //log_trace("running (ctrl-c in terminal to quit).....\n");
+ //g_main_loop_run(loop);
+ //log_trace("main loop done...\n");
+ //tfnow = gst_util_get_timestamp ();
+ //diff = GST_CLOCK_DIFF (tfthen, tfnow);
+ //log_trace(("Execution ended after %" G_GUINT64_FORMAT " ns.\n"),
diff);
+ }
+
+ void
+ VideoInputGst::webcamStop(GnashWebcamPrivate *webcam) {
+ gst_element_set_state (webcam->_pipeline, GST_STATE_NULL);
+ webcam->_pipelineIsPlaying = FALSE;
}
} //gst namespace
} //media namespace
=== modified file 'libmedia/gst/VideoInputGst.h'
--- a/libmedia/gst/VideoInputGst.h 2009-07-22 21:40:18 +0000
+++ b/libmedia/gst/VideoInputGst.h 2009-07-23 22:54:22 +0000
@@ -607,6 +607,8 @@
///
void webcamPlay(GnashWebcamPrivate *webcam);
+ void webcamStop(GnashWebcamPrivate *webcam);
+
/// \brief Accessor which returns the vid_vect private variable in the
/// VideoInputGst class.
///
=== modified file 'testsuite/libmedia.all/test_audioinput.cpp'
--- a/testsuite/libmedia.all/test_audioinput.cpp 2009-07-22 21:40:18
+0000
+++ b/testsuite/libmedia.all/test_audioinput.cpp 2009-07-23 22:54:22
+0000
@@ -68,13 +68,115 @@
gst::AudioInputGst aud;
aud.findAudioDevs();
- std::vector<GnashAudio*> *audioVect = aud.getAudioVect();
-
-
- //aud.makeAudioDevSelection();
-
- cerr << "placeholder" << endl;
-
+ vector<GnashAudio*> *audioVect = aud.getAudioVect();
+
+ if (audioVect == NULL) {
+ runtest.fail("the audiovector wasn't created.");
+ } else {
+ runtest.pass("the audiovector was created.");
+ }
+ if (audioVect->at(0)->getElementPtr() == NULL) {
+ runtest.fail("the test audio source doesn't have an element ptr");
+ } else {
+ runtest.pass("the test audio source has a ptr set");
+ }
+ if (g_strcmp0(audioVect->at(0)->getGstreamerSrc(), "audiotestsrc") != 0) {
+ runtest.fail("the test audio source has the wrong GstreamerSrc value");
+ } else {
+ runtest.pass("the test audio source has the correct GstreamerSrc
value");
+ }
+ if (g_strcmp0(audioVect->at(0)->getProductName(), "audiotest") != 0) {
+ runtest.fail("the test audio source has the wrong product name value");
+ } else {
+ runtest.pass("the test audio source has the right product name value");
+ }
+
+ int devselect;
+ devselect = aud.makeAudioDevSelection();
+
+ GnashAudioPrivate *audio = NULL;
+ audio = aud.transferToPrivate(devselect);
+ if (audio == NULL) {
+ runtest.fail("the transferToPrivate function returned nothing");
+ } else {
+ runtest.pass("the transferToPrivate function returned a class");
+ }
+ if (audio->getAudioDevice() == NULL) {
+ runtest.fail("the audioDevice variable wasn't set");
+ } else {
+ runtest.pass("the audioDevice variable was set");
+ }
+ if (audio->getDeviceName() == NULL) {
+ runtest.fail("the productName variable wasn't set");
+ } else {
+ runtest.pass("the productName variable was set");
+ }
+ if (aud.getGlobalAudio() == NULL) {
+ runtest.fail("the _globalAudio reference wasn't set");
+ } else {
+ runtest.pass("the _globalAudio reference was set during
transferToPrivate");
+ }
+
+ bool ok = false;
+ ok = aud.audioCreateMainBin(audio);
+ if (ok != true) {
+ runtest.fail("audioCreateMainBin() function reported an error");
+ } else {
+ runtest.pass("audioCreateMainBin() function reported no errors");
+ }
+ if (audio->_pipeline == NULL) {
+ runtest.fail("the audio pipeline wasn't created or a reference wasn't
stored");
+ } else {
+ runtest.pass("the audio pipeline reference is in the private class");
+ }
+ if (audio->_audioMainBin == NULL) {
+ runtest.fail("the audioMainBin wasn't created or a reference wasn't
stored");
+ } else {
+ runtest.pass("the audioMainBin reference is in the private class");
+ }
+ if (audio->_audioSourceBin == NULL) {
+ runtest.fail("the audioSourceBin wasn't created or a reference wasn't
store");
+ } else {
+ runtest.pass("the audioSourceBin reference is in the private class");
+ }
+
+ ok = aud.audioCreatePlaybackBin(audio);
+ if (ok != true) {
+ runtest.fail("audioCreatePlaybackBin() function reported an error");
+ } else {
+ runtest.pass("audioCreatePlaybackBin() function reported no errors");
+ }
+ if (audio->_audioPlaybackBin == NULL) {
+ runtest.fail("the audioPlaybackBin wasn't created or a reference
wasn't stored");
+ } else {
+ runtest.pass("the audioPlaybackBin reference is in the private class");
+ }
+
+ ok = aud.audioCreateSaveBin(audio);
+ if (ok != true) {
+ runtest.fail("audioCreateSaveBin() function reported an error");
+ } else {
+ runtest.pass("audioCreateSaveBin() function reported no errors");
+ }
+ if (audio->_audioSaveBin == NULL) {
+ runtest.fail("the audioSaveBin wasn't created or a reference wasn't
stored");
+ } else {
+ runtest.pass("the audioSaveBin reference is in the private class");
+ }
+
+ ok = aud.makeAudioSourcePlaybackLink(audio);
+ if (ok != true) {
+ runtest.fail("makeAudioSourcePlaybackLink() function reported an
error");
+ } else {
+ runtest.pass("makeAudioSourcePlaybackLink() function reported no
errors");
+ }
+
+ ok = aud.makeAudioSourceSaveLink(audio);
+ if (ok != true) {
+ runtest.fail("makeAudioSourceSaveLink() function reported an error");
+ } else {
+ runtest.pass("makeAudioSourceSaveLink() function reported no errors");
+ }
}
=== modified file 'testsuite/libmedia.all/test_videoinput.cpp'
--- a/testsuite/libmedia.all/test_videoinput.cpp 2009-07-22 21:34:00
+0000
+++ b/testsuite/libmedia.all/test_videoinput.cpp 2009-07-23 22:54:22
+0000
@@ -23,6 +23,7 @@
#include <string>
#include <cstdio>
+#include <sys/stat.h>
#include "dejagnu.h"
#include "log.h"
@@ -174,12 +175,12 @@
} else {
runtest.pass("the _videoSource reference was created");
}
- if (webcam->_capsFilter == NULL) {
+ if (webcam->_capsFilter == NULL && (devselect !=0)) {
runtest.fail("the _capsFilter reference wasn't created");
} else {
runtest.pass("the _capsFilter reference was created");
}
- if (webcam->_currentFormat == NULL) {
+ if (webcam->_currentFormat == NULL && (devselect != 0)) {
runtest.fail("no format was set (_currentFormat == NULL!)");
} else {
runtest.pass("format is set");
@@ -253,7 +254,29 @@
runtest.pass("webcam->_videoFileSink reference is set");
}
- //end of setup tests
+ //end of setup tests, now startup the webcamPipeline, run for a few seconds
+ //and then make sure there is a file present after running
+ vig.webcamPlay(webcam);
+ if (webcam->_pipelineIsPlaying != true) {
+ runtest.fail("the _pipelineIsPlaying variable isn't being set");
+ } else {
+ runtest.pass("the _pipelineIsPlaying variable is properly set");
+ }
+ sleep(5);
+ vig.webcamStop(webcam);
+
+ struct stat st;
+ std::string file = "./vidoutput.ogg";
+ if (stat(file.c_str(), &st) == 0) {
+ runtest.pass("vidoutput.ogg file is in testsuite/libmedia.all");
+ if (st.st_blocks == 0) {
+ runtest.fail("the output file is there, but there's no information
in it!");
+ } else {
+ runtest.pass("the output file has data in it");
+ }
+ } else {
+ runtest.fail("there's no output video file in testsuite/libmedia.all");
+ }
}
=== modified file 'utilities/findwebcams.cpp'
--- a/utilities/findwebcams.cpp 2009-07-20 21:10:47 +0000
+++ b/utilities/findwebcams.cpp 2009-07-23 22:54:22 +0000
@@ -36,13 +36,19 @@
data();
gchar* deviceName;
gchar* deviceType;
+ gint deviceNumber;
+ gboolean duplicate;
};
data::data() {
deviceName = NULL;
deviceType = NULL;
+ gint deviceNumber = -1;
+ duplicate = false;
};
+gint numDuplicates = 0;
+
gint findVidDevs(std::vector<data*>& vidVect) {
gint numdevs = 0;
@@ -57,6 +63,7 @@
vidVect.push_back(new data);
vidVect[numdevs]->deviceName = g_strdup_printf("videotestsrc");
vidVect[numdevs]->deviceType = g_strdup_printf("videotestsrc");
+ vidVect[numdevs]->deviceNumber = 0;
numdevs += 1;
}
@@ -85,6 +92,7 @@
vidVect.push_back(new data);
vidVect[numdevs]->deviceType = g_strdup_printf("v4lsrc");
vidVect[numdevs]->deviceName = dev_name;
+ vidVect[numdevs]->deviceNumber = numdevs;
numdevs += 1;
}
}
@@ -97,6 +105,7 @@
probe = NULL;
element = NULL;
devarr = NULL;
+ gint g;
element = gst_element_factory_make ("v4l2src", "v4l2vidsrc");
probe = GST_PROPERTY_PROBE (element);
@@ -113,18 +122,26 @@
if (dev_name == "null") {
g_print("no v4l2 video sources found.\n");
}
- else {
+ else {
vidVect.push_back(new data);
vidVect[numdevs]->deviceType = g_strdup_printf("v4l2src");
vidVect[numdevs]->deviceName = dev_name;
-
+ vidVect[numdevs]->deviceNumber = numdevs;
+ //mark duplicates (we like v4l2 sources more than v4l, so if
+ //they're both detected, mark the v4l source as a duplicate)
+ for (g=1; g < (vidVect.size()-1); g++) {
+ if (g_strcmp0(vidVect[numdevs]->deviceName,
+ vidVect[g]->deviceName) == 0) {
+ vidVect[g]->duplicate = true;
+ numDuplicates += 1;
+ }
+ }
numdevs += 1;
}
}
if (devarr) {
g_value_array_free (devarr);
}
-
return numdevs;
}
@@ -138,18 +155,32 @@
int fromrc = rcfile.getWebcamDevice();
if (fromrc == -1) {
- g_print("Use this utility to set your desired default webcam
device.\n");
+ g_print("\nUse this utility to set your desired default webcam
device.\n");
numdevs = findVidDevs(vidVector);
- g_print("\nFound %d video devices: \n\n", numdevs);
+ g_print("\nINFO: these devices were ignored because they are supported
by both");
+ g_print("\nvideo4linux and video4linux2:\n\n");
+ for (i = 0; i < numdevs; ++i) {
+ if (vidVector[i]->duplicate == true) {
+ g_print(" %s (%s)\n", vidVector[i]->deviceName,
vidVector[i]->deviceType);
+ }
+ }
+ g_print("\nGnash interacts with v4l2 sources better than v4l sources,
thus they");
+ g_print("\nwill not be printed in the list below.\n");
+ g_print("\nFound %d video devices: \n\n", (numdevs - numDuplicates));
+ gint counter = 0;
for (i = 0; i < numdevs; ++i)
{
if (i == 0 && (vidVector[i] != 0)) {
- g_print("%d. device[%d] = Video Test Source (videotestsrc)\n",
i, i);
+ g_print(" %d. Video Test Source (videotestsrc)\n", i, i);
+ counter++;
} else if (i == 0 && (vidVector[i] == 0)) {
g_print("no test video device available");
} else {
- g_print("%d. device[%d] = %s (%s)\n", i, i,
vidVector[i]->deviceName,
- vidVector[i]->deviceType);
+ if (vidVector[i]->duplicate != true) {
+ g_print(" %d. %s (%s)\n", counter,
vidVector[i]->deviceName,
+ vidVector[i]->deviceType);
+ counter++;
+ }
}
}
//prompt user for device selection
@@ -158,7 +189,7 @@
do {
dev_select = -1;
g_print("\nChoose the device you would like to use (0-%d): ",
- (numdevs - 1));
+ (numdevs - numDuplicates - 1));
std::cin >> fromCin;
if (fromCin.size() != 1) {
dev_select = -1;
@@ -167,12 +198,12 @@
} else {
dev_select = atoi(fromCin.c_str());
}
- if ((dev_select < 0) || (dev_select > (numdevs - 1))) {
+ if ((dev_select < 0) || (dev_select > (numdevs - numDuplicates -
1))) {
g_print("You must make a valid device selection\n");
}
- } while ((dev_select < 0) || (dev_select > (numdevs - 1)));
+ } while ((dev_select < 0) || (dev_select > (numdevs - numDuplicates -
1)));
g_print("\nTo select this camera, add this line to your gnashrc
file:\n");
- g_print("set webcamDevice %d\n", dev_select);
+ g_print("set webcamDevice %d\n", vidVector[dev_select +
numDuplicates]->deviceNumber);
} else {
numdevs = findVidDevs(vidVector);
g_print("\nThe gnashrc file reports default webcam is set to:\n");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11309: updated the audio and video input testcases and the findwebcams utility,
Ben Limmer <=