Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
74972220
Commit
74972220
authored
11 years ago
by
Ed Torbett
Committed by
Martin Storsjö
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
rtpproto: Support more than one SSM include address, support excludes
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
7d99c929
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavformat/rtpproto.c
+86
-24
86 additions, 24 deletions
libavformat/rtpproto.c
with
86 additions
and
24 deletions
libavformat/rtpproto.c
+
86
−
24
View file @
74972220
...
...
@@ -42,8 +42,8 @@
typedef
struct
RTPContext
{
URLContext
*
rtp_hd
,
*
rtcp_hd
;
int
rtp_fd
,
rtcp_fd
,
ssm
;
struct
sockaddr_storage
ssm_
addr
;
int
rtp_fd
,
rtcp_fd
,
nb_ssm_include_addrs
,
nb_ssm_exclude_addrs
;
struct
sockaddr_storage
**
ssm_
include_addrs
,
**
ssm_exclude_addrs
;
}
RTPContext
;
/**
...
...
@@ -115,6 +115,25 @@ static int compare_addr(const struct sockaddr_storage *a,
return
1
;
}
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:
* "http://host:port/path?option1=val1&option2=val2...
...
...
@@ -139,7 +158,8 @@ static void build_udp_url(char *buf, int buf_size,
const
char
*
hostname
,
int
port
,
int
local_port
,
int
ttl
,
int
max_packet_size
,
int
connect
,
const
char
*
sources
)
const
char
*
include_sources
,
const
char
*
exclude_sources
)
{
ff_url_join
(
buf
,
buf_size
,
"udp"
,
NULL
,
hostname
,
port
,
NULL
);
if
(
local_port
>=
0
)
...
...
@@ -150,8 +170,50 @@ static void build_udp_url(char *buf, int buf_size,
url_add_option
(
buf
,
buf_size
,
"pkt_size=%d"
,
max_packet_size
);
if
(
connect
)
url_add_option
(
buf
,
buf_size
,
"connect=1"
);
if
(
sources
&&
sources
[
0
])
url_add_option
(
buf
,
buf_size
,
"sources=%s"
,
sources
);
if
(
include_sources
&&
include_sources
[
0
])
url_add_option
(
buf
,
buf_size
,
"sources=%s"
,
include_sources
);
if
(
exclude_sources
&&
exclude_sources
[
0
])
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
)
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
;
}
}
}
/**
...
...
@@ -178,7 +240,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
int
rtp_port
,
rtcp_port
,
ttl
,
connect
,
local_rtp_port
,
local_rtcp_port
,
max_packet_size
;
char
hostname
[
256
],
sources
[
1024
]
=
""
;
char
hostname
[
256
],
include_sources
[
1024
]
=
""
,
exclude_
sources
[
1024
]
=
""
;
char
buf
[
1024
];
char
path
[
1024
];
const
char
*
p
;
...
...
@@ -217,26 +279,18 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
connect
=
strtol
(
buf
,
NULL
,
10
);
}
if
(
av_find_info_tag
(
buf
,
sizeof
(
buf
),
"sources"
,
p
))
{
struct
addrinfo
*
sourceaddr
=
NULL
;
av_strlcpy
(
sources
,
buf
,
sizeof
(
sources
));
/* Try resolving the IP if only one IP is specified - we don't
* support manually checking more than one IP. */
if
(
!
strchr
(
sources
,
','
))
sourceaddr
=
rtp_resolve_host
(
sources
,
0
,
SOCK_DGRAM
,
AF_UNSPEC
,
AI_NUMERICHOST
);
if
(
sourceaddr
)
{
s
->
ssm
=
1
;
memcpy
(
&
s
->
ssm_addr
,
sourceaddr
->
ai_addr
,
sourceaddr
->
ai_addrlen
);
freeaddrinfo
(
sourceaddr
);
}
av_strlcpy
(
include_sources
,
buf
,
sizeof
(
include_sources
));
rtp_parse_addr_list
(
h
,
buf
,
&
s
->
ssm_include_addrs
,
&
s
->
nb_ssm_include_addrs
);
}
if
(
av_find_info_tag
(
buf
,
sizeof
(
buf
),
"block"
,
p
))
{
av_strlcpy
(
exclude_sources
,
buf
,
sizeof
(
exclude_sources
));
rtp_parse_addr_list
(
h
,
buf
,
&
s
->
ssm_exclude_addrs
,
&
s
->
nb_ssm_exclude_addrs
);
}
}
build_udp_url
(
buf
,
sizeof
(
buf
),
hostname
,
rtp_port
,
local_rtp_port
,
ttl
,
max_packet_size
,
connect
,
sources
);
connect
,
include_sources
,
exclude_
sources
);
if
(
ffurl_open
(
&
s
->
rtp_hd
,
buf
,
flags
,
&
h
->
interrupt_callback
,
NULL
)
<
0
)
goto
fail
;
if
(
local_rtp_port
>=
0
&&
local_rtcp_port
<
0
)
...
...
@@ -244,7 +298,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
build_udp_url
(
buf
,
sizeof
(
buf
),
hostname
,
rtcp_port
,
local_rtcp_port
,
ttl
,
max_packet_size
,
connect
,
sources
);
connect
,
include_sources
,
exclude_
sources
);
if
(
ffurl_open
(
&
s
->
rtcp_hd
,
buf
,
flags
,
&
h
->
interrupt_callback
,
NULL
)
<
0
)
goto
fail
;
...
...
@@ -290,7 +344,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
continue
;
return
AVERROR
(
EIO
);
}
if
(
s
->
ssm
&&
compare_addr
(
&
from
,
&
s
->
ssm_addr
))
if
(
rtp_check_source_lists
(
s
,
&
from
))
continue
;
break
;
}
...
...
@@ -305,7 +359,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
continue
;
return
AVERROR
(
EIO
);
}
if
(
s
->
ssm
&&
compare_addr
(
&
from
,
&
s
->
ssm_addr
))
if
(
rtp_check_source_lists
(
s
,
&
from
))
continue
;
break
;
}
...
...
@@ -339,6 +393,14 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
static
int
rtp_close
(
URLContext
*
h
)
{
RTPContext
*
s
=
h
->
priv_data
;
int
i
;
for
(
i
=
0
;
i
<
s
->
nb_ssm_include_addrs
;
i
++
)
av_free
(
s
->
ssm_include_addrs
[
i
]);
av_freep
(
&
s
->
ssm_include_addrs
);
for
(
i
=
0
;
i
<
s
->
nb_ssm_exclude_addrs
;
i
++
)
av_free
(
s
->
ssm_exclude_addrs
[
i
]);
av_freep
(
&
s
->
ssm_exclude_addrs
);
ffurl_close
(
s
->
rtp_hd
);
ffurl_close
(
s
->
rtcp_hd
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment