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
dce37564
Commit
dce37564
authored
Mar 31, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avio: make url_read_complete() internal.
parent
bc371aca
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
35 deletions
+41
-35
avio.c
libavformat/avio.c
+5
-1
avio.h
libavformat/avio.h
+1
-9
mmsh.c
libavformat/mmsh.c
+5
-5
mmst.c
libavformat/mmst.c
+4
-4
rtmppkt.c
libavformat/rtmppkt.c
+8
-8
rtmpproto.c
libavformat/rtmpproto.c
+2
-2
rtsp.c
libavformat/rtsp.c
+4
-4
rtspdec.c
libavformat/rtspdec.c
+3
-2
url.h
libavformat/url.h
+9
-0
No files found.
libavformat/avio.c
View file @
dce37564
...
...
@@ -184,6 +184,10 @@ int url_read(URLContext *h, unsigned char *buf, int size)
{
return
ffurl_read
(
h
,
buf
,
size
);
}
int
url_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
{
return
ffurl_read_complete
(
h
,
buf
,
size
);
}
#endif
#define URL_SCHEME_CHARS \
...
...
@@ -269,7 +273,7 @@ int ffurl_read(URLContext *h, unsigned char *buf, int size)
return
retry_transfer_wrapper
(
h
,
buf
,
size
,
1
,
h
->
prot
->
url_read
);
}
int
url_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
int
ff
url_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
{
if
(
h
->
flags
&
URL_WRONLY
)
return
AVERROR
(
EIO
);
...
...
libavformat/avio.h
View file @
dce37564
...
...
@@ -106,17 +106,9 @@ attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
attribute_deprecated
int
url_connect
(
URLContext
*
h
);
attribute_deprecated
int
url_open
(
URLContext
**
h
,
const
char
*
url
,
int
flags
);
attribute_deprecated
int
url_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
attribute_deprecated
int
url_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
#endif
/**
* Read as many bytes as possible (up to size), calling the
* read function multiple times if necessary.
* This makes special short-read handling in applications
* unnecessary, if the return value is < size then it is
* certain there was either an error or the end of file was reached.
*/
int
url_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
/**
* Write size bytes from buf to the resource accessed by h.
*
...
...
libavformat/mmsh.c
View file @
dce37564
...
...
@@ -79,7 +79,7 @@ static ChunkType get_chunk_header(MMSHContext *mmsh, int *len)
ChunkType
chunk_type
;
int
chunk_len
,
res
,
ext_header_len
;
res
=
url_read_complete
(
mms
->
mms_hd
,
chunk_header
,
CHUNK_HEADER_LENGTH
);
res
=
ff
url_read_complete
(
mms
->
mms_hd
,
chunk_header
,
CHUNK_HEADER_LENGTH
);
if
(
res
!=
CHUNK_HEADER_LENGTH
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Read data packet header failed!
\n
"
);
return
AVERROR
(
EIO
);
...
...
@@ -101,7 +101,7 @@ static ChunkType get_chunk_header(MMSHContext *mmsh, int *len)
return
AVERROR_INVALIDDATA
;
}
res
=
url_read_complete
(
mms
->
mms_hd
,
ext_header
,
ext_header_len
);
res
=
ff
url_read_complete
(
mms
->
mms_hd
,
ext_header
,
ext_header_len
);
if
(
res
!=
ext_header_len
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Read ext header failed!
\n
"
);
return
AVERROR
(
EIO
);
...
...
@@ -122,7 +122,7 @@ static int read_data_packet(MMSHContext *mmsh, const int len)
len
,
sizeof
(
mms
->
in_buffer
));
return
AVERROR
(
EIO
);
}
res
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
len
);
res
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
len
);
av_dlog
(
NULL
,
"Data packet len = %d
\n
"
,
len
);
if
(
res
!=
len
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Read data packet failed!
\n
"
);
...
...
@@ -174,7 +174,7 @@ static int get_http_header_data(MMSHContext *mmsh)
len
,
mms
->
asf_header_size
);
return
AVERROR
(
EIO
);
}
res
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
asf_header
,
len
);
res
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
asf_header
,
len
);
if
(
res
!=
len
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Recv asf header data len %d != expected len %d
\n
"
,
res
,
len
);
...
...
@@ -197,7 +197,7 @@ static int get_http_header_data(MMSHContext *mmsh)
len
,
sizeof
(
mms
->
in_buffer
));
return
AVERROR
(
EIO
);
}
res
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
len
);
res
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
len
);
if
(
res
!=
len
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Read other chunk type data failed!
\n
"
);
return
AVERROR
(
EIO
);
...
...
libavformat/mmst.c
View file @
dce37564
...
...
@@ -241,7 +241,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
MMSSCPacketType
packet_type
=
-
1
;
MMSContext
*
mms
=
&
mmst
->
mms
;
for
(;;)
{
read_result
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
8
);
read_result
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
8
);
if
(
read_result
!=
8
)
{
if
(
read_result
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
...
...
@@ -261,7 +261,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
int
length_remaining
,
hr
;
mmst
->
incoming_flags
=
mms
->
in_buffer
[
3
];
read_result
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
8
,
4
);
read_result
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
8
,
4
);
if
(
read_result
!=
4
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Reading command packet length failed: %d (%s)
\n
"
,
...
...
@@ -281,7 +281,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
length_remaining
,
sizeof
(
mms
->
in_buffer
)
-
12
);
return
AVERROR_INVALIDDATA
;
}
read_result
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
12
,
read_result
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
12
,
length_remaining
)
;
if
(
read_result
!=
length_remaining
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
...
...
@@ -319,7 +319,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
}
mms
->
remaining_in_len
=
length_remaining
;
mms
->
read_in_ptr
=
mms
->
in_buffer
;
read_result
=
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
length_remaining
);
read_result
=
ff
url_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
length_remaining
);
if
(
read_result
!=
length_remaining
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Failed to read packet data of size %d: %d (%s)
\n
"
,
...
...
libavformat/rtmppkt.c
View file @
dce37564
...
...
@@ -86,7 +86,7 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
if
(
channel_id
<
2
)
{
//special case for channel number >= 64
buf
[
1
]
=
0
;
if
(
url_read_complete
(
h
,
buf
,
channel_id
+
1
)
!=
channel_id
+
1
)
if
(
ff
url_read_complete
(
h
,
buf
,
channel_id
+
1
)
!=
channel_id
+
1
)
return
AVERROR
(
EIO
);
size
+=
channel_id
+
1
;
channel_id
=
AV_RL16
(
buf
)
+
64
;
...
...
@@ -99,28 +99,28 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
if
(
hdr
==
RTMP_PS_ONEBYTE
)
{
timestamp
=
prev_pkt
[
channel_id
].
ts_delta
;
}
else
{
if
(
url_read_complete
(
h
,
buf
,
3
)
!=
3
)
if
(
ff
url_read_complete
(
h
,
buf
,
3
)
!=
3
)
return
AVERROR
(
EIO
);
size
+=
3
;
timestamp
=
AV_RB24
(
buf
);
if
(
hdr
!=
RTMP_PS_FOURBYTES
)
{
if
(
url_read_complete
(
h
,
buf
,
3
)
!=
3
)
if
(
ff
url_read_complete
(
h
,
buf
,
3
)
!=
3
)
return
AVERROR
(
EIO
);
size
+=
3
;
data_size
=
AV_RB24
(
buf
);
if
(
url_read_complete
(
h
,
buf
,
1
)
!=
1
)
if
(
ff
url_read_complete
(
h
,
buf
,
1
)
!=
1
)
return
AVERROR
(
EIO
);
size
++
;
type
=
buf
[
0
];
if
(
hdr
==
RTMP_PS_TWELVEBYTES
)
{
if
(
url_read_complete
(
h
,
buf
,
4
)
!=
4
)
if
(
ff
url_read_complete
(
h
,
buf
,
4
)
!=
4
)
return
AVERROR
(
EIO
);
size
+=
4
;
extra
=
AV_RL32
(
buf
);
}
}
if
(
timestamp
==
0xFFFFFF
)
{
if
(
url_read_complete
(
h
,
buf
,
4
)
!=
4
)
if
(
ff
url_read_complete
(
h
,
buf
,
4
)
!=
4
)
return
AVERROR
(
EIO
);
timestamp
=
AV_RB32
(
buf
);
}
...
...
@@ -140,7 +140,7 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
prev_pkt
[
channel_id
].
extra
=
extra
;
while
(
data_size
>
0
)
{
int
toread
=
FFMIN
(
data_size
,
chunk_size
);
if
(
url_read_complete
(
h
,
p
->
data
+
offset
,
toread
)
!=
toread
)
{
if
(
ff
url_read_complete
(
h
,
p
->
data
+
offset
,
toread
)
!=
toread
)
{
ff_rtmp_packet_destroy
(
p
);
return
AVERROR
(
EIO
);
}
...
...
@@ -148,7 +148,7 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
offset
+=
chunk_size
;
size
+=
chunk_size
;
if
(
data_size
>
0
)
{
url_read_complete
(
h
,
&
t
,
1
);
//marker
ff
url_read_complete
(
h
,
&
t
,
1
);
//marker
size
++
;
if
(
t
!=
(
0xC0
+
channel_id
))
return
-
1
;
...
...
libavformat/rtmpproto.c
View file @
dce37564
...
...
@@ -487,12 +487,12 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
client_pos
=
rtmp_handshake_imprint_with_digest
(
tosend
+
1
);
url_write
(
rt
->
stream
,
tosend
,
RTMP_HANDSHAKE_PACKET_SIZE
+
1
);
i
=
url_read_complete
(
rt
->
stream
,
serverdata
,
RTMP_HANDSHAKE_PACKET_SIZE
+
1
);
i
=
ff
url_read_complete
(
rt
->
stream
,
serverdata
,
RTMP_HANDSHAKE_PACKET_SIZE
+
1
);
if
(
i
!=
RTMP_HANDSHAKE_PACKET_SIZE
+
1
)
{
av_log
(
LOG_CONTEXT
,
AV_LOG_ERROR
,
"Cannot read RTMP handshake response
\n
"
);
return
-
1
;
}
i
=
url_read_complete
(
rt
->
stream
,
clientdata
,
RTMP_HANDSHAKE_PACKET_SIZE
);
i
=
ff
url_read_complete
(
rt
->
stream
,
clientdata
,
RTMP_HANDSHAKE_PACKET_SIZE
);
if
(
i
!=
RTMP_HANDSHAKE_PACKET_SIZE
)
{
av_log
(
LOG_CONTEXT
,
AV_LOG_ERROR
,
"Cannot read RTMP handshake response
\n
"
);
return
-
1
;
...
...
libavformat/rtsp.c
View file @
dce37564
...
...
@@ -818,7 +818,7 @@ void ff_rtsp_skip_packet(AVFormatContext *s)
int
ret
,
len
,
len1
;
uint8_t
buf
[
1024
];
ret
=
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
3
);
ret
=
ff
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
3
);
if
(
ret
!=
3
)
return
;
len
=
AV_RB16
(
buf
+
1
);
...
...
@@ -830,7 +830,7 @@ void ff_rtsp_skip_packet(AVFormatContext *s)
len1
=
len
;
if
(
len1
>
sizeof
(
buf
))
len1
=
sizeof
(
buf
);
ret
=
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
len1
);
ret
=
ff
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
len1
);
if
(
ret
!=
len1
)
return
;
len
-=
len1
;
...
...
@@ -855,7 +855,7 @@ int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
for
(;;)
{
q
=
buf
;
for
(;;)
{
ret
=
url_read_complete
(
rt
->
rtsp_hd
,
&
ch
,
1
);
ret
=
ff
url_read_complete
(
rt
->
rtsp_hd
,
&
ch
,
1
);
#ifdef DEBUG_RTP_TCP
av_dlog
(
s
,
"ret=%d c=%02x [%c]
\n
"
,
ret
,
ch
,
ch
);
#endif
...
...
@@ -903,7 +903,7 @@ int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
if
(
content_length
>
0
)
{
/* leave some room for a trailing '\0' (useful for simple parsing) */
content
=
av_malloc
(
content_length
+
1
);
(
void
)
url_read_complete
(
rt
->
rtsp_hd
,
content
,
content_length
);
ff
url_read_complete
(
rt
->
rtsp_hd
,
content
,
content_length
);
content
[
content_length
]
=
'\0'
;
}
if
(
content_ptr
)
...
...
libavformat/rtspdec.c
View file @
dce37564
...
...
@@ -28,6 +28,7 @@
#include "os_support.h"
#include "rtsp.h"
#include "rdt.h"
#include "url.h"
//#define DEBUG
//#define DEBUG_RTP_TCP
...
...
@@ -200,7 +201,7 @@ redo:
if
(
rt
->
state
!=
RTSP_STATE_STREAMING
)
return
0
;
}
ret
=
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
3
);
ret
=
ff
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
3
);
if
(
ret
!=
3
)
return
-
1
;
id
=
buf
[
0
];
...
...
@@ -211,7 +212,7 @@ redo:
if
(
len
>
buf_size
||
len
<
12
)
goto
redo
;
/* get the data */
ret
=
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
len
);
ret
=
ff
url_read_complete
(
rt
->
rtsp_hd
,
buf
,
len
);
if
(
ret
!=
len
)
return
-
1
;
if
(
rt
->
transport
==
RTSP_TRANSPORT_RDT
&&
...
...
libavformat/url.h
View file @
dce37564
...
...
@@ -69,4 +69,13 @@ int ffurl_open(URLContext **h, const char *url, int flags);
*/
int
ffurl_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
/**
* Read as many bytes as possible (up to size), calling the
* read function multiple times if necessary.
* This makes special short-read handling in applications
* unnecessary, if the return value is < size then it is
* certain there was either an error or the end of file was reached.
*/
int
ffurl_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
);
#endif //AVFORMAT_URL_H
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