Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
51885599
Commit
51885599
authored
Jul 24, 2002
by
Fabrice Bellard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added local port option
Originally committed as revision 791 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
3ffe3793
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
13 deletions
+60
-13
rtpproto.c
libav/rtpproto.c
+60
-13
No files found.
libav/rtpproto.c
View file @
51885599
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "avformat.h"
#include "avformat.h"
#include <unistd.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in.h>
...
@@ -39,10 +40,6 @@ typedef struct RTPContext {
...
@@ -39,10 +40,6 @@ typedef struct RTPContext {
* get the local port first, then you must call this function to set
* get the local port first, then you must call this function to set
* the remote server address.
* the remote server address.
*
*
* url syntax: rtp://host:port[?option=val...]
* option: 'multicast=1' : enable multicast
* 'ttl=n' : set the ttl value (for multicast only)
*
* @param s1 media file context
* @param s1 media file context
* @param uri of the remote server
* @param uri of the remote server
* @return zero if no error.
* @return zero if no error.
...
@@ -52,6 +49,7 @@ int rtp_set_remote_url(URLContext *h, const char *uri)
...
@@ -52,6 +49,7 @@ int rtp_set_remote_url(URLContext *h, const char *uri)
RTPContext
*
s
=
h
->
priv_data
;
RTPContext
*
s
=
h
->
priv_data
;
char
hostname
[
256
];
char
hostname
[
256
];
int
port
;
int
port
;
char
buf
[
1024
];
char
buf
[
1024
];
char
path
[
1024
];
char
path
[
1024
];
...
@@ -67,14 +65,51 @@ int rtp_set_remote_url(URLContext *h, const char *uri)
...
@@ -67,14 +65,51 @@ int rtp_set_remote_url(URLContext *h, const char *uri)
}
}
/* add option to url of the form:
"http://host:port/path?option1=val1&option2=val2... */
void
url_add_option
(
char
*
buf
,
int
buf_size
,
const
char
*
fmt
,
...)
{
char
buf1
[
1024
];
va_list
ap
;
va_start
(
ap
,
fmt
);
if
(
strchr
(
buf
,
'?'
))
pstrcat
(
buf
,
buf_size
,
"&"
);
else
pstrcat
(
buf
,
buf_size
,
"?"
);
vsnprintf
(
buf1
,
sizeof
(
buf1
),
fmt
,
ap
);
pstrcat
(
buf
,
buf_size
,
buf1
);
va_end
(
ap
);
}
void
build_udp_url
(
char
*
buf
,
int
buf_size
,
const
char
*
hostname
,
int
port
,
int
local_port
,
int
multicast
,
int
ttl
)
{
snprintf
(
buf
,
buf_size
,
"udp://%s:%d"
,
hostname
,
port
);
if
(
local_port
>=
0
)
url_add_option
(
buf
,
buf_size
,
"localport=%d"
,
local_port
);
if
(
multicast
)
url_add_option
(
buf
,
buf_size
,
"multicast=1"
,
multicast
);
if
(
ttl
>=
0
)
url_add_option
(
buf
,
buf_size
,
"ttl=%d"
,
ttl
);
}
/*
* url syntax: rtp://host:port[?option=val...]
* option: 'multicast=1' : enable multicast
* 'ttl=n' : set the ttl value (for multicast only)
* 'localport=n' : set the local port to n
*
*/
static
int
rtp_open
(
URLContext
*
h
,
const
char
*
uri
,
int
flags
)
static
int
rtp_open
(
URLContext
*
h
,
const
char
*
uri
,
int
flags
)
{
{
RTPContext
*
s
;
RTPContext
*
s
;
int
port
,
is_output
,
local_port
;
int
port
,
is_output
,
is_multicast
,
ttl
,
local_port
;
char
hostname
[
256
];
char
hostname
[
256
];
char
buf
[
1024
];
char
buf
[
1024
];
char
path
[
1024
];
char
path
[
1024
];
URLContext
*
tmp_hd
;
const
char
*
p
;
is_output
=
(
flags
&
URL_WRONLY
);
is_output
=
(
flags
&
URL_WRONLY
);
...
@@ -85,9 +120,23 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
...
@@ -85,9 +120,23 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
url_split
(
NULL
,
0
,
hostname
,
sizeof
(
hostname
),
&
port
,
url_split
(
NULL
,
0
,
hostname
,
sizeof
(
hostname
),
&
port
,
path
,
sizeof
(
path
),
uri
);
path
,
sizeof
(
path
),
uri
);
/* extract parameters */
is_multicast
=
0
;
ttl
=
-
1
;
local_port
=
-
1
;
p
=
strchr
(
uri
,
'?'
);
if
(
p
)
{
is_multicast
=
find_info_tag
(
buf
,
sizeof
(
buf
),
"multicast"
,
p
);
if
(
find_info_tag
(
buf
,
sizeof
(
buf
),
"ttl"
,
p
))
{
ttl
=
strtol
(
buf
,
NULL
,
10
);
}
if
(
find_info_tag
(
buf
,
sizeof
(
buf
),
"localport"
,
p
))
{
local_port
=
strtol
(
buf
,
NULL
,
10
);
}
}
snprintf
(
buf
,
sizeof
(
buf
),
"udp://%s:%d%s"
,
build_udp_url
(
buf
,
sizeof
(
buf
),
hostname
,
port
,
path
);
hostname
,
port
,
local_port
,
is_multicast
,
ttl
);
if
(
url_open
(
&
s
->
rtp_hd
,
buf
,
flags
)
<
0
)
if
(
url_open
(
&
s
->
rtp_hd
,
buf
,
flags
)
<
0
)
goto
fail
;
goto
fail
;
local_port
=
udp_get_local_port
(
s
->
rtp_hd
);
local_port
=
udp_get_local_port
(
s
->
rtp_hd
);
...
@@ -95,10 +144,8 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
...
@@ -95,10 +144,8 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
/* well, should suppress localport in path */
/* well, should suppress localport in path */
snprintf
(
buf
,
sizeof
(
buf
),
"udp://%s:%d%s%clocalport=%d"
,
build_udp_url
(
buf
,
sizeof
(
buf
),
hostname
,
port
+
1
,
path
,
hostname
,
port
+
1
,
local_port
+
1
,
is_multicast
,
ttl
);
strchr
(
path
,
'?'
)
!=
NULL
?
'&'
:
'?'
,
local_port
+
1
);
if
(
url_open
(
&
s
->
rtcp_hd
,
buf
,
flags
)
<
0
)
if
(
url_open
(
&
s
->
rtcp_hd
,
buf
,
flags
)
<
0
)
goto
fail
;
goto
fail
;
...
@@ -182,7 +229,7 @@ static int rtp_read(URLContext *h, UINT8 *buf, int size)
...
@@ -182,7 +229,7 @@ static int rtp_read(URLContext *h, UINT8 *buf, int size)
static
int
rtp_write
(
URLContext
*
h
,
UINT8
*
buf
,
int
size
)
static
int
rtp_write
(
URLContext
*
h
,
UINT8
*
buf
,
int
size
)
{
{
RTPContext
*
s
=
h
->
priv_data
;
RTPContext
*
s
=
h
->
priv_data
;
int
ret
,
fd
;
int
ret
;
URLContext
*
hd
;
URLContext
*
hd
;
if
(
buf
[
1
]
>=
200
&&
buf
[
1
]
<=
204
)
{
if
(
buf
[
1
]
>=
200
&&
buf
[
1
]
<=
204
)
{
...
...
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