Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
9d4829f3
Commit
9d4829f3
authored
Sep 13, 2018
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/rtpproto: use factorized ip functions
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
826972c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
117 deletions
+11
-117
Makefile
libavformat/Makefile
+1
-1
rtpproto.c
libavformat/rtpproto.c
+10
-116
No files found.
libavformat/Makefile
View file @
9d4829f3
...
@@ -596,7 +596,7 @@ OBJS-$(CONFIG_RTMPS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
...
@@ -596,7 +596,7 @@ OBJS-$(CONFIG_RTMPS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
OBJS-$(CONFIG_RTMPT_PROTOCOL)
+=
rtmpproto.o
rtmpdigest.o
rtmppkt.o
OBJS-$(CONFIG_RTMPT_PROTOCOL)
+=
rtmpproto.o
rtmpdigest.o
rtmppkt.o
OBJS-$(CONFIG_RTMPTE_PROTOCOL)
+=
rtmpproto.o
rtmpdigest.o
rtmppkt.o
OBJS-$(CONFIG_RTMPTE_PROTOCOL)
+=
rtmpproto.o
rtmpdigest.o
rtmppkt.o
OBJS-$(CONFIG_RTMPTS_PROTOCOL)
+=
rtmpproto.o
rtmpdigest.o
rtmppkt.o
OBJS-$(CONFIG_RTMPTS_PROTOCOL)
+=
rtmpproto.o
rtmpdigest.o
rtmppkt.o
OBJS-$(CONFIG_RTP_PROTOCOL)
+=
rtpproto.o
OBJS-$(CONFIG_RTP_PROTOCOL)
+=
rtpproto.o
ip.o
OBJS-$(CONFIG_SCTP_PROTOCOL)
+=
sctp.o
OBJS-$(CONFIG_SCTP_PROTOCOL)
+=
sctp.o
OBJS-$(CONFIG_SRTP_PROTOCOL)
+=
srtpproto.o
srtp.o
OBJS-$(CONFIG_SRTP_PROTOCOL)
+=
srtpproto.o
srtp.o
OBJS-$(CONFIG_SUBFILE_PROTOCOL)
+=
subfile.o
OBJS-$(CONFIG_SUBFILE_PROTOCOL)
+=
subfile.o
...
...
libavformat/rtpproto.c
View file @
9d4829f3
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "rtp.h"
#include "rtp.h"
#include "rtpproto.h"
#include "rtpproto.h"
#include "url.h"
#include "url.h"
#include "ip.h"
#include <stdarg.h>
#include <stdarg.h>
#include "internal.h"
#include "internal.h"
...
@@ -45,8 +46,8 @@
...
@@ -45,8 +46,8 @@
typedef
struct
RTPContext
{
typedef
struct
RTPContext
{
const
AVClass
*
class
;
const
AVClass
*
class
;
URLContext
*
rtp_hd
,
*
rtcp_hd
,
*
fec_hd
;
URLContext
*
rtp_hd
,
*
rtcp_hd
,
*
fec_hd
;
int
rtp_fd
,
rtcp_fd
,
nb_ssm_include_addrs
,
nb_ssm_exclude_addrs
;
int
rtp_fd
,
rtcp_fd
;
struct
sockaddr_storage
**
ssm_include_addrs
,
**
ssm_exclude_add
rs
;
IPSourceFilters
filte
rs
;
int
write_to_source
;
int
write_to_source
;
struct
sockaddr_storage
last_rtp_source
,
last_rtcp_source
;
struct
sockaddr_storage
last_rtp_source
,
last_rtcp_source
;
socklen_t
last_rtp_source_len
,
last_rtcp_source_len
;
socklen_t
last_rtp_source_len
,
last_rtcp_source_len
;
...
@@ -126,45 +127,6 @@ int ff_rtp_set_remote_url(URLContext *h, const char *uri)
...
@@ -126,45 +127,6 @@ int ff_rtp_set_remote_url(URLContext *h, const char *uri)
return
0
;
return
0
;
}
}
static
struct
addrinfo
*
rtp_resolve_host
(
const
char
*
hostname
,
int
port
,
int
type
,
int
family
,
int
flags
)
{
struct
addrinfo
hints
=
{
0
},
*
res
=
0
;
int
error
;
char
service
[
16
];
snprintf
(
service
,
sizeof
(
service
),
"%d"
,
port
);
hints
.
ai_socktype
=
type
;
hints
.
ai_family
=
family
;
hints
.
ai_flags
=
flags
;
if
((
error
=
getaddrinfo
(
hostname
,
service
,
&
hints
,
&
res
)))
{
res
=
NULL
;
av_log
(
NULL
,
AV_LOG_ERROR
,
"rtp_resolve_host: %s
\n
"
,
gai_strerror
(
error
));
}
return
res
;
}
static
int
compare_addr
(
const
struct
sockaddr_storage
*
a
,
const
struct
sockaddr_storage
*
b
)
{
if
(
a
->
ss_family
!=
b
->
ss_family
)
return
1
;
if
(
a
->
ss_family
==
AF_INET
)
{
return
(((
const
struct
sockaddr_in
*
)
a
)
->
sin_addr
.
s_addr
!=
((
const
struct
sockaddr_in
*
)
b
)
->
sin_addr
.
s_addr
);
}
#if HAVE_STRUCT_SOCKADDR_IN6
if
(
a
->
ss_family
==
AF_INET6
)
{
const
uint8_t
*
s6_addr_a
=
((
const
struct
sockaddr_in6
*
)
a
)
->
sin6_addr
.
s6_addr
;
const
uint8_t
*
s6_addr_b
=
((
const
struct
sockaddr_in6
*
)
b
)
->
sin6_addr
.
s6_addr
;
return
memcmp
(
s6_addr_a
,
s6_addr_b
,
16
);
}
#endif
return
1
;
}
static
int
get_port
(
const
struct
sockaddr_storage
*
ss
)
static
int
get_port
(
const
struct
sockaddr_storage
*
ss
)
{
{
if
(
ss
->
ss_family
==
AF_INET
)
if
(
ss
->
ss_family
==
AF_INET
)
...
@@ -186,25 +148,6 @@ static void set_port(struct sockaddr_storage *ss, int port)
...
@@ -186,25 +148,6 @@ static void set_port(struct sockaddr_storage *ss, int port)
#endif
#endif
}
}
static
int
rtp_check_source_lists
(
RTPContext
*
s
,
struct
sockaddr_storage
*
source_addr_ptr
)
{
int
i
;
if
(
s
->
nb_ssm_exclude_addrs
)
{
for
(
i
=
0
;
i
<
s
->
nb_ssm_exclude_addrs
;
i
++
)
{
if
(
!
compare_addr
(
source_addr_ptr
,
s
->
ssm_exclude_addrs
[
i
]))
return
1
;
}
}
if
(
s
->
nb_ssm_include_addrs
)
{
for
(
i
=
0
;
i
<
s
->
nb_ssm_include_addrs
;
i
++
)
{
if
(
!
compare_addr
(
source_addr_ptr
,
s
->
ssm_include_addrs
[
i
]))
return
0
;
}
return
1
;
}
return
0
;
}
/**
/**
* add option to url of the form:
* add option to url of the form:
* "http://host:port/path?option1=val1&option2=val2...
* "http://host:port/path?option1=val1&option2=val2...
...
@@ -252,48 +195,6 @@ static void build_udp_url(RTPContext *s,
...
@@ -252,48 +195,6 @@ static void build_udp_url(RTPContext *s,
url_add_option
(
buf
,
buf_size
,
"block=%s"
,
exclude_sources
);
url_add_option
(
buf
,
buf_size
,
"block=%s"
,
exclude_sources
);
}
}
static
void
rtp_parse_addr_list
(
URLContext
*
h
,
char
*
buf
,
struct
sockaddr_storage
***
address_list_ptr
,
int
*
address_list_size_ptr
)
{
struct
addrinfo
*
ai
=
NULL
;
struct
sockaddr_storage
*
source_addr
;
char
tmp
=
'\0'
,
*
p
=
buf
,
*
next
;
/* Resolve all of the IPs */
while
(
p
&&
p
[
0
])
{
next
=
strchr
(
p
,
','
);
if
(
next
)
{
tmp
=
*
next
;
*
next
=
'\0'
;
}
ai
=
rtp_resolve_host
(
p
,
0
,
SOCK_DGRAM
,
AF_UNSPEC
,
0
);
if
(
ai
)
{
source_addr
=
av_mallocz
(
sizeof
(
struct
sockaddr_storage
));
if
(
!
source_addr
)
{
freeaddrinfo
(
ai
);
break
;
}
memcpy
(
source_addr
,
ai
->
ai_addr
,
ai
->
ai_addrlen
);
freeaddrinfo
(
ai
);
dynarray_add
(
address_list_ptr
,
address_list_size_ptr
,
source_addr
);
}
else
{
av_log
(
h
,
AV_LOG_WARNING
,
"Unable to resolve %s
\n
"
,
p
);
}
if
(
next
)
{
*
next
=
tmp
;
p
=
next
+
1
;
}
else
{
p
=
NULL
;
}
}
}
/**
/**
* url syntax: rtp://host:port[?option=val...]
* url syntax: rtp://host:port[?option=val...]
* option: 'ttl=n' : set the ttl value (for multicast only)
* option: 'ttl=n' : set the ttl value (for multicast only)
...
@@ -366,17 +267,16 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
...
@@ -366,17 +267,16 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
}
}
if
(
av_find_info_tag
(
buf
,
sizeof
(
buf
),
"sources"
,
p
))
{
if
(
av_find_info_tag
(
buf
,
sizeof
(
buf
),
"sources"
,
p
))
{
av_strlcpy
(
include_sources
,
buf
,
sizeof
(
include_sources
));
av_strlcpy
(
include_sources
,
buf
,
sizeof
(
include_sources
));
ff_ip_parse_sources
(
h
,
buf
,
&
s
->
filters
);
rtp_parse_addr_list
(
h
,
buf
,
&
s
->
ssm_include_addrs
,
&
s
->
nb_ssm_include_addrs
);
}
else
{
}
else
{
rtp_parse_addr_list
(
h
,
s
->
sources
,
&
s
->
ssm_include_addrs
,
&
s
->
nb_ssm_include_add
rs
);
ff_ip_parse_sources
(
h
,
s
->
sources
,
&
s
->
filte
rs
);
sources
=
s
->
sources
;
sources
=
s
->
sources
;
}
}
if
(
av_find_info_tag
(
buf
,
sizeof
(
buf
),
"block"
,
p
))
{
if
(
av_find_info_tag
(
buf
,
sizeof
(
buf
),
"block"
,
p
))
{
av_strlcpy
(
exclude_sources
,
buf
,
sizeof
(
exclude_sources
));
av_strlcpy
(
exclude_sources
,
buf
,
sizeof
(
exclude_sources
));
rtp_parse_addr_list
(
h
,
buf
,
&
s
->
ssm_exclude_addrs
,
&
s
->
nb_ssm_exclude_add
rs
);
ff_ip_parse_blocks
(
h
,
buf
,
&
s
->
filte
rs
);
}
else
{
}
else
{
rtp_parse_addr_list
(
h
,
s
->
block
,
&
s
->
ssm_exclude_addrs
,
&
s
->
nb_ssm_exclude_add
rs
);
ff_ip_parse_blocks
(
h
,
s
->
block
,
&
s
->
filte
rs
);
block
=
s
->
block
;
block
=
s
->
block
;
}
}
}
}
...
@@ -500,7 +400,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
...
@@ -500,7 +400,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
continue
;
continue
;
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
}
}
if
(
rtp_check_source_lists
(
s
,
addrs
[
i
]
))
if
(
ff_ip_check_source_lists
(
addrs
[
i
],
&
s
->
filters
))
continue
;
continue
;
return
len
;
return
len
;
}
}
...
@@ -603,14 +503,8 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
...
@@ -603,14 +503,8 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
static
int
rtp_close
(
URLContext
*
h
)
static
int
rtp_close
(
URLContext
*
h
)
{
{
RTPContext
*
s
=
h
->
priv_data
;
RTPContext
*
s
=
h
->
priv_data
;
int
i
;
ff_ip_reset_filters
(
&
s
->
filters
);
for
(
i
=
0
;
i
<
s
->
nb_ssm_include_addrs
;
i
++
)
av_freep
(
&
s
->
ssm_include_addrs
[
i
]);
av_freep
(
&
s
->
ssm_include_addrs
);
for
(
i
=
0
;
i
<
s
->
nb_ssm_exclude_addrs
;
i
++
)
av_freep
(
&
s
->
ssm_exclude_addrs
[
i
]);
av_freep
(
&
s
->
ssm_exclude_addrs
);
ffurl_close
(
s
->
rtp_hd
);
ffurl_close
(
s
->
rtp_hd
);
ffurl_close
(
s
->
rtcp_hd
);
ffurl_close
(
s
->
rtcp_hd
);
...
...
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