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
5e6001db
Commit
5e6001db
authored
Aug 09, 2012
by
Samuel Pitoiset
Committed by
Luca Barbato
Aug 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtmp: Factorize the code by adding handle_invoke_result
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
54918d03
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
69 deletions
+78
-69
rtmpproto.c
libavformat/rtmpproto.c
+78
-69
No files found.
libavformat/rtmpproto.c
View file @
5e6001db
...
...
@@ -1021,25 +1021,14 @@ static int handle_server_bw(URLContext *s, RTMPPacket *pkt)
return
0
;
}
static
int
handle_invoke
(
URLContext
*
s
,
RTMPPacket
*
pkt
)
static
int
handle_invoke
_result
(
URLContext
*
s
,
RTMPPacket
*
pkt
)
{
RTMPContext
*
rt
=
s
->
priv_data
;
int
i
,
t
;
const
uint8_t
*
data_end
=
pkt
->
data
+
pkt
->
data_size
;
char
*
tracked_method
=
NULL
;
int
ret
=
0
;
//TODO: check for the messages sent for wrong state?
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\006
_error"
,
9
))
{
uint8_t
tmpstr
[
256
];
if
(
!
ff_amf_get_field_value
(
pkt
->
data
+
9
,
data_end
,
"description"
,
tmpstr
,
sizeof
(
tmpstr
)))
av_log
(
s
,
AV_LOG_ERROR
,
"Server error: %s
\n
"
,
tmpstr
);
return
-
1
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\007
_result"
,
10
))
{
GetByteContext
gbc
;
double
pkt_id
;
int
ret
=
0
;
int
i
;
bytestream2_init
(
&
gbc
,
pkt
->
data
+
10
,
pkt
->
data_size
);
if
((
ret
=
ff_amf_read_number
(
&
gbc
,
&
pkt_id
))
<
0
)
...
...
@@ -1056,35 +1045,33 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt)
if
(
!
tracked_method
)
{
/* Ignore this reply when the current method is not tracked. */
return
0
;
return
ret
;
}
if
(
!
memcmp
(
tracked_method
,
"connect"
,
7
))
{
if
(
!
rt
->
is_input
)
{
if
((
ret
=
gen_release_stream
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
if
((
ret
=
gen_fcpublish_stream
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
}
else
{
if
((
ret
=
gen_server_bw
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
}
if
((
ret
=
gen_create_stream
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
if
(
rt
->
is_input
)
{
/* Send the FCSubscribe command when the name of live
* stream is defined by the user or if it's a live stream. */
if
(
rt
->
subscribe
)
{
if
((
ret
=
gen_fcsubscribe_stream
(
s
,
rt
,
rt
->
subscribe
))
<
0
)
goto
invoke_fail
;
if
((
ret
=
gen_fcsubscribe_stream
(
s
,
rt
,
rt
->
subscribe
))
<
0
)
goto
fail
;
}
else
if
(
rt
->
live
==
-
1
)
{
if
((
ret
=
gen_fcsubscribe_stream
(
s
,
rt
,
rt
->
playpath
))
<
0
)
goto
invoke_fail
;
if
((
ret
=
gen_fcsubscribe_stream
(
s
,
rt
,
rt
->
playpath
))
<
0
)
goto
fail
;
}
}
}
else
if
(
!
memcmp
(
tracked_method
,
"createStream"
,
12
))
{
...
...
@@ -1097,14 +1084,38 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt)
if
(
!
rt
->
is_input
)
{
if
((
ret
=
gen_publish
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
}
else
{
if
((
ret
=
gen_play
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
if
((
ret
=
gen_buffer_time
(
s
,
rt
))
<
0
)
goto
invoke_
fail
;
goto
fail
;
}
}
fail:
av_free
(
tracked_method
);
return
ret
;
}
static
int
handle_invoke
(
URLContext
*
s
,
RTMPPacket
*
pkt
)
{
RTMPContext
*
rt
=
s
->
priv_data
;
int
i
,
t
;
const
uint8_t
*
data_end
=
pkt
->
data
+
pkt
->
data_size
;
int
ret
=
0
;
//TODO: check for the messages sent for wrong state?
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\006
_error"
,
9
))
{
uint8_t
tmpstr
[
256
];
if
(
!
ff_amf_get_field_value
(
pkt
->
data
+
9
,
data_end
,
"description"
,
tmpstr
,
sizeof
(
tmpstr
)))
av_log
(
s
,
AV_LOG_ERROR
,
"Server error: %s
\n
"
,
tmpstr
);
return
-
1
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\007
_result"
,
10
))
{
if
((
ret
=
handle_invoke_result
(
s
,
pkt
))
<
0
)
return
ret
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\010
onStatus"
,
11
))
{
const
uint8_t
*
ptr
=
pkt
->
data
+
11
;
uint8_t
tmpstr
[
256
];
...
...
@@ -1134,8 +1145,6 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt)
return
ret
;
}
invoke_fail:
av_free
(
tracked_method
);
return
ret
;
}
...
...
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