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
ed8d5bcb
Commit
ed8d5bcb
authored
Sep 17, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle RTSP URLs that ends with a single slash properly
parent
5631171f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
17 deletions
+34
-17
modules/stream_out/rtp.c
modules/stream_out/rtp.c
+6
-1
modules/stream_out/rtsp.c
modules/stream_out/rtsp.c
+28
-16
No files found.
modules/stream_out/rtp.c
View file @
ed8d5bcb
...
@@ -708,9 +708,14 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
...
@@ -708,9 +708,14 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
id
->
psz_rtpmap
,
id
->
psz_fmtp
);
id
->
psz_rtpmap
,
id
->
psz_fmtp
);
if
(
rtsp_url
!=
NULL
)
if
(
rtsp_url
!=
NULL
)
sdp_AddAttribute
(
&
psz_sdp
,
"control"
,
"%s/trackID=%d"
,
{
assert
(
strlen
(
rtsp_url
)
>
0
);
vlc_bool_t
addslash
=
(
rtsp_url
[
strlen
(
rtsp_url
)
-
1
]
!=
'/'
);
sdp_AddAttribute
(
&
psz_sdp
,
"control"
,
addslash
?
"%s/trackID=%u"
:
"%strackID=%u"
,
rtsp_url
,
i
);
rtsp_url
,
i
);
}
}
}
return
psz_sdp
;
return
psz_sdp
;
}
}
...
...
modules/stream_out/rtsp.c
View file @
ed8d5bcb
...
@@ -48,6 +48,7 @@ struct rtsp_stream_t
...
@@ -48,6 +48,7 @@ struct rtsp_stream_t
httpd_host_t
*
host
;
httpd_host_t
*
host
;
httpd_url_t
*
url
;
httpd_url_t
*
url
;
char
*
psz_path
;
char
*
psz_path
;
const
char
*
track_fmt
;
unsigned
port
;
unsigned
port
;
int
sessionc
;
int
sessionc
;
...
@@ -68,30 +69,40 @@ rtsp_stream_t *RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url )
...
@@ -68,30 +69,40 @@ rtsp_stream_t *RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url )
rtsp_stream_t
*
rtsp
=
malloc
(
sizeof
(
*
rtsp
)
);
rtsp_stream_t
*
rtsp
=
malloc
(
sizeof
(
*
rtsp
)
);
if
(
rtsp
==
NULL
||
(
url
->
i_port
>
99999
)
)
if
(
rtsp
==
NULL
||
(
url
->
i_port
>
99999
)
)
{
free
(
rtsp
);
return
NULL
;
return
NULL
;
}
rtsp
->
owner
=
p_stream
;
rtsp
->
owner
=
p_stream
;
rtsp
->
sessionc
=
0
;
rtsp
->
sessionc
=
0
;
rtsp
->
sessionv
=
NULL
;
rtsp
->
sessionv
=
NULL
;
rtsp
->
host
=
NULL
;
rtsp
->
url
=
NULL
;
rtsp
->
psz_path
=
NULL
;
vlc_mutex_init
(
p_stream
,
&
rtsp
->
lock
);
vlc_mutex_init
(
p_stream
,
&
rtsp
->
lock
);
msg_Dbg
(
p_stream
,
"rtsp setup: %s : %d / %s
\n
"
,
url
->
psz_host
,
url
->
i_port
,
url
->
psz_path
);
rtsp
->
port
=
(
url
->
i_port
>
0
)
?
url
->
i_port
:
554
;
rtsp
->
port
=
(
url
->
i_port
>
0
)
?
url
->
i_port
:
554
;
if
(
url
->
psz_path
!=
NULL
)
rtsp
->
psz_path
=
strdup
(
(
url
->
psz_path
!=
NULL
)
?
url
->
psz_path
:
"/"
);
rtsp
->
psz_path
=
strdup
(
url
->
psz_path
+
1
);
if
(
rtsp
->
psz_path
==
NULL
)
goto
error
;
assert
(
strlen
(
rtsp
->
psz_path
)
>
0
);
if
(
rtsp
->
psz_path
[
strlen
(
rtsp
->
psz_path
)
-
1
]
==
'/'
)
rtsp
->
track_fmt
=
"%strackID=%u"
;
else
else
rtsp
->
psz_path
=
NULL
;
rtsp
->
track_fmt
=
"%s/trackID=%u"
;
msg_Dbg
(
p_stream
,
"RTSP stream: host %s port %d at %s"
,
url
->
psz_host
,
rtsp
->
port
,
rtsp
->
psz_path
);
rtsp
->
host
=
httpd_HostNew
(
VLC_OBJECT
(
p_stream
),
url
->
psz_host
,
rtsp
->
host
=
httpd_HostNew
(
VLC_OBJECT
(
p_stream
),
url
->
psz_host
,
rtsp
->
port
);
rtsp
->
port
);
if
(
rtsp
->
host
==
NULL
)
if
(
rtsp
->
host
==
NULL
)
goto
error
;
goto
error
;
rtsp
->
url
=
httpd_UrlNewUnique
(
rtsp
->
host
,
rtsp
->
url
=
httpd_UrlNewUnique
(
rtsp
->
host
,
rtsp
->
psz_path
,
url
->
psz_path
?
url
->
psz_path
:
"/"
,
NULL
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
);
if
(
rtsp
->
url
==
NULL
)
if
(
rtsp
->
url
==
NULL
)
goto
error
;
goto
error
;
...
@@ -121,6 +132,7 @@ void RtspUnsetup( rtsp_stream_t *rtsp )
...
@@ -121,6 +132,7 @@ void RtspUnsetup( rtsp_stream_t *rtsp )
if
(
rtsp
->
host
)
if
(
rtsp
->
host
)
httpd_HostDelete
(
rtsp
->
host
);
httpd_HostDelete
(
rtsp
->
host
);
free
(
rtsp
->
psz_path
);
vlc_mutex_destroy
(
&
rtsp
->
lock
);
vlc_mutex_destroy
(
&
rtsp
->
lock
);
}
}
...
@@ -165,7 +177,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
...
@@ -165,7 +177,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
const
char
*
dst
,
int
ttl
,
const
char
*
dst
,
int
ttl
,
unsigned
loport
,
unsigned
hiport
)
unsigned
loport
,
unsigned
hiport
)
{
{
char
urlbuf
[
sizeof
(
"/
/
trackID=123"
)
+
strlen
(
rtsp
->
psz_path
)];
char
urlbuf
[
sizeof
(
"/trackID=123"
)
+
strlen
(
rtsp
->
psz_path
)];
rtsp_stream_id_t
*
id
=
malloc
(
sizeof
(
*
id
)
);
rtsp_stream_id_t
*
id
=
malloc
(
sizeof
(
*
id
)
);
httpd_url_t
*
url
;
httpd_url_t
*
url
;
...
@@ -183,7 +195,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
...
@@ -183,7 +195,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
id
->
hiport
=
hiport
;
id
->
hiport
=
hiport
;
}
}
snprintf
(
urlbuf
,
sizeof
(
urlbuf
),
"/%s/trackID=%u"
,
rtsp
->
psz_path
,
snprintf
(
urlbuf
,
sizeof
(
urlbuf
),
rtsp
->
track_fmt
,
rtsp
->
psz_path
,
num
);
num
);
msg_Dbg
(
rtsp
->
owner
,
"RTSP: adding %s"
,
urlbuf
);
msg_Dbg
(
rtsp
->
owner
,
"RTSP: adding %s"
,
urlbuf
);
url
=
id
->
url
=
httpd_UrlNewUnique
(
rtsp
->
host
,
urlbuf
,
NULL
,
NULL
,
NULL
);
url
=
id
->
url
=
httpd_UrlNewUnique
(
rtsp
->
host
,
urlbuf
,
NULL
,
NULL
,
NULL
);
...
@@ -356,7 +368,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
...
@@ -356,7 +368,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
}
}
char
ip
[
NI_MAXNUMERICHOST
],
*
ptr
;
char
ip
[
NI_MAXNUMERICHOST
],
*
ptr
;
char
control
[
sizeof
(
"rtsp://[]:12345
/
"
)
+
sizeof
(
ip
)
char
control
[
sizeof
(
"rtsp://[]:12345"
)
+
sizeof
(
ip
)
+
strlen
(
rtsp
->
psz_path
)];
+
strlen
(
rtsp
->
psz_path
)];
/* Build self-referential URL */
/* Build self-referential URL */
...
@@ -366,11 +378,11 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
...
@@ -366,11 +378,11 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
*
ptr
=
'\0'
;
*
ptr
=
'\0'
;
if
(
strchr
(
ip
,
':'
)
!=
NULL
)
if
(
strchr
(
ip
,
':'
)
!=
NULL
)
sprintf
(
control
,
"rtsp://[%s]:%u
/
%s"
,
ip
,
rtsp
->
port
,
sprintf
(
control
,
"rtsp://[%s]:%u%s"
,
ip
,
rtsp
->
port
,
(
rtsp
->
psz_path
!=
NULL
)
?
rtsp
->
psz_path
:
""
);
rtsp
->
psz_path
);
else
else
sprintf
(
control
,
"rtsp://%s:%u
/
%s"
,
ip
,
rtsp
->
port
,
sprintf
(
control
,
"rtsp://%s:%u%s"
,
ip
,
rtsp
->
port
,
(
rtsp
->
psz_path
!=
NULL
)
?
rtsp
->
psz_path
:
""
);
rtsp
->
psz_path
);
ptr
=
SDPGenerate
(
rtsp
->
owner
,
control
);
ptr
=
SDPGenerate
(
rtsp
->
owner
,
control
);
...
...
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