Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
e23ba242
Commit
e23ba242
authored
Feb 05, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* convert SAP announce name & group from locale to
UTF-8
* fix bug in previous SAP commit
parent
65484e2a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
18 deletions
+83
-18
include/stream_output.h
include/stream_output.h
+3
-0
modules/services_discovery/sap.c
modules/services_discovery/sap.c
+21
-10
src/stream_output/sap.c
src/stream_output/sap.c
+59
-8
No files found.
include/stream_output.h
View file @
e23ba242
...
@@ -322,6 +322,9 @@ struct sap_handler_t
...
@@ -322,6 +322,9 @@ struct sap_handler_t
int
(
*
pf_add
)
(
sap_handler_t
*
,
session_descriptor_t
*
,
announce_method_t
*
);
int
(
*
pf_add
)
(
sap_handler_t
*
,
session_descriptor_t
*
,
announce_method_t
*
);
int
(
*
pf_del
)
(
sap_handler_t
*
,
session_descriptor_t
*
);
int
(
*
pf_del
)
(
sap_handler_t
*
,
session_descriptor_t
*
);
/* private data, not in p_sys as there is one kind of sap_handler_t */
vlc_iconv_t
iconvHandle
;
};
};
/* The main announce handler object */
/* The main announce handler object */
...
...
modules/services_discovery/sap.c
View file @
e23ba242
...
@@ -274,7 +274,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -274,7 +274,7 @@ static int Open( vlc_object_t *p_this )
p_sys
->
i_timeout
=
config_GetInt
(
p_sd
,
"sap-timeout"
);
p_sys
->
i_timeout
=
config_GetInt
(
p_sd
,
"sap-timeout"
);
vlc_current_charset
(
&
psz_charset
);
vlc_current_charset
(
&
psz_charset
);
p_sys
->
iconvHandle
=
vlc_iconv_open
(
psz_charset
,
"UTF-8"
);
p_sys
->
iconvHandle
=
vlc_iconv_open
(
psz_charset
,
"UTF-8"
);
free
(
psz_charset
);
free
(
psz_charset
);
if
(
p_sys
->
iconvHandle
==
(
vlc_iconv_t
)(
-
1
)
)
if
(
p_sys
->
iconvHandle
==
(
vlc_iconv_t
)(
-
1
)
)
{
{
...
@@ -812,9 +812,13 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
...
@@ -812,9 +812,13 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
char
*
psz_value
;
char
*
psz_value
;
sap_announce_t
*
p_sap
=
(
sap_announce_t
*
)
malloc
(
sap_announce_t
*
p_sap
=
(
sap_announce_t
*
)
malloc
(
sizeof
(
sap_announce_t
)
);
sizeof
(
sap_announce_t
)
);
if
(
!
p_sap
)
psz_value
=
convert_from_utf8
(
p_sd
,
p_sdp
->
psz_sessionname
);
if
(
p_sap
==
NULL
||
psz_value
==
NULL
)
{
{
msg_Err
(
p_sd
,
"out of memory"
);
msg_Err
(
p_sd
,
"out of memory"
);
FREE
(
p_sap
);
FREE
(
psz_value
);
p_sd
->
b_die
=
VLC_TRUE
;
p_sd
->
b_die
=
VLC_TRUE
;
return
NULL
;
return
NULL
;
}
}
...
@@ -824,9 +828,8 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
...
@@ -824,9 +828,8 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
p_sap
->
p_item
=
NULL
;
p_sap
->
p_item
=
NULL
;
/* Create the playlist item here */
/* Create the playlist item here */
psz_value
=
convert_from_utf8
(
p_sd
,
p_sap
->
p_sdp
->
psz_sessionname
);
p_item
=
playlist_ItemNew
(
p_sd
,
p_sap
->
p_sdp
->
psz_uri
,
psz_value
);
p_item
=
playlist_ItemNew
(
p_sd
,
p_sap
->
p_sdp
->
psz_uri
,
psz_value
);
FREE
(
psz_value
);
free
(
psz_value
);
if
(
!
p_item
)
if
(
!
p_item
)
{
{
...
@@ -853,16 +856,24 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
...
@@ -853,16 +856,24 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
if
(
psz_value
!=
NULL
)
if
(
psz_value
!=
NULL
)
{
{
char
*
psz_grp
=
convert_from_utf8
(
p_sd
,
psz_value
);
char
*
psz_grp
=
convert_from_utf8
(
p_sd
,
psz_value
);
free
(
psz_value
);
p_child
=
playlist_ChildSearchName
(
p_sd
->
p_sys
->
p_node
,
psz_grp
);
if
(
psz_grp
!=
NULL
)
{
p_child
=
playlist_ChildSearchName
(
p_sd
->
p_sys
->
p_node
,
psz_grp
);
if
(
p_child
==
NULL
)
if
(
p_child
==
NULL
)
p_child
=
playlist_NodeCreate
(
p_playlist
,
VIEW_CATEGORY
,
psz_grp
,
p_sd
->
p_sys
->
p_node
);
free
(
psz_grp
);
}
else
{
{
p_child
=
playlist_NodeCreate
(
p_playlist
,
VIEW_CATEGORY
,
vlc_object_release
(
p_playlist
);
psz_grp
,
p_sd
->
p_sys
->
p_node
);
msg_Err
(
p_sd
,
"out of memory"
);
free
(
p_sap
);
return
NULL
;
}
}
free
(
psz_grp
);
}
}
else
else
{
{
...
...
src/stream_output/sap.c
View file @
e23ba242
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include <vlc/sout.h>
#include <vlc/sout.h>
#include <network.h>
#include <network.h>
#include "charset.h"
#define SAP_IPV4_ADDR "224.2.127.254"
/* Standard port and address for SAP */
#define SAP_IPV4_ADDR "224.2.127.254"
/* Standard port and address for SAP */
#define SAP_PORT 9875
#define SAP_PORT 9875
...
@@ -62,6 +63,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
...
@@ -62,6 +63,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
static
int
announce_SAPAnnounceDel
(
sap_handler_t
*
p_sap
,
static
int
announce_SAPAnnounceDel
(
sap_handler_t
*
p_sap
,
session_descriptor_t
*
p_session
);
session_descriptor_t
*
p_session
);
static
char
*
convert_to_utf8
(
struct
sap_handler_t
*
p_this
,
char
*
psz_local
);
#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
...
@@ -75,6 +77,7 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
...
@@ -75,6 +77,7 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
sap_handler_t
*
announce_SAPHandlerCreate
(
announce_handler_t
*
p_announce
)
sap_handler_t
*
announce_SAPHandlerCreate
(
announce_handler_t
*
p_announce
)
{
{
sap_handler_t
*
p_sap
;
sap_handler_t
*
p_sap
;
char
*
psz_charset
;
p_sap
=
vlc_object_create
(
p_announce
,
sizeof
(
sap_handler_t
)
);
p_sap
=
vlc_object_create
(
p_announce
,
sizeof
(
sap_handler_t
)
);
...
@@ -86,6 +89,14 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
...
@@ -86,6 +89,14 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
vlc_mutex_init
(
p_sap
,
&
p_sap
->
object_lock
);
vlc_mutex_init
(
p_sap
,
&
p_sap
->
object_lock
);
vlc_current_charset
(
&
psz_charset
);
p_sap
->
iconvHandle
=
vlc_iconv_open
(
"UTF-8"
,
psz_charset
);
free
(
psz_charset
);
if
(
p_sap
->
iconvHandle
==
(
vlc_iconv_t
)(
-
1
)
)
{
msg_Warn
(
p_sap
,
"Unable to do requested conversion"
);
}
p_sap
->
pf_add
=
announce_SAPAnnounceAdd
;
p_sap
->
pf_add
=
announce_SAPAnnounceAdd
;
p_sap
->
pf_del
=
announce_SAPAnnounceDel
;
p_sap
->
pf_del
=
announce_SAPAnnounceDel
;
...
@@ -144,6 +155,9 @@ void announce_SAPHandlerDestroy( sap_handler_t *p_sap )
...
@@ -144,6 +155,9 @@ void announce_SAPHandlerDestroy( sap_handler_t *p_sap )
FREE
(
p_address
);
FREE
(
p_address
);
}
}
if
(
p_sap
->
iconvHandle
!=
(
vlc_iconv_t
)(
-
1
)
)
vlc_iconv_close
(
p_sap
->
iconvHandle
);
/* Free the structure */
/* Free the structure */
vlc_object_destroy
(
p_sap
);
vlc_object_destroy
(
p_sap
);
}
}
...
@@ -478,6 +492,10 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
...
@@ -478,6 +492,10 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
{
{
int64_t
i_sdp_id
=
mdate
();
int64_t
i_sdp_id
=
mdate
();
int
i_sdp_version
=
1
+
p_sap
->
i_sessions
+
(
rand
()
&
0xfff
);
int
i_sdp_version
=
1
+
p_sap
->
i_sessions
+
(
rand
()
&
0xfff
);
char
*
psz_group
,
*
psz_name
;
psz_group
=
convert_to_utf8
(
p_sap
,
p_session
->
psz_group
);
psz_name
=
convert_to_utf8
(
p_sap
,
p_session
->
psz_name
);
/* see the lists in modules/stream_out/rtp.c for compliance stuff */
/* see the lists in modules/stream_out/rtp.c for compliance stuff */
p_session
->
psz_sdp
=
(
char
*
)
malloc
(
p_session
->
psz_sdp
=
(
char
*
)
malloc
(
...
@@ -489,14 +507,15 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
...
@@ -489,14 +507,15 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
"m=video udp
\r\n
"
"m=video udp
\r\n
"
"a=tool:"
PACKAGE_STRING
"
\r\n
"
"a=tool:"
PACKAGE_STRING
"
\r\n
"
"a=type:broadcast
\r\n
"
)
"a=type:broadcast
\r\n
"
)
+
strlen
(
p
_session
->
p
sz_name
)
+
strlen
(
psz_name
)
+
strlen
(
p_session
->
psz_uri
)
+
300
+
strlen
(
p_session
->
psz_uri
)
+
300
+
(
p_session
->
psz_group
?
+
(
psz_group
?
strlen
(
psz_group
)
:
0
)
);
strlen
(
p_session
->
psz_group
)
:
0
)
);
if
(
!
p_session
->
psz_sdp
)
if
(
p_session
->
psz_sdp
==
NULL
||
psz_name
==
NULL
)
{
{
msg_Err
(
p_sap
,
"out of memory"
);
msg_Err
(
p_sap
,
"out of memory"
);
FREE
(
psz_name
);
FREE
(
psz_group
);
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
}
sprintf
(
p_session
->
psz_sdp
,
sprintf
(
p_session
->
psz_sdp
,
...
@@ -509,15 +528,16 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
...
@@ -509,15 +528,16 @@ static int SDPGenerate( sap_handler_t *p_sap, session_descriptor_t *p_session )
"a=tool:"
PACKAGE_STRING
"
\r\n
"
"a=tool:"
PACKAGE_STRING
"
\r\n
"
"a=type:broadcast
\r\n
"
,
"a=type:broadcast
\r\n
"
,
i_sdp_id
,
i_sdp_version
,
i_sdp_id
,
i_sdp_version
,
p
_session
->
p
sz_name
,
psz_name
,
p_session
->
psz_uri
,
p_session
->
i_ttl
,
p_session
->
psz_uri
,
p_session
->
i_ttl
,
p_session
->
i_port
,
p_session
->
i_payload
);
p_session
->
i_port
,
p_session
->
i_payload
);
free
(
psz_name
);
if
(
p
_session
->
p
sz_group
)
if
(
psz_group
)
{
{
sprintf
(
p_session
->
psz_sdp
,
"%sa=x-plgroup:%s
\r\n
"
,
sprintf
(
p_session
->
psz_sdp
,
"%sa=x-plgroup:%s
\r\n
"
,
p_session
->
psz_sdp
,
p_session
->
psz_sdp
,
psz_group
);
p_session
->
psz_group
);
free
(
psz_group
);
}
}
msg_Dbg
(
p_sap
,
"Generated SDP (%i bytes):
\n
%s"
,
strlen
(
p_session
->
psz_sdp
),
msg_Dbg
(
p_sap
,
"Generated SDP (%i bytes):
\n
%s"
,
strlen
(
p_session
->
psz_sdp
),
...
@@ -582,3 +602,34 @@ static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
...
@@ -582,3 +602,34 @@ static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
char
*
convert_to_utf8
(
struct
sap_handler_t
*
p_this
,
char
*
psz_local
)
{
char
*
psz_unicode
,
*
psz_in
,
*
psz_out
;
size_t
ret
,
i_in
,
i_out
;
if
(
psz_local
==
NULL
)
return
NULL
;
if
(
p_this
->
iconvHandle
==
(
vlc_iconv_t
)(
-
1
)
)
return
strdup
(
psz_local
);
psz_in
=
psz_local
;
i_in
=
strlen
(
psz_local
);
i_out
=
6
*
i_in
;
psz_unicode
=
malloc
(
i_out
+
1
);
if
(
psz_unicode
==
NULL
)
return
strdup
(
psz_local
);
psz_out
=
psz_unicode
;
ret
=
vlc_iconv
(
p_this
->
iconvHandle
,
&
psz_in
,
&
i_in
,
&
psz_out
,
&
i_out
);
if
(
ret
==
(
size_t
)(
-
1
)
||
i_in
)
{
msg_Warn
(
p_this
,
"Failed to convert
\"
%s
\"
to UTF-8"
,
psz_local
);
return
strdup
(
psz_local
);
}
*
psz_out
=
'\0'
;
return
psz_unicode
;
}
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