Created
August 20, 2019 22:15
-
-
Save anselmobattisti/4b0cc100c55e14d51b4ed0a23a1212b6 to your computer and use it in GitHub Desktop.
Simple program in c that uses gstreamer to play a ogg audio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gst/gst.h> | |
// gst-launch-1.0 videotestsrc ! videobalance saturation=0 ! x264enc ! video/x-h264, stream-format=byte-stream ! rtph264pay ! udpsink host=35.153.160.117 port=5000 | |
int main (int argc, char *argv[]) { | |
GstElement *pipeline, *src; | |
GstElement *x264enc; | |
// GstElement *x264enc, | |
// GstElement *rtph264pay, | |
GstElement *autovideosink; | |
// GstElement *udpsink; | |
GstBus *bus; | |
GstMessage *msg; | |
GstStateChangeReturn ret; | |
gst_init(&argc, &argv); | |
pipeline = gst_element_factory_make("pipeline","pipeline"); | |
src = gst_element_factory_make("filesrc","src"); | |
x264enc = gst_element_factory_make("x264enc","x264enc"); | |
autovideosink = gst_element_factory_make ("autovideosink", "autovideosink"); | |
// x264enc = gst_element_factory_make ("x264enc", "x264enc"); | |
// rtph264pay = gst_element_factory_make ("rtph264pay", "rtph264pay"); | |
// udpsink = gst_element_factory_make ("udpsink", "udpsink"); | |
// gst_bin_add_many (GST_BIN (pipeline), src, x264enc, rtph264pay, autovideosink, NULL); | |
// gst_element_link_many (src, x264enc, rtph264pay, autovideosink, NULL); | |
gst_bin_add_many (GST_BIN (pipeline), src, x264enc, autovideosink, NULL); | |
gst_element_link_many (src, x264enc, autovideosink, NULL); | |
g_object_set (G_OBJECT (src), "location", "/home/battisti/versionado/alfa/samples/sample.mp4", NULL); | |
ret = gst_element_set_state (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 (pipeline); | |
return -1; | |
} | |
// host=35.153.160.117 port=5000 | |
bus = gst_element_get_bus (pipeline); | |
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); | |
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; | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment