Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
8b61d4ef
Commit
8b61d4ef
authored
Nov 08, 2004
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Services discovery support
parent
cd24fec6
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
332 additions
and
132 deletions
+332
-132
Makefile.am
Makefile.am
+1
-0
configure.ac
configure.ac
+4
-2
include/vlc_common.h
include/vlc_common.h
+2
-0
include/vlc_objects.h
include/vlc_objects.h
+1
-0
include/vlc_playlist.h
include/vlc_playlist.h
+22
-0
modules/misc/Modules.am
modules/misc/Modules.am
+0
-1
modules/services_discovery/hal.c
modules/services_discovery/hal.c
+38
-41
modules/services_discovery/sap.c
modules/services_discovery/sap.c
+85
-85
src/interface/interface.c
src/interface/interface.c
+0
-2
src/libvlc.c
src/libvlc.c
+4
-0
src/libvlc.h
src/libvlc.h
+7
-0
src/misc/objects.c
src/misc/objects.c
+4
-0
src/playlist/playlist.c
src/playlist/playlist.c
+6
-1
src/playlist/services_discovery.c
src/playlist/services_discovery.c
+158
-0
No files found.
Makefile.am
View file @
8b61d4ef
...
...
@@ -330,6 +330,7 @@ SOURCES_libvlc_common = \
src/playlist/item.c
\
src/playlist/item-ext.c
\
src/playlist/info.c
\
src/playlist/services_discovery.c
\
src/input/access.c
\
src/input/clock.c
\
src/input/control.c
\
...
...
configure.ac
View file @
8b61d4ef
...
...
@@ -678,8 +678,9 @@ fi
dnl Check for hal
PKG_CHECK_MODULES(HAL, hal >= 0.2.97,
[AC_DEFINE(HAVE_HAL, [], [Define if you have the HAL library])
VLC_ADD_LDFLAGS([vlc],[$HAL_LIBS])
VLC_ADD_CFLAGS([vlc],[$HAL_CFLAGS])],
VLC_ADD_PLUGINS([hal])
VLC_ADD_LDFLAGS([vlc hal],[$HAL_LIBS])
VLC_ADD_CFLAGS([vlc hal],[$HAL_CFLAGS])],
[AC_MSG_WARN(HAL library not found)])
dnl Build the gtk_main plugins?
...
...
@@ -4216,6 +4217,7 @@ AC_CONFIG_FILES([
modules/mux/Makefile
modules/mux/mpeg/Makefile
modules/packetizer/Makefile
modules/services_discovery/Makefile
modules/stream_out/Makefile
modules/stream_out/transrate/Makefile
modules/video_chroma/Makefile
...
...
include/vlc_common.h
View file @
8b61d4ef
...
...
@@ -221,6 +221,8 @@ typedef struct playlist_t playlist_t;
typedef
struct
playlist_item_t
playlist_item_t
;
typedef
struct
playlist_view_t
playlist_view_t
;
typedef
struct
playlist_export_t
playlist_export_t
;
typedef
struct
services_discovery_t
services_discovery_t
;
typedef
struct
services_discovery_sys_t
services_discovery_sys_t
;
/* Modules */
typedef
struct
module_bank_t
module_bank_t
;
...
...
include/vlc_objects.h
View file @
8b61d4ef
...
...
@@ -57,6 +57,7 @@
#define VLC_OBJECT_VOD (-23)
#define VLC_OBJECT_SPU (-24)
#define VLC_OBJECT_TLS (-25)
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_GENERIC (-666)
...
...
include/vlc_playlist.h
View file @
8b61d4ef
...
...
@@ -112,6 +112,19 @@ struct playlist_view_t
*/
typedef
enum
{
PLAYLIST_STOPPED
,
PLAYLIST_RUNNING
,
PLAYLIST_PAUSED
}
playlist_status_t
;
struct
services_discovery_t
{
VLC_COMMON_MEMBERS
const
char
*
psz_module
;
module_t
*
p_module
;
services_discovery_sys_t
*
p_sys
;
void
(
*
pf_run
)
(
services_discovery_t
*
);
};
/**
* Structure containing information about the playlist
*/
...
...
@@ -146,6 +159,9 @@ struct playlist_t
playlist_item_t
*
p_general
;
/**< Keep a pointer on the "general"
category */
services_discovery_t
**
pp_sds
;
int
i_sds
;
vlc_bool_t
b_go_next
;
/*< Go further than the parent node ? */
struct
{
...
...
@@ -210,6 +226,12 @@ VLC_EXPORT( int, playlist_Control, ( playlist_t *, int, ... ) );
VLC_EXPORT
(
int
,
playlist_Clear
,
(
playlist_t
*
)
);
/* Services discovery */
VLC_EXPORT
(
int
,
playlist_ServicesDiscoveryAdd
,
(
playlist_t
*
,
const
char
*
));
VLC_EXPORT
(
void
,
playlist_ServicesDiscoveryRemove
,
(
playlist_t
*
,
const
char
*
));
VLC_EXPORT
(
int
,
playlist_AddSDModules
,
(
playlist_t
*
,
char
*
));
/* Item management functions (act on items) */
#define playlist_AddItem(p,pi,i1,i2) playlist_ItemAdd(p,pi,i1,i2)
#define playlist_ItemNew( a , b, c ) __playlist_ItemNew(VLC_OBJECT(a) , b , c )
...
...
modules/misc/Modules.am
View file @
8b61d4ef
...
...
@@ -2,7 +2,6 @@ SOURCES_gtk_main = gtk_main.c
SOURCES_gnome_main = gtk_main.c
SOURCES_gtk2_main = gtk_main.c
SOURCES_gnome2_main = gtk_main.c
SOURCES_sap = sap.c
SOURCES_screensaver = screensaver.c
SOURCES_qte_main = qte_main.cpp
SOURCES_freetype = freetype.c
...
...
modules/
misc
/hal.c
→
modules/
services_discovery
/hal.c
View file @
8b61d4ef
...
...
@@ -62,7 +62,7 @@
vlc_module_begin
();
set_description
(
_
(
"HAL device detection"
)
);
set_capability
(
"
interface
"
,
0
);
set_capability
(
"
services_discovery
"
,
0
);
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
...
...
@@ -72,10 +72,10 @@ vlc_module_end();
* Local structures
*****************************************************************************/
struct
intf
_sys_t
struct
services_discovery
_sys_t
{
LibHalContext
*
p_ctx
;
/* playlist node */
playlist_item_t
*
p_node
;
...
...
@@ -86,42 +86,42 @@ struct intf_sys_t
*****************************************************************************/
/* Main functions */
static
void
Run
(
intf_thread
_t
*
p_intf
);
static
void
Run
(
services_discovery
_t
*
p_intf
);
/*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
malloc
(
sizeof
(
intf_sys_t
)
);
services_discovery_t
*
p_sd
=
(
services_discovery_t
*
)
p_this
;
services_discovery_sys_t
*
p_sys
=
malloc
(
sizeof
(
services_discovery_sys_t
)
);
playlist_t
*
p_playlist
;
playlist_view_t
*
p_view
;
p_
intf
->
pf_run
=
Run
;
p_
intf
->
p_sys
=
p_sys
;
p_
sd
->
pf_run
=
Run
;
p_
sd
->
p_sys
=
p_sys
;
if
(
!
(
p_sys
->
p_ctx
=
hal_initialize
(
NULL
,
FALSE
)
)
)
{
free
(
p_sys
);
msg_Err
(
p_
intf
,
"hal not available"
);
msg_Err
(
p_
sd
,
"hal not available"
);
return
VLC_EGENERIC
;
}
/* Create our playlist node */
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
intf
,
VLC_OBJECT_PLAYLIST
,
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
sd
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
if
(
!
p_playlist
)
{
msg_Warn
(
p_
intf
,
"unable to find playlist, cancelling HAL listening"
);
msg_Warn
(
p_
sd
,
"unable to find playlist, cancelling HAL listening"
);
return
VLC_EGENERIC
;
}
p_view
=
playlist_ViewFind
(
p_playlist
,
VIEW_CATEGORY
);
p_sys
->
p_node
=
playlist_NodeCreate
(
p_playlist
,
VIEW_CATEGORY
,
_
(
"Devices"
),
p_view
->
p_root
);
vlc_object_release
(
p_playlist
);
return
VLC_SUCCESS
;
...
...
@@ -132,27 +132,27 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
services_discovery_t
*
p_sd
=
(
services_discovery_t
*
)
p_sd
;
services_discovery_sys_t
*
p_sys
=
malloc
(
sizeof
(
services_discovery_sys_t
)
);
free
(
p_sys
);
}
static
void
AddDvd
(
intf_thread_t
*
p_intf
,
char
*
psz_device
)
static
void
AddDvd
(
services_discovery_t
*
p_sd
,
char
*
psz_device
)
{
char
*
psz_name
;
char
*
psz_uri
;
char
*
psz_blockdevice
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
playlist_t
*
p_playlist
;
playlist_item_t
*
p_item
;
psz_name
=
hal_device_get_property_string
(
p_
intf
->
p_sys
->
p_ctx
,
psz_name
=
hal_device_get_property_string
(
p_
sd
->
p_sys
->
p_ctx
,
psz_device
,
"volume.label"
);
psz_blockdevice
=
hal_device_get_property_string
(
p_
intf
->
p_sys
->
p_ctx
,
psz_blockdevice
=
hal_device_get_property_string
(
p_
sd
->
p_sys
->
p_ctx
,
psz_device
,
"block.device"
);
asprintf
(
&
psz_uri
,
"dvd://%s"
,
psz_blockdevice
);
/* Create the playlist item here */
p_item
=
playlist_ItemNew
(
p_
intf
,
psz_uri
,
p_item
=
playlist_ItemNew
(
p_
sd
,
psz_uri
,
psz_name
);
free
(
psz_uri
);
hal_free_string
(
psz_device
);
...
...
@@ -161,11 +161,11 @@ static void AddDvd( intf_thread_t *p_intf, char *psz_device )
return
;
}
p_item
->
i_flags
&=
~
PLAYLIST_SKIP_FLAG
;
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
intf
,
VLC_OBJECT_PLAYLIST
,
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
sd
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
if
(
!
p_playlist
)
{
msg_Err
(
p_
intf
,
"playlist not found"
);
msg_Err
(
p_
sd
,
"playlist not found"
);
return
;
}
...
...
@@ -173,22 +173,21 @@ static void AddDvd( intf_thread_t *p_intf, char *psz_device )
PLAYLIST_APPEND
,
PLAYLIST_END
);
vlc_object_release
(
p_playlist
);
}
static
void
AddCdda
(
intf_thread_t
*
p_intf
,
char
*
psz_device
)
static
void
AddCdda
(
services_discovery_t
*
p_sd
,
char
*
psz_device
)
{
char
*
psz_name
=
"Audio CD"
;
char
*
psz_uri
;
char
*
psz_blockdevice
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
playlist_t
*
p_playlist
;
playlist_item_t
*
p_item
;
psz_blockdevice
=
hal_device_get_property_string
(
p_
intf
->
p_sys
->
p_ctx
,
psz_blockdevice
=
hal_device_get_property_string
(
p_
sd
->
p_sys
->
p_ctx
,
psz_device
,
"block.device"
);
asprintf
(
&
psz_uri
,
"cdda://%s"
,
psz_blockdevice
);
/* Create the playlist item here */
p_item
=
playlist_ItemNew
(
p_
intf
,
psz_uri
,
p_item
=
playlist_ItemNew
(
p_
sd
,
psz_uri
,
psz_name
);
free
(
psz_uri
);
hal_free_string
(
psz_device
);
...
...
@@ -197,11 +196,11 @@ static void AddCdda( intf_thread_t *p_intf, char *psz_device )
return
;
}
p_item
->
i_flags
&=
~
PLAYLIST_SKIP_FLAG
;
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
intf
,
VLC_OBJECT_PLAYLIST
,
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
sd
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
if
(
!
p_playlist
)
{
msg_Err
(
p_
intf
,
"playlist not found"
);
msg_Err
(
p_
sd
,
"playlist not found"
);
return
;
}
...
...
@@ -210,13 +209,12 @@ static void AddCdda( intf_thread_t *p_intf, char *psz_device )
vlc_object_release
(
p_playlist
);
}
static
void
ParseDevice
(
intf_thread_t
*
p_intf
,
char
*
psz_device
)
static
void
ParseDevice
(
services_discovery_t
*
p_sd
,
char
*
psz_device
)
{
char
*
psz_disc_type
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
if
(
hal_device_property_exists
(
p_sys
->
p_ctx
,
psz_device
,
"volume.disc.type"
)
)
{
...
...
@@ -225,40 +223,39 @@ static void ParseDevice( intf_thread_t *p_intf, char *psz_device )
"volume.disc.type"
);
if
(
!
strcmp
(
psz_disc_type
,
"dvd_rom"
)
)
{
AddDvd
(
p_
intf
,
psz_device
);
AddDvd
(
p_
sd
,
psz_device
);
}
else
if
(
!
strcmp
(
psz_disc_type
,
"cd_rom"
)
)
{
if
(
hal_device_get_property_bool
(
p_sys
->
p_ctx
,
psz_device
,
"volume.disc.has_audio"
)
)
{
AddCdda
(
p_
intf
,
psz_device
);
AddCdda
(
p_
sd
,
psz_device
);
}
}
hal_free_string
(
psz_disc_type
);
}
}
/*****************************************************************************
* Run: main HAL thread
*****************************************************************************/
static
void
Run
(
intf_thread_t
*
p_intf
)
static
void
Run
(
services_discovery_t
*
p_sd
)
{
int
i
,
i_devices
;
char
**
devices
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
/* parse existing devices first */
if
(
(
devices
=
hal_get_all_devices
(
p_sys
->
p_ctx
,
&
i_devices
)
)
)
{
for
(
i
=
0
;
i
<
i_devices
;
i
++
)
{
ParseDevice
(
p_
intf
,
devices
[
i
]
);
ParseDevice
(
p_
sd
,
devices
[
i
]
);
}
}
while
(
!
p_
intf
->
b_die
)
while
(
!
p_
sd
->
b_die
)
{
msleep
(
1000
);
msleep
(
1000
00
);
}
}
modules/
misc
/sap.c
→
modules/
services_discovery
/sap.c
View file @
8b61d4ef
...
...
@@ -106,7 +106,7 @@ vlc_module_begin();
add_bool
(
"sap-parse"
,
1
,
NULL
,
SAP_PARSE_TEXT
,
SAP_PARSE_LONGTEXT
,
VLC_TRUE
);
set_capability
(
"
interface
"
,
0
);
set_capability
(
"
services_discovery
"
,
0
);
set_callbacks
(
Open
,
Close
);
add_submodule
();
...
...
@@ -167,7 +167,7 @@ struct sap_announce_t
playlist_item_t
*
p_item
;
};
struct
intf
_sys_t
struct
services_discovery
_sys_t
{
/* Socket descriptors */
int
i_fd
;
...
...
@@ -195,21 +195,21 @@ struct intf_sys_t
/* Main functions */
static
int
Demux
(
demux_t
*
p_demux
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
static
void
Run
(
intf_thread_t
*
p_intf
);
static
void
Run
(
services_discovery_t
*
p_sd
);
/* Main parsing functions */
static
int
ParseConnection
(
vlc_object_t
*
p_obj
,
sdp_t
*
p_sdp
);
static
int
ParseSAP
(
intf_thread_t
*
p_intf
,
uint8_t
*
p_buffer
,
int
i_read
);
static
sdp_t
*
ParseSDP
(
vlc_object_t
*
p_
intf
,
char
*
psz_sdp
);
static
sap_announce_t
*
CreateAnnounce
(
intf_thread
_t
*
,
uint16_t
,
sdp_t
*
);
static
int
RemoveAnnounce
(
intf_thread_t
*
p_intf
,
sap_announce_t
*
p_announce
);
static
int
ParseSAP
(
services_discovery_t
*
p_sd
,
uint8_t
*
p_buffer
,
int
i_read
);
static
sdp_t
*
ParseSDP
(
vlc_object_t
*
p_
sd
,
char
*
psz_sdp
);
static
sap_announce_t
*
CreateAnnounce
(
services_discovery
_t
*
,
uint16_t
,
sdp_t
*
);
static
int
RemoveAnnounce
(
services_discovery_t
*
p_sd
,
sap_announce_t
*
p_announce
);
/* Cache */
static
void
CacheLoad
(
intf_thread_t
*
p_intf
);
static
void
CacheSave
(
intf_thread_t
*
p_intf
);
static
void
CacheLoad
(
services_discovery_t
*
p_sd
);
static
void
CacheSave
(
services_discovery_t
*
p_sd
);
/* Helper functions */
static
char
*
GetAttribute
(
sdp_t
*
p_sdp
,
const
char
*
psz_search
);
static
int
InitSocket
(
intf_thread_t
*
p_intf
,
char
*
psz_address
,
int
i_port
);
static
int
InitSocket
(
services_discovery_t
*
p_sd
,
char
*
psz_address
,
int
i_port
);
#ifdef HAVE_ZLIB_H
static
int
Decompress
(
unsigned
char
*
psz_src
,
unsigned
char
**
_dst
,
int
i_len
);
static
void
FreeSDP
(
sdp_t
*
p_sdp
);
...
...
@@ -225,17 +225,17 @@ static int ismult( char * );
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
{
intf_thread_t
*
p_intf
=
(
intf_thread
_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
malloc
(
sizeof
(
intf
_sys_t
)
);
services_discovery_t
*
p_sd
=
(
services_discovery
_t
*
)
p_this
;
services_discovery_sys_t
*
p_sys
=
malloc
(
sizeof
(
services_discovery
_sys_t
)
);
playlist_t
*
p_playlist
;
playlist_view_t
*
p_view
;
p_sys
->
i_timeout
=
config_GetInt
(
p_
intf
,
"sap-timeout"
);
p_sys
->
i_timeout
=
config_GetInt
(
p_
sd
,
"sap-timeout"
);
p_
intf
->
pf_run
=
Run
;
p_
intf
->
p_sys
=
p_sys
;
p_
sd
->
pf_run
=
Run
;
p_
sd
->
p_sys
=
p_sys
;
p_sys
->
pi_fd
=
NULL
;
p_sys
->
i_fd
=
0
;
...
...
@@ -243,16 +243,16 @@ static int Open( vlc_object_t *p_this )
/* FIXME */
p_sys
->
b_strict
=
VLC_FALSE
;
if
(
config_GetInt
(
p_
intf
,
"sap-use-cache"
)
)
if
(
config_GetInt
(
p_
sd
,
"sap-use-cache"
)
)
{
CacheLoad
(
p_
intf
);
CacheLoad
(
p_
sd
);
}
if
(
config_GetInt
(
p_
intf
,
"sap-ipv4"
)
)
if
(
config_GetInt
(
p_
sd
,
"sap-ipv4"
)
)
{
InitSocket
(
p_
intf
,
SAP_V4_ADDRESS
,
SAP_PORT
);
InitSocket
(
p_
sd
,
SAP_V4_ADDRESS
,
SAP_PORT
);
}
if
(
config_GetInt
(
p_
intf
,
"sap-ipv6"
)
)
if
(
config_GetInt
(
p_
sd
,
"sap-ipv6"
)
)
{
/* TODO */
}
...
...
@@ -261,16 +261,16 @@ static int Open( vlc_object_t *p_this )
if
(
p_sys
->
i_fd
==
0
)
{
msg_Err
(
p_
intf
,
"unable to read on any address"
);
msg_Err
(
p_
sd
,
"unable to read on any address"
);
return
VLC_EGENERIC
;
}
/* Create our playlist node */
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
intf
,
VLC_OBJECT_PLAYLIST
,
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_
sd
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
if
(
!
p_playlist
)
{
msg_Warn
(
p_
intf
,
"unable to find playlist, cancelling SAP listening"
);
msg_Warn
(
p_
sd
,
"unable to find playlist, cancelling SAP listening"
);
return
VLC_EGENERIC
;
}
...
...
@@ -322,8 +322,8 @@ static int OpenDemux( vlc_object_t *p_this )
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
{
intf_thread_t
*
p_intf
=
(
intf_thread
_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
services_discovery_t
*
p_sd
=
(
services_discovery
_t
*
)
p_this
;
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
int
i
;
for
(
i
=
p_sys
->
i_fd
-
1
;
i
>=
0
;
i
--
)
...
...
@@ -331,14 +331,14 @@ static void Close( vlc_object_t *p_this )
net_Close
(
p_sys
->
pi_fd
[
i
]
);
}
if
(
config_GetInt
(
p_
intf
,
"sap-use-cache"
)
)
if
(
config_GetInt
(
p_
sd
,
"sap-use-cache"
)
)
{
CacheSave
(
p_
intf
);
CacheSave
(
p_
sd
);
}
for
(
i
=
p_sys
->
i_announces
-
1
;
i
>=
0
;
i
--
)
{
RemoveAnnounce
(
p_
intf
,
p_sys
->
pp_announces
[
i
]
);
RemoveAnnounce
(
p_
sd
,
p_sys
->
pp_announces
[
i
]
);
}
free
(
p_sys
);
...
...
@@ -359,7 +359,7 @@ static void CloseDemux( vlc_object_t *p_this )
*****************************************************************************/
#define MAX_SAP_BUFFER 5000
static
void
Run
(
intf_thread_t
*
p_intf
)
static
void
Run
(
services_discovery_t
*
p_sd
)
{
uint8_t
*
p_buffer
;
/* Dirty hack to slow down the startup of the sap interface */
...
...
@@ -367,53 +367,53 @@ static void Run( intf_thread_t *p_intf )
// msleep( 500000 );
/* read SAP packets */
while
(
!
p_
intf
->
b_die
)
while
(
!
p_
sd
->
b_die
)
{
p_buffer
=
(
uint8_t
*
)
malloc
(
MAX_SAP_BUFFER
);
if
(
!
p_buffer
)
{
msg_Err
(
p_
intf
,
"out of memory"
);
p_
intf
->
b_die
=
VLC_TRUE
;
msg_Err
(
p_
sd
,
"out of memory"
);
p_
sd
->
b_die
=
VLC_TRUE
;
continue
;
}
int
i_read
=
net_Select
(
p_
intf
,
p_intf
->
p_sys
->
pi_fd
,
NULL
,
p_
intf
->
p_sys
->
i_fd
,
p_buffer
,
int
i_read
=
net_Select
(
p_
sd
,
p_sd
->
p_sys
->
pi_fd
,
NULL
,
p_
sd
->
p_sys
->
i_fd
,
p_buffer
,
MAX_SAP_BUFFER
,
500000
);
#if 0
/* Check for items that need deletion */
for( i = 0 ; i< p_
intf
->p_sys->i_announces ; i++ )
for( i = 0 ; i< p_
sd
->p_sys->i_announces ; i++ )
{
struct sap_announce_t *p_announce;
mtime_t i_timeout = ( mtime_t ) 1000000*p_sys->i_timeout;
if( mdate() - p_
intf
->p_sys->pp_announces[i]->i_last > i_timeout )
if( mdate() - p_
sd
->p_sys->pp_announces[i]->i_last > i_timeout )
{
msg_Dbg( p_
intf
,"Time out for %s, deleting (%i/%i)",
p_
intf
->p_sys->pp_announces[i]->psz_name,
i , p_
intf
->p_sys->i_announces );
msg_Dbg( p_
sd
,"Time out for %s, deleting (%i/%i)",
p_
sd
->p_sys->pp_announces[i]->psz_name,
i , p_
sd
->p_sys->i_announces );
/* Remove the playlist item */
p_playlist = vlc_object_find( p_
intf
, VLC_OBJECT_PLAYLIST,
p_playlist = vlc_object_find( p_
sd
, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
int i_pos = playlist_GetPositionById( p_playlist,
p_
intf
->p_sys->pp_announces[i]->i_id );
p_
sd
->p_sys->pp_announces[i]->i_id );
playlist_Delete( p_playlist, i_pos );
vlc_object_release( p_playlist );
}
/* Free the p_announce */
p_announce = p_
intf
->p_sys->pp_announces[i];
p_announce = p_
sd
->p_sys->pp_announces[i];
if( p_announce->psz_name )
free( p_announce->psz_name );
if( p_announce->psz_uri )
free( p_announce->psz_uri );
/* Remove the sap_announce from the array */
REMOVE_ELEM( p_
intf
->p_sys->pp_announces,
p_
intf
->p_sys->i_announces,
REMOVE_ELEM( p_
sd
->p_sys->pp_announces,
p_
sd
->p_sys->i_announces,
i );
free( p_announce );
...
...
@@ -427,7 +427,7 @@ static void Run( intf_thread_t *p_intf )
{
if
(
i_read
<
0
)
{
msg_Warn
(
p_
intf
,
"socket read error"
);
msg_Warn
(
p_
sd
,
"socket read error"
);
}
continue
;
}
...
...
@@ -435,7 +435,7 @@ static void Run( intf_thread_t *p_intf )
p_buffer
[
i_read
]
=
'\0'
;
/* Parse the packet */
ParseSAP
(
p_
intf
,
p_buffer
,
i_read
);
ParseSAP
(
p_
sd
,
p_buffer
,
i_read
);
free
(
p_buffer
);
}
...
...
@@ -521,7 +521,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
* Local functions
**************************************************************/
static
int
ParseSAP
(
intf_thread_t
*
p_intf
,
uint8_t
*
p_buffer
,
int
i_read
)
static
int
ParseSAP
(
services_discovery_t
*
p_sd
,
uint8_t
*
p_buffer
,
int
i_read
)
{
int
i_version
,
i_address_type
,
i_hash
,
i
;
uint8_t
*
psz_sdp
;
...
...
@@ -538,26 +538,26 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
if
(
i_version
!=
1
)
{
msg_Dbg
(
p_
intf
,
"strange sap version %d found"
,
i_version
);
msg_Dbg
(
p_
sd
,
"strange sap version %d found"
,
i_version
);
}
i_address_type
=
p_buffer
[
0
]
&
0x10
;
if
(
(
p_buffer
[
0
]
&
0x08
)
!=
0
)
{
msg_Dbg
(
p_
intf
,
"reserved bit incorrectly set"
);
msg_Dbg
(
p_
sd
,
"reserved bit incorrectly set"
);
return
VLC_EGENERIC
;
}
if
(
(
p_buffer
[
0
]
&
0x04
)
!=
0
)
{
msg_Dbg
(
p_
intf
,
"session deletion packet"
);
msg_Dbg
(
p_
sd
,
"session deletion packet"
);
b_need_delete
=
VLC_TRUE
;
}
if
(
p_buffer
[
0
]
&
0x02
)
{
msg_Dbg
(
p_
intf
,
"encrypted packet, unsupported"
);
msg_Dbg
(
p_
sd
,
"encrypted packet, unsupported"
);
return
VLC_EGENERIC
;
}
...
...
@@ -565,9 +565,9 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
i_hash
=
(
p_buffer
[
2
]
<<
8
)
+
p_buffer
[
3
];
if
(
p_
intf
->
p_sys
->
b_strict
&&
i_hash
==
0
)
if
(
p_
sd
->
p_sys
->
b_strict
&&
i_hash
==
0
)
{
msg_Dbg
(
p_
intf
,
"strict mode, discarding announce with null id hash"
);
msg_Dbg
(
p_
sd
,
"strict mode, discarding announce with null id hash"
);
return
VLC_EGENERIC
;
}
...
...
@@ -594,7 +594,7 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
free
(
p_decompressed_buffer
);
}
#else
msg_Warn
(
p_
intf
,
"Ignoring compressed sap packet"
);
msg_Warn
(
p_
sd
,
"Ignoring compressed sap packet"
);
return
VLC_EGENERIC
;
#endif
}
...
...
@@ -615,7 +615,7 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
}
/* Parse SDP info */
p_sdp
=
ParseSDP
(
VLC_OBJECT
(
p_
intf
),
psz_sdp
);
p_sdp
=
ParseSDP
(
VLC_OBJECT
(
p_
sd
),
psz_sdp
);
if
(
p_sdp
==
NULL
)
{
...
...
@@ -625,14 +625,14 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
/* Decide whether we should add a playlist item for this SDP */
/* Multi-media or no-parse -> pass to LIVE.COM */
if
(
p_sdp
->
i_media
>
1
||
p_
intf
->
p_sys
->
b_parse
==
VLC_FALSE
)
if
(
p_sdp
->
i_media
>
1
||
p_
sd
->
p_sys
->
b_parse
==
VLC_FALSE
)
{
asprintf
(
&
p_sdp
->
psz_uri
,
"sdp://%s"
,
p_sdp
->
psz_sdp
);
}
else
{
/* Parse connection information (c= & m= ) */
if
(
ParseConnection
(
VLC_OBJECT
(
p_
intf
),
p_sdp
)
)
if
(
ParseConnection
(
VLC_OBJECT
(
p_
sd
),
p_sdp
)
)
{
p_sdp
->
psz_uri
=
NULL
;
}
...
...
@@ -640,21 +640,21 @@ static int ParseSAP( intf_thread_t *p_intf, uint8_t *p_buffer, int i_read )
if
(
p_sdp
->
psz_uri
==
NULL
)
return
VLC_EGENERIC
;
for
(
i
=
0
;
i
<
p_
intf
->
p_sys
->
i_announces
;
i
++
)