{"id":1195,"date":"2024-01-20T22:22:41","date_gmt":"2024-01-20T14:22:41","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=1195"},"modified":"2024-01-21T09:47:04","modified_gmt":"2024-01-21T01:47:04","slug":"gsteamer-tutorial-1","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=1195","title":{"rendered":"gsteamer tutorial 1"},"content":{"rendered":"<p>GStreamer \u662f\u5982\u6b64\u8457\u540d\u7684\u591a\u5a92\u4f53\u6846\u67b6\uff0c\u5b83\u7684\u7ba1\u9053\u548c\u63d2\u4ef6\u6a21\u5f0f\u4ee4\u4eba\u5370\u8c61\u6df1\u523b\uff0c\u773c\u754c\u5927\u5f00\uff0c\u539f\u6765\u7ba1\u9053\u6a21\u5f0f\u53ef\u4ee5\u73a9\u5f97\u8fd9\u4e48\u7cbe\u5999\u3002<\/p>\n<h2>\u76ee\u6807<\/h2>\n<p>Nothing better to get a first impression about a software library than to print \u201cHello World\u201d on the screen!<\/p>\n<p>\u719f\u6089\u4f7f\u7528\u4efb\u4f55\u4e00\u79cd\u65b0\u7684\u5f00\u53d1\u8f6f\u4ef6\u8bed\u8a00\u6216\u8005\u8f6f\u4ef6\u4ee3\u7801\u5e93\u7684\u65b9\u6cd5\uff0c\u6700\u83ab\u8fc7\u4e8e\u5728\u5c4f\u5e55\u4e0a\u6253\u5370 &quot;Hello world&quot;.<\/p>\n<p>\u800c\u5bf9\u4e8e\u591a\u5a92\u4f53\u6846\u67b6\u6765\u8bf4\uff0c\u64ad\u653e\u4e00\u6bb5\u89c6\u9891\u6bd4 hello world \u66f4\u5408\u9002\u4e8e\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<p>\u4e0b\u9762\u4ee3\u7801\u8fdc\u591a\u4e8e\u4e00\u4e2a\u6807\u51c6\u7684 Hello world, \u4e0d\u8fc7\u591a\u6570\u662f\u521d\u59cb\u5316\u548c\u6e05\u7406\u4ee3\u7801\uff0c\u771f\u6b63\u8d77\u4f5c\u7528\u7684\u4e5f\u5c31\u56db\u884c\u4ee3\u7801\u3002<\/p>\n<p>\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u8fd8\u662f\u770b\u4ee3\u7801\u5427\u3002<\/p>\n<h2>\u7a0b\u5e8f\u6d41\u7a0b<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2024\/01\/image-1705761179274.png\" alt=\"file\" \/><\/p>\n<pre><code>\n@startuml\n\nstart\n:\u521d\u59cb\u5316 gst_init;\n:\u6784\u5efa\u7ba1\u9053 gst_gst_parse_launch;\n:\u5f00\u59cb\u64ad\u653e gst_element_set_state;\n:\u7b49\u5f85\u7ed3\u675f gst_bus_timed_pop_filtered;\n:\u91ca\u653e\u8d44\u6e90 gst_object_unref ...;\nstop\n\n@enduml<\/code><\/pre>\n<h2>\u6e90\u4ee3\u7801<\/h2>\n<pre><code class=\"language-cpp\">\n#include &lt;gst\/gst.h&gt;\n\n#ifdef __APPLE__\n#include &lt;TargetConditionals.h&gt;\n#endif\n\nint\ntutorial_main (int argc, char *argv[])\n{\n  GstElement *pipeline;\n  GstBus *bus;\n  GstMessage *msg;\n\n  \/* Initialize GStreamer *\/\n  gst_init (&amp;argc, &amp;argv);\n\n  \/* Build the pipeline *\/\n  pipeline =\n      gst_parse_launch\n      (&quot;playbin uri=https:\/\/gstreamer.freedesktop.org\/data\/media\/sintel_trailer-480p.webm&quot;,\n      NULL);\n\n  \/* Start playing *\/\n  gst_element_set_state (pipeline, GST_STATE_PLAYING);\n\n  \/* Wait until error or EOS *\/\n  bus = gst_element_get_bus (pipeline);\n  msg =\n      gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,\n      GST_MESSAGE_ERROR | GST_MESSAGE_EOS);\n\n  \/* See next tutorial for proper error message handling\/parsing *\/\n  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {\n    g_error (&quot;An error occurred! Re-run with the GST_DEBUG=*:WARN environment &quot;\n        &quot;variable set for more details.&quot;);\n  }\n\n  \/* Free resources *\/\n  gst_message_unref (msg);\n  gst_object_unref (bus);\n  gst_element_set_state (pipeline, GST_STATE_NULL);\n  gst_object_unref (pipeline);\n  return 0;\n}\n\nint\nmain (int argc, char *argv[])\n{\n#if defined(__APPLE__) &amp;&amp; TARGET_OS_MAC &amp;&amp; !TARGET_OS_IPHONE\n  return gst_macos_main (tutorial_main, argc, argv, NULL);\n#else\n  return tutorial_main (argc, argv);\n#endif\n}\n<\/code><\/pre>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u7531\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\u4e0b\u9762\u51e0\u4e2a\u95ee\u9898\u7684\u7b54\u6848\u4e86\u3002<\/p>\n<ul>\n<li>\n<p>Q. \u5982\u4f55\u521d\u59cb\u5316 GStreamer<br \/>\n\u4f7f\u7528 gst_init<\/p>\n<\/li>\n<li>\n<p>Q. \u5982\u4f55\u6839\u636e\u6587\u672c\u63cf\u8ff0\u5feb\u901f\u6784\u5efa\u7ba1\u9053<\/p>\n<\/li>\n<\/ul>\n<p>\u4f7f\u7528 gst_parse_launch<\/p>\n<ul>\n<li>Q. \u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u81ea\u52a8\u64ad\u653e\u7684\u7ba1\u9053<\/li>\n<\/ul>\n<p>\u4f7f\u7528 playbin<\/p>\n<ul>\n<li>Q. \u5982\u4f55\u544a\u8bc9 GStreamer \u5f00\u59cb\u64ad\u653e<\/li>\n<\/ul>\n<p>\u4f7f\u7528 gst_element_set_state()<\/p>\n<ul>\n<li>Q. \u5982\u4f55\u7b49\u7740\u77a7 Gstreamer \u6765\u641e\u5b9a\u6bcf\u4e00\u4ef6\u4e8b<\/li>\n<\/ul>\n<p>\u4f7f\u7528 gst_element_get_bus() \u548c gst_bus_timed_pop_filtered()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GStreamer \u662f\u5982\u6b64\u8457\u540d\u7684\u591a\u5a92\u4f53\u6846\u67b6\uff0c\u5b83\u7684\u7ba1\u9053\u548c\u63d2\u4ef6\u6a21\u5f0f\u4ee4\u4eba\u5370\u8c61\u6df1\u523b\uff0c\u773c\u754c\u5927\u5f00\uff0c\u539f\u6765\u7ba1\u9053\u6a21\u5f0f\u53ef\u4ee5\u73a9\u5f97\u8fd9\u4e48\u7cbe\u5999\u3002 \u76ee\u6807 Nothing better to get a first impression about a software library than to print \u201cHello World\u201d on the screen! \u719f\u6089\u4f7f\u7528\u4efb\u4f55\u4e00\u79cd\u65b0\u7684\u5f00\u53d1\u8f6f\u4ef6\u8bed\u8a00\u6216\u8005\u8f6f\u4ef6\u4ee3\u7801\u5e93\u7684\u65b9\u6cd5\uff0c\u6700\u83ab\u8fc7\u4e8e\u5728\u5c4f\u5e55\u4e0a\u6253\u5370 &quot;Hello world&quot;. \u800c\u5bf9\u4e8e\u591a\u5a92\u4f53\u6846\u67b6\u6765\u8bf4\uff0c\u64ad\u653e\u4e00\u6bb5\u89c6\u9891\u6bd4 hello world \u66f4\u5408\u9002\u4e8e\u5feb\u901f\u4e0a\u624b\u3002 \u4e0b\u9762\u4ee3\u7801\u8fdc\u591a\u4e8e\u4e00\u4e2a\u6807\u51c6\u7684 Hello world, \u4e0d\u8fc7\u591a\u6570\u662f\u521d\u59cb\u5316\u548c\u6e05\u7406\u4ee3\u7801\uff0c\u771f\u6b63\u8d77\u4f5c\u7528\u7684\u4e5f\u5c31\u56db\u884c\u4ee3\u7801\u3002 \u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u8fd8\u662f\u770b\u4ee3\u7801\u5427\u3002 \u7a0b\u5e8f\u6d41\u7a0b @startuml start :\u521d\u59cb\u5316 gst_init; :\u6784\u5efa\u7ba1\u9053 gst_gst_parse_launch; :\u5f00\u59cb\u64ad\u653e gst_element_set_state; :\u7b49\u5f85\u7ed3\u675f gst_bus_timed_pop_filtered; :\u91ca\u653e\u8d44\u6e90 gst_object_unref &#8230;; stop @enduml \u6e90\u4ee3\u7801 #include &lt;gst\/gst.h&gt; #ifdef __APPLE__ [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=1195\" title=\"Permanent Link to: gsteamer tutorial 1\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1195","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1195"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1195"}],"version-history":[{"count":6,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1195\/revisions"}],"predecessor-version":[{"id":1204,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1195\/revisions\/1204"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}