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
cdf8253a
Commit
cdf8253a
authored
Sep 30, 2019
by
Steven Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/mmst: add logging context to log
Signed-off-by:
Steven Liu
<
lq@chinaffmpeg.org
>
parent
4ff97342
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
mmst.c
libavformat/mmst.c
+20
-20
No files found.
libavformat/mmst.c
View file @
cdf8253a
...
@@ -141,7 +141,7 @@ static int send_command_packet(MMSTContext *mmst)
...
@@ -141,7 +141,7 @@ static int send_command_packet(MMSTContext *mmst)
// write it out.
// write it out.
write_result
=
ffurl_write
(
mms
->
mms_hd
,
mms
->
out_buffer
,
exact_length
);
write_result
=
ffurl_write
(
mms
->
mms_hd
,
mms
->
out_buffer
,
exact_length
);
if
(
write_result
!=
exact_length
)
{
if
(
write_result
!=
exact_length
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Failed to write data of length %d: %d (%s)
\n
"
,
"Failed to write data of length %d: %d (%s)
\n
"
,
exact_length
,
write_result
,
exact_length
,
write_result
,
write_result
<
0
?
strerror
(
AVUNERROR
(
write_result
))
:
write_result
<
0
?
strerror
(
AVUNERROR
(
write_result
))
:
...
@@ -215,11 +215,11 @@ static int send_media_file_request(MMSTContext *mmst)
...
@@ -215,11 +215,11 @@ static int send_media_file_request(MMSTContext *mmst)
static
void
handle_packet_stream_changing_type
(
MMSTContext
*
mmst
)
static
void
handle_packet_stream_changing_type
(
MMSTContext
*
mmst
)
{
{
MMSContext
*
mms
=
&
mmst
->
mms
;
MMSContext
*
mms
=
&
mmst
->
mms
;
av_log
(
NULL
,
AV_LOG_TRACE
,
"Stream changing!
\n
"
);
av_log
(
mms
->
mms_hd
,
AV_LOG_TRACE
,
"Stream changing!
\n
"
);
// 40 is the packet header size, 7 is the prefix size.
// 40 is the packet header size, 7 is the prefix size.
mmst
->
header_packet_id
=
AV_RL32
(
mms
->
in_buffer
+
40
+
7
);
mmst
->
header_packet_id
=
AV_RL32
(
mms
->
in_buffer
+
40
+
7
);
av_log
(
NULL
,
AV_LOG_TRACE
,
"Changed header prefix to 0x%x"
,
mmst
->
header_packet_id
);
av_log
(
mms
->
mms_hd
,
AV_LOG_TRACE
,
"Changed header prefix to 0x%x"
,
mmst
->
header_packet_id
);
}
}
static
int
send_keepalive_packet
(
MMSTContext
*
mmst
)
static
int
send_keepalive_packet
(
MMSTContext
*
mmst
)
...
@@ -251,12 +251,12 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -251,12 +251,12 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
8
);
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
8
);
if
(
read_result
!=
8
)
{
if
(
read_result
!=
8
)
{
if
(
read_result
<
0
)
{
if
(
read_result
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Error reading packet header: %d (%s)
\n
"
,
"Error reading packet header: %d (%s)
\n
"
,
read_result
,
strerror
(
AVUNERROR
(
read_result
)));
read_result
,
strerror
(
AVUNERROR
(
read_result
)));
packet_type
=
SC_PKT_CANCEL
;
packet_type
=
SC_PKT_CANCEL
;
}
else
{
}
else
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"The server closed the connection
\n
"
);
"The server closed the connection
\n
"
);
packet_type
=
SC_PKT_NO_DATA
;
packet_type
=
SC_PKT_NO_DATA
;
}
}
...
@@ -270,7 +270,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -270,7 +270,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
mmst
->
incoming_flags
=
mms
->
in_buffer
[
3
];
mmst
->
incoming_flags
=
mms
->
in_buffer
[
3
];
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
8
,
4
);
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
8
,
4
);
if
(
read_result
!=
4
)
{
if
(
read_result
!=
4
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Reading command packet length failed: %d (%s)
\n
"
,
"Reading command packet length failed: %d (%s)
\n
"
,
read_result
,
read_result
,
read_result
<
0
?
strerror
(
AVUNERROR
(
read_result
))
:
read_result
<
0
?
strerror
(
AVUNERROR
(
read_result
))
:
...
@@ -279,11 +279,11 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -279,11 +279,11 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
}
}
length_remaining
=
AV_RL32
(
mms
->
in_buffer
+
8
)
+
4
;
length_remaining
=
AV_RL32
(
mms
->
in_buffer
+
8
)
+
4
;
av_log
(
NULL
,
AV_LOG_TRACE
,
"Length remaining is %d
\n
"
,
length_remaining
);
av_log
(
mms
->
mms_hd
,
AV_LOG_TRACE
,
"Length remaining is %d
\n
"
,
length_remaining
);
// read the rest of the packet.
// read the rest of the packet.
if
(
length_remaining
<
0
if
(
length_remaining
<
0
||
length_remaining
>
sizeof
(
mms
->
in_buffer
)
-
12
)
{
||
length_remaining
>
sizeof
(
mms
->
in_buffer
)
-
12
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Incoming packet length %d exceeds bufsize %"
SIZE_SPECIFIER
"
\n
"
,
"Incoming packet length %d exceeds bufsize %"
SIZE_SPECIFIER
"
\n
"
,
length_remaining
,
sizeof
(
mms
->
in_buffer
)
-
12
);
length_remaining
,
sizeof
(
mms
->
in_buffer
)
-
12
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -291,7 +291,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -291,7 +291,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
12
,
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
+
12
,
length_remaining
)
;
length_remaining
)
;
if
(
read_result
!=
length_remaining
)
{
if
(
read_result
!=
length_remaining
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Reading pkt data (length=%d) failed: %d (%s)
\n
"
,
"Reading pkt data (length=%d) failed: %d (%s)
\n
"
,
length_remaining
,
read_result
,
length_remaining
,
read_result
,
read_result
<
0
?
strerror
(
AVUNERROR
(
read_result
))
:
read_result
<
0
?
strerror
(
AVUNERROR
(
read_result
))
:
...
@@ -300,7 +300,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -300,7 +300,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
}
}
packet_type
=
AV_RL16
(
mms
->
in_buffer
+
36
);
packet_type
=
AV_RL16
(
mms
->
in_buffer
+
36
);
if
(
read_result
>=
44
&&
(
hr
=
AV_RL32
(
mms
->
in_buffer
+
40
)))
{
if
(
read_result
>=
44
&&
(
hr
=
AV_RL32
(
mms
->
in_buffer
+
40
)))
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Server sent a message with packet type 0x%x and error status code 0x%08x
\n
"
,
packet_type
,
hr
);
"Server sent a message with packet type 0x%x and error status code 0x%08x
\n
"
,
packet_type
,
hr
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
...
@@ -319,7 +319,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -319,7 +319,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
if
(
length_remaining
<
0
if
(
length_remaining
<
0
||
length_remaining
>
sizeof
(
mms
->
in_buffer
)
-
8
)
{
||
length_remaining
>
sizeof
(
mms
->
in_buffer
)
-
8
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Data length %d is invalid or too large (max=%"
SIZE_SPECIFIER
")
\n
"
,
"Data length %d is invalid or too large (max=%"
SIZE_SPECIFIER
")
\n
"
,
length_remaining
,
sizeof
(
mms
->
in_buffer
));
length_remaining
,
sizeof
(
mms
->
in_buffer
));
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -328,7 +328,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -328,7 +328,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
mms
->
read_in_ptr
=
mms
->
in_buffer
;
mms
->
read_in_ptr
=
mms
->
in_buffer
;
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
length_remaining
);
read_result
=
ffurl_read_complete
(
mms
->
mms_hd
,
mms
->
in_buffer
,
length_remaining
);
if
(
read_result
!=
length_remaining
)
{
if
(
read_result
!=
length_remaining
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
mms
->
mms_hd
,
AV_LOG_ERROR
,
"Failed to read packet data of size %d: %d (%s)
\n
"
,
"Failed to read packet data of size %d: %d (%s)
\n
"
,
length_remaining
,
read_result
,
length_remaining
,
read_result
,
read_result
<
0
?
strerror
(
AVUNERROR
(
read_result
))
:
read_result
<
0
?
strerror
(
AVUNERROR
(
read_result
))
:
...
@@ -358,7 +358,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
...
@@ -358,7 +358,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
}
else
if
(
packet_id_type
==
mmst
->
packet_id
)
{
}
else
if
(
packet_id_type
==
mmst
->
packet_id
)
{
packet_type
=
SC_PKT_ASF_MEDIA
;
packet_type
=
SC_PKT_ASF_MEDIA
;
}
else
{
}
else
{
av_log
(
NULL
,
AV_LOG_TRACE
,
"packet id type %d is old."
,
packet_id_type
);
av_log
(
mms
->
mms_hd
,
AV_LOG_TRACE
,
"packet id type %d is old."
,
packet_id_type
);
continue
;
continue
;
}
}
}
}
...
@@ -555,14 +555,14 @@ static int mms_open(URLContext *h, const char *uri, int flags)
...
@@ -555,14 +555,14 @@ static int mms_open(URLContext *h, const char *uri, int flags)
if
(
err
)
if
(
err
)
goto
fail
;
goto
fail
;
if
((
mmst
->
incoming_flags
!=
0X08
)
&&
(
mmst
->
incoming_flags
!=
0X0C
))
{
if
((
mmst
->
incoming_flags
!=
0X08
)
&&
(
mmst
->
incoming_flags
!=
0X0C
))
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
h
,
AV_LOG_ERROR
,
"The server does not support MMST (try MMSH or RTSP)
\n
"
);
"The server does not support MMST (try MMSH or RTSP)
\n
"
);
err
=
AVERROR
(
EINVAL
);
err
=
AVERROR
(
EINVAL
);
goto
fail
;
goto
fail
;
}
}
err
=
ff_mms_asf_header_parser
(
mms
);
err
=
ff_mms_asf_header_parser
(
mms
);
if
(
err
)
{
if
(
err
)
{
av_log
(
NULL
,
AV_LOG_TRACE
,
"asf header parsed failed!
\n
"
);
av_log
(
h
,
AV_LOG_TRACE
,
"asf header parsed failed!
\n
"
);
goto
fail
;
goto
fail
;
}
}
mms
->
header_parsed
=
1
;
mms
->
header_parsed
=
1
;
...
@@ -579,11 +579,11 @@ static int mms_open(URLContext *h, const char *uri, int flags)
...
@@ -579,11 +579,11 @@ static int mms_open(URLContext *h, const char *uri, int flags)
if
(
err
)
{
if
(
err
)
{
goto
fail
;
goto
fail
;
}
}
av_log
(
NULL
,
AV_LOG_TRACE
,
"Leaving open (success)
\n
"
);
av_log
(
h
,
AV_LOG_TRACE
,
"Leaving open (success)
\n
"
);
return
0
;
return
0
;
fail:
fail:
mms_close
(
h
);
mms_close
(
h
);
av_log
(
NULL
,
AV_LOG_TRACE
,
"Leaving open (failure: %d)
\n
"
,
err
);
av_log
(
mms
->
mms_hd
,
AV_LOG_TRACE
,
"Leaving open (failure: %d)
\n
"
,
err
);
return
err
;
return
err
;
}
}
...
@@ -608,7 +608,7 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
...
@@ -608,7 +608,7 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
int
err
=
mms_safe_send_recv
(
mmst
,
NULL
,
SC_PKT_ASF_MEDIA
);
int
err
=
mms_safe_send_recv
(
mmst
,
NULL
,
SC_PKT_ASF_MEDIA
);
if
(
err
==
0
)
{
if
(
err
==
0
)
{
if
(
mms
->
remaining_in_len
>
mms
->
asf_packet_len
)
{
if
(
mms
->
remaining_in_len
>
mms
->
asf_packet_len
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
av_log
(
h
,
AV_LOG_ERROR
,
"Incoming pktlen %d is larger than ASF pktsize %d
\n
"
,
"Incoming pktlen %d is larger than ASF pktsize %d
\n
"
,
mms
->
remaining_in_len
,
mms
->
asf_packet_len
);
mms
->
remaining_in_len
,
mms
->
asf_packet_len
);
result
=
AVERROR
(
EIO
);
result
=
AVERROR
(
EIO
);
...
@@ -616,12 +616,12 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
...
@@ -616,12 +616,12 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
// copy the data to the packet buffer.
// copy the data to the packet buffer.
result
=
ff_mms_read_data
(
mms
,
buf
,
size
);
result
=
ff_mms_read_data
(
mms
,
buf
,
size
);
if
(
result
==
0
)
{
if
(
result
==
0
)
{
av_log
(
NULL
,
AV_LOG_TRACE
,
"Read ASF media packet size is zero!
\n
"
);
av_log
(
h
,
AV_LOG_TRACE
,
"Read ASF media packet size is zero!
\n
"
);
break
;
break
;
}
}
}
}
}
else
{
}
else
{
av_log
(
NULL
,
AV_LOG_TRACE
,
"read packet error!
\n
"
);
av_log
(
h
,
AV_LOG_TRACE
,
"read packet error!
\n
"
);
break
;
break
;
}
}
}
}
...
...
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