• gst_init之后如何再打开GST DEBUG呢?


    打开gstreamer debug一般方法是:export GST_DEBUG=filesrc:5这样的做法,然后运行程序。但是通过看gstreamer的代码,这个环境变量是在gst_init的时候被读取并设置的,具体是在init_pre这个函数里面。如果程序已经在运行了,gst_init已经做过了,这个时候要打开debug怎么办呢?(Media server就有这样的需求)。

    通过看init_pre中的代码,发现很简单,直接调用gst_debug_set_threshold_for_name或gst_debug_set_default_threshold就可以。下面是测试代码:
    #include <gst/gst.h>
    #include 
    <unistd.h>

    GstElement 
    *pipeline, *source, *sink;

    int main(int argc, char *argv[])
    {
        gst_init(
    &argc, &argv);

        
    // create elements
        pipeline = gst_pipeline_new("test-pipeline");
        source 
    = gst_element_factory_make("filesrc""file-source");
        sink 
    = gst_element_factory_make("fakesink""fake-sink");
        
    if (!pipeline || !source || !sink) {
            g_print(
    "One element could not be created!\n");
            
    return 1;
        }

        
    // set file name
        g_object_set(G_OBJECT(source), "location""/home/eric/rphonenfs/medias/Audios/lddgy.mp3", NULL);

        
    // put all elements into bin
        gst_bin_add_many(GST_BIN(pipeline), source, sink, NULL);

        
    // link together
        gst_element_link_many(source, sink, NULL);

        
    // change state to PAUSED
        g_print("Before debug on, Setting to PAUSED\n");
        gst_element_set_state(pipeline, GST_STATE_PAUSED);
        sleep(
    1);
        g_print(
    "Then we set pipeline to NULL\n");
        gst_element_set_state(pipeline, GST_STATE_NULL);
        
        
    // try to open debug
        g_print("Open debug infos...\n");

        
    // This function call is from "init_pre" which be called in "gst_init_check"
        
    // gst_debug_set_threshold_for_name("filesrc", 5);
        gst_debug_set_default_threshold(5);

        g_print(
    "Rechange pipeline to PAUSED\n");
        gst_element_set_state(pipeline, GST_STATE_PAUSED);
        sleep(
    1);
        g_print(
    "Change pipeline to NULL and terminate.\n");
        gst_element_set_state(pipeline, GST_STATE_NULL);
        gst_object_unref(GST_OBJECT(pipeline));

        
    return 0;
    }
  • 相关阅读:
    ipad与windows互传文件(不需要安装app)
    为WordPress所有的Tags标签添加Nofollow
    为什么应该用网站来替代电商平台是开网店?
    实体转JSON时,值为null的字段丢失问题
    finally 与 return
    URI, URL, and URN
    HTTP
    EasyPoi 一对多数据导入 null值问题
    热点探测
    elasticsearch数据操作02
  • 原文地址:https://www.cnblogs.com/super119/p/1924418.html
Copyright © 2020-2023  润新知