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
f87b1b37
Commit
f87b1b37
authored
Apr 04, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avio: AVIO_ prefixes for URL_ open flags.
parent
3d42d493
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
92 additions
and
65 deletions
+92
-65
ffmpeg.c
ffmpeg.c
+1
-1
ffserver.c
ffserver.c
+2
-2
applehttp.c
libavformat/applehttp.c
+2
-2
applehttpproto.c
libavformat/applehttpproto.c
+3
-3
avio.c
libavformat/avio.c
+6
-6
avio.h
libavformat/avio.h
+28
-1
aviobuf.c
libavformat/aviobuf.c
+7
-7
file.c
libavformat/file.c
+3
-3
gopher.c
libavformat/gopher.c
+1
-1
http.c
libavformat/http.c
+3
-3
img2.c
libavformat/img2.c
+2
-2
librtmp.c
libavformat/librtmp.c
+1
-1
matroskadec.c
libavformat/matroskadec.c
+1
-1
md5proto.c
libavformat/md5proto.c
+2
-2
mmsh.c
libavformat/mmsh.c
+2
-2
mmst.c
libavformat/mmst.c
+1
-1
mov.c
libavformat/mov.c
+1
-1
output-example.c
libavformat/output-example.c
+1
-1
rtmpproto.c
libavformat/rtmpproto.c
+2
-2
rtpproto.c
libavformat/rtpproto.c
+1
-1
rtsp.c
libavformat/rtsp.c
+8
-8
sapdec.c
libavformat/sapdec.c
+1
-1
sapenc.c
libavformat/sapenc.c
+2
-2
tcp.c
libavformat/tcp.c
+2
-2
udp.c
libavformat/udp.c
+8
-8
utils.c
libavformat/utils.c
+1
-1
No files found.
ffmpeg.c
View file @
f87b1b37
...
@@ -3750,7 +3750,7 @@ static void opt_output_file(const char *filename)
...
@@ -3750,7 +3750,7 @@ static void opt_output_file(const char *filename)
}
}
/* open the file */
/* open the file */
if
((
err
=
avio_open
(
&
oc
->
pb
,
filename
,
URL
_WRONLY
))
<
0
)
{
if
((
err
=
avio_open
(
&
oc
->
pb
,
filename
,
AVIO
_WRONLY
))
<
0
)
{
print_error
(
filename
,
err
);
print_error
(
filename
,
err
);
ffmpeg_exit
(
1
);
ffmpeg_exit
(
1
);
}
}
...
...
ffserver.c
View file @
f87b1b37
...
@@ -3427,7 +3427,7 @@ static int rtp_new_av_stream(HTTPContext *c,
...
@@ -3427,7 +3427,7 @@ static int rtp_new_av_stream(HTTPContext *c,
"rtp://%s:%d"
,
ipaddr
,
ntohs
(
dest_addr
->
sin_port
));
"rtp://%s:%d"
,
ipaddr
,
ntohs
(
dest_addr
->
sin_port
));
}
}
if
(
url_open
(
&
h
,
ctx
->
filename
,
URL
_WRONLY
)
<
0
)
if
(
url_open
(
&
h
,
ctx
->
filename
,
AVIO
_WRONLY
)
<
0
)
goto
fail
;
goto
fail
;
c
->
rtp_handles
[
stream_index
]
=
h
;
c
->
rtp_handles
[
stream_index
]
=
h
;
max_packet_size
=
url_get_max_packet_size
(
h
);
max_packet_size
=
url_get_max_packet_size
(
h
);
...
@@ -3767,7 +3767,7 @@ static void build_feed_streams(void)
...
@@ -3767,7 +3767,7 @@ static void build_feed_streams(void)
}
}
/* only write the header of the ffm file */
/* only write the header of the ffm file */
if
(
avio_open
(
&
s
->
pb
,
feed
->
feed_filename
,
URL
_WRONLY
)
<
0
)
{
if
(
avio_open
(
&
s
->
pb
,
feed
->
feed_filename
,
AVIO
_WRONLY
)
<
0
)
{
http_log
(
"Could not open output feed file '%s'
\n
"
,
http_log
(
"Could not open output feed file '%s'
\n
"
,
feed
->
feed_filename
);
feed
->
feed_filename
);
exit
(
1
);
exit
(
1
);
...
...
libavformat/applehttp.c
View file @
f87b1b37
...
@@ -169,7 +169,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
...
@@ -169,7 +169,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
if
(
!
in
)
{
if
(
!
in
)
{
close_in
=
1
;
close_in
=
1
;
if
((
ret
=
avio_open
(
&
in
,
url
,
URL
_RDONLY
))
<
0
)
if
((
ret
=
avio_open
(
&
in
,
url
,
AVIO
_RDONLY
))
<
0
)
return
ret
;
return
ret
;
}
}
...
@@ -292,7 +292,7 @@ reload:
...
@@ -292,7 +292,7 @@ reload:
ret
=
url_open
(
&
v
->
input
,
ret
=
url_open
(
&
v
->
input
,
v
->
segments
[
v
->
cur_seq_no
-
v
->
start_seq_no
]
->
url
,
v
->
segments
[
v
->
cur_seq_no
-
v
->
start_seq_no
]
->
url
,
URL
_RDONLY
);
AVIO
_RDONLY
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
...
libavformat/applehttpproto.c
View file @
f87b1b37
...
@@ -115,7 +115,7 @@ static int parse_playlist(URLContext *h, const char *url)
...
@@ -115,7 +115,7 @@ static int parse_playlist(URLContext *h, const char *url)
char
line
[
1024
];
char
line
[
1024
];
const
char
*
ptr
;
const
char
*
ptr
;
if
((
ret
=
avio_open
(
&
in
,
url
,
URL
_RDONLY
))
<
0
)
if
((
ret
=
avio_open
(
&
in
,
url
,
AVIO
_RDONLY
))
<
0
)
return
ret
;
return
ret
;
read_chomp_line
(
in
,
line
,
sizeof
(
line
));
read_chomp_line
(
in
,
line
,
sizeof
(
line
));
...
@@ -180,7 +180,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
...
@@ -180,7 +180,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
int
ret
,
i
;
int
ret
,
i
;
const
char
*
nested_url
;
const
char
*
nested_url
;
if
(
flags
&
(
URL_WRONLY
|
URL
_RDWR
))
if
(
flags
&
(
AVIO_WRONLY
|
AVIO
_RDWR
))
return
AVERROR
(
ENOSYS
);
return
AVERROR
(
ENOSYS
);
s
=
av_mallocz
(
sizeof
(
AppleHTTPContext
));
s
=
av_mallocz
(
sizeof
(
AppleHTTPContext
));
...
@@ -275,7 +275,7 @@ retry:
...
@@ -275,7 +275,7 @@ retry:
}
}
url
=
s
->
segments
[
s
->
cur_seq_no
-
s
->
start_seq_no
]
->
url
,
url
=
s
->
segments
[
s
->
cur_seq_no
-
s
->
start_seq_no
]
->
url
,
av_log
(
NULL
,
AV_LOG_DEBUG
,
"opening %s
\n
"
,
url
);
av_log
(
NULL
,
AV_LOG_DEBUG
,
"opening %s
\n
"
,
url
);
ret
=
ffurl_open
(
&
s
->
seg_hd
,
url
,
URL
_RDONLY
);
ret
=
ffurl_open
(
&
s
->
seg_hd
,
url
,
AVIO
_RDONLY
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
url_interrupt_cb
())
if
(
url_interrupt_cb
())
return
AVERROR_EXIT
;
return
AVERROR_EXIT
;
...
...
libavformat/avio.c
View file @
f87b1b37
...
@@ -144,7 +144,7 @@ int ffurl_connect(URLContext* uc)
...
@@ -144,7 +144,7 @@ int ffurl_connect(URLContext* uc)
return
err
;
return
err
;
uc
->
is_connected
=
1
;
uc
->
is_connected
=
1
;
//We must be careful here as ffurl_seek() could be slow, for example for http
//We must be careful here as ffurl_seek() could be slow, for example for http
if
(
(
uc
->
flags
&
(
URL_WRONLY
|
URL
_RDWR
))
if
(
(
uc
->
flags
&
(
AVIO_WRONLY
|
AVIO
_RDWR
))
||
!
strcmp
(
uc
->
prot
->
name
,
"file"
))
||
!
strcmp
(
uc
->
prot
->
name
,
"file"
))
if
(
!
uc
->
is_streamed
&&
ffurl_seek
(
uc
,
0
,
SEEK_SET
)
<
0
)
if
(
!
uc
->
is_streamed
&&
ffurl_seek
(
uc
,
0
,
SEEK_SET
)
<
0
)
uc
->
is_streamed
=
1
;
uc
->
is_streamed
=
1
;
...
@@ -275,7 +275,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
...
@@ -275,7 +275,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
ret
=
transfer_func
(
h
,
buf
+
len
,
size
-
len
);
ret
=
transfer_func
(
h
,
buf
+
len
,
size
-
len
);
if
(
ret
==
AVERROR
(
EINTR
))
if
(
ret
==
AVERROR
(
EINTR
))
continue
;
continue
;
if
(
h
->
flags
&
URL
_FLAG_NONBLOCK
)
if
(
h
->
flags
&
AVIO
_FLAG_NONBLOCK
)
return
ret
;
return
ret
;
if
(
ret
==
AVERROR
(
EAGAIN
))
{
if
(
ret
==
AVERROR
(
EAGAIN
))
{
ret
=
0
;
ret
=
0
;
...
@@ -296,21 +296,21 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
...
@@ -296,21 +296,21 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
int
ffurl_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
int
ffurl_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
{
{
if
(
h
->
flags
&
URL
_WRONLY
)
if
(
h
->
flags
&
AVIO
_WRONLY
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
return
retry_transfer_wrapper
(
h
,
buf
,
size
,
1
,
h
->
prot
->
url_read
);
return
retry_transfer_wrapper
(
h
,
buf
,
size
,
1
,
h
->
prot
->
url_read
);
}
}
int
ffurl_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
int
ffurl_read_complete
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
{
{
if
(
h
->
flags
&
URL
_WRONLY
)
if
(
h
->
flags
&
AVIO
_WRONLY
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
return
retry_transfer_wrapper
(
h
,
buf
,
size
,
size
,
h
->
prot
->
url_read
);
return
retry_transfer_wrapper
(
h
,
buf
,
size
,
size
,
h
->
prot
->
url_read
);
}
}
int
ffurl_write
(
URLContext
*
h
,
const
unsigned
char
*
buf
,
int
size
)
int
ffurl_write
(
URLContext
*
h
,
const
unsigned
char
*
buf
,
int
size
)
{
{
if
(
!
(
h
->
flags
&
(
URL_WRONLY
|
URL
_RDWR
)))
if
(
!
(
h
->
flags
&
(
AVIO_WRONLY
|
AVIO
_RDWR
)))
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
/* avoid sending too big packets */
/* avoid sending too big packets */
if
(
h
->
max_packet_size
&&
size
>
h
->
max_packet_size
)
if
(
h
->
max_packet_size
&&
size
>
h
->
max_packet_size
)
...
@@ -348,7 +348,7 @@ int ffurl_close(URLContext *h)
...
@@ -348,7 +348,7 @@ int ffurl_close(URLContext *h)
int
url_exist
(
const
char
*
filename
)
int
url_exist
(
const
char
*
filename
)
{
{
URLContext
*
h
;
URLContext
*
h
;
if
(
ffurl_open
(
&
h
,
filename
,
URL
_RDONLY
)
<
0
)
if
(
ffurl_open
(
&
h
,
filename
,
AVIO
_RDONLY
)
<
0
)
return
0
;
return
0
;
ffurl_close
(
h
);
ffurl_close
(
h
);
return
1
;
return
1
;
...
...
libavformat/avio.h
View file @
f87b1b37
...
@@ -63,7 +63,6 @@ typedef struct URLPollEntry {
...
@@ -63,7 +63,6 @@ typedef struct URLPollEntry {
int
events
;
int
events
;
int
revents
;
int
revents
;
}
URLPollEntry
;
}
URLPollEntry
;
#endif
/**
/**
* @defgroup open_modes URL open modes
* @defgroup open_modes URL open modes
...
@@ -91,6 +90,7 @@ typedef struct URLPollEntry {
...
@@ -91,6 +90,7 @@ typedef struct URLPollEntry {
* silently ignored.
* silently ignored.
*/
*/
#define URL_FLAG_NONBLOCK 4
#define URL_FLAG_NONBLOCK 4
#endif
typedef
int
URLInterruptCB
(
void
);
typedef
int
URLInterruptCB
(
void
);
...
@@ -511,6 +511,33 @@ attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
...
@@ -511,6 +511,33 @@ attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
int
url_resetbuf
(
AVIOContext
*
s
,
int
flags
);
int
url_resetbuf
(
AVIOContext
*
s
,
int
flags
);
#endif
#endif
/**
* @defgroup open_modes URL open modes
* The flags argument to avio_open must be one of the following
* constants, optionally ORed with other flags.
* @{
*/
#define AVIO_RDONLY 0
/**< read-only */
#define AVIO_WRONLY 1
/**< write-only */
#define AVIO_RDWR 2
/**< read-write */
/**
* @}
*/
/**
* Use non-blocking mode.
* If this flag is set, operations on the context will return
* AVERROR(EAGAIN) if they can not be performed immediately.
* If this flag is not set, operations on the context will never return
* AVERROR(EAGAIN).
* Note that this flag does not affect the opening/connecting of the
* context. Connecting a protocol will always block if necessary (e.g. on
* network protocols) but never hang (e.g. on busy devices).
* Warning: non-blocking protocols is work-in-progress; this flag may be
* silently ignored.
*/
#define AVIO_FLAG_NONBLOCK 4
/**
/**
* Create and initialize a AVIOContext for accessing the
* Create and initialize a AVIOContext for accessing the
* resource indicated by url.
* resource indicated by url.
...
...
libavformat/aviobuf.c
View file @
f87b1b37
...
@@ -55,7 +55,7 @@ int ffio_init_context(AVIOContext *s,
...
@@ -55,7 +55,7 @@ int ffio_init_context(AVIOContext *s,
s
->
buffer_size
=
buffer_size
;
s
->
buffer_size
=
buffer_size
;
s
->
buf_ptr
=
buffer
;
s
->
buf_ptr
=
buffer
;
s
->
opaque
=
opaque
;
s
->
opaque
=
opaque
;
url_resetbuf
(
s
,
write_flag
?
URL_WRONLY
:
URL
_RDONLY
);
url_resetbuf
(
s
,
write_flag
?
AVIO_WRONLY
:
AVIO
_RDONLY
);
s
->
write_packet
=
write_packet
;
s
->
write_packet
=
write_packet
;
s
->
read_packet
=
read_packet
;
s
->
read_packet
=
read_packet
;
s
->
seek
=
seek
;
s
->
seek
=
seek
;
...
@@ -845,7 +845,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
...
@@ -845,7 +845,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
}
}
if
(
ffio_init_context
(
*
s
,
buffer
,
buffer_size
,
if
(
ffio_init_context
(
*
s
,
buffer
,
buffer_size
,
(
h
->
flags
&
URL_WRONLY
||
h
->
flags
&
URL
_RDWR
),
h
,
(
h
->
flags
&
AVIO_WRONLY
||
h
->
flags
&
AVIO
_RDWR
),
h
,
ffurl_read
,
ffurl_write
,
ffurl_seek
)
<
0
)
{
ffurl_read
,
ffurl_write
,
ffurl_seek
)
<
0
)
{
av_free
(
buffer
);
av_free
(
buffer
);
av_freep
(
s
);
av_freep
(
s
);
...
@@ -874,7 +874,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
...
@@ -874,7 +874,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
s
->
buffer
=
buffer
;
s
->
buffer
=
buffer
;
s
->
buffer_size
=
buf_size
;
s
->
buffer_size
=
buf_size
;
s
->
buf_ptr
=
buffer
;
s
->
buf_ptr
=
buffer
;
url_resetbuf
(
s
,
s
->
write_flag
?
URL_WRONLY
:
URL
_RDONLY
);
url_resetbuf
(
s
,
s
->
write_flag
?
AVIO_WRONLY
:
AVIO
_RDONLY
);
return
0
;
return
0
;
}
}
...
@@ -885,13 +885,13 @@ static int url_resetbuf(AVIOContext *s, int flags)
...
@@ -885,13 +885,13 @@ static int url_resetbuf(AVIOContext *s, int flags)
#endif
#endif
{
{
#if FF_API_URL_RESETBUF
#if FF_API_URL_RESETBUF
if
(
flags
&
URL
_RDWR
)
if
(
flags
&
AVIO
_RDWR
)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
#else
#else
assert
(
flags
==
URL_WRONLY
||
flags
==
URL
_RDONLY
);
assert
(
flags
==
AVIO_WRONLY
||
flags
==
AVIO
_RDONLY
);
#endif
#endif
if
(
flags
&
URL
_WRONLY
)
{
if
(
flags
&
AVIO
_WRONLY
)
{
s
->
buf_end
=
s
->
buffer
+
s
->
buffer_size
;
s
->
buf_end
=
s
->
buffer
+
s
->
buffer_size
;
s
->
write_flag
=
1
;
s
->
write_flag
=
1
;
}
else
{
}
else
{
...
@@ -1049,7 +1049,7 @@ int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags)
...
@@ -1049,7 +1049,7 @@ int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags)
if
(
!*
s
)
if
(
!*
s
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
ret
=
ffio_init_context
(
*
s
,
buf
,
buf_size
,
ret
=
ffio_init_context
(
*
s
,
buf
,
buf_size
,
(
flags
&
URL_WRONLY
||
flags
&
URL
_RDWR
),
(
flags
&
AVIO_WRONLY
||
flags
&
AVIO
_RDWR
),
NULL
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
,
NULL
);
if
(
ret
!=
0
)
if
(
ret
!=
0
)
av_freep
(
s
);
av_freep
(
s
);
...
...
libavformat/file.c
View file @
f87b1b37
...
@@ -59,9 +59,9 @@ static int file_open(URLContext *h, const char *filename, int flags)
...
@@ -59,9 +59,9 @@ static int file_open(URLContext *h, const char *filename, int flags)
av_strstart
(
filename
,
"file:"
,
&
filename
);
av_strstart
(
filename
,
"file:"
,
&
filename
);
if
(
flags
&
URL
_RDWR
)
{
if
(
flags
&
AVIO
_RDWR
)
{
access
=
O_CREAT
|
O_TRUNC
|
O_RDWR
;
access
=
O_CREAT
|
O_TRUNC
|
O_RDWR
;
}
else
if
(
flags
&
URL
_WRONLY
)
{
}
else
if
(
flags
&
AVIO
_WRONLY
)
{
access
=
O_CREAT
|
O_TRUNC
|
O_WRONLY
;
access
=
O_CREAT
|
O_TRUNC
|
O_WRONLY
;
}
else
{
}
else
{
access
=
O_RDONLY
;
access
=
O_RDONLY
;
...
@@ -116,7 +116,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
...
@@ -116,7 +116,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
fd
=
strtol
(
filename
,
&
final
,
10
);
fd
=
strtol
(
filename
,
&
final
,
10
);
if
((
filename
==
final
)
||
*
final
)
{
/* No digits found, or something like 10ab */
if
((
filename
==
final
)
||
*
final
)
{
/* No digits found, or something like 10ab */
if
(
flags
&
URL
_WRONLY
)
{
if
(
flags
&
AVIO
_WRONLY
)
{
fd
=
1
;
fd
=
1
;
}
else
{
}
else
{
fd
=
0
;
fd
=
0
;
...
...
libavformat/gopher.c
View file @
f87b1b37
...
@@ -100,7 +100,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags)
...
@@ -100,7 +100,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags)
ff_url_join
(
buf
,
sizeof
(
buf
),
"tcp"
,
NULL
,
hostname
,
port
,
NULL
);
ff_url_join
(
buf
,
sizeof
(
buf
),
"tcp"
,
NULL
,
hostname
,
port
,
NULL
);
s
->
hd
=
NULL
;
s
->
hd
=
NULL
;
err
=
ffurl_open
(
&
s
->
hd
,
buf
,
URL
_RDWR
);
err
=
ffurl_open
(
&
s
->
hd
,
buf
,
AVIO
_RDWR
);
if
(
err
<
0
)
if
(
err
<
0
)
goto
fail
;
goto
fail
;
...
...
libavformat/http.c
View file @
f87b1b37
...
@@ -124,7 +124,7 @@ static int http_open_cnx(URLContext *h)
...
@@ -124,7 +124,7 @@ static int http_open_cnx(URLContext *h)
port
=
80
;
port
=
80
;
ff_url_join
(
buf
,
sizeof
(
buf
),
"tcp"
,
NULL
,
hostname
,
port
,
NULL
);
ff_url_join
(
buf
,
sizeof
(
buf
),
"tcp"
,
NULL
,
hostname
,
port
,
NULL
);
err
=
ffurl_open
(
&
hd
,
buf
,
URL
_RDWR
);
err
=
ffurl_open
(
&
hd
,
buf
,
AVIO
_RDWR
);
if
(
err
<
0
)
if
(
err
<
0
)
goto
fail
;
goto
fail
;
...
@@ -296,7 +296,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
...
@@ -296,7 +296,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
/* send http header */
/* send http header */
post
=
h
->
flags
&
URL
_WRONLY
;
post
=
h
->
flags
&
AVIO
_WRONLY
;
authstr
=
ff_http_auth_create_response
(
&
s
->
auth_state
,
auth
,
path
,
authstr
=
ff_http_auth_create_response
(
&
s
->
auth_state
,
auth
,
path
,
post
?
"POST"
:
"GET"
);
post
?
"POST"
:
"GET"
);
...
@@ -451,7 +451,7 @@ static int http_close(URLContext *h)
...
@@ -451,7 +451,7 @@ static int http_close(URLContext *h)
HTTPContext
*
s
=
h
->
priv_data
;
HTTPContext
*
s
=
h
->
priv_data
;
/* signal end of chunked encoding if used */
/* signal end of chunked encoding if used */
if
((
h
->
flags
&
URL
_WRONLY
)
&&
s
->
chunksize
!=
-
1
)
{
if
((
h
->
flags
&
AVIO
_WRONLY
)
&&
s
->
chunksize
!=
-
1
)
{
ret
=
ffurl_write
(
s
->
hd
,
footer
,
sizeof
(
footer
)
-
1
);
ret
=
ffurl_write
(
s
->
hd
,
footer
,
sizeof
(
footer
)
-
1
);
ret
=
ret
>
0
?
0
:
ret
;
ret
=
ret
>
0
?
0
:
ret
;
}
}
...
...
libavformat/img2.c
View file @
f87b1b37
...
@@ -270,7 +270,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
...
@@ -270,7 +270,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
s
->
path
,
s
->
img_number
)
<
0
&&
s
->
img_number
>
1
)
s
->
path
,
s
->
img_number
)
<
0
&&
s
->
img_number
>
1
)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
for
(
i
=
0
;
i
<
3
;
i
++
){
for
(
i
=
0
;
i
<
3
;
i
++
){
if
(
avio_open
(
&
f
[
i
],
filename
,
URL
_RDONLY
)
<
0
)
{
if
(
avio_open
(
&
f
[
i
],
filename
,
AVIO
_RDONLY
)
<
0
)
{
if
(
i
==
1
)
if
(
i
==
1
)
break
;
break
;
av_log
(
s1
,
AV_LOG_ERROR
,
"Could not open file : %s
\n
"
,
filename
);
av_log
(
s1
,
AV_LOG_ERROR
,
"Could not open file : %s
\n
"
,
filename
);
...
@@ -354,7 +354,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -354,7 +354,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
}
}
for
(
i
=
0
;
i
<
3
;
i
++
){
for
(
i
=
0
;
i
<
3
;
i
++
){
if
(
avio_open
(
&
pb
[
i
],
filename
,
URL
_WRONLY
)
<
0
)
{
if
(
avio_open
(
&
pb
[
i
],
filename
,
AVIO
_WRONLY
)
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open file : %s
\n
"
,
filename
);
av_log
(
s
,
AV_LOG_ERROR
,
"Could not open file : %s
\n
"
,
filename
);
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
}
}
...
...
libavformat/librtmp.c
View file @
f87b1b37
...
@@ -93,7 +93,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
...
@@ -93,7 +93,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
goto
fail
;
goto
fail
;
}
}
if
(
flags
&
URL
_WRONLY
)
if
(
flags
&
AVIO
_WRONLY
)
RTMP_EnableWrite
(
r
);
RTMP_EnableWrite
(
r
);
if
(
!
RTMP_Connect
(
r
,
NULL
)
||
!
RTMP_ConnectStream
(
r
,
0
))
{
if
(
!
RTMP_Connect
(
r
,
NULL
)
||
!
RTMP_ConnectStream
(
r
,
0
))
{
...
...
libavformat/matroskadec.c
View file @
f87b1b37
...
@@ -1330,7 +1330,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
...
@@ -1330,7 +1330,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
&&
track
->
codec_priv
.
size
>=
14
&&
track
->
codec_priv
.
size
>=
14
&&
track
->
codec_priv
.
data
!=
NULL
)
{
&&
track
->
codec_priv
.
data
!=
NULL
)
{
ffio_init_context
(
&
b
,
track
->
codec_priv
.
data
,
track
->
codec_priv
.
size
,
ffio_init_context
(
&
b
,
track
->
codec_priv
.
data
,
track
->
codec_priv
.
size
,
URL
_RDONLY
,
NULL
,
NULL
,
NULL
,
NULL
);
AVIO
_RDONLY
,
NULL
,
NULL
,
NULL
,
NULL
);
ff_get_wav_header
(
&
b
,
st
->
codec
,
track
->
codec_priv
.
size
);
ff_get_wav_header
(
&
b
,
st
->
codec
,
track
->
codec_priv
.
size
);
codec_id
=
st
->
codec
->
codec_id
;
codec_id
=
st
->
codec
->
codec_id
;
extradata_offset
=
FFMIN
(
track
->
codec_priv
.
size
,
18
);
extradata_offset
=
FFMIN
(
track
->
codec_priv
.
size
,
18
);
...
...
libavformat/md5proto.c
View file @
f87b1b37
...
@@ -36,7 +36,7 @@ static int md5_open(URLContext *h, const char *filename, int flags)
...
@@ -36,7 +36,7 @@ static int md5_open(URLContext *h, const char *filename, int flags)
return
-
1
;
return
-
1
;
}
}
if
(
flags
!=
URL
_WRONLY
)
if
(
flags
!=
AVIO
_WRONLY
)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
av_md5_init
(
h
->
priv_data
);
av_md5_init
(
h
->
priv_data
);
...
@@ -65,7 +65,7 @@ static int md5_close(URLContext *h)
...
@@ -65,7 +65,7 @@ static int md5_close(URLContext *h)
av_strstart
(
filename
,
"md5:"
,
&
filename
);
av_strstart
(
filename
,
"md5:"
,
&
filename
);
if
(
*
filename
)
{
if
(
*
filename
)
{
err
=
ffurl_open
(
&
out
,
filename
,
URL
_WRONLY
);
err
=
ffurl_open
(
&
out
,
filename
,
AVIO
_WRONLY
);
if
(
err
)
if
(
err
)
return
err
;
return
err
;
err
=
ffurl_write
(
out
,
buf
,
i
*
2
+
1
);
err
=
ffurl_write
(
out
,
buf
,
i
*
2
+
1
);
...
...
libavformat/mmsh.c
View file @
f87b1b37
...
@@ -233,7 +233,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
...
@@ -233,7 +233,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
port
=
80
;
// default mmsh protocol port
port
=
80
;
// default mmsh protocol port
ff_url_join
(
httpname
,
sizeof
(
httpname
),
"http"
,
NULL
,
host
,
port
,
path
);
ff_url_join
(
httpname
,
sizeof
(
httpname
),
"http"
,
NULL
,
host
,
port
,
path
);
if
(
ffurl_alloc
(
&
mms
->
mms_hd
,
httpname
,
URL
_RDONLY
)
<
0
)
{
if
(
ffurl_alloc
(
&
mms
->
mms_hd
,
httpname
,
AVIO
_RDONLY
)
<
0
)
{
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
}
}
...
@@ -261,7 +261,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
...
@@ -261,7 +261,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags)
// close the socket and then reopen it for sending the second play request.
// close the socket and then reopen it for sending the second play request.
ffurl_close
(
mms
->
mms_hd
);
ffurl_close
(
mms
->
mms_hd
);
memset
(
headers
,
0
,
sizeof
(
headers
));
memset
(
headers
,
0
,
sizeof
(
headers
));
if
(
ffurl_alloc
(
&
mms
->
mms_hd
,
httpname
,
URL
_RDONLY
)
<
0
)
{
if
(
ffurl_alloc
(
&
mms
->
mms_hd
,
httpname
,
AVIO
_RDONLY
)
<
0
)
{
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
}
}
stream_selection
=
av_mallocz
(
mms
->
stream_num
*
19
+
1
);
stream_selection
=
av_mallocz
(
mms
->
stream_num
*
19
+
1
);
...
...
libavformat/mmst.c
View file @
f87b1b37
...
@@ -523,7 +523,7 @@ static int mms_open(URLContext *h, const char *uri, int flags)
...
@@ -523,7 +523,7 @@ static int mms_open(URLContext *h, const char *uri, int flags)
// establish tcp connection.
// establish tcp connection.
ff_url_join
(
tcpname
,
sizeof
(
tcpname
),
"tcp"
,
NULL
,
mmst
->
host
,
port
,
NULL
);
ff_url_join
(
tcpname
,
sizeof
(
tcpname
),
"tcp"
,
NULL
,
mmst
->
host
,
port
,
NULL
);
err
=
ffurl_open
(
&
mms
->
mms_hd
,
tcpname
,
URL
_RDWR
);
err
=
ffurl_open
(
&
mms
->
mms_hd
,
tcpname
,
AVIO
_RDWR
);
if
(
err
)
if
(
err
)
goto
fail
;
goto
fail
;
...
...
libavformat/mov.c
View file @
f87b1b37
...
@@ -1722,7 +1722,7 @@ static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref)
...
@@ -1722,7 +1722,7 @@ static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref)
av_strlcat
(
filename
,
ref
->
path
+
l
+
1
,
1024
);
av_strlcat
(
filename
,
ref
->
path
+
l
+
1
,
1024
);
if
(
!
avio_open
(
pb
,
filename
,
URL
_RDONLY
))
if
(
!
avio_open
(
pb
,
filename
,
AVIO
_RDONLY
))
return
0
;
return
0
;
}
}
}
}
...
...
libavformat/output-example.c
View file @
f87b1b37
...
@@ -492,7 +492,7 @@ int main(int argc, char **argv)
...
@@ -492,7 +492,7 @@ int main(int argc, char **argv)
/* open the output file, if needed */
/* open the output file, if needed */
if
(
!
(
fmt
->
flags
&
AVFMT_NOFILE
))
{
if
(
!
(
fmt
->
flags
&
AVFMT_NOFILE
))
{
if
(
avio_open
(
&
oc
->
pb
,
filename
,
URL
_WRONLY
)
<
0
)
{
if
(
avio_open
(
&
oc
->
pb
,
filename
,
AVIO
_WRONLY
)
<
0
)
{
fprintf
(
stderr
,
"Could not open '%s'
\n
"
,
filename
);
fprintf
(
stderr
,
"Could not open '%s'
\n
"
,
filename
);
exit
(
1
);
exit
(
1
);
}
}
...
...
libavformat/rtmpproto.c
View file @
f87b1b37
...
@@ -812,7 +812,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
...
@@ -812,7 +812,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
if
(
!
rt
)
if
(
!
rt
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
s
->
priv_data
=
rt
;
s
->
priv_data
=
rt
;
rt
->
is_input
=
!
(
flags
&
URL
_WRONLY
);
rt
->
is_input
=
!
(
flags
&
AVIO
_WRONLY
);
av_url_split
(
proto
,
sizeof
(
proto
),
NULL
,
0
,
hostname
,
sizeof
(
hostname
),
&
port
,
av_url_split
(
proto
,
sizeof
(
proto
),
NULL
,
0
,
hostname
,
sizeof
(
hostname
),
&
port
,
path
,
sizeof
(
path
),
s
->
filename
);
path
,
sizeof
(
path
),
s
->
filename
);
...
@@ -821,7 +821,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
...
@@ -821,7 +821,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
port
=
RTMP_DEFAULT_PORT
;
port
=
RTMP_DEFAULT_PORT
;
ff_url_join
(
buf
,
sizeof
(
buf
),
"tcp"
,
NULL
,
hostname
,
port
,
NULL
);
ff_url_join
(
buf
,
sizeof
(
buf
),
"tcp"
,
NULL
,
hostname
,
port
,
NULL
);
if
(
ffurl_open
(
&
rt
->
stream
,
buf
,
URL
_RDWR
)
<
0
)
{
if
(
ffurl_open
(
&
rt
->
stream
,
buf
,
AVIO
_RDWR
)
<
0
)
{
av_log
(
LOG_CONTEXT
,
AV_LOG_ERROR
,
"Cannot open connection %s
\n
"
,
buf
);
av_log
(
LOG_CONTEXT
,
AV_LOG_ERROR
,
"Cannot open connection %s
\n
"
,
buf
);
goto
fail
;
goto
fail
;
}
}
...
...
libavformat/rtpproto.c
View file @
f87b1b37
...
@@ -145,7 +145,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
...
@@ -145,7 +145,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
char
path
[
1024
];
char
path
[
1024
];
const
char
*
p
;
const
char
*
p
;
is_output
=
(
flags
&
URL
_WRONLY
);
is_output
=
(
flags
&
AVIO
_WRONLY
);
s
=
av_mallocz
(
sizeof
(
RTPContext
));
s
=
av_mallocz
(
sizeof
(
RTPContext
));
if
(
!
s
)
if
(
!
s
)
...
...
libavformat/rtsp.c
View file @
f87b1b37
...
@@ -1116,14 +1116,14 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
...
@@ -1116,14 +1116,14 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
"?localport=%d"
,
j
);
"?localport=%d"
,
j
);
/* we will use two ports per rtp stream (rtp and rtcp) */
/* we will use two ports per rtp stream (rtp and rtcp) */
j
+=
2
;
j
+=
2
;
if
(
ffurl_open
(
&
rtsp_st
->
rtp_handle
,
buf
,
URL
_RDWR
)
==
0
)
if
(
ffurl_open
(
&
rtsp_st
->
rtp_handle
,
buf
,
AVIO
_RDWR
)
==
0
)
goto
rtp_opened
;
goto
rtp_opened
;
}
}
}
}
#if 0
#if 0
/* then try on any port */
/* then try on any port */
if (ffurl_open(&rtsp_st->rtp_handle, "rtp://",
URL
_RDONLY) < 0) {
if (ffurl_open(&rtsp_st->rtp_handle, "rtp://",
AVIO
_RDONLY) < 0) {
err = AVERROR_INVALIDDATA;
err = AVERROR_INVALIDDATA;
goto fail;
goto fail;
}
}
...
@@ -1269,7 +1269,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
...
@@ -1269,7 +1269,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
namebuf
,
sizeof
(
namebuf
),
NULL
,
0
,
NI_NUMERICHOST
);
namebuf
,
sizeof
(
namebuf
),
NULL
,
0
,
NI_NUMERICHOST
);
ff_url_join
(
url
,
sizeof
(
url
),
"rtp"
,
NULL
,
namebuf
,
ff_url_join
(
url
,
sizeof
(
url
),
"rtp"
,
NULL
,
namebuf
,
port
,
"?ttl=%d"
,
ttl
);
port
,
"?ttl=%d"
,
ttl
);
if
(
ffurl_open
(
&
rtsp_st
->
rtp_handle
,
url
,
URL
_RDWR
)
<
0
)
{
if
(
ffurl_open
(
&
rtsp_st
->
rtp_handle
,
url
,
AVIO
_RDWR
)
<
0
)
{
err
=
AVERROR_INVALIDDATA
;
err
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
...
@@ -1396,7 +1396,7 @@ redirect:
...
@@ -1396,7 +1396,7 @@ redirect:
av_get_random_seed
(),
av_get_random_seed
());
av_get_random_seed
(),
av_get_random_seed
());
/* GET requests */
/* GET requests */
if
(
ffurl_alloc
(
&
rt
->
rtsp_hd
,
httpname
,
URL
_RDONLY
)
<
0
)
{
if
(
ffurl_alloc
(
&
rt
->
rtsp_hd
,
httpname
,
AVIO
_RDONLY
)
<
0
)
{
err
=
AVERROR
(
EIO
);
err
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1417,7 +1417,7 @@ redirect:
...
@@ -1417,7 +1417,7 @@ redirect:
}
}
/* POST requests */
/* POST requests */
if
(
ffurl_alloc
(
&
rt
->
rtsp_hd_out
,
httpname
,
URL
_WRONLY
)
<
0
)
{
if
(
ffurl_alloc
(
&
rt
->
rtsp_hd_out
,
httpname
,
AVIO
_WRONLY
)
<
0
)
{
err
=
AVERROR
(
EIO
);
err
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1460,7 +1460,7 @@ redirect:
...
@@ -1460,7 +1460,7 @@ redirect:
}
else
{
}
else
{
/* open the tcp connection */
/* open the tcp connection */
ff_url_join
(
tcpname
,
sizeof
(
tcpname
),
"tcp"
,
NULL
,
host
,
port
,
NULL
);
ff_url_join
(
tcpname
,
sizeof
(
tcpname
),
"tcp"
,
NULL
,
host
,
port
,
NULL
);
if
(
ffurl_open
(
&
rt
->
rtsp_hd
,
tcpname
,
URL
_RDWR
)
<
0
)
{
if
(
ffurl_open
(
&
rt
->
rtsp_hd
,
tcpname
,
AVIO
_RDWR
)
<
0
)
{
err
=
AVERROR
(
EIO
);
err
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
}
}
...
@@ -1807,7 +1807,7 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
...
@@ -1807,7 +1807,7 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
namebuf
,
rtsp_st
->
sdp_port
,
namebuf
,
rtsp_st
->
sdp_port
,
"?localport=%d&ttl=%d"
,
rtsp_st
->
sdp_port
,
"?localport=%d&ttl=%d"
,
rtsp_st
->
sdp_port
,
rtsp_st
->
sdp_ttl
);
rtsp_st
->
sdp_ttl
);
if
(
ffurl_open
(
&
rtsp_st
->
rtp_handle
,
url
,
URL
_RDWR
)
<
0
)
{
if
(
ffurl_open
(
&
rtsp_st
->
rtp_handle
,
url
,
AVIO
_RDWR
)
<
0
)
{
err
=
AVERROR_INVALIDDATA
;
err
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
...
@@ -1863,7 +1863,7 @@ static int rtp_read_header(AVFormatContext *s,
...
@@ -1863,7 +1863,7 @@ static int rtp_read_header(AVFormatContext *s,
if
(
!
ff_network_init
())
if
(
!
ff_network_init
())
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
ret
=
ffurl_open
(
&
in
,
s
->
filename
,
URL
_RDONLY
);
ret
=
ffurl_open
(
&
in
,
s
->
filename
,
AVIO
_RDONLY
);
if
(
ret
)
if
(
ret
)
goto
fail
;
goto
fail
;
...
...
libavformat/sapdec.c
View file @
f87b1b37
...
@@ -85,7 +85,7 @@ static int sap_read_header(AVFormatContext *s,
...
@@ -85,7 +85,7 @@ static int sap_read_header(AVFormatContext *s,
ff_url_join
(
url
,
sizeof
(
url
),
"udp"
,
NULL
,
host
,
port
,
"?localport=%d"
,
ff_url_join
(
url
,
sizeof
(
url
),
"udp"
,
NULL
,
host
,
port
,
"?localport=%d"
,
port
);
port
);
ret
=
ffurl_open
(
&
sap
->
ann_fd
,
url
,
URL
_RDONLY
);
ret
=
ffurl_open
(
&
sap
->
ann_fd
,
url
,
AVIO
_RDONLY
);
if
(
ret
)
if
(
ret
)
goto
fail
;
goto
fail
;
...
...
libavformat/sapenc.c
View file @
f87b1b37
...
@@ -146,7 +146,7 @@ static int sap_write_header(AVFormatContext *s)
...
@@ -146,7 +146,7 @@ static int sap_write_header(AVFormatContext *s)
"?ttl=%d"
,
ttl
);
"?ttl=%d"
,
ttl
);
if
(
!
same_port
)
if
(
!
same_port
)
base_port
+=
2
;
base_port
+=
2
;
ret
=
ffurl_open
(
&
fd
,
url
,
URL
_WRONLY
);
ret
=
ffurl_open
(
&
fd
,
url
,
AVIO
_WRONLY
);
if
(
ret
)
{
if
(
ret
)
{
ret
=
AVERROR
(
EIO
);
ret
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
...
@@ -158,7 +158,7 @@ static int sap_write_header(AVFormatContext *s)
...
@@ -158,7 +158,7 @@ static int sap_write_header(AVFormatContext *s)
ff_url_join
(
url
,
sizeof
(
url
),
"udp"
,
NULL
,
announce_addr
,
port
,
ff_url_join
(
url
,
sizeof
(
url
),
"udp"
,
NULL
,
announce_addr
,
port
,
"?ttl=%d&connect=1"
,
ttl
);
"?ttl=%d&connect=1"
,
ttl
);
ret
=
ffurl_open
(
&
sap
->
ann_fd
,
url
,
URL
_WRONLY
);
ret
=
ffurl_open
(
&
sap
->
ann_fd
,
url
,
AVIO
_WRONLY
);
if
(
ret
)
{
if
(
ret
)
{
ret
=
AVERROR
(
EIO
);
ret
=
AVERROR
(
EIO
);
goto
fail
;
goto
fail
;
...
...
libavformat/tcp.c
View file @
f87b1b37
...
@@ -156,7 +156,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
...
@@ -156,7 +156,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
TCPContext
*
s
=
h
->
priv_data
;
TCPContext
*
s
=
h
->
priv_data
;
int
ret
;
int
ret
;
if
(
!
(
h
->
flags
&
URL
_FLAG_NONBLOCK
))
{
if
(
!
(
h
->
flags
&
AVIO
_FLAG_NONBLOCK
))
{
ret
=
ff_network_wait_fd
(
s
->
fd
,
0
);
ret
=
ff_network_wait_fd
(
s
->
fd
,
0
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
@@ -170,7 +170,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
...
@@ -170,7 +170,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
TCPContext
*
s
=
h
->
priv_data
;
TCPContext
*
s
=
h
->
priv_data
;
int
ret
;
int
ret
;
if
(
!
(
h
->
flags
&
URL
_FLAG_NONBLOCK
))
{
if
(
!
(
h
->
flags
&
AVIO
_FLAG_NONBLOCK
))
{
ret
=
ff_network_wait_fd
(
s
->
fd
,
1
);
ret
=
ff_network_wait_fd
(
s
->
fd
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
...
libavformat/udp.c
View file @
f87b1b37
...
@@ -317,7 +317,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
...
@@ -317,7 +317,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
h
->
is_streamed
=
1
;
h
->
is_streamed
=
1
;
h
->
max_packet_size
=
1472
;
h
->
max_packet_size
=
1472
;
is_output
=
(
flags
&
URL
_WRONLY
);
is_output
=
(
flags
&
AVIO
_WRONLY
);
s
=
av_mallocz
(
sizeof
(
UDPContext
));
s
=
av_mallocz
(
sizeof
(
UDPContext
));
if
(
!
s
)
if
(
!
s
)
...
@@ -360,14 +360,14 @@ static int udp_open(URLContext *h, const char *uri, int flags)
...
@@ -360,14 +360,14 @@ static int udp_open(URLContext *h, const char *uri, int flags)
/* XXX: fix av_url_split */
/* XXX: fix av_url_split */
if
(
hostname
[
0
]
==
'\0'
||
hostname
[
0
]
==
'?'
)
{
if
(
hostname
[
0
]
==
'\0'
||
hostname
[
0
]
==
'?'
)
{
/* only accepts null hostname if input */
/* only accepts null hostname if input */
if
(
flags
&
URL
_WRONLY
)
if
(
flags
&
AVIO
_WRONLY
)
goto
fail
;
goto
fail
;
}
else
{
}
else
{
if
(
ff_udp_set_remote_url
(
h
,
uri
)
<
0
)
if
(
ff_udp_set_remote_url
(
h
,
uri
)
<
0
)
goto
fail
;
goto
fail
;
}
}
if
(
s
->
is_multicast
&&
!
(
h
->
flags
&
URL
_WRONLY
))
if
(
s
->
is_multicast
&&
!
(
h
->
flags
&
AVIO
_WRONLY
))
s
->
local_port
=
port
;
s
->
local_port
=
port
;
udp_fd
=
udp_socket_create
(
s
,
&
my_addr
,
&
len
);
udp_fd
=
udp_socket_create
(
s
,
&
my_addr
,
&
len
);
if
(
udp_fd
<
0
)
if
(
udp_fd
<
0
)
...
@@ -384,7 +384,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
...
@@ -384,7 +384,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
/* the bind is needed to give a port to the socket now */
/* the bind is needed to give a port to the socket now */
/* if multicast, try the multicast address bind first */
/* if multicast, try the multicast address bind first */
if
(
s
->
is_multicast
&&
!
(
h
->
flags
&
URL
_WRONLY
))
{
if
(
s
->
is_multicast
&&
!
(
h
->
flags
&
AVIO
_WRONLY
))
{
bind_ret
=
bind
(
udp_fd
,(
struct
sockaddr
*
)
&
s
->
dest_addr
,
len
);
bind_ret
=
bind
(
udp_fd
,(
struct
sockaddr
*
)
&
s
->
dest_addr
,
len
);
}
}
/* bind to the local address if not multicast or if the multicast
/* bind to the local address if not multicast or if the multicast
...
@@ -397,7 +397,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
...
@@ -397,7 +397,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
s
->
local_port
=
udp_port
(
&
my_addr
,
len
);
s
->
local_port
=
udp_port
(
&
my_addr
,
len
);
if
(
s
->
is_multicast
)
{
if
(
s
->
is_multicast
)
{
if
(
h
->
flags
&
URL
_WRONLY
)
{
if
(
h
->
flags
&
AVIO
_WRONLY
)
{
/* output */
/* output */
if
(
udp_set_multicast_ttl
(
udp_fd
,
s
->
ttl
,
(
struct
sockaddr
*
)
&
s
->
dest_addr
)
<
0
)
if
(
udp_set_multicast_ttl
(
udp_fd
,
s
->
ttl
,
(
struct
sockaddr
*
)
&
s
->
dest_addr
)
<
0
)
goto
fail
;
goto
fail
;
...
@@ -446,7 +446,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
...
@@ -446,7 +446,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
UDPContext
*
s
=
h
->
priv_data
;
UDPContext
*
s
=
h
->
priv_data
;
int
ret
;
int
ret
;
if
(
!
(
h
->
flags
&
URL
_FLAG_NONBLOCK
))
{
if
(
!
(
h
->
flags
&
AVIO
_FLAG_NONBLOCK
))
{
ret
=
ff_network_wait_fd
(
s
->
udp_fd
,
0
);
ret
=
ff_network_wait_fd
(
s
->
udp_fd
,
0
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
@@ -460,7 +460,7 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size)
...
@@ -460,7 +460,7 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size)
UDPContext
*
s
=
h
->
priv_data
;
UDPContext
*
s
=
h
->
priv_data
;
int
ret
;
int
ret
;
if
(
!
(
h
->
flags
&
URL
_FLAG_NONBLOCK
))
{
if
(
!
(
h
->
flags
&
AVIO
_FLAG_NONBLOCK
))
{
ret
=
ff_network_wait_fd
(
s
->
udp_fd
,
1
);
ret
=
ff_network_wait_fd
(
s
->
udp_fd
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
...
@@ -480,7 +480,7 @@ static int udp_close(URLContext *h)
...
@@ -480,7 +480,7 @@ static int udp_close(URLContext *h)
{
{
UDPContext
*
s
=
h
->
priv_data
;
UDPContext
*
s
=
h
->
priv_data
;
if
(
s
->
is_multicast
&&
!
(
h
->
flags
&
URL
_WRONLY
))
if
(
s
->
is_multicast
&&
!
(
h
->
flags
&
AVIO
_WRONLY
))
udp_leave_multicast_group
(
s
->
udp_fd
,
(
struct
sockaddr
*
)
&
s
->
dest_addr
);
udp_leave_multicast_group
(
s
->
udp_fd
,
(
struct
sockaddr
*
)
&
s
->
dest_addr
);
closesocket
(
s
->
udp_fd
);
closesocket
(
s
->
udp_fd
);
av_free
(
s
);
av_free
(
s
);
...
...
libavformat/utils.c
View file @
f87b1b37
...
@@ -631,7 +631,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
...
@@ -631,7 +631,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
hack needed to handle RTSP/TCP */
hack needed to handle RTSP/TCP */
if
(
!
fmt
||
!
(
fmt
->
flags
&
AVFMT_NOFILE
))
{
if
(
!
fmt
||
!
(
fmt
->
flags
&
AVFMT_NOFILE
))
{
/* if no file needed do not try to open one */
/* if no file needed do not try to open one */
if
((
err
=
avio_open
(
&
pb
,
filename
,
URL
_RDONLY
))
<
0
)
{
if
((
err
=
avio_open
(
&
pb
,
filename
,
AVIO
_RDONLY
))
<
0
)
{
goto
fail
;
goto
fail
;
}
}
if
(
buf_size
>
0
)
{
if
(
buf_size
>
0
)
{
...
...
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