Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
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
videolan
vlc
Commits
4e75bc06
Commit
4e75bc06
authored
Jun 20, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sap: remove the sap handler object
parent
82870e2e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
128 deletions
+35
-128
src/libvlc.h
src/libvlc.h
+0
-5
src/stream_output/sap.c
src/stream_output/sap.c
+35
-123
No files found.
src/libvlc.h
View file @
4e75bc06
...
@@ -137,8 +137,6 @@ module_t *module_find_by_shortcut (const char *psz_shortcut);
...
@@ -137,8 +137,6 @@ module_t *module_find_by_shortcut (const char *psz_shortcut);
#define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
#define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
#define ZOOM_DOUBLE_KEY_TEXT N_("2:1 Double")
#define ZOOM_DOUBLE_KEY_TEXT N_("2:1 Double")
typedef
struct
sap_handler_t
sap_handler_t
;
/**
/**
* Private LibVLC instance data.
* Private LibVLC instance data.
*/
*/
...
@@ -159,9 +157,6 @@ typedef struct libvlc_priv_t
...
@@ -159,9 +157,6 @@ typedef struct libvlc_priv_t
/* Singleton objects */
/* Singleton objects */
vlm_t
*
p_vlm
;
///< the VLM singleton (or NULL)
vlm_t
*
p_vlm
;
///< the VLM singleton (or NULL)
vlc_object_t
*
p_dialog_provider
;
///< dialog provider
vlc_object_t
*
p_dialog_provider
;
///< dialog provider
#ifdef ENABLE_SOUT
sap_handler_t
*
p_sap
;
///< SAP SDP advertiser
#endif
struct
playlist_t
*
playlist
;
///< Playlist for interfaces
struct
playlist_t
*
playlist
;
///< Playlist for interfaces
struct
playlist_preparser_t
*
parser
;
///< Input item meta data handler
struct
playlist_preparser_t
*
parser
;
///< Input item meta data handler
struct
vlc_actions
*
actions
;
///< Hotkeys handler
struct
vlc_actions
*
actions
;
///< Hotkeys handler
...
...
src/stream_output/sap.c
View file @
4e75bc06
...
@@ -70,14 +70,7 @@ typedef struct sap_address_t
...
@@ -70,14 +70,7 @@ typedef struct sap_address_t
session_descriptor_t
*
first
;
session_descriptor_t
*
first
;
}
sap_address_t
;
}
sap_address_t
;
/* The SAP handler, running in a separate thread */
static
sap_address_t
*
sap_addrs
=
NULL
;
struct
sap_handler_t
{
VLC_COMMON_MEMBERS
sap_address_t
*
first
;
};
static
vlc_mutex_t
sap_mutex
=
VLC_STATIC_MUTEX
;
static
vlc_mutex_t
sap_mutex
=
VLC_STATIC_MUTEX
;
#define SAP_MAX_BUFFER 65534
#define SAP_MAX_BUFFER 65534
...
@@ -86,30 +79,6 @@ static vlc_mutex_t sap_mutex = VLC_STATIC_MUTEX;
...
@@ -86,30 +79,6 @@ static vlc_mutex_t sap_mutex = VLC_STATIC_MUTEX;
static
void
*
RunThread
(
void
*
);
static
void
*
RunThread
(
void
*
);
/**
* Create the SAP handler
*
* \param p_announce a VLC object
* \return the newly created SAP handler or NULL on error
*/
static
sap_handler_t
*
SAP_Create
(
vlc_object_t
*
p_announce
)
{
sap_handler_t
*
p_sap
;
p_sap
=
vlc_custom_create
(
p_announce
,
sizeof
(
*
p_sap
),
"sap sender"
);
if
(
p_sap
==
NULL
)
return
NULL
;
p_sap
->
first
=
NULL
;
return
p_sap
;
}
static
void
SAP_Destroy
(
sap_handler_t
*
p_sap
)
{
assert
(
p_sap
->
first
==
NULL
);
vlc_object_release
(
p_sap
);
}
static
sap_address_t
*
AddressCreate
(
vlc_object_t
*
obj
,
const
char
*
group
)
static
sap_address_t
*
AddressCreate
(
vlc_object_t
*
obj
,
const
char
*
group
)
{
{
int
fd
=
net_ConnectUDP
(
obj
,
group
,
IPPORT_SAP
,
255
);
int
fd
=
net_ConnectUDP
(
obj
,
group
,
IPPORT_SAP
,
255
);
...
@@ -194,11 +163,18 @@ static void *RunThread (void *self)
...
@@ -194,11 +163,18 @@ static void *RunThread (void *self)
assert
(
0
);
assert
(
0
);
}
}
#undef sout_AnnounceRegisterSDP
/**
/**
* Add a SAP announce
* Registers a new session with the announce handler, using a pregenerated SDP
*
* \param obj a VLC object
* \param sdp the SDP to register
* \param dst session address (needed for SAP address auto detection)
* \return the new session descriptor structure
*/
*/
static
session_descriptor_t
*
SAP_Add
(
sap_handler_t
*
p_sap
,
session_descriptor_t
*
const
char
*
sdp
,
const
char
*
dst
)
sout_AnnounceRegisterSDP
(
vlc_object_t
*
obj
,
const
char
*
sdp
,
const
char
*
dst
)
{
{
int
i
;
int
i
;
char
psz_addr
[
NI_MAXNUMERICHOST
];
char
psz_addr
[
NI_MAXNUMERICHOST
];
...
@@ -211,6 +187,8 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
...
@@ -211,6 +187,8 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
socklen_t
addrlen
=
0
;
socklen_t
addrlen
=
0
;
struct
addrinfo
*
res
;
struct
addrinfo
*
res
;
msg_Dbg
(
obj
,
"adding SAP session"
);
if
(
vlc_getaddrinfo
(
dst
,
0
,
NULL
,
&
res
)
==
0
)
if
(
vlc_getaddrinfo
(
dst
,
0
,
NULL
,
&
res
)
==
0
)
{
{
if
(
res
->
ai_addrlen
<=
sizeof
(
addr
))
if
(
res
->
ai_addrlen
<=
sizeof
(
addr
))
...
@@ -221,7 +199,7 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
...
@@ -221,7 +199,7 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
if
(
addrlen
==
0
||
addrlen
>
sizeof
(
addr
))
if
(
addrlen
==
0
||
addrlen
>
sizeof
(
addr
))
{
{
msg_Err
(
p_sap
,
"No/invalid address specified for SAP announce"
);
msg_Err
(
obj
,
"No/invalid address specified for SAP announce"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -271,8 +249,8 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
...
@@ -271,8 +249,8 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
if
(
ipv4
==
0
)
if
(
ipv4
==
0
)
{
{
msg_Err
(
p_sap
,
"Out-of-scope multicast address "
msg_Err
(
obj
,
"Out-of-scope multicast address "
"not supported by SAP"
);
"not supported by SAP"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -281,8 +259,8 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
...
@@ -281,8 +259,8 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
}
}
default:
default:
msg_Err
(
p_sap
,
"Address family %d not supported by SAP"
,
msg_Err
(
obj
,
"Address family %d not supported by SAP"
,
addr
.
a
.
sa_family
);
addr
.
a
.
sa_family
);
return
NULL
;
return
NULL
;
}
}
...
@@ -291,29 +269,29 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
...
@@ -291,29 +269,29 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
if
(
i
)
if
(
i
)
{
{
msg_Err
(
p_sap
,
"%s"
,
gai_strerror
(
i
)
);
msg_Err
(
obj
,
"%s"
,
gai_strerror
(
i
)
);
return
NULL
;
return
NULL
;
}
}
/* Find/create SAP address thread */
/* Find/create SAP address thread */
msg_Dbg
(
p_sap
,
"using SAP address: %s"
,
psz_addr
)
;
sap_address_t
*
sap_addr
;
msg_Dbg
(
obj
,
"using SAP address: %s"
,
psz_addr
);
vlc_mutex_lock
(
&
sap_mutex
);
vlc_mutex_lock
(
&
sap_mutex
);
sap_address_t
*
sap_addr
;
for
(
sap_addr
=
sap_addrs
;
sap_addr
;
sap_addr
=
sap_addr
->
next
)
for
(
sap_addr
=
p_sap
->
first
;
sap_addr
;
sap_addr
=
sap_addr
->
next
)
if
(
!
strcmp
(
psz_addr
,
sap_addr
->
group
))
if
(
!
strcmp
(
psz_addr
,
sap_addr
->
group
))
break
;
break
;
if
(
sap_addr
==
NULL
)
if
(
sap_addr
==
NULL
)
{
{
sap_addr
=
AddressCreate
(
VLC_OBJECT
(
p_sap
)
,
psz_addr
);
sap_addr
=
AddressCreate
(
obj
,
psz_addr
);
if
(
sap_addr
==
NULL
)
if
(
sap_addr
==
NULL
)
{
{
vlc_mutex_unlock
(
&
sap_mutex
);
vlc_mutex_unlock
(
&
sap_mutex
);
return
NULL
;
return
NULL
;
}
}
sap_addr
->
next
=
p_sap
->
first
;
sap_addr
->
next
=
sap_addrs
;
p_sap
->
first
=
sap_addr
;
sap_addrs
=
sap_addr
;
}
}
/* Switch locks.
/* Switch locks.
* NEVER take the global SAP lock when holding a SAP thread lock! */
* NEVER take the global SAP lock when holding a SAP thread lock! */
...
@@ -393,16 +371,22 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
...
@@ -393,16 +371,22 @@ static session_descriptor_t *SAP_Add (sap_handler_t *p_sap,
return
session
;
return
session
;
}
}
#undef sout_AnnounceUnRegister
/**
/**
* Remove a SAP Announce
* Unregisters an existing session
*
* \param obj a VLC object
* \param session the session descriptor
* \return VLC_SUCCESS
*/
*/
static
void
SAP_Del
(
sap_handler_t
*
p_sap
,
session_descriptor_t
*
session
)
int
sout_AnnounceUnRegister
(
vlc_object_t
*
obj
,
session_descriptor_t
*
session
)
{
{
sap_address_t
*
addr
,
**
paddr
;
sap_address_t
*
addr
,
**
paddr
;
session_descriptor_t
**
psession
;
session_descriptor_t
**
psession
;
msg_Dbg
(
obj
,
"removing SAP session"
);
vlc_mutex_lock
(
&
sap_mutex
);
vlc_mutex_lock
(
&
sap_mutex
);
paddr
=
&
p_sap
->
first
;
paddr
=
&
sap_addrs
;
for
(;;)
for
(;;)
{
{
addr
=
*
paddr
;
addr
=
*
paddr
;
...
@@ -442,77 +426,5 @@ found:
...
@@ -442,77 +426,5 @@ found:
}
}
free
(
session
);
free
(
session
);
}
return
VLC_SUCCESS
;
/****************************************************************************
* Sout-side functions
****************************************************************************/
static
void
sap_destroy
(
vlc_object_t
*
p_this
)
{
libvlc_priv
(
p_this
->
p_libvlc
)
->
p_sap
=
NULL
;
}
#undef sout_AnnounceRegisterSDP
/**
* Registers a new session with the announce handler, using a pregenerated SDP
*
* \param obj a VLC object
* \param psz_sdp the SDP to register
* \param psz_dst session address (needed for SAP address auto detection)
* \return the new session descriptor structure
*/
session_descriptor_t
*
sout_AnnounceRegisterSDP
(
vlc_object_t
*
obj
,
const
char
*
psz_sdp
,
const
char
*
psz_dst
)
{
vlc_mutex_lock
(
&
sap_mutex
);
sap_handler_t
*
p_sap
=
libvlc_priv
(
obj
->
p_libvlc
)
->
p_sap
;
if
(
p_sap
==
NULL
)
{
p_sap
=
SAP_Create
(
VLC_OBJECT
(
obj
->
p_libvlc
));
libvlc_priv
(
obj
->
p_libvlc
)
->
p_sap
=
p_sap
;
vlc_object_set_destructor
((
vlc_object_t
*
)
p_sap
,
sap_destroy
);
}
else
vlc_object_hold
((
vlc_object_t
*
)
p_sap
);
vlc_mutex_unlock
(
&
sap_mutex
);
if
(
p_sap
==
NULL
)
return
NULL
;
msg_Dbg
(
obj
,
"adding SAP session"
);
session_descriptor_t
*
session
=
SAP_Add
(
p_sap
,
psz_sdp
,
psz_dst
);
if
(
session
==
NULL
)
{
vlc_mutex_lock
(
&
sap_mutex
);
vlc_object_release
((
vlc_object_t
*
)
p_sap
);
vlc_mutex_unlock
(
&
sap_mutex
);
}
return
session
;
}
#undef sout_AnnounceUnRegister
/**
* Unregisters an existing session
*
* \param obj a VLC object
* \param p_session the session descriptor
* \return VLC_SUCCESS or an error
*/
int
sout_AnnounceUnRegister
(
vlc_object_t
*
obj
,
session_descriptor_t
*
p_session
)
{
sap_handler_t
*
p_sap
=
libvlc_priv
(
obj
->
p_libvlc
)
->
p_sap
;
msg_Dbg
(
obj
,
"removing SAP session"
);
SAP_Del
(
p_sap
,
p_session
);
vlc_mutex_lock
(
&
sap_mutex
);
vlc_object_release
((
vlc_object_t
*
)
p_sap
);
vlc_mutex_unlock
(
&
sap_mutex
);
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment