Hi
Code is below ------------------------------------------------------------------------------------------------------------------------------------------- void NeedDataCallback(GstAppSrc* appsrc, guint length, gpointer user_data) { boost::mutex::scoped_lock(pushBufferFlagMutex); needsData = true; } void EnoughDataCallback(GstAppSrc* appsrc, gpointer user_data) { boost::mutex::scoped_lock(pushBufferFlagMutex); std::cout << "EnoughDataCallback!\n"; needsData = false; } gboolean SeekDataCallback(GstAppSrc* appsrc, guint64 offset, gpointer user_data) { return false; } bool SendBUF(GstBuffer* buffer) { boost::mutex::scoped_lock(pushBufferFlagMutex); if (!needsData) { return false; } if (buffer) { if (needsData){ GstFlowReturn ret = gst_app_src_push_buffer((GstAppSrc*)appsrc, buffer); // buffer released automatically g_print("\n%d\n",ret); } } return true; } void Process_frame0(){ GstSample* sample; GstMapInfo map; GstStructure* s; GstBuffer* buffer; GstCaps* caps; GstMemory* mem; int height, width, size; int count=0; void* map_data; while(is_streaming){ if(appSinkPipeline0->GetIsNewFrameAvailable()){ appSinkPipeline0->GetLatestSample(&sample); caps = gst_sample_get_caps(sample); buffer = gst_sample_get_buffer(sample); s = gst_caps_get_structure(caps, 0); gst_structure_get_int(s, "height", &height); gst_structure_get_int(s, "width", &width); size = gst_buffer_get_size(buffer); if (gst_buffer_map (buffer, &map, GST_MAP_READ)) { cv::Mat frame(height, width, CV_8UC3,map.data, cv::Mat::AUTO_STEP); std::string msg ="Copy Right"; cv::Point origin(0,0+13); cv::putText( frame, msg, origin, 1, 1, RED); // cv::namedWindow("View_CV"); // cv::imshow("cam0",frame); // cv::waitKey(1); // cv::waitKey(0); gst_buffer_unmap (buffer, &map); gst_buffer_ref(buffer); SendBUF(buffer); } gst_sample_unref (sample); appSinkPipeline0->ReleaseFrameBuffer(); } else { } } int main (int argc, char *argv[]) { XInitThreads(); boost::thread g_main_loop_thread0; GstAppSinkCallbacks appsinkCallbacks; GstAppSrcCallbacks appsrcCallbacks; appSinkPipeline0 = new GstAppSinkPipeline(); gst_init(&argc, &argv); GstElement *conv, *encoder, *rtppay, *udpsink; appSinkPipeline0->Initialize(SINK0,"APP_SINK0"); appSinkPipeline0->set_is_streaming(true); appSinkPipeline0->SetPipelineState(GST_STATE_PLAYING); GstElement *pipeline_sink, *sink,*pipeline_src,*src ; gint width, height; GstSample *sample; gchar *descr,*src_pip_str; GError *error = NULL; gint64 duration, position; GstStateChangeReturn ret; gboolean res; GstMapInfo map; pipeline_src = gst_pipeline_new("pipeline_src"); appsrc = gst_element_factory_make ("appsrc", "APP_SRC"); conv = gst_element_factory_make ("videoconvert", "conv"); encoder = gst_element_factory_make ("x265enc", "encoder"); rtppay = gst_element_factory_make ("rtph265pay", "rtppay"); udpsink = gst_element_factory_make ("udpsink", "sink"); g_object_set (G_OBJECT (rtppay), "ssrc",1, "pt",96, "config-interval",5, "sprop-parameter-sets","12345",NULL); g_object_set (G_OBJECT (appsrc), "caps", gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING, "BGR", "width", G_TYPE_INT, 640, "height", G_TYPE_INT, 480, "framerate", GST_TYPE_FRACTION, 30, 1, NULL), NULL); g_object_set( udpsink, "host", "127.0.0.1", NULL ); g_object_set( udpsink, "port", 3221, NULL ); g_object_set( udpsink, "sync", false, NULL ); g_object_set( udpsink, "async", false, NULL ); appsrcCallbacks.need_data = NeedDataCallback; appsrcCallbacks.enough_data = EnoughDataCallback; appsrcCallbacks.seek_data = SeekDataCallback; gst_app_src_set_callbacks(GST_APP_SRC(appsrc), &appsrcCallbacks, NULL, (GDestroyNotify)DestroyCallback_src); gst_app_src_set_max_bytes(GST_APP_SRC(appsrc), 0); g_object_set (G_OBJECT (appsrc), "stream-type", 0, "format", GST_FORMAT_TIME, NULL); gst_bin_add_many (GST_BIN (pipeline_src), appsrc, conv, encoder, rtppay, udpsink, NULL); gst_element_link_many (appsrc, conv, encoder, rtppay, udpsink , NULL); /* setup appsrc */ GstStateChangeReturn ret_src_set = gst_element_set_state(pipeline_src,GST_STATE_PLAYING); if (ret_src_set == GST_STATE_CHANGE_FAILURE) { g_printerr("Unable to set the pipeline_sink to the playing state"); gst_object_unref(pipeline_src); return false; } g_main_loop_thread0 = boost::thread(&Process_frame0); g_main_loop_thread0.join(); } ------------------------------------------------------------------------------------------------------------------------------------------- At the same time i use “ sudo tcpdump -i lo dst port 3221” ==================================================== tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes ==================================================== So, it seems that the appsrc didn't send and data by udpsink. I don't know where is wrong. Can someone give me some hint ??? Thanks a lot. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |