int64_t ofGstUtils::getDurationNanos() const{ GstFormat format = GST_FORMAT_TIME; #if GST_VERSION_MAJOR==0 if(!gst_element_query_duration(getPipeline(),&format,&durationNanos)) ofLogWarning("ofGstUtils") << "getDurationNanos(): couldn't query time duration"; #else if(!gst_element_query_duration(getPipeline(),format,&durationNanos)) ofLogWarning("ofGstUtils") << "getDurationNanos(): couldn't query time duration"; #endif return durationNanos; }
ulong ofGstUtils::getDurationNanos(){ GstFormat format = GST_FORMAT_TIME; #if GST_VERSION_MAJOR==0 if(!gst_element_query_duration(getPipeline(),&format,&durationNanos)) gLogManager.log("GStreamer: cannot query time duration",ELL_WARNING); #else if(!gst_element_query_duration(getPipeline(),format,&durationNanos)) gLogManager.log("GStreamer: cannot query time duration"); #endif return durationNanos; }
guint64 ofGstUtils::getDurationNanos(){ GstFormat format = GST_FORMAT_TIME; if(!gst_element_query_duration(getPipeline(),&format,&durationNanos)) ofLog(OF_LOG_WARNING,"GStreamer: cannot query time duration"); return durationNanos; }
void OkcViewDisplay::drawData(){ Pipeline* pl = getPipeline(); switch (pl->getPipelineType()) { case XmdvTool::PLTYPE_FLATNORMAL : case XmdvTool::PLTYPE_DIMR : drawDataFlatNormal(); break; case XmdvTool::PLTYPE_SBB : drawDataSBB(); break; } }
static jint nativeSetPipeline(JNIEnv *env, jobject thiz, ID_TYPE id_pipeline, jobject pipeline_obj) { ENTER(); jint result = JNI_ERR; ConvertPipeline *pipeline = reinterpret_cast<ConvertPipeline *>(id_pipeline); if (pipeline) { IPipeline *target_pipeline = getPipeline(env, pipeline_obj); result = pipeline->setPipeline(target_pipeline); } RETURN(result, jint); }
gpu::PipelinePointer DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool emmisive, bool depthBias) { SimpleProgramKey config{textured, culled, emmisive, depthBias}; gpu::PipelinePointer pipeline = getPipeline(config); batch.setPipeline(pipeline); gpu::ShaderPointer program = (config.isEmissive()) ? _emissiveShader : _simpleShader; int glowIntensity = program->getUniforms().findLocation("glowIntensity"); batch._glUniform1f(glowIntensity, 1.0f); if (!config.isTextured()) { // If it is not textured, bind white texture and keep using textured pipeline batch.setResourceTexture(0, DependencyManager::get<TextureCache>()->getWhiteTexture()); } batch.setResourceTexture(NORMAL_FITTING_MAP_SLOT, DependencyManager::get<TextureCache>()->getNormalFittingTexture()); return pipeline; }
bool ofGstUtils::gstHandleMessage(GstBus * bus, GstMessage * msg){ if(appsink && appsink->on_message(msg)) return true; /*ofLogVerbose("ofGstUtils") << "gstHandleMessage(): got " << GST_MESSAGE_TYPE_NAME(msg) << " message from " << GST_MESSAGE_SRC_NAME(msg);*/ switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_BUFFERING: gint pctBuffered; gst_message_parse_buffering(msg,&pctBuffered); ofLogVerbose("ofGstUtils") << "gstHandleMessage(): buffering " << pctBuffered; if(pctBuffered<100){ gst_element_set_state (gstPipeline, GST_STATE_PAUSED); }else if(!bPaused){ gst_element_set_state (gstPipeline, GST_STATE_PLAYING); } break; #if GST_VERSION_MAJOR==0 case GST_MESSAGE_DURATION:{ GstFormat format=GST_FORMAT_TIME; gst_element_query_duration(gstPipeline,&format,&durationNanos); }break; #else case GST_MESSAGE_DURATION_CHANGED: gst_element_query_duration(gstPipeline,GST_FORMAT_TIME,&durationNanos); break; #endif case GST_MESSAGE_STATE_CHANGED:{ GstState oldstate, newstate, pendstate; gst_message_parse_state_changed(msg, &oldstate, &newstate, &pendstate); if(isStream && newstate==GST_STATE_PAUSED && !bPlaying ){ bLoaded = true; bPlaying = true; if(!bPaused){ //ofLogVerbose("ofGstUtils") << "gstHandleMessage(): setting stream pipeline to play"; play(); } } /*ofLogVerbose("ofGstUtils") << "gstHandleMessage(): " << GST_MESSAGE_SRC_NAME(msg) << " state changed from " << getName(oldstate) << " to " << getName(newstate) << " (" + getName(pendstate) << ")";*/ }break; case GST_MESSAGE_ASYNC_DONE: ofLogVerbose("ofGstUtils") << "gstHandleMessage(): async done"; break; case GST_MESSAGE_ERROR: { GError *err; gchar *debug; gst_message_parse_error(msg, &err, &debug); gchar * name = gst_element_get_name(GST_MESSAGE_SRC (msg)); ofLogError("ofGstUtils") << "gstHandleMessage(): embedded video playback halted for plugin, module " << name << " reported: " << err->message; g_free(name); g_error_free(err); g_free(debug); gst_element_set_state(GST_ELEMENT(gstPipeline), GST_STATE_NULL); }break; case GST_MESSAGE_EOS:{ ofLogVerbose("ofGstUtils") << "gstHandleMessage(): end of the stream"; bool isClosing = closing; eos_cb(); if(isClosing){ busWatchID = 0; return false; } switch(loopMode){ case OF_LOOP_NORMAL:{ GstFormat format = GST_FORMAT_TIME; GstSeekFlags flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT); if(speed>0){ if(!gst_element_seek(GST_ELEMENT(gstPipeline), speed, format, flags, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, -1)) { ofLogWarning("ofGstUtils") << "gstHandleMessage(): unable to seek"; } }else if(speed<0){ if(!gst_element_seek(GST_ELEMENT(gstPipeline),speed, format, flags, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, durationNanos-1000000)) { ofLogWarning("ofGstUtils") << "gstHandleMessage(): unable to seek"; } } }break; case OF_LOOP_PALINDROME:{ GstFormat format = GST_FORMAT_TIME; GstSeekFlags flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH |GST_SEEK_FLAG_KEY_UNIT); gint64 pos; #if GST_VERSION_MAJOR==0 gst_element_query_position(GST_ELEMENT(gstPipeline),&format,&pos); #else gst_element_query_position(GST_ELEMENT(gstPipeline),format,&pos); #endif float loopSpeed; if(pos>0) loopSpeed=-speed; else loopSpeed=speed; if(!gst_element_seek(GST_ELEMENT(gstPipeline), loopSpeed, GST_FORMAT_UNDEFINED, flags, GST_SEEK_TYPE_NONE, 0, GST_SEEK_TYPE_NONE, 0)) { ofLogWarning("ofGstUtils") << "gstHandleMessage(): unable to seek"; } }break; default: break; } }break; case GST_MESSAGE_LATENCY: gst_bin_recalculate_latency (GST_BIN (getPipeline())); break; case GST_MESSAGE_REQUEST_STATE: { GstState state; gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (msg)); gst_message_parse_request_state (msg, &state); gst_element_set_state (getPipeline(), state); g_free (name); break; } case GST_MESSAGE_HAVE_CONTEXT:{ GstContext *context; const gchar *context_type; gchar *context_str; gst_message_parse_have_context (msg, &context); context_type = gst_context_get_context_type (context); context_str = gst_structure_to_string (gst_context_get_structure (context)); ofLogNotice("ofGstUtils","Got context from element '%s': %s=%s\n", GST_ELEMENT_NAME (GST_MESSAGE_SRC (msg)), context_type, context_str); g_free (context_str); gst_context_unref (context); break; } default: ofLogVerbose("ofGstUtils") << "gstHandleMessage(): unhandled message from " << GST_MESSAGE_SRC_NAME(msg); break; } return true; }
bool ofGstVideoUtils::setPipeline(string pipeline, ofPixelFormat pixelFormat, bool isStream, int w, int h){ internalPixelFormat = pixelFormat; #ifndef OF_USE_GST_GL string caps; #if GST_VERSION_MAJOR==0 switch(pixelFormat){ case OF_PIXELS_MONO: caps="video/x-raw-gray, depth=8, bpp=8"; break; case OF_PIXELS_RGBA: caps="video/x-raw-rgb, depth=24, bpp=32, endianness=4321, red_mask=0xff0000, green_mask=0x00ff00, blue_mask=0x0000ff, alpha_mask=0x000000ff"; break; case OF_PIXELS_BGRA: caps="video/x-raw-rgb, depth=24, bpp=32, endianness=4321, red_mask=0x0000ff, green_mask=0x00ff00, blue_mask=0xff0000, alpha_mask=0x000000ff"; break; case OF_PIXELS_RGB: default: caps="video/x-raw-rgb, depth=24, bpp=24, endianness=4321, red_mask=0xff0000, green_mask=0x00ff00, blue_mask=0x0000ff, alpha_mask=0x000000ff"; break; } #else if(pixelFormat!=OF_PIXELS_NATIVE){ caps="video/x-raw, format="+getGstFormatName(pixelFormat); }else{ caps = "video/x-raw,format={RGBA,BGRA,RGB,BGR,RGB16,GRAY8,YV12,I420,NV12,NV21,YUY2}"; } #endif if(w!=-1 && h!=-1){ caps+=", width=" + ofToString(w) + ", height=" + ofToString(h); } string pipeline_string = pipeline + " ! appsink name=ofappsink enable-last-sample=0 caps=\"" + caps + "\""; if((w==-1 || h==-1) || pixelFormat==OF_PIXELS_NATIVE || allocate(w,h,pixelFormat)){ return setPipelineWithSink(pipeline_string,"ofappsink",isStream); }else{ return false; } #else string pipeline_string = pipeline + " ! glcolorscale name=gl_filter ! appsink name=ofappsink enable-last-sample=0 caps=\"video/x-raw,format=RGBA\""; bool ret; if((w==-1 || h==-1) || pixelFormat==OF_PIXELS_NATIVE || allocate(w,h,pixelFormat)){ ret = setPipelineWithSink(pipeline_string,"ofappsink",isStream); }else{ ret = false; } auto glfilter = gst_bin_get_by_name(GST_BIN(getPipeline()),"gl_filter"); #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) glXMakeCurrent (ofGetX11Display(), None, 0); glDisplay = (GstGLDisplay *)gst_gl_display_x11_new_with_display(ofGetX11Display()); glContext = gst_gl_context_new_wrapped (glDisplay, (guintptr) ofGetGLXContext(), GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL); g_object_set (G_OBJECT (glfilter), "other-context", glContext, NULL); // FIXME: this seems to be the way to add the context in 1.4.5 // // GstBus * bus = gst_pipeline_get_bus (GST_PIPELINE(gstPipeline)); // gst_bus_enable_sync_message_emission (bus); // g_signal_connect (bus, "sync-message", G_CALLBACK (sync_bus_call), this); // gst_object_unref(bus); glXMakeCurrent (ofGetX11Display(), ofGetX11Window(), ofGetGLXContext()); #elif defined(TARGET_OPENGLES) cout << "current display " << ofGetEGLDisplay() << endl; eglMakeCurrent (eglGetDisplay(EGL_DEFAULT_DISPLAY), 0,0, 0); glDisplay = (GstGLDisplay *)gst_gl_display_egl_new_with_egl_display(eglGetDisplay(EGL_DEFAULT_DISPLAY)); glContext = gst_gl_context_new_wrapped (glDisplay, (guintptr) ofGetEGLContext(), GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL); g_object_set (G_OBJECT (glfilter), "other-context", glContext, NULL); // FIXME: this seems to be the way to add the context in 1.4.5 // // GstBus * bus = gst_pipeline_get_bus (GST_PIPELINE(gstPipeline)); // gst_bus_enable_sync_message_emission (bus); // g_signal_connect (bus, "sync-message", G_CALLBACK (sync_bus_call), this); // gst_object_unref(bus); eglMakeCurrent (ofGetEGLDisplay(), ofGetEGLSurface(), ofGetEGLSurface(), ofGetEGLContext()); #endif return ret; #endif }
const vx::gl::ProgramPipeline* ShaderManager::getPipeline(const char* id) const { return getPipeline(vx::make_sid(id)); }