Train Youself → GStreamer basic-tutorial-1: C + VS2019
If you have trouble 😟 understanding the Android Tutorials of GStreamer, you can wind back to the C basic Tutorials, which have more detail 😇 to describe how the GStreamer plugin works 🛠.
— === Menu === —
🍬1. Download 1.8.13
♖…………➕ Path: Add bin Directory
♖…………➕ System variable
♖…………📹 CMD — — Video Test
♖…………🏓 CMD — — Pingpong Test
🍖 2. Download the Tutorials
👨💼 3. VS2019 — — tutorials.sln
🐭4. Fix basic-tutorial-1
♖…………👷🏿 Working Directory
♖………… ⎌ C++ Additional Include
♖…………📞 Linker
👨🏫5. Analyze basic-tutorial-1
♖…………3️⃣ Variables
♖…………⚗️ Source
♖…………🚚 bus → Express Mail
♖…………♻️ Recycle
👻6. Test with the Wrong Link
🍬1. Download 1.8.13 …… →Menu
Please install the VS2019 Community Edition from Microsoft at first.
MSVC 64-bit (VS 2019, Release CRT)
- 1.18.3 runtime installer ← First
- 1.18.3 development installer ← Second
Please install them in order. I will install mine at “D:\gstreamer”.
After that, please open your Windows Environment:
The root path has installed automatically.
➕ Path: Add bin Directory…… →Menu
Example:D:\gstreamer\1.0\msvc_x86_64\bin
➕ System variable…… →Menu
Example: D:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0
📹 CMD — — Video Test…… →Menu
Please turn on the CMD terminal:
gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
Pass? If not, please check your path.
🏓 CMD — — Pingpong Test…… →Menu
gst-launch-1.0 -v videotestsrc pattern=ball ! video/x-raw,width=320,height=240 ! videoconvert ! tee ! autovideosink device=0
👨💼 3. VS2019 — — tutorials.sln…… →Menu
- gst-docs-master\examples\tutorials\vs2010
🏑Double click — — tutorials.sln
Upgrade? Yes.
In VS2019,
Now, let’s begin the tutorial one by one.
🐭4. Fix basic-tutorial-1…… →Menu
🚒 Damn it, we cannot run the tutorial.
It has some path & library issues. Let’s fix the property.
👷🏿 Working Directory…… →Menu
Example: D:\gstreamer\1.0\msvc_x86_64\bin
⎌ C++ Additional Include …… →Menu
📞 Linker …… →Menu
🎖️ General — — Library
➽ Input — — Dependencies
Done.
Let’s move back to the C file:
No more error.
👨🏫5. Analyze basic-tutorial-1…… →Menu
#include <gst/gst.h>int
main (int argc, char *argv[])
{
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;/* Initialize GStreamer */
gst_init (&argc, &argv);/* Build the pipeline */
pipeline =
gst_parse_launch
("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
NULL);/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg =
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
It’s in one big main.
3️⃣ Variables…… →Menu
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;
pipeline → Media
bus & msg → They are partners. The bus runs in a delivery cycle and the mail is the message.
⚗️ Source…… →Menu
pipeline =
gst_parse_launch
("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
NULL);
🚚 bus → Express Mail…… →Menu
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg =
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
The mails: GST_MESSAGE_ERROR, GST_MESSAGE_EOS
♻️ Recycle…… →Menu
/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
Recycle variables back to the memory. You’d do it in order.
Let’s run:
Nice! The project is working fine.
👻6. Test with the Wrong Link…… →Menu
Let’s change the URI to see what happened:
D:\gstreamer\gst-docs-master\examples\tutorials\vs2010\x64\Debug\basic-tutorial-1.exe (process 26668) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
Nothing shows up. The basic tutorial 1 has no error checking.