gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11316: updated VideoInput files to


From: Ben Limmer
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11316: updated VideoInput files to support breaking bin links and updated videotest file
Date: Mon, 27 Jul 2009 12:49:27 -0600
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11316
committer: Ben Limmer <address@hidden>
branch nick: trunk
timestamp: Mon 2009-07-27 12:49:27 -0600
message:
  updated VideoInput files to support breaking bin links and updated videotest 
file
modified:
  libmedia/gst/VideoInputGst.cpp
  libmedia/gst/VideoInputGst.h
  testsuite/libmedia.all/test_videoinput.cpp
    ------------------------------------------------------------
    revno: 11315.1.1
    committer: Ben Limmer <address@hidden>
    branch nick: cam_mic_impl_2
    timestamp: Mon 2009-07-27 12:48:53 -0600
    message:
      updated VideoInput files to support breaking bin links and updated 
videotest file
    modified:
      libmedia/gst/VideoInputGst.cpp
      libmedia/gst/VideoInputGst.h
      testsuite/libmedia.all/test_videoinput.cpp
=== modified file 'libmedia/gst/VideoInputGst.cpp'
--- a/libmedia/gst/VideoInputGst.cpp    2009-07-27 15:44:55 +0000
+++ b/libmedia/gst/VideoInputGst.cpp    2009-07-27 18:48:53 +0000
@@ -779,11 +779,44 @@
         }
     }
     
+    //break the link that displays the webcam video to the screen
+    gboolean
+    VideoInputGst::webcamBreakVideoDisplayLink(GnashWebcamPrivate *webcam) {
+        if (webcam->_pipelineIsPlaying == true) {
+            GstStateChangeReturn state;
+            state = gst_element_set_state(webcam->_pipeline, GST_STATE_NULL);
+            if (state != GST_STATE_CHANGE_FAILURE) {
+                webcam->_pipelineIsPlaying = false;
+            } else {
+                return false;
+            }
+        }
+        
+        gboolean ok;
+        GstPad *videoDisplayQueueSrc, *videoDisplayBinSink;
+        
+        videoDisplayQueueSrc = gst_element_get_pad(webcam->_webcamMainBin,
+            "video_display_queue_src");
+        videoDisplayBinSink = gst_element_get_pad(webcam->_videoDisplayBin,
+            "sink");
+        
+        ok = gst_pad_unlink(videoDisplayQueueSrc, videoDisplayBinSink);
+        
+        if (ok != true) {
+            log_error("%s: the unlinking of the pads failed", __FUNCTION__);
+            return false;
+        } else {
+            return true;
+        }
+    }
+    
     //make link to saveQueue in main bin
     gboolean
     VideoInputGst::webcamMakeVideoSaveLink(GnashWebcamPrivate *webcam) {
-        gst_bin_add (GST_BIN(webcam->_pipeline), webcam->_videoSaveBin);
-        
+        if (gst_bin_get_by_name(GST_BIN(webcam->_pipeline), "video_save_bin") 
== NULL) {
+            gst_bin_add(GST_BIN(webcam->_pipeline), webcam->_videoSaveBin);
+        }
+
         //linking
         GstPad *video_save_queue_src, *video_save_sink;
         
@@ -802,6 +835,46 @@
         }
     }
     
+    //break link to saveQueue in main bin
+    gboolean
+    VideoInputGst::webcamBreakVideoSaveLink(GnashWebcamPrivate *webcam) {
+        if (webcam->_pipelineIsPlaying == true) {
+            GstStateChangeReturn state;
+            state = gst_element_set_state(webcam->_pipeline, GST_STATE_NULL);
+            if (state != GST_STATE_CHANGE_FAILURE) {
+                webcam->_pipelineIsPlaying = false;
+            } else {
+                return false;
+            }
+        }
+        gboolean ok;
+        GstPad *videoSaveQueueSrc, *videoSaveSink;
+        GstStateChangeReturn state;
+        videoSaveQueueSrc = gst_element_get_pad(webcam->_webcamMainBin,
+            "save_queue_src");
+        videoSaveSink = gst_element_get_pad(webcam->_videoSaveBin, "sink");
+        
+        ok = gst_pad_unlink(videoSaveQueueSrc, videoSaveSink);
+        if (ok != true) {
+            log_error("%s: unlink failed", __FUNCTION__);
+            return false;
+        } else {
+            state = gst_element_set_state(webcam->_videoSaveBin, 
GST_STATE_NULL);
+            if (state != GST_STATE_CHANGE_FAILURE) {
+                ok = gst_bin_remove(GST_BIN(webcam->_pipeline), 
webcam->_videoSaveBin);
+                if (ok != true) {
+                    log_error("%s: couldn't remove saveBin from pipeline", 
__FUNCTION__);
+                    return false;
+                } else {
+                    return true;
+                }
+            } else {
+                log_error("%s: videoSaveBin state change failed", 
__FUNCTION__);
+                return false;
+            }
+        }
+    }
+    
     //create a bin to take the video stream and dump it out to
     //an ogg file
     gboolean
