From 591b1cf7e05c3e0f6617cf1b3c6c88b84672355f Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 23 Jul 2023 08:04:09 -0700 Subject: [PATCH] adding in gstreamer working although another window created and meson with it --- compile_commands.json | 13 +++++++------ meson.build | 3 ++- meson.sh | 5 +++++ src/main.cpp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/compile_commands.json b/compile_commands.json index 674eac3..4b966b0 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -1,7 +1,8 @@ [ -{ - "directory": "/home/talksik/Code/flowy/client", - "command": "/usr/bin/c++ -I/usr/include/sigc++-3.0 -I/usr/lib/x86_64-linux-gnu/sigc++-3.0/include -I/usr/include/gtk-4.0/unix-print -I/usr/include/gtk-4.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gtkmm-4.0 -I/usr/lib/gtkmm-4.0/include -I/usr/include/pangomm-2.48 -I/usr/lib/pangomm-2.48/include -I/usr/include/giomm-2.68 -I/usr/lib/giomm-2.68/include -I/usr/include/glibmm-2.68 -I/usr/lib/glibmm-2.68/include -I/usr/include/cairomm-1.16 -I/usr/lib/cairomm-1.16/include -g -o CMakeFiles/flowy.dir/src/main.cpp.o -c /home/talksik/Code/flowy/client/src/main.cpp", - "file": "/home/talksik/Code/flowy/client/src/main.cpp" -} -] \ No newline at end of file + { + "directory": "/home/talksik/Code/flowy/client/build", + "command": "c++ -Iflowy.p -I. -I.. -I/usr/include/sigc++-3.0 -I/usr/lib/x86_64-linux-gnu/sigc++-3.0/include -I/usr/include/gtk-4.0/unix-print -I/usr/include/gtk-4.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gtkmm-4.0 -I/usr/lib/gtkmm-4.0/include -I/usr/include/pangomm-2.48 -I/usr/lib/pangomm-2.48/include -I/usr/include/giomm-2.68 -I/usr/lib/giomm-2.68/include -I/usr/include/glibmm-2.68 -I/usr/lib/glibmm-2.68/include -I/usr/include/cairomm-1.16 -I/usr/lib/cairomm-1.16/include -I/usr/include/gstreamer-1.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -g -pthread -mfpmath=sse -msse -msse2 -MD -MQ flowy.p/src_main.cpp.o -MF flowy.p/src_main.cpp.o.d -o flowy.p/src_main.cpp.o -c ../src/main.cpp", + "file": "../src/main.cpp", + "output": "flowy.p/src_main.cpp.o" + } +] diff --git a/meson.build b/meson.build index a6cccd4..298bd06 100644 --- a/meson.build +++ b/meson.build @@ -1,9 +1,10 @@ project('flowy', 'cpp') gtkmm_dep = dependency('gtkmm-4.0', version: '>= 4.6.0') +gstreamer_dep = dependency('gstreamer-1.0') exe_file = executable('flowy', 'src/main.cpp', - dependencies: gtkmm_dep, + dependencies: [gtkmm_dep, gstreamer_dep], win_subsystem: 'windows', ) diff --git a/meson.sh b/meson.sh index 3b83561..9fed295 100755 --- a/meson.sh +++ b/meson.sh @@ -7,6 +7,11 @@ echo "Compiling..." cd build meson compile + +echo "Placing compile_commands.json in root directory..." +rm ../compile_commands.json +cp compile_commands.json ../ + echo "Running..." ./flowy diff --git a/src/main.cpp b/src/main.cpp index 2849d4d..79d0ee7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,41 @@ #include "gtkmm/button.h" +#include #include #include #include "main.h" +void test_gstreamer() { + GstElement *pipeline = nullptr; + GstBus *bus = nullptr; + GstMessage *msg = nullptr; + + // building pipeline + pipeline = + gst_parse_launch("playbin " + "uri=https://www.freedesktop.org/software/gstreamer-sdk/" + "data/media/sintel_trailer-480p.webm", + nullptr); + + // start playing + gst_element_set_state(pipeline, GST_STATE_PLAYING); + + // wait until error or EOS ( End Of Stream ) + bus = gst_element_get_bus(pipeline); + msg = gst_bus_timed_pop_filtered( + bus, GST_CLOCK_TIME_NONE, + static_cast(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)); + + // free memory + if (msg != nullptr) + gst_message_unref(msg); + gst_object_unref(bus); + gst_element_set_state(pipeline, GST_STATE_NULL); + gst_object_unref(pipeline); +} + MyWindow::MyWindow() { + set_title("Basic application"); Gtk::Button button("start capture"); @@ -22,6 +53,9 @@ MyWindow::~MyWindow() {} void MyWindow::startCapture() { std::cout << "start capture" << std::endl; } int main(int argc, char **argv) { + gst_init(&argc, &argv); + test_gstreamer(); + auto app = Gtk::Application::create("org.gtkmm.examples.base"); return app->make_window_and_run(argc, argv);