vscode调试gstreamer

配置launch.json

vscode的debug和前面的qtcreator实际上是一样的,vscode需要安装Native Debug工具,配置json文件,配置好之后vscode用起来一样方便。

首先,安装Native Debug插件:

配置launch.json

安装好之后,如图所示,选择点击左侧的Run and Debug图标,然后点击"Run and Debug"-> “C++ GDB” -> “default configuration”,就会打开默认的launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "enter program name, for example ${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

修改json中的下面几项,即可以进入调试

program

  • "/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/bin/gst-launch-1.0"

args,格式为:["arg1", "arg2"],必须用空格的地方得用双引号隔开

  • "playbin","uri=http://192.168.31.122/hls/index.m3u8"

environment,格式为: {"name":"var2", "value": "var2_value"}

 {"name":"GST_PLUGIN_SCANNER", "value":"/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/libexec/gstreamer-1.0/gst-plugin-scanner"},
 {"name":"LD_LIBRARY_PATH", "value":"$LD_LIBRARY_PATH:/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/lib/x86_64-linux-gnu"},
 {"name":"GST_PLUGIN_PATH", "value":"/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/lib/x86_64-linux-gnu/gstreamer-1.0"}

完整的launch文件如下:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/bin/gst-launch-1.0",
            // ["arg1", "arg2"]
            "args": [
                "playbin","uri=http://192.168.31.122/hls/index.m3u8"
            ],
            "stopAtEntry": false,
            // "cwd": "${workspaceFolder}",
            "cwd": "/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/subprojects",
            // "cwd": "/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/subprojects/gst-plugins-bad",
            
            "environment": [
                // {"name":"var2", "value": "var2_value"}
                {"name":"GST_PLUGIN_SCANNER", "value":"/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/libexec/gstreamer-1.0/gst-plugin-scanner"},
                {"name":"LD_LIBRARY_PATH", "value":"$LD_LIBRARY_PATH:/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/lib/x86_64-linux-gnu"},
                {"name":"GST_PLUGIN_PATH", "value":"/home/hui/disk4t/codes/gstreamer/gst-open-source/gst-build-1.16.3/inst/lib/x86_64-linux-gnu/gstreamer-1.0"}
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

高版本的配置,注意args部分的区别:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/hui/disk4t/codes/gstreamer/gst-open-source/gstreamer-meson/inst/usr/local/bin/gst-launch-1.0",
            "args": [
                "filesrc", "location=/home/hui/disk4t/media-test/media-files/1.mp4", "!qtdemux!h264parse!avdec_h264!xvimagesink"
            ],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [
                {"name":"GST_PLUGIN_SCANNER", "value":"/home/hui/disk4t/codes/gstreamer/gst-open-source/gstreamer-meson/inst/usr/local/libexec/gstreamer-1.0/gst-plugin-scanner"},
                {"name":"LD_LIBRARY_PATH", "value":"$LD_LIBRARY_PATH:/home/hui/disk4t/codes/gstreamer/gst-open-source/gstreamer-meson/inst/usr/local/lib/x86_64-linux-gnu"},
                {"name":"GST_PLUGIN_PATH", "value":"/home/hui/disk4t/codes/gstreamer/gst-open-source/gstreamer-meson/inst/usr/local/lib/x86_64-linux-gnu/gstreamer-1.0"}
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

播放audio的命令和args的对应写法对比

gst-launch-1.0 filesrc location=/home/hui/disk4t/media-test/media-files/debug/audio.data \
! qtdemux  ! aacparse ! audio/mpeg,stream-format=adts ! avdec_aac_fixed ! audioconvert ! audioresample ! pulsesink
"program": "/home/hui/disk4t/codes/gstreamer/gst-open-source/gstreamer-meson/inst/usr/local/bin/gst-launch-1.0",
"args": [
   "filesrc", "location=/home/hui/disk4t/media-test/media-files/debug/audio.data", "!qtdemux!aacparse!audio/mpeg,stream-format=adts!avdec_aac_fixed!audioconvert!audioresample!pulsesink"
],

F5进入DEBUG模式

设置断点,f5进入debug模式,左侧的callstack看起来很漂亮。如果没有断点成功,就需要检查下前面配置的json中参数,环境变量是否路径正确。

在这里插入图片描述


参考

launch-json-reference

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值