void ofxSprite::load(string filename, int numFrames, int start, string id) { this->id = id; for (int i=start; i<numFrames+start; i++) { addFile(ofVAArgsToString(filename.c_str(), i)); } }
void ofFileLoggerChannel::log(ofLogLevel level, const string & module, const char* format, va_list args){ file << "[" << ofGetLogLevelName(level, true) << "] "; if(module != ""){ file << module << ": "; } file << ofVAArgsToString(format,args) << endl; }
//-------------------------------------------------------------- void ofxScreenLoggerChannel::log(ofLogLevel level, const string & module, const char* format, va_list args) { // Compose the message. std::ostringstream oss; if (_bPrefixTimestamp) { oss << ofGetTimestampString("%H:%M:%S:%i") << " "; } oss << "[" << ofGetLogLevelName(level, true) << "] "; if (module != "") { oss << module << ": "; } oss << ofVAArgsToString(format, args) << endl; // Add it to the buffer. _buffer.push_front(oss.str()); // Adjust offset if necessary. if (_scrollOffset > 0) ++_scrollOffset; // Erase older messages. while (_buffer.size() > _maxBufferCount) { _buffer.pop_back(); } }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetWindowShape(WIDTH, HEIGHT); ofSetWindowPosition((ofGetScreenWidth() - ofGetWidth()) / 2, (ofGetScreenHeight() - ofGetHeight()) / 2); ofSetFrameRate(60); ofDisableArbTex(); //ofSetVerticalSync(true); #ifdef SHIPPING ofLogToFile(ofVAArgsToString("logs/%s_log.txt", ofGetTimestampString("%Y-%m-%d-%H-%M-%S").c_str())); ofHideCursor(); bDebugVisible = false; isFullscreen = true; switchScreenSize(isFullscreen); #endif { ofLog(OF_LOG_NOTICE, "application start with resolution: %u x %u", ofGetWidth(), ofGetHeight()); } { const string theme_path = "fonts/theme.xml"; ofVec2f gui_pos; ofxGuiGroupRef gui; auto getNextPosition = [&]() -> ofVec2f { return gui->getPosition() + ofVec2f(gui->getWidth(), 0); }; mSettings.setName("settings"); mSettings.add(gThreshold.set("threshold", 128.0f, 0.0f, 255.0f)); mUniforms.setName("uniforms"); mUniforms.add(uDeltaTime.set("uDeltaTime", 0.0f, 0.0f, 1.0f)); mUniforms.add(uElapsedTime.set("uElapsedTime", ofGetElapsedTimef())); gui.reset(new ofxGuiGroup); loadGuiTheme(gui, theme_path); gui->setup("gui"); gui->add(mSettings); gui->add(mUniforms); gui_pos = getNextPosition(); mGui.push_back(gui); gui.reset(new ofxGuiGroup); loadGuiTheme(gui, theme_path); ofParameterGroup infos; infos.setName("hot key"); infos.add(ofParameter<string>().set("ESC", "exit")); infos.add(ofParameter<string>().set("F1", "gui")); infos.add(ofParameter<string>().set("F5", "reload shaders")); infos.add(ofParameter<string>().set("F11", "fullscreen")); infos.add(ofParameter<string>().set("S", "save settings")); infos.add(ofParameter<string>().set("L", "load settings")); infos.setSerializable(false); gui->setup("info"); gui->add(infos); gui->setPosition(gui_pos); gui_pos = getNextPosition(); mGui.push_back(gui); for (auto& g : mGui) { g->loadFromFile(getGuiFilename(g)); g->saveToFile(getGuiFilename(g)); } } { ofXml xml; if (xml.load("settings/config.xml")) { spout_prefix = xml.getValue("spout_prefix"); num_spout = xml.getValue<int>("num_spout"); screen_width = xml.getValue<int>("screen_width"); screen_height = xml.getValue<int>("screen_height"); offset_width = xml.getValue<int>("offset_width"); offset_height = xml.getValue<int>("offset_height"); ofLog(OF_LOG_NOTICE, "get config setting:\nspout_prefix: %s\nnum_spout: %u\nscreen_width: %u\nscreen_height: %u\noffset_width: %u\noffset_height: %u", spout_prefix, num_spout, screen_width, screen_height, offset_width, offset_height); if (num_spout > 0) { bundles.resize(num_spout); for (int i = 0; i < bundles.size(); i++) { string channel_name = ofVAArgsToString("%s_%u - Resolume Arena", spout_prefix.c_str(), i); printf("create spout receiver with channel name: %s\n", channel_name.c_str()); bundles[i].receiver.init(channel_name); } } } } { ofFbo::Settings s; s.width = screen_width * num_spout; s.height = screen_height; s.useDepth = false; s.colorFormats.emplace_back(GL_RGBA); mFbo.reset(new ofFbo); mFbo->allocate(s); } }
string ofApp::getGuiFilename(ofxGuiGroupRef gui) { return ofVAArgsToString("settings/%s_setting.xml", gui->getName().c_str()); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetVerticalSync(true); ofSetLogLevel(OF_LOG_VERBOSE); grabber.initGrabber(320, 240); //int quality = settings.getValue("settings:quality",48); //int keyframe_freq = settings.getValue("settings:keyframe-freq",64); //bool keyframe_auto = settings.getValue("settings:keyframe-auto",true); //string server = settings.getValue("settings:server","91.121.134.23"); //int port = settings.getValue("settings:port",8002); //string mount = settings.getValue("settings:mount","kinect.ogg"); //string passwd = settings.getValue("settings:passwd","myd9v"); //int width = settings.getValue("settings:width",320); //int height = settings.getValue("settings:height",240); int quality = 48; int keyframe_freq = 64; bool keyframe_auto = true; string server = "127.0.0.1"; int port = 8002; string mount = "kinect.ogg"; string passwd = "myd9v"; int width = 640; int height = 480; /*"v4l2src device=/dev/video0 ! video/x-raw-yuv,width=320,height=240 ! " "queue ! videorate ! video/x-raw-yuv,framerate=25/2 ! " "videoscale ! video/x-raw-yuv,width=320,height=240 ! " "ffmpegcolorspace ! tee name=tscreen ! queue ! " "autovideosink tscreen. ! queue ! " "theoraenc quality=16 ! queue ! " "oggmux name=mux pulsesrc ! audio/x-raw-int,rate=22050,channels=1 ! queue ! audioconvert ! vorbisenc quality=0.2 ! queue ! mux. mux. ! queue ! " "shout2send ip=www.giss.tv port=8000 mount=mountpoint.ogg password=xxxxx streamname= description= genre= url=";*/ string appsrc; string videorate; string videoscale; if( 1 ){ appsrc = "appsrc name=video_src is-live=true do-timestamp=true ! " "video/x-raw-rgb,width=640,height=480,depth=24,bpp=24,framerate=30/1,endianness=4321,red_mask=16711680, green_mask=65280, blue_mask=255 ! queue ! "; videorate = "videorate ! video/x-raw-rgb,depth=24,bpp=24,framerate=25/2,endianness=4321,red_mask=16711680, green_mask=65280, blue_mask=255 ! "; videoscale = "videoscale ! video/x-raw-rgb,width=" + ofToString(width) + ",height=" + ofToString(height) + ",depth=24,bpp=24,endianness=4321,red_mask=16711680, green_mask=65280, blue_mask=255 ! "; }else{ appsrc = "appsrc name=video_src is-live=true do-timestamp=true ! " "video/x-raw-gray,width=640,height=480,depth=8,bpp=8,framerate=30/1 ! queue ! "; videorate = "videorate ! video/x-raw-gray,depth=8,bpp=8,framerate=25/2 ! "; videoscale = "videoscale ! video/x-raw-gray,width=" + ofToString(width) + ",height=" + ofToString(height) + ",depth=8,bpp=8 ! "; } string colorspace = " ffmpegcolorspace ! video/x-raw-yuv,width=" + ofToString(width) + ",height=" + ofToString(height) + " ! "; string theoraenc = ofVAArgsToString("theoraenc quality=%d keyframe-auto=%s keyframe-freq=%d ! queue ! ",quality,keyframe_auto?"true":"false",keyframe_freq); string audio = "oggmux name=mux pulsesrc ! audio/x-raw-int,rate=22050,channels=1 ! queue ! audioconvert ! vorbisenc quality=0.2 ! queue ! mux. mux. ! queue ! "; string shoutcast = ofVAArgsToString("shout2send name=shoutsink ip=%s port=%d mount=%s password=%s streamname= description= genre= url=",server.c_str(),port,mount.c_str(),passwd.c_str()); string pipeline = appsrc + videorate + videoscale + colorspace + theoraenc + audio + shoutcast; /*ofVAArgsToString("appsrc name=video_src is-live=true do-timestamp=true ! " "video/x-raw-rgb,width=640,height=480,depth=24,bpp=24,framerate=30/1,endianness=4321,red_mask=16711680, green_mask=65280, blue_mask=255 ! queue ! " "videorate ! video/x-raw-rgb,depth=24,bpp=24,framerate=25/2,endianness=4321,red_mask=16711680, green_mask=65280, blue_mask=255 ! videoscale ! " "video/x-raw-rgb,width=%d,height=%d,depth=24,bpp=24,endianness=4321,red_mask=16711680, green_mask=65280, blue_mask=255 ! ffmpegcolorspace ! " "video/x-raw-yuv,width=%d,height=%d ! theoraenc quality=%d keyframe-auto=%s keyframe-freq=%d ! " "oggmux ! shout2send name=shoutsink ip=%s port=%d mount=%s password=%s streamname= description= genre= url=" ,width,height,width,height,quality,keyframe_auto?"true":"false",keyframe_freq,server.c_str(),port,mount.c_str(),passwd.c_str());*/ gst.setPipelineWithSink(pipeline,"shoutsink",false); gstSrc = (GstAppSrc*)gst_bin_get_by_name(GST_BIN(gst.getPipeline()),"video_src"); if(gstSrc){ gst_app_src_set_stream_type (gstSrc,GST_APP_STREAM_TYPE_STREAM); g_object_set (G_OBJECT(gstSrc), "format", GST_FORMAT_TIME, NULL); } pixels.allocate(640,480,OF_IMAGE_COLOR); gst.play(); }
void ofFileLoggerChannel::log(ofLogLevel logLevel, const string & module, const char* format, va_list args){ file << module << ": " << ofGetLogLevelName(logLevel) << ": "; file << ofVAArgsToString(format,args) << endl; }
void ofxAvahiCoreBrowser::resolve_cb( AvahiSServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *address, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, ofxAvahiCoreBrowser* browser) { assert(r); /* Called whenever a service has been resolved successfully or timed out */ switch (event) { case AVAHI_RESOLVER_FAILURE: ofLogError(LOG_NAME) << "(Resolver) Failed to resolve service '" << name << "' of type '" << type << "' in domain '" << domain << "':" << avahi_strerror(avahi_server_errno(browser->server)); break; case AVAHI_RESOLVER_FOUND: { char a[AVAHI_ADDRESS_STR_MAX], *t; ofLogNotice(LOG_NAME) << "(Resolver) Service '" << name << "' of type '" << type << "' in domain '" << domain; avahi_address_snprint(a, sizeof(a), address); t = avahi_string_list_to_string(txt); ofLogNotice(LOG_NAME) << ofVAArgsToString( "\t%s:%u (%s)\n" "\tTXT=%s\n" "\tcookie is %u\n" "\tis_local: %i\n" "\twide_area: %i\n" "\tmulticast: %i\n" "\tcached: %i\n", host_name, port, a, t, avahi_string_list_get_service_cookie(txt), !!(flags & AVAHI_LOOKUP_RESULT_LOCAL), !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA), !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST), !!(flags & AVAHI_LOOKUP_RESULT_CACHED)); ofxAvahiService service; service.domain = domain; service.host_name = host_name; service.ip = a; service.name = name; service.port = port; ofNotifyEvent(browser->serviceNewE,service); avahi_free(t); break; } } avahi_s_service_resolver_free(r); }
void ofxThreadedLoggerChannel::log(ofLogLevel level, const string &module, const char *format, va_list args) { log(level, module, ofVAArgsToString(format,args)); }