[gst-devel] tcpserversrc restarting (Antoine Martin)

Antoine Martin antoine at nagafix.co.uk
Mon May 17 06:25:14 CEST 2010


libing195 wrote:
> I have improved the tcpserversrc  to a retentive service to receive tcp data continually.
Thanks for that, the only difficulty for me is that my current code is
pure python, and I dont fancy shipping my own gst modules for all the
platforms I want to support..

Have you looked at getting this merged upstream?

Cheers
Antoine


> 
> this is my code:
> 
> struct _GstTCPServerSrc {
>   GstPushSrc element;
> 
> //../Add some gboolean vars
> gboolean    recvError;           default = FALSE;
>  gboolean        bReconnected;  default=TRUE;
> }
> 
> Then   in    gst_tcp_server_src_create():
> 
> static GstFlowReturn
> gst_tcp_server_src_create(GstPushSrc * psrc,
>         GstBuffer ** outbuf) {
>     GstTCPServerSrc *src;
>     GstFlowReturn ret = GST_FLOW_OK;
> /*    static gint indexPocket = 0;
>     int i = 0;*/
> 
>     src = GST_TCP_SERVER_SRC (psrc);
> 
>     if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCP_SERVER_SRC_OPEN))
>         goto wrong_state;
> 
> restart:
> 
> //Libing begin
>     if (src->client_sock_fd.fd >= 0) {
>         if(src->recvError){
> //            g_print("**********Client connection has closed fd=%d clientnum=%d**************\n",
> //                    src->client_sock_fd.fd, src->clientnum);
> 
>             gst_poll_remove_fd(src->fdset, &src->client_sock_fd);
>             gst_poll_fd_ctl_read(src->fdset, &src->server_sock_fd, TRUE);
>             src->client_sock_fd.fd = -1;
>             src->bReconnected = TRUE;
>         }else{
>             /* if we have a client, wait for read */
>             gst_poll_fd_ctl_read(src->fdset, &src->server_sock_fd, FALSE);
>             gst_poll_fd_ctl_read(src->fdset, &src->client_sock_fd, TRUE);
>         }
> 
>     } else {
>         /* else wait on server socket for connections */
>         gst_poll_fd_ctl_read(src->fdset, &src->server_sock_fd, TRUE);
>     }
> //Libing end
> 
> //    g_print("Poll will wait!!!!~~~~~~\n");
> 
>     /* no action (0) is an error too in our case */
>     if ((ret = gst_poll_wait(src->fdset, GST_CLOCK_TIME_NONE)) <= 0) {
>         if (ret == -1 && errno == EBUSY)
>             goto select_cancelled;
>         else
>             goto select_error;
>     }
> 
>     /* if we have no client socket we can accept one now */
>     if (src->client_sock_fd.fd < 0) {
>         if (gst_poll_fd_can_read(src->fdset, &src->server_sock_fd)) {
>             if ((src->client_sock_fd.fd = accept(src->server_sock_fd.fd,
>                     (struct sockaddr *) &src->client_sin,
>                     &src->client_sin_len)) == -1)
>                 goto accept_error;
> 
>             gst_poll_add_fd(src->fdset, &src->client_sock_fd);
>             src->recvError = FALSE;
> 
> /*            g_print("**********Client has connected fd=%d clientnum=%d**************\n",
>                     src->client_sock_fd.fd, src->clientnum);*/
>         }
>         /* and restart now to poll the socket. */
>         goto restart;
>     }
> 
>     GST_LOG_OBJECT(src, "asked for a buffer");
> 
>     switch (src->protocol) {
>         case GST_TCP_PROTOCOL_NONE:{
>             if((ret = gst_tcp_server_src_read_buffer(src, src->client_sock_fd.fd,
>                     src->fdset, outbuf)) == GST_FLOW_OK){
>                 return ret;
>             }else{
>                 g_print("____________Receive Error!\n");
>                 close(src->client_sock_fd.fd);
>                 src->recvError = TRUE;
>                 goto restart;
>             }
>             break;
>         }
>         case GST_TCP_PROTOCOL_GDP:{
>             if (!src->caps_received) {
>                 GstCaps *caps;
>                 gchar *string;
> 
>                 ret = gst_tcp_gdp_read_caps(GST_ELEMENT (src),
>                         src->client_sock_fd.fd, src->fdset, &caps);
> 
>                 if (ret == GST_FLOW_WRONG_STATE)
>                     goto gdp_cancelled;
> 
>                 if (ret != GST_FLOW_OK)
>                     goto gdp_caps_read_error;
> 
>                 src->caps_received = TRUE;
>                 string = gst_caps_to_string(caps);
>                 GST_DEBUG_OBJECT(src, "Received caps through GDP: %s", string);
>                 g_free(string);
> 
>                 gst_pad_set_caps(GST_BASE_SRC_PAD (psrc), caps);
>             }
> 
>             ret = gst_tcp_gdp_read_buffer(GST_ELEMENT (src),
>                     src->client_sock_fd.fd, src->fdset, outbuf);
> 
>             if (ret == GST_FLOW_OK)
>                 gst_buffer_set_caps(*outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (src)));
> 
>             break;
>         }
>         default:
>             /* need to assert as buf == NULL */
>             g_assert("Unhandled protocol type");
>             break;
>     }
> 
>     if (ret == GST_FLOW_OK) {
>         GST_LOG_OBJECT    (src,
>             "Returning buffer from _get of size %d, ts %"
>             GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
>             ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
>             GST_BUFFER_SIZE (*outbuf),
>             GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
>             GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
>             GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
>     }
> 
>     return ret;
> 
>     wrong_state:
>     {
>         GST_DEBUG_OBJECT (src, "connection to closed, cannot read data");
>         return GST_FLOW_WRONG_STATE;
>     }
>     select_error:
>     {
>         GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
>                 ("Select error: %s", g_strerror (errno)));
>         return GST_FLOW_ERROR;
>     }
>     select_cancelled:
>     {
>         GST_DEBUG_OBJECT (src, "select canceled");
>         return GST_FLOW_WRONG_STATE;
>     }
>     accept_error:
>     {
>         GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
>                 ("Could not accept client on server socket: %s", g_strerror (errno)));
>         return GST_FLOW_ERROR;
>     }
>     gdp_cancelled:
>     {
>         GST_DEBUG_OBJECT (src, "reading gdp canceled");
>         return GST_FLOW_WRONG_STATE;
>     }
>     gdp_caps_read_error:
>     {
>         /* if we did not get canceled, report an error */
>         if (ret != GST_FLOW_WRONG_STATE) {
>             GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
>                     ("Could not read caps through GDP"));
>         }
>         return ret;
>     }
> }
> 
> 
> GstFlowReturn
> gst_tcp_server_src_read_buffer (GstTCPServerSrc* src, int socket,
>         GstPoll * fdset, GstBuffer ** buf)
> 
> 
> 
> --
> 
> Bercy Li
> +8615954811012
> libing195 at 163.com
> 
> 
> 
> 
> 在2010-05-15 14:44:11,gstreamer-devel-request at lists.sourceforge.net 写道:
>> Send gstreamer-devel mailing list submissions to
>> 	gstreamer-devel at lists.sourceforge.net
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> 	https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>> or, via email, send a message with subject or body 'help' to
>> 	gstreamer-devel-request at lists.sourceforge.net
>>
>> You can reach the person managing the list at
>> 	gstreamer-devel-owner at lists.sourceforge.net
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of gstreamer-devel digest..."
>>
>>
>> Today's Topics:
>>
>>   1. tcpserversrc restarting (Antoine Martin)
>>   2. Re: GStreamer Conference 2010 (wl2776)
>>   3. Re: No EOS message at the end of file. (wl2776)
>>   4. Re: RTSP Seek and DVB subtitles (Alexander Olekhnovich)
>>   5. Framestepping backwards in MPEG2 files (wl2776)
>>   6. Pre-releases! gst-plugins-good 0.10.22.2, -ugly 0.10.14.2,
>>      -bad 0.10.18.2 (Tim-Philipp M?ller)
>>   7. Memory profiling and hunting memory leaks (Loc Nguyen)
>>   8. Re: Black-and-white output (Marco Ballesio)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Fri, 14 May 2010 18:20:28 +0700
>> From: Antoine Martin <antoine at nagafix.co.uk>
>> Subject: [gst-devel] tcpserversrc restarting
>> To: "gstreamer-devel at lists.sourceforge.net"
>> 	<gstreamer-devel at lists.sourceforge.net>
>> Message-ID: <4BED31FC.2090405 at nagafix.co.uk>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Hi,
>>
>> I have some code largely based on this tcpserversrc example:
>> http://www.jejik.com/articles/2007/01/streaming_audio_over_tcp_with_python-gstreamer/
>>
>> I want to ensure that it keeps working after the first client 
>> disconnects, which is not the case by default.
>> At the moment, the tcp socket shows as "listening" but any further data 
>> sent will not be processed.
>>
>> I've tried unlink()ing the decoder when receiving EOS and re-adding a 
>> new one, but it complained that that there was an existing one with the 
>> same name. How do I free the resources to start again? How about even 
>> freeing the socket?
>>
>> I would rather not switch to using RTP... But if I have to I will, how 
>> does gstrtpbin deal with multiple clients connecting?
>>
>> Thanks
>> Antoine
>>
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Fri, 14 May 2010 04:38:05 -0700 (PDT)
>> From: wl2776 <wl2776 at gmail.com>
>> Subject: Re: [gst-devel] GStreamer Conference 2010
>> To: gstreamer-devel at lists.sourceforge.net
>> Message-ID: <1273837085181-2216448.post at n4.nabble.com>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> Great to hear this.
>>
>> What's the registration fee?
>> -- 
>> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GStreamer-Conference-2010-tp2123970p2216448.html
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>>
>>
>>
>> ------------------------------
>>
>> Message: 3
>> Date: Fri, 14 May 2010 05:34:17 -0700 (PDT)
>> From: wl2776 <wl2776 at gmail.com>
>> Subject: Re: [gst-devel] No EOS message at the end of file.
>> To: gstreamer-devel at lists.sourceforge.net
>> Message-ID: <1273840457055-2216515.post at n4.nabble.com>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>>
>> Wim Taymans wrote:
>>> On Fri, 2010-05-14 at 11:42 +0100, Giles Atkinson wrote:
>>>>  > My problem is that the EOS message doesn't appear on playbin2's bus,
>>>> after
>>>>  > some manipulations with reverse and forward playback. But the playbin2
>>>> is
>>>>  > surely at the end of file, as reported by _query_position().
>>> EOS should always be sent in the PLAYING state when the pipeline is EOS,
>>> if not, please file a bug with an example or a way to reproduce the
>>> strange behaviour that you are seeing.
>>>
>> Hmm... The problem is gone now. After rebuild.
>> -- 
>> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/No-EOS-message-at-the-end-of-file-tp2216227p2216515.html
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>>
>>
>>
>> ------------------------------
>>
>> Message: 4
>> Date: Fri, 14 May 2010 15:23:16 +0300
>> From: Alexander Olekhnovich <a.olekhnovich at gmail.com>
>> Subject: Re: [gst-devel] RTSP Seek and DVB subtitles
>> To: Marc Leeman <marc.leeman at gmail.com>, 	Discussion of the
>> 	development of GStreamer	<gstreamer-devel at lists.sourceforge.net>
>> Message-ID:
>> 	<AANLkTimoGwsXJlzjOgX7SE449wL76Od70A7d9Q3FUGX9 at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> Hi Marc,
>>
>> I think ppl are interested :) At least I would really like to have a look at
>> that.
>>
>> On Thu, May 13, 2010 at 7:24 PM, Marc Leeman <marc.leeman at gmail.com> wrote:
>>
>>>> Regarding dvb subtitles, there is a little bit of work going on. One
>>>> with gst-teletext to grab subtitles from teletext and another with
>>>> image subtitles.
>>> I've got a working implementation that I am willing to share if ppl are
>>> interested.
>>>
>>> You can use pango to get an approximate of a full TT page or just get
>>> the subs (page) in text format.
>>>
>>> Tested on a number of DVB-S streams with good result.
>>>
>>> --
>>>  greetz, marc
>>> After an instrument has been assembled, extra components will be found
>>> on the bench.
>>> crichton 2.6.26 #1 PREEMPT Tue Jul 29 21:17:59 CDT 2008 GNU/Linux
>>>
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.6 (GNU/Linux)
>>>
>>> iD8DBQFL7CfOUQpj09NWLeERAoeFAKDPbRQw/hGwVPZXD7/ll3NZdjEp8QCZAVsN
>>> 7CCwL8z16lUE6OgsbktpAWU=
>>> =lYBv
>>> -----END PGP SIGNATURE-----
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> gstreamer-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>
>>>
>>
>> -- 
>> Thank you,
>> Alexander Olekhnovich
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>>
>> ------------------------------
>>
>> Message: 5
>> Date: Fri, 14 May 2010 08:03:24 -0700 (PDT)
>> From: wl2776 <wl2776 at gmail.com>
>> Subject: [gst-devel] Framestepping backwards in MPEG2 files
>> To: gstreamer-devel at lists.sourceforge.net
>> Message-ID: <1273849404627-2216718.post at n4.nabble.com>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> Is it complete?
>> My pipeline doesn't step one frame backwards.
>>
>> m_player is an instance of the playbin2. It has loaded the MPEG2 Program
>> Stream.
>> Then, the pipeline was paused before calling step_left
>>
>> void gst_player::step_left(void)
>> {GstFormat fmt=GST_FORMAT_TIME;
>>
>>  if(m_player){
>>    if(m_current_position>=40*GST_MSECOND){
>>      gboolean rb=gst_element_seek(m_player,-1.0,GST_FORMAT_TIME,
>>                                         
>> (GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
>>                                         
>> GST_SEEK_TYPE_SET,m_current_position,GST_SEEK_TYPE_SET,m_stream_duration);
>>      GST_DEBUG("seek backwards: %d",rb);
>>      GstEvent *event = gst_event_new_step (GST_FORMAT_BUFFERS, 1, 1.0,
>> TRUE, FALSE);
>>      rb=gst_element_send_event (m_player, event);
>>      GST_DEBUG("send step event: %d",rb);
>>    }
>>  }
>> }
>>
>>
>> Both _seek and _send_event(_new_step) return TRUE.
>> However, I don't see any changes in picture on the screen. 
>> After several calls to step_left() I get the EOS.
>> What am I doing wrong?
>> -- 
>> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Framestepping-backwards-in-MPEG2-files-tp2216718p2216718.html
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>>
>>
>>
>> ------------------------------
>>
>> Message: 6
>> Date: Fri, 14 May 2010 20:49:47 +0100
>> From: Tim-Philipp M?ller <t.i.m at zen.co.uk>
>> Subject: [gst-devel] Pre-releases! gst-plugins-good 0.10.22.2, -ugly
>> 	0.10.14.2, -bad 0.10.18.2
>> To: gstreamer-devel at lists.sourceforge.net
>> Message-ID: <1273866587.26703.6.camel at zingle>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> Hi,
>>
>> Below the latest pre-releases for gst-plugins-good, -ugly and -bad.
>>
>> Please test them thoroughly and file blocker bugs for all regressions or
>> other major issues you find at http://gstreamer.freedesktop.org/bugs/
>>
>> Packagers please note some plugins/elements have moved from -bad to
>> -good (imagefreeze plugin, oss4 plugin, capsfilter element).
>>
>> md5sums and links:
>>
>> 794e8d737657c60b2d6f4d44475d8b59  gst-plugins-good-0.10.22.2.tar.gz
>> 59403cd259529dee36ad09435898d80f  gst-plugins-good-0.10.22.2.tar.bz2
>>
>> http://gstreamer.freedesktop.org/src/gst-plugins-good/pre/gst-plugins-good-0.10.22.2.tar.gz
>> http://gstreamer.freedesktop.org/src/gst-plugins-good/pre/gst-plugins-good-0.10.22.2.tar.bz2
>>
>> bafd26e74b2bacecb59fd6c938888ed0  gst-plugins-ugly-0.10.14.2.tar.gz
>> 41bf784355cce044c0a7072c20fa053c  gst-plugins-ugly-0.10.14.2.tar.bz2
>>
>> http://gstreamer.freedesktop.org/src/gst-plugins-ugly/pre/gst-plugins-ugly-0.10.14.2.tar.gz
>> http://gstreamer.freedesktop.org/src/gst-plugins-ugly/pre/gst-plugins-ugly-0.10.14.2.tar.bz2
>>
>> 2f5f14c58c50e1b476fb2a31af6270c4  gst-plugins-bad-0.10.18.2.tar.gz
>> fe4fde65ed036c927427a158f0165298  gst-plugins-bad-0.10.18.2.tar.bz2
>>
>> http://gstreamer.freedesktop.org/src/gst-plugins-bad/pre/gst-plugins-bad-0.10.18.2.tar.gz
>> http://gstreamer.freedesktop.org/src/gst-plugins-bad/pre/gst-plugins-bad-0.10.18.2.tar.bz2
>>
>> Cheers
>> -Tim
>>
>>
>>
>>
>>
>> ------------------------------
>>
>> Message: 7
>> Date: Fri, 14 May 2010 16:19:22 -0700
>> From: Loc Nguyen <loc.x.nguyen at oracle.com>
>> Subject: [gst-devel] Memory profiling and hunting memory leaks
>> To: gstreamer-devel at lists.sourceforge.net
>> Message-ID: <4BEDDA7A.2090703 at oracle.com>
>> Content-Type: text/plain; charset=UTF-8; format=flowed
>>
>> Hey, I sent an email a few days ago but was never sent to the mailing 
>> list.  I'm trying to hunt down some memory leaks in gstreamer on 
>> Windows.  Can anyone advise on how core gstreamer devs are doing this?  
>> Any internal APIs that maybe useful for me to try?
>>
>> -Loc
>>
>>
>>
>> ------------------------------
>>
>> Message: 8
>> Date: Sat, 15 May 2010 09:44:04 +0300
>> From: Marco Ballesio <gibrovacco at gmail.com>
>> Subject: Re: [gst-devel] Black-and-white output
>> To: Discussion of the development of GStreamer
>> 	<gstreamer-devel at lists.sourceforge.net>
>> Message-ID:
>> 	<AANLkTinXaUJMYOytUyvpgHoB88pyHJZsR57Fr4hH97Xx at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> Hi,
>>
>> On Wed, May 12, 2010 at 7:11 PM, Louis-Simon Houde <houdelou at hotmail.com>wrote:
>>
>>>  Hello,
>>>
>>> The question might sound completely silly for you but does gstreamer needs
>>> a video card to generate video output on command line with its gst-launch
>>> command ?
>>>
>> it shouldn't matter as long as you're not rendering the output on the card
>> itself.. can you please post the gst-launch command you're using?
>>
>> Regards
>>
>>
>>> I'm asking this question because we use gst-launch to generate video
>>> output. On one of the server, with identical command, the output is
>>> black-and-white. One of the server doesn't have any video card because it is
>>> hosted on Amazon EC2.
>>>
>>> Ubuntu versions are different also so it might be another cue. But it is
>>> the same gstreamer version on both servers.
>>>
>>> Thanks
>>>
>>> ------------------------------
>>> 10 000 $ de magasinage avec Hotmail. Inscrivez-vous!<http://go.microsoft.com/?linkid=9729716>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>>
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> gstreamer-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>
>>>
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>>
>> ------------------------------
>>
>> ------------------------------------------------------------------------------
>>
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>>
>> End of gstreamer-devel Digest, Vol 48, Issue 23
>> ***********************************************
>>
>> ------------------------------------------------------------------------
>>
>> ------------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel





More information about the gstreamer-devel mailing list