[vlc-commits] SAP : handle legacy v0 where the hash is not set ( I forgot this case in c495d676f1)
Sébastien Escudier
git at videolan.org
Mon Mar 5 11:12:37 CET 2012
vlc/vlc-2.0 | branch: master | Sébastien Escudier <sebastien-devel at celeos.eu> | Mon Mar 5 09:47:33 2012 +0100| [58b1bc3a141ebcbcca2a6dafa131eccdfd311c79] | committer: Sébastien Escudier
SAP : handle legacy v0 where the hash is not set (I forgot this case in c495d676f1)
(cherry picked from commit d77948263d850f221ac18606f3e0f6c19295d51b)
Signed-off-by: Sébastien Escudier <sebastien-devel at celeos.eu>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=58b1bc3a141ebcbcca2a6dafa131eccdfd311c79
---
modules/services_discovery/sap.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index 1e84e43..7035149 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -256,6 +256,7 @@ struct demux_sys_t
static const char *FindAttribute (const sdp_t *sdp, unsigned media,
const char *name);
+ static bool IsSameSession( sdp_t *p_sdp1, sdp_t *p_sdp2 );
static int InitSocket( services_discovery_t *p_sd, const char *psz_address, int i_port );
static int Decompress( const unsigned char *psz_src, unsigned char **_dst, int i_len );
static void FreeSDP( sdp_t *p_sdp );
@@ -788,7 +789,9 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
{
sap_announce_t * p_announce = p_sd->p_sys->pp_announces[i];
/* FIXME: slow */
- if( p_announce->i_hash == i_hash && !memcmp(p_announce->i_source, i_source, sizeof(i_source)) )
+ if( ( !i_hash && IsSameSession( p_announce->p_sdp, p_sdp ) )
+ || ( i_hash && p_announce->i_hash == i_hash
+ && !memcmp(p_announce->i_source, i_source, sizeof(i_source)) ) )
{
/* We don't support delete announcement as they can easily
* Be used to highjack an announcement by a third party.
@@ -1543,6 +1546,27 @@ static int RemoveAnnounce( services_discovery_t *p_sd,
return VLC_SUCCESS;
}
+/*
+ * Compare two sessions, when hash is not set (SAP v0)
+ */
+static bool IsSameSession( sdp_t *p_sdp1, sdp_t *p_sdp2 )
+{
+ /* A session is identified by
+ * - username,
+ * - session_id,
+ * - network type (which is always IN),
+ * - address type (currently, this means IP version),
+ * - and hostname.
+ */
+ if (strcmp (p_sdp1->username, p_sdp2->username)
+ || (p_sdp1->session_id != p_sdp2->session_id)
+ || (p_sdp1->orig_ip_version != p_sdp2->orig_ip_version)
+ || strcmp (p_sdp1->orig_host, p_sdp2->orig_host))
+ return false;
+
+ return true;
+}
+
static inline attribute_t *MakeAttribute (const char *str)
{
attribute_t *a = malloc (sizeof (*a) + strlen (str) + 1);
More information about the vlc-commits
mailing list