@@ -853,7 +926,7 @@
         gst_bin_add_many (GST_BIN (webcam->_videoSaveBin), video_save_csp, 
                 video_save_rate, video_save_scale, video_enc, mux, 
webcam->_videoFileSink,
                 NULL);
-                      
+
         //add ghostpad
         pad = gst_element_get_pad (video_save_csp, "sink");
         gst_element_add_pad (webcam->_videoSaveBin, gst_ghost_pad_new ("sink", 
pad));
@@ -902,7 +975,7 @@
     }
     
     //start the pipeline and run the g_main_loop
-    bool
+    gboolean
     VideoInputGst::webcamPlay(GnashWebcamPrivate *webcam) {
         GstStateChangeReturn state;
         GstBus *bus;
@@ -918,10 +991,13 @@
             
             if (state != GST_STATE_CHANGE_FAILURE) {
                 webcam->_pipelineIsPlaying = true;
+                return true;
+            } else {
+                return false;
             }
     }
     
-    bool
+    gboolean
     VideoInputGst::webcamStop(GnashWebcamPrivate *webcam) {
         GstStateChangeReturn state;
         

=== modified file 'libmedia/gst/VideoInputGst.h'
--- a/libmedia/gst/VideoInputGst.h      2009-07-27 15:44:55 +0000
+++ b/libmedia/gst/VideoInputGst.h      2009-07-27 18:48:53 +0000
@@ -578,6 +578,15 @@
     ///        False otherwise.
     gboolean webcamMakeVideoDisplayLink(GnashWebcamPrivate *webcam);
     
+    /// \brief Function breaks the link between the _videoDisplayBin and the
+    ///    _videoDisplayQueue in the main bin
+    ///
+    /// @param webcam A pointer to the GnashWebcamPrivate webcam structure
+    ///            created previously in a call to transferToPrivate()
+    ///
+    /// @return True if the link was successfully broken, false otherwise
+    gboolean webcamBreakVideoDisplayLink(GnashWebcamPrivate *webcam);
+    
     /// \brief Function links the videoSaveBin to the videoSaveQueue in the
     ///   main bin.
     /// @param webcam A pointer to the GnashWebcamPrivate webcam structure
@@ -587,6 +596,13 @@
     ///    otherwise.
     gboolean webcamMakeVideoSaveLink(GnashWebcamPrivate *webcam);
 
+    /// \brief Function breaks link between the videoSaveBin and the 
videoSaveQueue
+    ///   in the main bin.
+    /// @param webcam A pointer to the GnashWebcamPrivate webcam structure
+    ///             created previously in a call to transferToPrivate()
+    /// @return True if the link was succesfully broken, false otherwise
+    gboolean webcamBreakVideoSaveLink(GnashWebcamPrivate *webcam);
+
     /// \brief Function creates the save bin. For more information on pipeline
     ///       implementation and this function in general see the definition of
     ///       the _webcam_save_bin variable in the GnashWebcamPrivate structure
@@ -606,14 +622,14 @@
     ///             created previously in a call to transferToPrivate()
     ///
     /// @return True if the pipeline was started correctly, false otherwise.
-    bool webcamPlay(GnashWebcamPrivate *webcam);
+    gboolean webcamPlay(GnashWebcamPrivate *webcam);
     
     /// \brief Function stops the pipeline designed earlier in code execution.
     ///
     /// @param webcam A pointer to the GnashWebcamPrivate webcam structure
     ///   created previously in a call to transferToPrivate()
     /// @return True if the pipeline was stopped correctly, false otherwise.
-    bool webcamStop(GnashWebcamPrivate *webcam);
+    gboolean webcamStop(GnashWebcamPrivate *webcam);
     
     /// \brief Accessor which returns the vid_vect private variable in the
     ///       VideoInputGst class.

=== modified file 'testsuite/libmedia.all/test_videoinput.cpp'
--- a/testsuite/libmedia.all/test_videoinput.cpp        2009-07-27 15:44:55 
+0000
+++ b/testsuite/libmedia.all/test_videoinput.cpp        2009-07-27 18:48:53 
+0000
@@ -23,6 +23,7 @@
 
 #include <string>
 #include <cstdio>
+#include <unistd.h>
 #include <sys/stat.h>
 
 #include "dejagnu.h"
@@ -263,6 +264,7 @@
         runtest.pass("webcamPlay() function reported no errors");
     }
     
