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
150e99d6
Commit
150e99d6
authored
Feb 19, 2017
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtsp: Factor out packet reading
parent
4141a5a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
26 deletions
+40
-26
rtsp.c
libavformat/rtsp.c
+40
-26
No files found.
libavformat/rtsp.c
View file @
150e99d6
...
...
@@ -2043,6 +2043,44 @@ static int pick_stream(AVFormatContext *s, RTSPStream **rtsp_st,
return
AVERROR
(
EAGAIN
);
}
static
int
read_packet
(
AVFormatContext
*
s
,
RTSPStream
**
rtsp_st
,
RTSPStream
*
first_queue_st
,
int64_t
wait_end
)
{
RTSPState
*
rt
=
s
->
priv_data
;
int
len
;
switch
(
rt
->
lower_transport
)
{
default:
#if CONFIG_RTSP_DEMUXER
case
RTSP_LOWER_TRANSPORT_TCP
:
len
=
ff_rtsp_tcp_read_packet
(
s
,
rtsp_st
,
rt
->
recvbuf
,
RECVBUF_SIZE
);
break
;
#endif
case
RTSP_LOWER_TRANSPORT_UDP
:
case
RTSP_LOWER_TRANSPORT_UDP_MULTICAST
:
len
=
udp_read_packet
(
s
,
rtsp_st
,
rt
->
recvbuf
,
RECVBUF_SIZE
,
wait_end
);
if
(
len
>
0
&&
(
*
rtsp_st
)
->
transport_priv
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
)
ff_rtp_check_and_send_back_rr
((
*
rtsp_st
)
->
transport_priv
,
(
*
rtsp_st
)
->
rtp_handle
,
NULL
,
len
);
break
;
case
RTSP_LOWER_TRANSPORT_CUSTOM
:
if
(
first_queue_st
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
&&
wait_end
&&
wait_end
<
av_gettime_relative
())
len
=
AVERROR
(
EAGAIN
);
else
len
=
ffio_read_partial
(
s
->
pb
,
rt
->
recvbuf
,
RECVBUF_SIZE
);
len
=
pick_stream
(
s
,
rtsp_st
,
rt
->
recvbuf
,
len
);
if
(
len
>
0
&&
(
*
rtsp_st
)
->
transport_priv
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
)
ff_rtp_check_and_send_back_rr
((
*
rtsp_st
)
->
transport_priv
,
NULL
,
s
->
pb
,
len
);
break
;
}
if
(
len
==
0
)
return
AVERROR_EOF
;
return
len
;
}
int
ff_rtsp_fetch_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
RTSPState
*
rt
=
s
->
priv_data
;
...
...
@@ -2107,30 +2145,7 @@ redo:
return
AVERROR
(
ENOMEM
);
}
switch
(
rt
->
lower_transport
)
{
default:
#if CONFIG_RTSP_DEMUXER
case
RTSP_LOWER_TRANSPORT_TCP
:
len
=
ff_rtsp_tcp_read_packet
(
s
,
&
rtsp_st
,
rt
->
recvbuf
,
RECVBUF_SIZE
);
break
;
#endif
case
RTSP_LOWER_TRANSPORT_UDP
:
case
RTSP_LOWER_TRANSPORT_UDP_MULTICAST
:
len
=
udp_read_packet
(
s
,
&
rtsp_st
,
rt
->
recvbuf
,
RECVBUF_SIZE
,
wait_end
);
if
(
len
>
0
&&
rtsp_st
->
transport_priv
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
)
ff_rtp_check_and_send_back_rr
(
rtsp_st
->
transport_priv
,
rtsp_st
->
rtp_handle
,
NULL
,
len
);
break
;
case
RTSP_LOWER_TRANSPORT_CUSTOM
:
if
(
first_queue_st
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
&&
wait_end
&&
wait_end
<
av_gettime_relative
())
len
=
AVERROR
(
EAGAIN
);
else
len
=
ffio_read_partial
(
s
->
pb
,
rt
->
recvbuf
,
RECVBUF_SIZE
);
len
=
pick_stream
(
s
,
&
rtsp_st
,
rt
->
recvbuf
,
len
);
if
(
len
>
0
&&
rtsp_st
->
transport_priv
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
)
ff_rtp_check_and_send_back_rr
(
rtsp_st
->
transport_priv
,
NULL
,
s
->
pb
,
len
);
break
;
}
len
=
read_packet
(
s
,
&
rtsp_st
,
first_queue_st
,
wait_end
);
if
(
len
==
AVERROR
(
EAGAIN
)
&&
first_queue_st
&&
rt
->
transport
==
RTSP_TRANSPORT_RTP
)
{
av_log
(
s
,
AV_LOG_WARNING
,
...
...
@@ -2141,8 +2156,7 @@ redo:
}
if
(
len
<
0
)
return
len
;
if
(
len
==
0
)
return
AVERROR_EOF
;
if
(
rt
->
transport
==
RTSP_TRANSPORT_RDT
)
{
ret
=
ff_rdt_parse_packet
(
rtsp_st
->
transport_priv
,
pkt
,
&
rt
->
recvbuf
,
len
);
}
else
if
(
rt
->
transport
==
RTSP_TRANSPORT_RTP
)
{
...
...
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