zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    [SCOI2012]滑雪与时间胶囊
    [SCOI2012]喵星球上的点名
    SDOI2012 Round1 day2 拯救小云公主(dis)解题报告
    SDOI2012 Round1 day2 象棋(chess)解题报告
    SDOI2012 Round1 day2 集合(set)解题报告
    [Sdoi2014]数数[数位dp+AC自动机]
    [NOI2013]快餐店
    java 日期的格式化 输入/输出
    elastic search 查询语句
    elasticsearch数据迁移——elasticsearch-dump使用
  • 原文地址:https://www.cnblogs.com/super119/p/1924418.html
Copyright © 2011-2022 走看看