+    g_print("        NOTE: the output window will close automatically\n");
     
     if (webcam->_pipelineIsPlaying != true) {
         runtest.fail("the _pipelineIsPlaying variable isn't being set");
@@ -279,6 +281,7 @@
 
     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) {
@@ -289,6 +292,111 @@
     } else {
         runtest.fail("there's no output video file in testsuite/libmedia.all");
     }
+    
+    //delete the old vidoutput.ogg file
+    if (unlink(file.c_str()) == 0) {
+        g_print("        NOTE: deleting output file...\n");
+    }
+    
+    result = vig.webcamBreakVideoDisplayLink(webcam);
+    if (result != true) {
+        runtest.fail("the webcamBreakVideoDisplayLink() function reported an 
error");
+    } else {
+        runtest.pass("the webcamBreakVideoDisplayLink() function reported no 
errors");
+    }
+    
+    result = vig.webcamPlay(webcam);
+    if (result != true) {
+        runtest.fail("webcamPlay() reported errors after breaking display 
link");
+    } else {
+        runtest.pass("webcamPlay() still works after breaking display link");
+    }
+    g_print("        NOTE: sleeping for 5 seconds here....\n");
+    sleep(5);
+    
+    result = vig.webcamStop(webcam);
+    if (result != true) {
+        runtest.fail("webcamStop() reported errors after breaking display 
link");
+    } else {
+        runtest.pass("webcamStop() reported success after breaking display 
link");
+    }
+    
+    if (stat(file.c_str(), &st) == 0) {
+        runtest.pass("the a new vidoput.ogg file was created");
+    } else {
+        runtest.fail("there's no new vidoutput.ogg file!");
+    }
+    
+    //delete the old vidoutput.ogg file
+    if (unlink(file.c_str()) == 0) {
+        g_print("        NOTE: deleting output file...\n");
+    }
+    
+    result = vig.webcamBreakVideoSaveLink(webcam);
+    if (result != true) {
+        runtest.fail("breaking the videoSaveLink failed");
+    } else {
+        runtest.pass("breaking the videoSaveLink was successful");
+    }
+    
+    result = vig.webcamMakeVideoDisplayLink(webcam);
+    if (result != true) {
+        runtest.fail("making videosrc -> display link failed");
+    } else {
+        runtest.pass("making videosrc -> display link succeeded");
+    }
+
+    result = vig.webcamPlay(webcam);
+    if (result != true) {
+        runtest.fail("webcamPlay() reported errors after relinking display");
+    } else {
+        runtest.pass("webcamPlay() still works after relinking display");
+    }
+    g_print("        NOTE: sleeping for 5 seconds here....\n");
+    sleep(5);
+    
+    result = vig.webcamStop(webcam);
+    if (result != true) {
+        runtest.fail("webcamStop() reported errors after breaking display 
link");
+    } else {
+        runtest.pass("webcamStop() reported success after breaking display 
link");
+    }
+
+    if (stat(file.c_str(), &st) == 0) {
+        runtest.fail("a vidoutput.ogg file was created, and it shouldn't be");
+    } else {
+        runtest.pass("no vidoutput.ogg file wasn't created");
+    }
+    
+    result = vig.webcamMakeVideoSaveLink(webcam);
+    if (result != true) {
+        runtest.fail("webcamMakeVideoSaveLink() reported an error");
+    } else {
+        runtest.pass("webcamMakeVideoSaveLink() reported no errors");
+    }
+    
+    result = vig.webcamPlay(webcam);
+    if (result != true) {
+        runtest.fail("webcamPlay() reported errors");
+    } else {
+        runtest.pass("webcamPlay() reported no errors");
+    }
+    
+    g_print("        NOTE: sleeping for 5 seconds here....\n");
+    sleep(5);
+    
+    result = vig.webcamStop(webcam);
+    if (result != true) {
+        runtest.fail("webcamStop() reported errors after breaking display 
link");
+    } else {
+        runtest.pass("webcamStop() reported success after breaking display 
link");
+    }
+    
+    if (stat(file.c_str(), &st) == 0) {
+        runtest.pass("the a new vidoput.ogg file was created");
+    } else {
+        runtest.fail("there's no new vidoutput.ogg file!");
+    }
 }
 
 


reply via email to

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