After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729776 - Set client port from URL
Set client port from URL
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
git master
Other Linux
: Normal normal
: 1.3.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-08 06:14 UTC by Christian Nilsson
Modified: 2014-05-20 13:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Suggestion for fix (844 bytes, patch)
2014-05-08 06:15 UTC, Christian Nilsson
rejected Details | Review

Description Christian Nilsson 2014-05-08 06:14:47 UTC
When running RTP over TCP the destination port is not set. This is needed for when collecting statistics for a stream. The port is set in the same fashion as the destination address. (see attachment for implementation suggestion)
Comment 1 Christian Nilsson 2014-05-08 06:15:40 UTC
Created attachment 276128 [details] [review]
Suggestion for fix
Comment 2 Wim Taymans 2014-05-09 13:30:16 UTC
What exactly does this fix?

You override ct->client_port.min, which:

 - is not used to make the server transport in TCP mode
 - will send the wrong port back to the client in UDP mode
Comment 3 Christian Nilsson 2014-05-12 05:45:32 UTC
Okay, not exactly the intention :).
I wanted to set the port for tcp connections so it would be readable later (without needing to extract it from the socket). This would be used for identifying active streams for statistics collection.

I guess I should put it after the TCP check?

if (ct->lower_transport & GST_RTSP_LOWER_TRANS_TCP) {
...
Comment 4 Christian Nilsson 2014-05-14 10:42:33 UTC
Setting back to unconfirmed.
Comment 5 Wim Taymans 2014-05-15 13:15:49 UTC
You want the port number that the client used to connect to the server? When do you need this information?
Comment 6 Christian Nilsson 2014-05-16 07:05:00 UTC
I use the info for identifying a stream by its socketaddress (source & dest ip & port) outside gstreamer. It can be used for collecting uncooked stats via for example libpcap. I use it already for the udp case and it would be very convenient to be able to use it for tcp aswell. Would it be possible to add this functionality?
Comment 7 Wim Taymans 2014-05-16 14:20:26 UTC
It's possible to add but I think it's already available in the client GstRTSPConnection object. That's why I ask how and when you get this information.

For UDP you get this information from GstRTSPTransport object via RTSPSessionMedia->RTSPStreamTransport->RTSPTransport. You do this? Do you want to get the remote and local ports in RTSPTransport as well for TCP?

For TCP you can iterate the RTSPClient objects and get the RTSPConnection from it and look at the ports.
Comment 8 Christian Nilsson 2014-05-19 07:49:09 UTC
Yes that is correct, that is how I fetch it in the UDP case.

Not sure how you mean by iterating the client?
I use the "play-request" signal on the client to get a callback from where I iterate the streams in the media. 
Perhaps a dumb question, but are all connections same for all streams within a client?
I can get the Connection from the client with gst_rtsp_client_get_connection, and then use gst_rtsp_connection_get_write_socket to get the writing socket, and then extract the sockaddr from the sockets fd? Seems a bit more complicated than for the UDP case :), or have I missed something?
Wouldnt it be more consistent to set it so It can be readable for TCP as we do for UDP?
Comment 9 Wim Taymans 2014-05-19 08:36:28 UTC
(In reply to comment #8)
> Perhaps a dumb question, but are all connections same for all streams within a
> client?

The Client object is the TCP connection that a client has with a server, if the RTSP data is send with TCP, it is also sent over this connection.

> I can get the Connection from the client with gst_rtsp_client_get_connection,
> and then use gst_rtsp_connection_get_write_socket to get the writing socket,
> and then extract the sockaddr from the sockets fd? Seems a bit more complicated
> than for the UDP case :), or have I missed something?

No, it's not as easy.

> Wouldnt it be more consistent to set it so It can be readable for TCP as we do
> for UDP?

It would be good but it seems a little weird to abuse the min/max values of the Transport for that. I guess if we document this properly, It would be acceptable. Let me take a closer look.
Comment 10 Christian Nilsson 2014-05-19 08:41:27 UTC
Ok great, let me know what you come up with!
Comment 11 Wim Taymans 2014-05-19 14:19:08 UTC
There could be 4 port:

 - port used by client to send RTP/RTCP
 - port used by client to receive RTP/RTCP
 - port used by server to send RTP/RTCP
 - port used by server to receive RTP/RTCP

Sender and receiver ports can be different when tunnelling over HTTP. In practice we always send RTP and RTCP over the same TCP connection, there is nothing defined in RTSP to split that up.

We could use:
 
 client_port.min and client_port.max for the client sender/receiver ports respectively and
 server_port.min and server_port.max for the server sender/receiver ports respectively.
Comment 12 Christian Nilsson 2014-05-20 06:16:57 UTC
Yes, that sounds good!
Comment 13 Wim Taymans 2014-05-20 13:59:27 UTC
commit 5aa06b8058423e7ecd1f656d6d420cab6d581d1e
Author: Wim Taymans <wtaymans@redhat.com>
Date:   Tue May 20 15:57:30 2014 +0200

    client: store TCP ports in transport
    
    Store the TCP ports in the transport when we are doing RTSP over TCP.
    This way, we can easily get to the ports from the transport.
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=729776