#include #include int main (int argc, char *argv[]) { GstElement *bin, *rtpbin, *encoder, *payloader; GMainLoop *loop; gst_init (&argc, &argv); loop = g_main_loop_new(NULL, FALSE); bin = gst_pipeline_new("pipe"); fprintf(stderr,"bin: %p\n",bin); if (argc != 4) { printf("Usage :g711send [rtcplocalport-1] [destaddr:port] \n"); return 0; } int port = atoi (argv[1]); char *addr = argv[2]; // first we create our rtpbin object rtpbin = gst_element_factory_make("rtpbin", "rtpbin"); fprintf(stderr,"rtpbin: %p\n",rtpbin); g_object_set(G_OBJECT(rtpbin), "destinations", addr, NULL); g_object_set(G_OBJECT(rtpbin), "rtcp-support", TRUE, NULL); g_object_set(G_OBJECT(rtpbin), "localport", port, NULL); // then our encoder/payloader encoder = gst_element_factory_make("oggdemux", "oggdemux"); parser = gst_element_factory_make("vorbisparse","vorbisparse"); payloader = gst_element_factory_make("rtpvorbispay", "rtpvorbispay"); // add both to the piepline and link them gst_bin_add_many(GST_BIN(bin), rtpbin, encoder,parser, payloader, NULL); gst_element_link_pads(encoder, "src", parser, "sink"); gst_element_link_pads(parser,"src",payloader,"sink"); gst_element_link_pads(payloader, "src", rtpbin, "sink%d"); // our videotestsrc and link it to the encoder GstElement *source = gst_element_factory_make ("filesrc", "file-source"); g_object_set (G_OBJECT (source), "location", argv[3], NULL); //GstElement *testsrc = gst_element_factory_make("audiotestsrc", "alsasrc"); //g_object_set(G_OBJECT(testsrc), "blocksize", 320, NULL); gst_bin_add_many(GST_BIN(bin), source, NULL); gst_element_link_pads(source, "src", encoder, "sink"); // let's start playing gst_element_set_state (bin, GST_STATE_PLAYING); printf (" \n============================================ tube streaming ==================================\n"); //gst_debug_set_threshold_for_name ("rtpbin", 1); //gst_debug_set_threshold_for_name ("rtpsend", 5); //gst_debug_set_threshold_for_name ("*pad*", 5); g_main_loop_run(loop); return 0; }