Permalink
Browse files

Updated for new version of ofxIpVideoGrabber. Should increase stabili…

…ty significantly.
  • Loading branch information...
1 parent 35504af commit 3fff379ef75c794c36ec930d609ea90727cd3b07 @bakercp committed Aug 21, 2012
@@ -35,6 +35,8 @@
FD4921BF15D8A6D700E72D68 /* ofxXmlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD4921BA15D8A6D700E72D68 /* ofxXmlSettings.cpp */; };
FD4921C515D8A97700E72D68 /* Syphon.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD49216C15D8A69000E72D68 /* Syphon.framework */; };
FD4921DA15D8B27700E72D68 /* tv.icns in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD4921D715D8B17100E72D68 /* tv.icns */; };
+ FDA5D60B15E32C7900853D6E /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA5D60A15E32C7900853D6E /* QTKit.framework */; };
+ FDA5D60D15E32C8700853D6E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA5D60C15E32C8700853D6E /* QuartzCore.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -117,6 +119,8 @@
FD4921BA15D8A6D700E72D68 /* ofxXmlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxXmlSettings.cpp; sourceTree = "<group>"; };
FD4921BB15D8A6D700E72D68 /* ofxXmlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxXmlSettings.h; sourceTree = "<group>"; };
FD4921D715D8B17100E72D68 /* tv.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = tv.icns; sourceTree = "<group>"; };
+ FDA5D60A15E32C7900853D6E /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = ../../../../../../../../../System/Library/Frameworks/QTKit.framework; sourceTree = "<group>"; };
+ FDA5D60C15E32C8700853D6E /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = ../../../../../../../../../System/Library/Frameworks/QuartzCore.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -139,6 +143,8 @@
E4C2424810CC5A17004149E2 /* Cocoa.framework in Frameworks */,
E4C2424910CC5A17004149E2 /* IOKit.framework in Frameworks */,
FD49218815D8A69100E72D68 /* Syphon.framework in Frameworks */,
+ FDA5D60B15E32C7900853D6E /* QTKit.framework in Frameworks */,
+ FDA5D60D15E32C8700853D6E /* QuartzCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -158,6 +164,8 @@
BBAB23C913894ECA00AA2426 /* system frameworks */ = {
isa = PBXGroup;
children = (
+ FDA5D60C15E32C8700853D6E /* QuartzCore.framework */,
+ FDA5D60A15E32C7900853D6E /* QTKit.framework */,
E4C2424410CC5A17004149E2 /* AppKit.framework */,
E4C2424510CC5A17004149E2 /* Cocoa.framework */,
E4C2424610CC5A17004149E2 /* IOKit.framework */,
@@ -1,25 +1,25 @@
-<window x="100" y="100" width="1024" height="768" rows="4" cols="4" videoDisplayWidth="256" videoDisplayHeight="192" disableRendering="0"/>
+<window x="100" y="100" width="1024" height="768" rows="4" cols="4" videoDisplayWidth="256" videoDisplayHeight="192" disableRendering="0" showStats="1"/>
<logger level="VERBOSE"/>
<streams>
- <stream address="http://81.8.151.136:88/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam0" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://148.61.142.228/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam1" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://82.79.176.85:8081/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam2" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://213.77.33.2:8080/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam3" type="ipcam" username="" password="" width="320" height="240" display="1"/>
+ <stream address="http://81.8.151.136:88/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam0" username="" password="" display="1"/>
+ <stream address="http://148.61.142.228/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam1" username="" password="" display="1"/>
+ <stream address="http://82.79.176.85:8081/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam2" username="" password="" display="1"/>
+ <stream address="http://213.77.33.2:8080/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam3" username="" password="" display="1"/>
- <stream address="http://130.15.110.15/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam4" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://212.244.173.167/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam5" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://194.103.218.15/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam6" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://216.8.159.21/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam7" type="ipcam" username="" password="" width="320" height="240" display="1"/>
+ <stream address="http://130.15.110.15/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam4" username="" password="" display="1"/>
+ <stream address="http://212.244.173.167/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam5" username="" password="" display="1"/>
+ <stream address="http://194.103.218.15/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam6" username="" password="" display="1"/>
+ <stream address="http://216.8.159.21/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam7" username="" password="" display="1"/>
- <stream address="http://147.134.38.233/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam8" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://216.99.115.55/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam9" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://kassertheatercam.montclair.edu/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam10" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://134.29.208.43/mjpg/video.mjpg?resolution=320x240" name="ipcam11" type="ipcam" username="" password="" width="320" height="240" display="1"/>
+ <stream address="http://147.134.38.233/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam8" username="" password="" display="1"/>
+ <stream address="http://216.99.115.55/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam9" username="" password="" display="1"/>
+ <stream address="http://kassertheatercam.montclair.edu/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam10" username="" password="" display="1"/>
+ <stream address="http://cafe-cam.wulib.wustl.edu/axis-cgi/mjpg/video.cgi?camera=&resolution=352x240" name="ipcam11" username="" password="" display="1"/>
- <stream address="http://212.219.113.227/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam12" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://129.171.176.150/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam13" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://129.89.28.32/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam14" type="ipcam" username="" password="" width="320" height="240" display="1"/>
- <stream address="http://webcam.magic.iac.es/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam15" type="ipcam" username="" password="" width="320" height="240" display="1"/>
+ <stream address="http://212.219.113.227/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam12" username="" password="" display="1"/>
+ <stream address="http://129.171.176.150/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam13" username="" password="" display="1"/>
+ <stream address="http://72.227.87.110/anony/mjpg.cgi" name="ipcam14" username="" password="" display="1"/>
+ <stream address="http://webcam.magic.iac.es/axis-cgi/mjpg/video.cgi?resolution=320x240" name="ipcam15" username="" password="" display="1"/>
</streams>
@@ -34,8 +34,6 @@ class IPCAM2SYPHONApp : public ofBaseApp{
public:
- virtual ~IPCAM2SYPHONApp();
-
void setup();
void update();
void draw();
@@ -45,7 +43,7 @@ class IPCAM2SYPHONApp : public ofBaseApp{
void loadStreams();
vector< ofxSyphonServer* > ipcam;
- vector< ofxIpVideoGrabber* > ipGrabber;
+ vector< ofxIpVideoGrabber* > ipGrabber;
bool disableRendering;
@@ -62,6 +60,7 @@ class IPCAM2SYPHONApp : public ofBaseApp{
float totalFPS;
int numCams;
+ bool showStats;
ofxXmlSettings XML;
@@ -22,41 +22,8 @@ of this software and associated documentation files (the "Software"), to deal
==============================================================================*/
-/*==============================================================================
-
- Copyright (c) 2009-2012 Christopher Baker <http://christopherbaker.net>
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-
- ==============================================================================*/
-
#include "IPCAM2SYPHONApp.h"
-IPCAM2SYPHONApp::~IPCAM2SYPHONApp() {
- for(int i = 0; i < ipcam.size(); i++) {
- ofRemoveListener(ipGrabber[i]->videoResized, this, &IPCAM2SYPHONApp::videoResized);
- }
-
- ipcam.clear();
- ipGrabber.clear();
-}
-
//--------------------------------------------------------------
void IPCAM2SYPHONApp::setup(){
ofSetLogLevel(OF_LOG_NOTICE);
@@ -70,7 +37,7 @@ of this software and associated documentation files (the "Software"), to deal
//--------------------------------------------------------------
void IPCAM2SYPHONApp::update(){
// update the cameras
- for(int i = 0; i < ipcam.size(); i++) {
+ for(int i = 0; i < ipGrabber.size(); i++) {
ipGrabber[i]->update();
}
}
@@ -106,7 +73,7 @@ of this software and associated documentation files (the "Software"), to deal
ofTranslate(x,y);
- if(i < ipcam.size()) {
+ if(i < ipGrabber.size()) {
float kbps = ipGrabber[i]->getBitRate() / 1000.0;
totalKBPS+=kbps;
@@ -118,24 +85,36 @@ of this software and associated documentation files (the "Software"), to deal
ofSetColor(255,255,255,255);
ipGrabber[i]->draw(0,0,vidWidth,vidHeight);
-
- ofSetColor(0,0,0,127);
- ofFill();
- ofRect(10,vidHeight-85,vidWidth-20,75);
-
-
- ofSetColor(255,255,255);
-
- ofDrawBitmapString("NAME: " + ipGrabber[i]->getName(), 20, vidHeight-65);
- ofDrawBitmapString("SIZE: " + ofToString(ipGrabber[i]->getWidth())
- + "x"
- + ofToString(ipGrabber[i]->getHeight()), 20, vidHeight-50);
- ofDrawBitmapString(" FPS: " + ofToString(fps, 2), 20, vidHeight-35);
- ofDrawBitmapString("Kb/S: " + ofToString(kbps,2), 20, vidHeight-20);
+ if(showStats) {
+
+ ofSetColor(0,0,0,127);
+ ofFill();
+ // draw the info box
+ ofSetColor(0,80);
+ ofRect(5,5,vidWidth-10,vidHeight-10);
+
+ stringstream ss;
+
+ ss << " NAME: " << ipGrabber[i]->getCameraName() << endl;
+ ss << " HOST: " << ipGrabber[i]->getHost() << endl;
+ ss << " FPS: " << ofToString(fps, 2,13,' ') << endl;
+ ss << " Kb/S: " << ofToString(kbps, 2,13,' ') << endl;
+ ss << " #Bytes Recv'd: " << ofToString(ipGrabber[i]->getNumBytesReceived(), 0,10,' ') << endl;
+ ss << "#Frames Recv'd: " << ofToString(ipGrabber[i]->getNumFramesReceived(), 0,10,' ') << endl;
+ ss << "Auto Reconnect: " << (ipGrabber[i]->getAutoReconnect() ? "YES" : "NO") << endl;
+ ss << " Needs Connect: " << (ipGrabber[i]->getNeedsReconnect() ? "YES" : "NO") << endl;
+ ss << "Time Till Next: " << ipGrabber[i]->getTimeTillNextAutoRetry() << " ms" << endl;
+ ss << "Num Reconnects: " << ofToString(ipGrabber[i]->getReconnectCount()) << endl;
+ ss << "Max Reconnects: " << ofToString(ipGrabber[i]->getMaxReconnects()) << endl;
+ ss << " Connect Fail: " << (ipGrabber[i]->hasConnectionFailed() ? "YES" : "NO");
+
+ ofSetColor(255);
+ ofDrawBitmapString(ss.str(), 10, 10+12);
+ }
} else {
ofSetColor(255,255,255,255);
- ofDrawBitmapString("PREVIEW DISABLED (" + ipGrabber[i]->getName() + ")", 20, vidHeight-65);
+ ofDrawBitmapString("PREVIEW DISABLED (" + ipGrabber[i]->getCameraName() + ")", 20, vidHeight-65);
}
} else {
@@ -155,11 +134,8 @@ of this software and associated documentation files (the "Software"), to deal
ofNoFill();
ofRect(4,4,vidWidth-8, vidHeight-8);
-
- }
+ }
-
-
ofDisableAlphaBlending();
ofPopMatrix();
@@ -169,9 +145,8 @@ of this software and associated documentation files (the "Software"), to deal
ofDrawBitmapString("PRESS (E) TO RE-ENABLE RENDERING", 10, 20);
}
-
// update the syphon cameras
- for(int i = 0; i < ipcam.size(); i++) {
+ for(int i = 0; i < ipGrabber.size(); i++) {
if(ipGrabber[i]->isFrameNew()) {
ipcam[i]->publishTexture(&ipGrabber[i]->getTextureReference());
}
@@ -207,14 +182,14 @@ of this software and associated documentation files (the "Software"), to deal
showVideo[currentCamera] = !showVideo[currentCamera];
} else if(key == 'E') {
disableRendering = !disableRendering;
+ } else if(key == 's') {
+ showStats = !showStats;
}
}
-void IPCAM2SYPHONApp::loadStreams()
-{
- //ofxXmlSettings XML;
+void IPCAM2SYPHONApp::loadStreams() {
- ofLog(OF_LOG_NOTICE, "---------------Loading Streams---------------");
+ ofLogNotice("IPCAM2SYPHONApp") << "---------------Loading Streams---------------";
if( XML.loadFile("streams.xml") ){
@@ -233,9 +208,11 @@ of this software and associated documentation files (the "Software"), to deal
vidWidth = XML.getAttribute("window", "videoDisplayWidth", 341, 0);
vidHeight = XML.getAttribute("window", "videoDisplayHeight", 256, 0);
- disableRendering = (bool)XML.getAttribute("window", "disableRendering", 0, 0);
+ showStats = XML.getAttribute("window", "showStats", 1, 0) > 0;
+
+ disableRendering = XML.getAttribute("window", "disableRendering", 0, 0) > 0;
- string logLevel = XML.getAttribute("logger","level","error");
+ string logLevel = XML.getAttribute("logger","level","error", 0);
if(Poco::icompare(logLevel,"verbose") == 0) {
ofSetLogLevel(OF_LOG_VERBOSE);
@@ -254,8 +231,6 @@ of this software and associated documentation files (the "Software"), to deal
}
- // ofSetLogLevel((ofLogLevel)XML.getAttribute("logger","level",OF_LOG_WARNING));
-
XML.pushTag("streams");
string tag = "stream";
@@ -267,24 +242,19 @@ of this software and associated documentation files (the "Software"), to deal
string username = XML.getAttribute(tag, "username", "NULL", n);
string password = XML.getAttribute(tag, "password", "NULL", n);
- int w = XML.getAttribute(tag, "width", 320,n);
- int h = XML.getAttribute(tag, "height", 240,n);
-
bool display = (bool)XML.getAttribute(tag,"display", 1, n);
string logMessage = "STREAM LOADED: " + name +
" address: " + address +
" username: " + username +
- " password: " + password +
- " width: " + ofToString(w) +
- " height: " + ofToString(h);
+ " password: " + password;
- ofLog(OF_LOG_NOTICE, logMessage);
+ ofLogNotice("IPCAM2SYPHONApp") << logMessage;
ofxIpVideoGrabber* ipGrabberI = new ofxIpVideoGrabber();
ofxSyphonServer* syphonServerI = new ofxSyphonServer();
- ipGrabberI->setName(name);
+ ipGrabberI->setCameraName(name);
ipGrabberI->setUsername(username);
ipGrabberI->setPassword(password);
URI uri(address);
@@ -308,23 +278,23 @@ of this software and associated documentation files (the "Software"), to deal
} else {
- ofLog(OF_LOG_ERROR, "Unable to load streams.xml.");
+ ofLogError("IPCAM2SYPHONApp") << "Unable to load streams.xml.";
}
- ofLog(OF_LOG_NOTICE, "-----------Loading Streams Complete----------");
+ ofLogNotice("IPCAM2SYPHONApp") << "-----------Loading Streams Complete----------";
}
//--------------------------------------------------------------
void IPCAM2SYPHONApp::videoResized(const void * sender, ofResizeEventArgs& arg) {
- ofLog(OF_LOG_VERBOSE, "A VIDEO GRABBER WAS RESIZED");
+ ofLogVerbose("IPCAM2SYPHONApp") << "A VIDEO GRABBER WAS RESIZED";
// find the camera that sent the resize event changed
- for(int i = 0; i < ipcam.size(); i++) {
+ for(int i = 0; i < ipGrabber.size(); i++) {
if(sender == ipGrabber[i]) {
- string msg = "\tCamera connected to: " + ipGrabber[i]->getURI() + " ";
- msg+= ("New DIM = " + ofToString(arg.width) + "/" + ofToString(arg.height));
- ofLog(OF_LOG_VERBOSE, msg);
-
+ stringstream msg;
+ msg << "\tCamera connected to: " << ipGrabber[i]->getURI() << " ";
+ msg << "New DIM = " << arg.width << "/" << arg.height;
+ ofLogVerbose("IPCAM2SYPHONApp") << msg;
}
}
View
@@ -23,6 +23,7 @@ For optimal speed, you can disable previews on the __IPCAM2SYPHON__ app. Key co
* '[' disables all previews
* ']' enables all previews
* 'E' toggles screen rendering
+* 's' toggles stream statistics
If you encounter problems, use `/Applications/Utilities/Console.app` to check the log files. You will likely get some hints there. Otherwise, please feel free to post an issue to this repository.

0 comments on commit 3fff379

Please sign in to comment.