我正在尝试将gstreamer bash脚本转码为c ++代码,但是我无法将调试日志保存到文件中
这是我的代码
int main(int argc, char *argv[])
{
YoctoLinuxSystem* hola;
//hola->YoctoLinuxSystem();
CustomData DataTest, DataDvi;
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;
GMainLoop *loop;
//vector<string> lines = YoctoLinuxSystem::getCmdOutputAsLines("./scripts/get_system_temps.sh");
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/******************************/
/****AJUSTES GSTREAMER TEST****/
/******************************/
DataTest.source = gst_element_factory_make ("videotestsrc", "source");
DataTest.capsfilter = gst_element_factory_make ("capsfilter","caps");
DataTest.sink = gst_element_factory_make ("imxipuvideosink", "sink");
DataTest.pipeline = gst_pipeline_new ("test-pipeline");
if (!DataTest.pipeline || !DataTest.source || !DataTest.capsfilter || !DataTest.sink) {
g_printerr ("Not all elements could be created.\n");
return -1;
}
/* Modify the source's properties */
g_object_set (DataTest.source, "pattern", 0, NULL);
g_object_set(DataTest.capsfilter, "caps", gst_caps_new_simple("video/x-raw", "framerate", GST_TYPE_FRACTION, 25, 1,"width", G_TYPE_INT, 1920, "height", G_TYPE_INT, 1080, "format", G_TYPE_STRING, "RGB", NULL), NULL);
/* Build the pipeline */
gst_bin_add_many (GST_BIN (DataTest.pipeline), DataTest.source, DataTest.capsfilter, DataTest.sink, NULL);
if (gst_element_link (DataTest.source, DataTest.capsfilter) != TRUE) {
g_printerr ("Elements source-caps could not be linked.\n");
gst_object_unref (DataTest.pipeline);
return -1;
}
if (gst_element_link (DataTest.capsfilter, DataTest.sink) != TRUE) {
g_printerr ("Elements caps-sink could not be linked.\n");
gst_object_unref (DataTest.pipeline);
return -1;
}
gst_element_link_many (DataTest.source, DataTest.capsfilter, DataTest.sink, NULL);
/******************************/
/****AJUSTES GSTREAMER DVI****/
/******************************/
DataDvi.source = gst_element_factory_make ("v4l2src", "source");
DataDvi.sink = gst_element_factory_make ("imxipuvideosink", "sink");
DataDvi.pipeline = gst_pipeline_new ("test-pipeline");
if (!DataDvi.pipeline || !DataDvi.source || !DataDvi.sink) {
g_printerr ("Not all elements could be created.\n");
return -1;
}
/* Modify the source's properties */
g_object_set (DataDvi.source, "device", "/dev/video0", NULL);
/* Build the pipeline */
gst_bin_add_many (GST_BIN (DataDvi.pipeline), DataDvi.source, DataDvi.sink, NULL);
if (gst_element_link (DataDvi.source, DataDvi.sink) != TRUE) {
g_printerr ("Elements caps-sink could not be linked.\n");
gst_object_unref (DataDvi.pipeline);
return -1;
}
gst_element_link_many (DataDvi.source, DataDvi.sink, NULL);
GST_DEBUG=2;
ifstream fileread;
// fileread.open("/var/log/data.log");
while(1)
{
ifstream fileread("/var/log/data.log");
if (!fileread.good())
{
/* Start playing */
//g_print ("Now playing: \n");
gst_element_set_state (DataDvi.pipeline, GST_STATE_PAUSED);
ret = gst_element_set_state (DataTest.pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.\n");
gst_object_unref (DataTest.pipeline);
return -1;
}
}
else
{
gst_element_set_state (DataTest.pipeline, GST_STATE_PAUSED);
ret = gst_element_set_state (DataDvi.pipeline, GST_STATE_PLAYING);
/*HERE I NEED TO KNOW THE DEBUG OF THE PIPELINE*/
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.\n");
gst_object_unref (DataDvi.pipeline);
return -1;
}
}
}
g_print ("SALE\n");
return 0;
}
我正在使用gstreamer-1.0库,并且已经看到我需要使用GST_DEBUG_FILE,但是我不知道如何从c ++调用这些函数。
谢谢您的帮助!
最佳答案
GST_DEBUG_FILE是环境变量,因此与C ++无关。
您可以使用类似
export GST_DEBUG_FILE=~/gst.log
在运行您的应用程序之前。或在您的bash启动脚本中添加类似的内容。
关于c++ - Gstreamer调试管道C++,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38767313/