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
420977bc
Commit
420977bc
authored
Jun 20, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sout: merge SAP and announce code in a single file
parent
d0e3349d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
165 deletions
+115
-165
src/Makefile.am
src/Makefile.am
+0
-1
src/stream_output/announce.c
src/stream_output/announce.c
+0
-135
src/stream_output/sap.c
src/stream_output/sap.c
+115
-11
src/stream_output/stream_output.h
src/stream_output/stream_output.h
+0
-18
No files found.
src/Makefile.am
View file @
420977bc
...
...
@@ -493,7 +493,6 @@ SOURCES_libvlc_httpd = \
SOURCES_libvlc_sout
=
\
stream_output/stream_output.c
\
stream_output/stream_output.h
\
stream_output/announce.c
\
stream_output/sap.c
\
stream_output/sdp.c
\
$(NULL)
...
...
src/stream_output/announce.c
deleted
100644 → 0
View file @
d0e3349d
/*****************************************************************************
* announce.c : announce handler
*****************************************************************************
* Copyright (C) 2002-2007 VLC authors and VideoLAN
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_sout.h>
#include "stream_output.h"
#include "libvlc.h"
#include <assert.h>
/****************************************************************************
* Sout-side functions
****************************************************************************/
static
void
sap_destroy
(
vlc_object_t
*
p_this
)
{
libvlc_priv
(
p_this
->
p_libvlc
)
->
p_sap
=
NULL
;
}
#undef sout_AnnounceRegisterSDP
static
vlc_mutex_t
sap_mutex
=
VLC_STATIC_MUTEX
;
/**
* 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
)
{
session_descriptor_t
*
p_session
=
calloc
(
1
,
sizeof
(
*
p_session
)
);
if
(
!
p_session
)
return
NULL
;
p_session
->
psz_sdp
=
strdup
(
psz_sdp
);
/* GRUIK. We should not convert back-and-forth from string to numbers */
struct
addrinfo
*
res
;
if
(
vlc_getaddrinfo
(
psz_dst
,
0
,
NULL
,
&
res
)
==
0
)
{
if
(
res
->
ai_addrlen
<=
sizeof
(
p_session
->
addr
))
memcpy
(
&
p_session
->
addr
,
res
->
ai_addr
,
p_session
->
addrlen
=
res
->
ai_addrlen
);
freeaddrinfo
(
res
);
}
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
)
goto
error
;
msg_Dbg
(
obj
,
"adding SAP session"
);
if
(
SAP_Add
(
p_sap
,
p_session
))
{
vlc_mutex_lock
(
&
sap_mutex
);
vlc_object_release
((
vlc_object_t
*
)
p_sap
);
vlc_mutex_unlock
(
&
sap_mutex
);
goto
error
;
}
return
p_session
;
error:
free
(
p_session
->
psz_sdp
);
free
(
p_session
);
return
NULL
;
}
#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
);
free
(
p_session
->
psz_sdp
);
free
(
p_session
);
return
0
;
}
src/stream_output/sap.c
View file @
420977bc
...
...
@@ -22,10 +22,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
...
...
@@ -46,6 +42,17 @@
/* SAP is always on that port */
#define IPPORT_SAP 9875
struct
session_descriptor_t
{
struct
sockaddr_storage
orig
;
socklen_t
origlen
;
struct
sockaddr_storage
addr
;
socklen_t
addrlen
;
char
*
psz_sdp
;
bool
b_ssm
;
};
/* A SAP session descriptor, enqueued in the SAP handler queue */
typedef
struct
sap_session_t
{
...
...
@@ -88,9 +95,6 @@ struct sap_handler_t
#define MIN_INTERVAL 2
#define MAX_INTERVAL 300
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
void
*
RunThread
(
void
*
);
/**
...
...
@@ -99,7 +103,7 @@ static void *RunThread (void *);
* \param p_announce a VLC object
* \return the newly created SAP handler or NULL on error
*/
sap_handler_t
*
SAP_Create
(
vlc_object_t
*
p_announce
)
s
tatic
s
ap_handler_t
*
SAP_Create
(
vlc_object_t
*
p_announce
)
{
sap_handler_t
*
p_sap
;
...
...
@@ -112,7 +116,7 @@ sap_handler_t *SAP_Create (vlc_object_t *p_announce)
return
p_sap
;
}
void
SAP_Destroy
(
sap_handler_t
*
p_sap
)
static
void
SAP_Destroy
(
sap_handler_t
*
p_sap
)
{
assert
(
p_sap
->
first
==
NULL
);
vlc_mutex_destroy
(
&
p_sap
->
lock
);
...
...
@@ -206,7 +210,7 @@ static void *RunThread (void *self)
/**
* Add a SAP announce
*/
int
SAP_Add
(
sap_handler_t
*
p_sap
,
session_descriptor_t
*
p_session
)
static
int
SAP_Add
(
sap_handler_t
*
p_sap
,
session_descriptor_t
*
p_session
)
{
int
i
;
char
psz_addr
[
NI_MAXNUMERICHOST
];
...
...
@@ -406,7 +410,8 @@ int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session)
/**
* Remove a SAP Announce
*/
void
SAP_Del
(
sap_handler_t
*
p_sap
,
const
session_descriptor_t
*
p_session
)
static
void
SAP_Del
(
sap_handler_t
*
p_sap
,
const
session_descriptor_t
*
p_session
)
{
vlc_mutex_lock
(
&
p_sap
->
lock
);
...
...
@@ -453,3 +458,102 @@ found:
free
(
session
);
}
/****************************************************************************
* Sout-side functions
****************************************************************************/
static
void
sap_destroy
(
vlc_object_t
*
p_this
)
{
libvlc_priv
(
p_this
->
p_libvlc
)
->
p_sap
=
NULL
;
}
#undef sout_AnnounceRegisterSDP
static
vlc_mutex_t
sap_mutex
=
VLC_STATIC_MUTEX
;
/**
* 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
)
{
session_descriptor_t
*
p_session
=
calloc
(
1
,
sizeof
(
*
p_session
)
);
if
(
!
p_session
)
return
NULL
;
p_session
->
psz_sdp
=
strdup
(
psz_sdp
);
/* GRUIK. We should not convert back-and-forth from string to numbers */
struct
addrinfo
*
res
;
if
(
vlc_getaddrinfo
(
psz_dst
,
0
,
NULL
,
&
res
)
==
0
)
{
if
(
res
->
ai_addrlen
<=
sizeof
(
p_session
->
addr
))
memcpy
(
&
p_session
->
addr
,
res
->
ai_addr
,
p_session
->
addrlen
=
res
->
ai_addrlen
);
freeaddrinfo
(
res
);
}
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
)
goto
error
;
msg_Dbg
(
obj
,
"adding SAP session"
);
if
(
SAP_Add
(
p_sap
,
p_session
))
{
vlc_mutex_lock
(
&
sap_mutex
);
vlc_object_release
((
vlc_object_t
*
)
p_sap
);
vlc_mutex_unlock
(
&
sap_mutex
);
goto
error
;
}
return
p_session
;
error:
free
(
p_session
->
psz_sdp
);
free
(
p_session
);
return
NULL
;
}
#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
);
free
(
p_session
->
psz_sdp
);
free
(
p_session
);
return
0
;
}
src/stream_output/stream_output.h
View file @
420977bc
...
...
@@ -50,22 +50,4 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *, es_format_t * );
int
sout_InputDelete
(
sout_packetizer_input_t
*
);
int
sout_InputSendBuffer
(
sout_packetizer_input_t
*
,
block_t
*
);
/* Announce system */
struct
session_descriptor_t
{
struct
sockaddr_storage
orig
;
socklen_t
origlen
;
struct
sockaddr_storage
addr
;
socklen_t
addrlen
;
char
*
psz_sdp
;
bool
b_ssm
;
};
struct
sap_handler_t
*
SAP_Create
(
vlc_object_t
*
);
void
SAP_Destroy
(
struct
sap_handler_t
*
);
int
SAP_Add
(
struct
sap_handler_t
*
,
session_descriptor_t
*
);
void
SAP_Del
(
struct
sap_handler_t
*
,
const
session_descriptor_t
*
);
#endif
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