gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11387: improved implementations of


From: Ben Limmer
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11387: improved implementations of camera_as and microphone_as and associated testcases
Date: Tue, 25 Aug 2009 18:28:57 -0000
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11387
committer: Ben Limmer <address@hidden>
branch nick: trunk
timestamp: Fri 2009-08-07 13:56:42 -0600
message:
  improved implementations of camera_as and microphone_as and associated 
testcases
modified:
  libcore/asobj/flash/media/Camera_as.cpp
  libcore/asobj/flash/media/Microphone_as.cpp
  libmedia/AudioInput.cpp
  libmedia/VideoInput.cpp
  libmedia/VideoInput.h
  libmedia/gst/AudioInputGst.cpp
  libmedia/gst/AudioInputGst.h
  libmedia/gst/VideoInputGst.cpp
  testsuite/actionscript.all/Camera.as
  testsuite/actionscript.all/Microphone.as
  utilities/findmicrophones.cpp
  utilities/findwebcams.cpp
=== modified file 'libcore/asobj/flash/media/Camera_as.cpp'
--- a/libcore/asobj/flash/media/Camera_as.cpp   2009-08-06 11:00:20 +0000
+++ b/libcore/asobj/flash/media/Camera_as.cpp   2009-08-07 19:56:42 +0000
@@ -47,7 +47,6 @@
 as_value camera_setmotionlevel(const fn_call& fn);
 as_value camera_setquality(const fn_call& fn);
 as_value camera_setLoopback(const fn_call& fn);
-as_value camera_setCursor(const fn_call& fn);
 as_value camera_setKeyFrameInterval(const fn_call& fn);
 
 as_value camera_activitylevel(const fn_call& fn);
@@ -100,7 +99,8 @@
     o.init_member("setMode", gl->createFunction(camera_setmode));
     o.init_member("setMotionLevel", gl->createFunction(camera_setmotionlevel));
     o.init_member("setQuality", gl->createFunction(camera_setquality));
-    o.init_member("setCursor", gl->createFunction(camera_setCursor));
+// setCursor is not in the specs for Camera (as2 or 3)
+//    o.init_member("setCursor", gl->createFunction(camera_setCursor));
     o.init_member("setLoopback", gl->createFunction(camera_setLoopback));
     o.init_member("setKeyFrameInterval",
             gl->createFunction(camera_setKeyFrameInterval));
@@ -313,6 +313,7 @@
                     ptr->set_motionLevel(argument);
                 } else {
                     log_error("%s: bad value passed for first argument", 
__FUNCTION__);
+                    ptr->set_motionLevel(100);
                 }
                 if (ptr->get_motionTimeout() != 2000) {
                     ptr->set_motionTimeout(2000);
@@ -326,6 +327,7 @@
                     ptr->set_motionLevel(argument1);
                 } else {
                     log_error("%s: bad value passed for first argument", 
__FUNCTION__);
+                    ptr->set_motionLevel(100);
                 }
                 ptr->set_motionTimeout(fn.arg(1).to_number());
                 break;
@@ -367,10 +369,11 @@
             {
                 double argument2 = fn.arg(1).to_number();
                 ptr->set_bandwidth(fn.arg(0).to_number());
-                if ((argument2 <= 0) && (argument2 >= 100)) {
+                if ((argument2 >= 0) && (argument2 <= 100)) {
                     ptr->set_quality(fn.arg(1).to_number());
                 } else {
                     log_error("%s: Second argument not in range 0-100", 
__FUNCTION__);
+                    ptr->set_quality(100);
                 }
                 break;
             }
@@ -540,7 +543,8 @@
 as_value
 camera_motionTimeout(const fn_call& fn)
 {
-    boost::intrusive_ptr<camera_as_object> ptr = 
ensureType<camera_as_object>(fn.this_ptr);
+    boost::intrusive_ptr<camera_as_object> ptr = ensureType<camera_as_object>
+        (fn.this_ptr);
 
     if ( fn.nargs == 0 ) // getter
     {
@@ -658,22 +662,34 @@
 }
 
 as_value
-camera_setLoopback(const fn_call&)
-{
-    LOG_ONCE(log_unimpl("Camera.setLoopback"));
-    return as_value();
-}
-
-as_value camera_setCursor(const fn_call&)
-{
-    LOG_ONCE(log_unimpl("Camera.setCursor"));
+camera_setLoopback(const fn_call& fn)
+{
+    boost::intrusive_ptr<camera_as_object> ptr = ensureType<camera_as_object>
+        (fn.this_ptr);
+    
+    int numargs = fn.nargs;
+    if (numargs > 1) {
+        log_error("%s: Too many arguments", __FUNCTION__);
+    } else {
+        ptr->set_loopback(fn.arg(0).to_bool());
+    }
+    
     return as_value();
 }
 
 as_value
-camera_setKeyFrameInterval(const fn_call&)
+camera_setKeyFrameInterval(const fn_call& fn)
 {
-    LOG_ONCE(log_unimpl("Camera.setKeyFrameInterval"));
+    boost::intrusive_ptr<camera_as_object> ptr = ensureType<camera_as_object>
+        (fn.this_ptr);
+    
+    int numargs = fn.nargs;
+    if (numargs > 1) {
+        log_error("%s: Too many arguments", __FUNCTION__);
+    } else {
+        ptr->set_loopback(fn.arg(0).to_int());
+    }
+    
     return as_value();
 }
 

=== modified file 'libcore/asobj/flash/media/Microphone_as.cpp'
--- a/libcore/asobj/flash/media/Microphone_as.cpp       2009-08-06 11:35:27 
+0000
+++ b/libcore/asobj/flash/media/Microphone_as.cpp       2009-08-07 19:56:42 
+0000
@@ -42,7 +42,7 @@
 
 namespace gnash {
 
-as_value microphone_new(const fn_call& fn);
+as_value microphone_ctor(const fn_call& fn);
 as_value microphone_get(const fn_call& fn);
 as_value microphone_getMicrophone(const fn_call& fn);
 as_value microphone_setgain(const fn_call& fn);
@@ -80,7 +80,6 @@
     o.init_property("names", *getset, *getset);
 }
 
-// getMicrophone is a static property in AS3.
 void
 attachMicrophoneAS3StaticInterface(as_object& o)
 {
@@ -178,7 +177,7 @@
 // There is a constructor for Microphone that returns an object with
 // the correct properties, but it is not usable.
 as_value
-microphone_new(const fn_call& fn)
+microphone_ctor(const fn_call& fn)
 {
     Global_as* gl = getGlobal(fn);
     as_object* proto = getMicrophoneInterface();
@@ -189,39 +188,49 @@
 as_value
 microphone_get(const fn_call& fn)
 {
-
-    // TODO: this should return the *same* object when the same device
-    // is returned, not a new object.
-    // TODO: check what the function returns when there is no microphone.
-    boost::intrusive_ptr<as_object> obj = new microphone_as_object;
-    
-    int numargs = fn.nargs;
-    if (numargs > 0) {
-        log_debug("%s: the mic is automatically chosen from gnashrc",
-                __FUNCTION__);
+    static size_t newcount = 0;
+    static boost::intrusive_ptr<microphone_as_object> permaMicPtr;
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    if (newcount == 0) {
+        log_debug("creating a new microphone_as object");
+        ptr = new microphone_as_object;
+        newcount++;
+        permaMicPtr = ptr;
+        return as_value(ptr);
+    } else {
+        return as_value(permaMicPtr);
     }
-    return as_value(obj.get()); //will keep alive
 }
 
 // AS3 static accessor.
 as_value
 microphone_getMicrophone(const fn_call& fn)
 {
-    boost::intrusive_ptr<as_object> obj = new microphone_as_object;
-    
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        ptr = new microphone_as_object;
+    }
     int numargs = fn.nargs;
     if (numargs > 0) {
         log_debug("%s: the mic is automatically chosen from gnashrc", 
__FUNCTION__);
     }
-    return as_value(obj.get()); //will keep alive
+    return as_value(ptr.get()); //will keep alive
 }
 
 
 as_value 
 microphone_setgain(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: you must first initialize the microphone before setting 
vals",
+            __FUNCTION__);
+        return as_value();
+    }
     
     int numargs = fn.nargs;
     if (numargs != 1) {
@@ -262,8 +271,14 @@
 as_value
 microphone_setrate(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: you must first initialize the microphone before setting 
vals",
+            __FUNCTION__);
+        return as_value();
+    }
     
     int numargs = fn.nargs;
     const int32_t argument = fn.arg(0).to_int();
@@ -271,10 +286,26 @@
     if (numargs != 1) {
         log_error("%s: wrong number of parameters passed", __FUNCTION__);
     } else if ((argument != 5) && (argument != 8) && (argument != 11) &&
-        (argument != 22) && (argument != 44)) {
+        (argument != 16) && (argument != 22) && (argument != 44)) {
         log_error("%s: invalid rate argument (%d) passed", __FUNCTION__,
             argument);
-        ptr->set_rate(11000);
+        //choose the next supported rate
+        if (argument > 44) {
+            ptr->set_rate(44000);
+        } else {
+            int supported[] = {5, 8, 11, 16, 22, 44};
+            for (size_t i = 0; i < 6; ++i) {
+                if (argument < supported[i]) {
+                    ptr->set_rate(supported[i]*1000);
+                    break;
+                } else {
+                    continue;
+                }
+            }
+        }
+#ifdef USE_GST
+        ptr->audioChangeSourceBin(ptr->getGlobalAudio());
+#endif
     } else {
         int32_t gstarg = argument * 1000;
         ptr->set_rate(gstarg);
@@ -287,8 +318,14 @@
 
 as_value
 microphone_activityLevel(const fn_call& fn) {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -307,23 +344,29 @@
 
 as_value
 microphone_gain(const fn_call& fn) {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
         
     if ( fn.nargs == 0 ) // getter
     {
 #ifdef USE_GST
     double gain;
     if (ptr->get_gain() == 0) {
-        return as_value(50);
+        return as_value(50.0);
     } else {
-        gain = ((ptr->get_gain())*(0.8333333333)) + 50;
+        gain = ((ptr->get_gain())*(0.8333333333333)) + 50;
         gain = round(gain);
         return as_value(gain);
     }
 #endif
         log_unimpl("FFMPEG not implemented. Returning a number");
-        return as_value(0.0);
+        return as_value(50.0);
     }
     else // setter
     {
@@ -337,8 +380,14 @@
 
 as_value
 microphone_index(const fn_call& fn) {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    };
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -357,9 +406,14 @@
 as_value
 microphone_muted(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object>(fn.this_ptr);
-        
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
     if ( fn.nargs == 0 ) // getter
     {
         log_unimpl("Microphone::muted is always false (always allows access)");
@@ -378,9 +432,14 @@
 as_value
 microphone_name(const fn_call& fn)
 {
-    log_unimpl("Microphone::names: There's some problem with this function");
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -437,12 +496,23 @@
 as_value
 microphone_rate(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
-        
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
+    
     if ( fn.nargs == 0 ) // getter
     {
+#ifdef USE_GST
         return as_value(ptr->get_rate()/1000);
+#else
+        log_unimpl("FFMPEG is unsupported, returning default val");
+        return as_value(8);
+#endif
     }
     else // setter
     {
@@ -456,8 +526,14 @@
 
 as_value
 microphone_silenceLevel(const fn_call& fn) {
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -477,8 +553,14 @@
 as_value
 microphone_silenceTimeout(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object>(fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
         
     if ( fn.nargs == 0 ) // getter
     {
@@ -495,14 +577,17 @@
     return as_value();
 }
 
-// This is documented to return a Boolean (which would be sensible), but in
-// fact returns a Number.
 as_value
 microphone_useEchoSuppression(const fn_call& fn)
 {
-    boost::intrusive_ptr<microphone_as_object> ptr =
-        ensureType<microphone_as_object>(fn.this_ptr);
-        
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: microphone object not yet initialized, call new",
+            __FUNCTION__);
+        return as_value();
+    }
     if ( fn.nargs == 0 ) // getter
     {
         log_unimpl("Microphone::useEchoSuppression can be set, but is "
@@ -523,8 +608,14 @@
 as_value
 microphone_setsilencelevel(const fn_call& fn) {
     log_unimpl ("Microphone::setSilenceLevel can be set, but it's not 
implemented");
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: can't set values until you have a new microphone 
object",
+            __FUNCTION__);
+        return as_value();
+    }
     
     int numargs = fn.nargs;
     if (numargs > 2) {
@@ -561,8 +652,14 @@
 microphone_setuseechosuppression(const fn_call& fn)
 {
     log_unimpl ("Microphone::setUseEchoSuppression can be set, but it's not 
implemented");
-    boost::intrusive_ptr<microphone_as_object> ptr = 
ensureType<microphone_as_object>
-        (fn.this_ptr);
+    boost::intrusive_ptr<microphone_as_object> ptr;
+    try {
+        ptr = ensureType<microphone_as_object> (fn.this_ptr);
+    } catch (ActionTypeError& e) {
+        log_error("%s: can't set values until you create a new microphone 
object",
+            __FUNCTION__);
+        return as_value();
+    }
         
     int numargs = fn.nargs;
     if (numargs > 1) {
@@ -584,10 +681,10 @@
     as_object* cl;
 
     if (isAS3(getVM(where))) {
-        cl = gl->createClass(microphone_new, proto);
+        cl = gl->createClass(microphone_ctor, proto);
         attachMicrophoneAS3StaticInterface(*cl);
     } else {
-        cl = gl->createClass(microphone_new, proto);
+        cl = gl->createClass(microphone_ctor, proto);
         attachMicrophoneStaticInterface(*cl);
     }
         

=== modified file 'libmedia/AudioInput.cpp'
--- a/libmedia/AudioInput.cpp   2009-08-06 07:26:58 +0000
+++ b/libmedia/AudioInput.cpp   2009-08-07 19:56:42 +0000
@@ -17,6 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "AudioInput.h"
+#include "gnashconfig.h"
 
 namespace gnash {
 namespace media {
@@ -26,10 +27,23 @@
         :
         //actionscript default values
         _activityLevel(-1),
-        _gain(5000),
+//Gstreamer uses different values for the gain parameter, thus this doesn't
+//exactly match the AS livedocs, but when you get the value back it will be
+//correct (see libcore/asobj/flash/Microphone_as.cpp:gain)
+#ifdef USE_GST
+        _gain(0),
+#else
+        _gain(50),
+#endif
         _index(0),
-        _muted(false),
+        _muted(true),
+//Again, gstreamer wants a different value for the _rate parameter (in hz) 
whereas
+//AS wants the value in khz. Thus, the ifdefs
+#ifdef USE_GST
         _rate(8000),
+#else
+        _rate(8),
+#endif
         _silenceLevel(10),
         _silenceTimeout(2000), // in milliseconds
         _useEchoSuppression(false)

=== modified file 'libmedia/VideoInput.cpp'
--- a/libmedia/VideoInput.cpp   2009-08-04 17:46:54 +0000
+++ b/libmedia/VideoInput.cpp   2009-08-07 19:56:42 +0000
@@ -34,7 +34,7 @@
         _loopback = false;
         _motionLevel = 50;
         _motionTimeout = 2000;  //millisecs
-        _muted = false;  //security (false = allow, true = decline)
+        _muted = true;  //security (false = allow, true = decline)
         _quality = 0;
         _width = 160;
     } 

=== modified file 'libmedia/VideoInput.h'
--- a/libmedia/VideoInput.h     2009-08-04 17:46:54 +0000
+++ b/libmedia/VideoInput.h     2009-08-07 19:56:42 +0000
@@ -22,6 +22,7 @@
 #include <boost/cstdint.hpp> // for C99 int types
 #include <string>
 #include <vector>
+#include <ostream>
 
 namespace gnash {
 namespace media {
@@ -53,11 +54,15 @@
     int get_height() {return _height;};
     
     void set_index(int i) {_index = i;};
-    int get_index() {return _index;};
+    std::string get_index() {
+        char buffer[2];
+        sprintf(buffer, "%i", _index);
+        return buffer;};
     
     void set_keyFrameInterval(int i) {_keyFrameInterval = i;};
     int get_keyFrameInterval() {return _keyFrameInterval;};
     
+    void set_loopback(bool l) {_loopback = l;};
     bool get_loopback() {return _loopback;};
     
     void set_motionLevel(int m) {_motionLevel = m;};

=== modified file 'libmedia/gst/AudioInputGst.cpp'
--- a/libmedia/gst/AudioInputGst.cpp    2009-08-06 07:29:55 +0000
+++ b/libmedia/gst/AudioInputGst.cpp    2009-08-07 19:56:42 +0000
@@ -96,7 +96,7 @@
             gst_element_set_state (element, GST_STATE_PLAYING);
             g_object_get (element, "device-name", &dev_name, NULL);
             gst_element_set_state (element, GST_STATE_NULL);
-            if (g_strcmp0(dev_name, "null") ||
+            if ((g_strcmp0(dev_name, "null") == 0) ||
                     (std::strstr(dev_name, "Monitor") != NULL)) {
                 log_trace("No pulse audio input devices.");
             }
@@ -118,7 +118,7 @@
     }
     
     bool
-    AudioInputGst::checkSupportedFormats(GnashAudio* /*aud*/, GstCaps *caps) {
+    AudioInputGst::checkSupportedFormats(GstCaps *caps) {
         gint num_structs;
         
         num_structs = gst_caps_get_size (caps);
@@ -203,7 +203,7 @@
                     log_error("%s: Template pad isn't an object for some 
reason",
                         __FUNCTION__);
                 }
-                bool ok = checkSupportedFormats(data_struct, caps);
+                bool ok = checkSupportedFormats(caps);
                 if (ok) {
                     log_error("The input device you selected isn't supported 
(yet)");
                 } else {
@@ -255,8 +255,9 @@
             audioStop(audio);
         }
         
-        //delete the old source bin if necessary
-        if (!GST_ELEMENT_PARENT(audio->_audioSourceBin)) {
+        //delete the old source bin if necessary (please don't delete the == 
NULL
+        //here as it breaks things.)
+        if (!(GST_ELEMENT_PARENT(audio->_audioSourceBin) == NULL)) {
             gst_bin_remove(GST_BIN(audio->_audioMainBin),
                     audio->_audioSourceBin);
             audio->_audioSourceBin = NULL;
@@ -663,7 +664,6 @@
         ret = gst_bus_add_watch (bus, audio_bus_call, audio);
         gst_object_unref (bus);
         
-        //tfthen = gst_util_get_timestamp ();
         state = gst_element_set_state (audio->_pipeline, GST_STATE_PLAYING);
         
         if (state != GST_STATE_CHANGE_FAILURE) {

=== modified file 'libmedia/gst/AudioInputGst.h'
--- a/libmedia/gst/AudioInputGst.h      2009-08-04 17:46:54 +0000
+++ b/libmedia/gst/AudioInputGst.h      2009-08-07 19:56:42 +0000
@@ -282,13 +282,11 @@
     
     /// \brief This function checks the format information enumerated in
     ///  getSelectedCaps and makes sure that Gnash can handle said input.
-    /// @param aud A pointer to a GnashAudio class that represents the
-    ///  selected device.
     /// @param caps A pointer to the capabilities of the device as enumerated
     ///  in the getSelectedCaps function
     /// @return A boolean value (true means that the device has at least one 
     ///  supported format, false means that the device has no supported 
formats)
-    bool checkSupportedFormats(GnashAudio *aud, GstCaps *caps);
+    bool checkSupportedFormats(GstCaps *caps);
     
     /// \brief This function transfers the selected audio device from a 
GnashAudio
     ///  class to a GnashAudioPrivate class. This function is called once the

=== modified file 'libmedia/gst/VideoInputGst.cpp'
--- a/libmedia/gst/VideoInputGst.cpp    2009-08-06 07:27:30 +0000
+++ b/libmedia/gst/VideoInputGst.cpp    2009-08-07 19:56:42 +0000
@@ -54,7 +54,11 @@
         devSelection = makeWebcamDeviceSelection();
         _devSelection = devSelection;
         //also set _index for actionscript accessibility
-        _index = devSelection;
+        if (devSelection < 10) {
+            _index = devSelection;
+        } else {
+            log_error("too high an index value, will cause segfault");
+        }
         
         transferToPrivate(devSelection);
         webcamCreateMainBin(_globalWebcam);
@@ -106,7 +110,7 @@
             gst_element_set_state (element, GST_STATE_PLAYING);
             g_object_get (element, "device-name", &dev_name, NULL);
             gst_element_set_state (element, GST_STATE_NULL);
-            if (!g_strcmp0(dev_name, "null")) {
+            if (g_strcmp0(dev_name, "null") == 0) {
                 log_trace("No v4l video sources. Checking for other vid 
inputs");
             }
             else { 
@@ -143,7 +147,7 @@
             gst_element_set_state (element, GST_STATE_PLAYING);
             g_object_get (element, "device-name", &dev_name, NULL);
             gst_element_set_state (element, GST_STATE_NULL);
-            if (g_strcmp0(dev_name, "null")) {
+            if (g_strcmp0(dev_name, "null") == 0) {
                 log_trace("no v4l2 video sources found.");
             }
             else { 

=== modified file 'testsuite/actionscript.all/Camera.as'
--- a/testsuite/actionscript.all/Camera.as      2009-08-06 11:35:27 +0000
+++ b/testsuite/actionscript.all/Camera.as      2009-08-07 19:56:42 +0000
@@ -32,15 +32,19 @@
 
 //trace("NOTE: System.capabilities.hasVideoEncoder:  " + 
System.capabilities.hasVideoEncoder);
 
-// test the Camera constuctor
+/*
+ This is not the proper way to construct a camera object. According to the
+ livedoc the constructor for Camera is Camera.get(). Flashplayer ignores
+ the call to new Camera.
+ test the Camera constuctor
 check(Camera);
 var cameraObj = new Camera;
 check(cameraObj);
 var cameraObj2 = new Camera();
 check(cameraObj2);
-
 check(cameraObj != cameraObj2);
 check_equals(typeof(cameraObj), 'object');
+*/
 
 // These properties are never present before Camera.get() is called.
 check(!Camera.prototype.hasOwnProperty("activityLevel"));
@@ -106,12 +110,81 @@
 check_equals(Camera.setMotionLevel, undefined);
 check_equals(Camera.setQuality, undefined);
 
-check(cameraObj.setMode); 
-check(cameraObj.setMotionLevel);
-check(cameraObj.setQuality);
-check_equals(typeof(cameraObj.setMode), "function");
-check_equals(typeof(cameraObj.setMotionLevel), "function");
-check_equals(typeof(cameraObj.setQuality), "function");
+// test Camera::setMode
+check_equals ( typeof(cam.setMode), 'function' );
+
+// test Camera::setMotionLevel
+check_equals ( typeof(cam.setMotionLevel), 'function' );
+
+// test Camrea::setQuality
+check_equals ( typeof(cam.setQuality), 'function');
+
+// check properties
+check_equals ( typeof(cam.activityLevel), 'number' );
+check_equals ( typeof(cam.bandwidth), 'number');
+check_equals ( typeof(cam.currentFps), 'number');
+check_equals ( typeof(cam.fps), 'number');
+check_equals ( typeof(cam.height), 'number');
+check_equals ( typeof(cam.index), 'string'); //differs from spec, testing real 
bhvior
+check_equals ( typeof(cam.motionLevel), 'number');
+check_equals ( typeof(cam.motionTimeout), 'number');
+check_equals ( typeof(cam.muted), 'boolean');
+check_equals ( typeof(cam.name), 'string');
+xcheck_equals ( typeof(cam.names), 'undefined');
+check_equals ( typeof(cam.quality), 'number');
+check_equals ( typeof(cam.width), 'number');
+
+// check initialized values as in spec (gnash initializes to default)
+check_equals ( cam.activityLevel, -1 );
+check_equals ( cam.bandwidth, 16384);
+check_equals ( cam.height, 120);
+check_equals ( cam.motionLevel, 50);
+check_equals ( cam.motionTimeout, 2000);
+check_equals ( cam.muted, true);
+check_equals ( cam.width, 160);
+
+// setting and getting
+
+// check Camera::setMode with no args
+cam.setMode();
+check_equals ( cam.width, 160);
+check_equals ( cam.height, 120);
+check_equals ( cam.fps, 15);
+
+// check Camera::setMode with all arguments set
+cam.setMode(320, 280, 30, false);
+check_equals ( cam.width, 320);
+check_equals ( cam.height, 280);
+check_equals ( cam.fps, 30);
+
+// check Camera::setMotionLevel with no args
+cam.setMotionLevel();
+check_equals (cam.motionLevel, 50);
+check_equals (cam.motionTimeout, 2000);
+
+// check Camera::setMotionLevel with all arguments set
+cam.setMotionLevel(75, 3000);
+check_equals (cam.motionLevel, 75);
+check_equals (cam.motionTimeout, 3000);
+
+// check Camera::setMotionLevel with bad motionLevel argument
+cam.setMotionLevel(200, 2000);
+check_equals (cam.motionLevel, 100);
+
+// check Camera::setQuality with no args
+cam.setQuality();
+check_equals (cam.bandwidth, 16384);
+check_equals (cam.quality, 0);
+
+// check Camera::setQuality with all arguments set
+cam.setQuality(18000, 75);
+check_equals (cam.bandwidth, 18000);
+check_equals (cam.quality, 75);
+
+// check Camera::setQuality with bad quality value
+cam.setQuality(18000, 420);
+check_equals (cam.bandwidth, 18000);
+check_equals (cam.quality, 100);
 
 #endif // OUTPUT_VERSION >= 6
 totals();

=== modified file 'testsuite/actionscript.all/Microphone.as'
--- a/testsuite/actionscript.all/Microphone.as  2009-08-06 11:35:27 +0000
+++ b/testsuite/actionscript.all/Microphone.as  2009-08-07 19:56:42 +0000
@@ -55,14 +55,18 @@
 check(!Microphone.prototype.hasOwnProperty("silenceTimeOut"));
 check(!Microphone.prototype.hasOwnProperty("useEchoSuppression"));
 
-f = new Microphone;
+/*
+There is no such thing as 'new Microphone'. If you ever want to get a new
+Microphone object, the proper call is f = Microphone.get()
+*/
+//f = new Microphone;
 
 // Called with new, Microphone returns an object with static
 // properties.
-check_equals(typeof(f), 'object');
-check_equals(typeof(f.setGain), 'function')
-check_equals(typeof(f.gain), 'undefined')
-check_equals(typeof(f.rate), 'undefined')
+//check_equals(typeof(f), 'object');
+//check_equals(typeof(f.setGain), 'function')
+//check_equals(typeof(f.gain), 'undefined')
+//check_equals(typeof(f.rate), 'undefined')
 
 // Still not present
 check(!Microphone.prototype.hasOwnProperty("get"));
@@ -101,7 +105,7 @@
 check(Microphone.prototype.hasOwnProperty("useEchoSuppression"));
 
 // test that Microphone.get() returns the same object.
-xcheck_equals(microphoneObj, Microphone.get());
+check_equals(microphoneObj, Microphone.get());
 
 // test that get() method is NOT exported to instances
 check_equals (typeof(microphoneObj.get), 'undefined');
@@ -132,9 +136,16 @@
 
 // Starting values // values before microphone is activated
 check_equals ( microphoneObj.activityLevel, -1 );
-xcheck_equals ( microphoneObj.gain, 50 );
-check_equals ( microphoneObj.index, 0 );
-xcheck_equals ( microphoneObj.muted, true );
+check_equals ( microphoneObj.gain, 50 );
+
+// this test is commented out because the index value might change based on
+// which microphone is selected (e.g. my index for my mic is 1). we already
+// check to make sure that the index value is a number -- this should be
+// sufficient as there is enough error testing to make sure that bad index
+// values are handled.
+//check_equals ( microphoneObj.index, 0 );
+
+check_equals ( microphoneObj.muted, true );
 check_equals ( microphoneObj.rate, 8 );
 check_equals ( microphoneObj.silenceTimeout, 2000 );
 
@@ -151,25 +162,27 @@
 microphoneObj.setSilenceLevel(16);
 check_equals (microphoneObj.silenceLevel, 16);
 
-
+#ifdef USE_GST
 // 5, 8, 11, 22, or 44 documented...
 microphoneObj.setRate(1);
-xcheck_equals (microphoneObj.rate, 5);
+check_equals (microphoneObj.rate, 5);
 microphoneObj.setRate(7);
-xcheck_equals (microphoneObj.rate, 8);
+check_equals (microphoneObj.rate, 8);
 microphoneObj.setRate(10);
 check_equals (microphoneObj.rate, 11);
 microphoneObj.setRate(15);
-xcheck_equals (microphoneObj.rate, 16);
+check_equals (microphoneObj.rate, 16);
 microphoneObj.setRate(17);
-xcheck_equals (microphoneObj.rate, 22);
+check_equals (microphoneObj.rate, 22);
 microphoneObj.setRate(27);
-xcheck_equals (microphoneObj.rate, 44);
+check_equals (microphoneObj.rate, 44);
 microphoneObj.setRate(34);
-xcheck_equals (microphoneObj.rate, 44);
+check_equals (microphoneObj.rate, 44);
+microphoneObj.setRate(1);
+check_equals (microphoneObj.rate, 5);
 microphoneObj.setRate(1000000);
-xcheck_equals (microphoneObj.rate, 44);
-
+check_equals (microphoneObj.rate, 44);
+#endif
 
 /// It's still a number, though.
 microphoneObj.setUseEchoSuppression(false);

=== modified file 'utilities/findmicrophones.cpp'
--- a/utilities/findmicrophones.cpp     2009-07-28 18:37:36 +0000
+++ b/utilities/findmicrophones.cpp     2009-08-07 19:56:42 +0000
@@ -69,12 +69,11 @@
     GstPropertyProbe *probe;
     GValueArray *devarr;
     element = NULL;
-    gint i;
     
     element = gst_element_factory_make ("pulsesrc", "pulsesrc");
     probe = GST_PROPERTY_PROBE (element);
     devarr = gst_property_probe_probe_and_get_values_name (probe, "device");
-    for (i = 0; devarr != NULL && i < devarr->n_values; ++i) {
+    for (size_t i = 0; devarr != NULL && i < devarr->n_values; ++i) {
         GValue *val;
         gchar *dev_name = NULL;
         
@@ -83,7 +82,7 @@
         gst_element_set_state (element, GST_STATE_PLAYING);
         g_object_get (element, "device-name", &dev_name, NULL);
         gst_element_set_state (element, GST_STATE_NULL);
-        if (dev_name == "null") {
+        if (g_strcmp0(dev_name, "null") == 0) {
             g_print("no pulse audio sources found\n");
         }
         else if ((strstr(dev_name, "Monitor") != NULL)) {

=== modified file 'utilities/findwebcams.cpp'
--- a/utilities/findwebcams.cpp 2009-07-28 18:39:20 +0000
+++ b/utilities/findwebcams.cpp 2009-08-07 19:56:42 +0000
@@ -71,12 +71,11 @@
     GstPropertyProbe *probe;
     GValueArray *devarr;
     element = NULL;
-    gint i;
     
     element = gst_element_factory_make ("v4lsrc", "v4lvidsrc");
     probe = GST_PROPERTY_PROBE (element);
     devarr = gst_property_probe_probe_and_get_values_name (probe, "device");
-    for (i = 0; devarr != NULL && i < devarr->n_values; ++i) {
+    for (size_t i = 0; devarr != NULL && i < devarr->n_values; ++i) {
         GValue *val;
         gchar *dev_name = NULL;
         
@@ -85,7 +84,7 @@
         gst_element_set_state (element, GST_STATE_PLAYING);
         g_object_get (element, "device-name", &dev_name, NULL);
         gst_element_set_state (element, GST_STATE_NULL);
-        if (dev_name == "null") {
+        if (g_strcmp0(dev_name, "null") == 0) {
             g_print("no v4l video sources found\n");
         }
         else { 
@@ -110,7 +109,7 @@
     element = gst_element_factory_make ("v4l2src", "v4l2vidsrc");
     probe = GST_PROPERTY_PROBE (element);
     devarr = gst_property_probe_probe_and_get_values_name (probe, "device");
-    for (i = 0; devarr != NULL && i < devarr->n_values; ++i) {
+    for (size_t i = 0; devarr != NULL && i < devarr->n_values; ++i) {
         GValue *val;
         gchar *dev_name = NULL;
         
@@ -119,7 +118,7 @@
         gst_element_set_state (element, GST_STATE_PLAYING);
         g_object_get (element, "device-name", &dev_name, NULL);
         gst_element_set_state (element, GST_STATE_NULL);
-        if (dev_name == "null") {
+        if (g_strcmp0(dev_name, "null") == 0) {
             g_print("no v4l2 video sources found.\n");
         }
         else {
@@ -150,7 +149,6 @@
     gst_init(NULL, NULL);
     gint numdevs = 0;
     std::vector<data*> vidVector;
-    gint i;
     
     int fromrc = rcfile.getWebcamDevice();
     
@@ -159,7 +157,7 @@
         numdevs = findVidDevs(vidVector);
         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) {
+        for (size_t i = 0; i < numdevs; ++i) {
             if (vidVector[i]->duplicate == true) {
                 g_print("    %s (%s)\n", vidVector[i]->deviceName, 
vidVector[i]->deviceType);
             }
@@ -168,7 +166,7 @@
         g_print("\nv4l sources will 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)
+        for (size_t i = 0; i < numdevs; ++i)
         {
             if (i == 0 && (vidVector[i] != 0)) {
                 g_print("    %d. Video Test Source (videotestsrc)\n", i, i);
@@ -218,5 +216,5 @@
             g_print("and running this program again\n");
         }
     }
-    return 1;
+    return 0;
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]