Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-06-28 16:43:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fea8755719cb64cab069ec1db3da96ca2d3324ea
fea87557
1 parent
4843c525
response the call message with null. 0.9.137
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
291 行增加
和
1 行删除
README.md
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_source.cpp
trunk/src/core/srs_core.hpp
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
trunk/src/rtmp/srs_protocol_rtmp_stack.hpp
README.md
查看文件 @
fea8755
...
...
@@ -242,6 +242,7 @@ Supported operating systems and hardware:
*
2013-10-17, Created.
<br/>
## History
*
v1.0, 2014-06-28, response the call message with null. 0.9.137
*
v1.0, 2014-06-28, fix
[
#110
](
https://github.com/winlinvip/simple-rtmp-server/issues/110
)
, thread start segment fault, thread cycle stop destroy thread. 0.9.136
*
v1.0, 2014-06-27, fix
[
#109
](
https://github.com/winlinvip/simple-rtmp-server/issues/109
)
, fix the system jump time, adjust system startup time. 0.9.135
*
<strong>
v1.0, 2014-06-27,
[
1.0 mainline5(0.9.134)
](
https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline5
)
released. 41573 lines.
</strong>
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
fea8755
...
...
@@ -51,6 +51,7 @@ using namespace std;
#include <srs_protocol_utility.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_protocol_msg_array.hpp>
#include <srs_protocol_amf0.hpp>
// when stream is busy, for example, streaming is already
// publishing, when a new client to request to publish,
...
...
@@ -852,6 +853,22 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsMessage* msg
return
ret
;
}
// call msg,
// support response null first,
// @see https://github.com/winlinvip/simple-rtmp-server/issues/106
SrsCallPacket
*
call
=
dynamic_cast
<
SrsCallPacket
*>
(
pkt
);
if
(
call
)
{
SrsCallResPacket
*
res
=
new
SrsCallResPacket
(
call
->
transaction_id
);
res
->
command_object
=
SrsAmf0Any
::
null
();
res
->
response
=
SrsAmf0Any
::
null
();
if
((
ret
=
rtmp
->
send_and_free_packet
(
res
,
0
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"response call failed. ret=%d"
,
ret
);
return
ret
;
}
return
ret
;
}
// pause or other msg.
SrsPausePacket
*
pause
=
dynamic_cast
<
SrsPausePacket
*>
(
pkt
);
if
(
!
pause
)
{
srs_info
(
"ignore all amf0/amf3 command except pause."
);
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
fea8755
...
...
@@ -926,6 +926,10 @@ int SrsSource::on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata)
metadata
->
metadata
->
set
(
"server"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_KEY
" "
RTMP_SIG_SRS_VERSION
" ("
RTMP_SIG_SRS_URL_SHORT
")"
));
metadata
->
metadata
->
set
(
"authors"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_PRIMARY_AUTHROS
));
// version, for example, 1.0.0
// add version to metadata, please donot remove it, for debug.
metadata
->
metadata
->
set
(
"server_version"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_VERSION
));
if
((
prop
=
metadata
->
metadata
->
get_property
(
"audiosamplerate"
))
!=
NULL
)
{
if
(
prop
->
is_number
())
{
sample_rate
=
(
int
)
prop
->
to_number
();
...
...
trunk/src/core/srs_core.hpp
查看文件 @
fea8755
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "13
6
"
#define VERSION_REVISION "13
7
"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
查看文件 @
fea8755
...
...
@@ -700,6 +700,10 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream,
srs_info
(
"decode the AMF0/AMF3 closeStream message."
);
*
ppacket
=
packet
=
new
SrsCloseStreamPacket
();
return
packet
->
decode
(
stream
);
}
else
if
(
header
.
is_amf0_command
()
||
header
.
is_amf3_command
())
{
srs_info
(
"decode the AMF0/AMF3 call message."
);
*
ppacket
=
packet
=
new
SrsCallPacket
();
return
packet
->
decode
(
stream
);
}
// default packet to drop message.
...
...
@@ -1976,6 +1980,202 @@ int SrsConnectAppResPacket::encode_packet(SrsStream* stream)
return
ret
;
}
SrsCallPacket
::
SrsCallPacket
()
{
command_name
=
""
;
transaction_id
=
0
;
command_object
=
NULL
;
arguments
=
NULL
;
}
SrsCallPacket
::~
SrsCallPacket
()
{
srs_freep
(
command_object
);
srs_freep
(
arguments
);
}
int
SrsCallPacket
::
decode
(
SrsStream
*
stream
)
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
srs_amf0_read_string
(
stream
,
command_name
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"amf0 decode call command_name failed. ret=%d"
,
ret
);
return
ret
;
}
if
(
command_name
.
empty
())
{
ret
=
ERROR_RTMP_AMF0_DECODE
;
srs_error
(
"amf0 decode call command_name failed. "
"command_name=%s, ret=%d"
,
command_name
.
c_str
(),
ret
);
return
ret
;
}
if
((
ret
=
srs_amf0_read_number
(
stream
,
transaction_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"amf0 decode call transaction_id failed. ret=%d"
,
ret
);
return
ret
;
}
srs_freep
(
command_object
);
if
((
ret
=
SrsAmf0Any
::
discovery
(
stream
,
&
command_object
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"amf0 discovery call command_object failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
command_object
->
read
(
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"amf0 decode call command_object failed. ret=%d"
,
ret
);
return
ret
;
}
if
(
!
stream
->
empty
())
{
srs_freep
(
arguments
);
if
((
ret
=
SrsAmf0Any
::
discovery
(
stream
,
&
arguments
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"amf0 discovery call arguments failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
arguments
->
read
(
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"amf0 decode call arguments failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_info
(
"amf0 decode call packet success"
);
return
ret
;
}
int
SrsCallPacket
::
get_perfer_cid
()
{
return
RTMP_CID_OverConnection
;
}
int
SrsCallPacket
::
get_message_type
()
{
return
RTMP_MSG_AMF0CommandMessage
;
}
int
SrsCallPacket
::
get_size
()
{
int
size
=
0
;
size
+=
SrsAmf0Size
::
str
(
command_name
)
+
SrsAmf0Size
::
number
();
if
(
command_object
)
{
size
+=
command_object
->
total_size
();
}
if
(
arguments
)
{
size
+=
arguments
->
total_size
();
}
return
size
;
}
int
SrsCallPacket
::
encode_packet
(
SrsStream
*
stream
)
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
srs_amf0_write_string
(
stream
,
command_name
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode command_name failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode command_name success."
);
if
((
ret
=
srs_amf0_write_number
(
stream
,
transaction_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode transaction_id failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode transaction_id success."
);
if
(
command_object
&&
(
ret
=
command_object
->
write
(
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode command_object failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode command_object success."
);
if
(
arguments
&&
(
ret
=
arguments
->
write
(
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode arguments failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode arguments success."
);
srs_info
(
"encode create stream request packet success."
);
return
ret
;
}
SrsCallResPacket
::
SrsCallResPacket
(
double
_transaction_id
)
{
command_name
=
RTMP_AMF0_COMMAND_RESULT
;
transaction_id
=
_transaction_id
;
command_object
=
NULL
;
response
=
NULL
;
}
SrsCallResPacket
::~
SrsCallResPacket
()
{
srs_freep
(
command_object
);
srs_freep
(
response
);
}
int
SrsCallResPacket
::
get_perfer_cid
()
{
return
RTMP_CID_OverConnection
;
}
int
SrsCallResPacket
::
get_message_type
()
{
return
RTMP_MSG_AMF0CommandMessage
;
}
int
SrsCallResPacket
::
get_size
()
{
int
size
=
0
;
size
+=
SrsAmf0Size
::
str
(
command_name
)
+
SrsAmf0Size
::
number
();
if
(
command_object
)
{
size
+=
command_object
->
total_size
();
}
if
(
response
)
{
size
+=
response
->
total_size
();
}
return
size
;
}
int
SrsCallResPacket
::
encode_packet
(
SrsStream
*
stream
)
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
srs_amf0_write_string
(
stream
,
command_name
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode command_name failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode command_name success."
);
if
((
ret
=
srs_amf0_write_number
(
stream
,
transaction_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode transaction_id failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode transaction_id success."
);
if
(
command_object
&&
(
ret
=
command_object
->
write
(
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode command_object failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode command_object success."
);
if
(
response
&&
(
ret
=
response
->
write
(
stream
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode response failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"encode response success."
);
srs_info
(
"encode call response packet success."
);
return
ret
;
}
SrsCreateStreamPacket
::
SrsCreateStreamPacket
()
{
command_name
=
RTMP_AMF0_COMMAND_CREATE_STREAM
;
...
...
trunk/src/rtmp/srs_protocol_rtmp_stack.hpp
查看文件 @
fea8755
...
...
@@ -534,6 +534,73 @@ protected:
};
/**
* 4.1.2. Call
* The call method of the NetConnection object runs remote procedure
* calls (RPC) at the receiving end. The called RPC name is passed as a
* parameter to the call command.
*/
class
SrsCallPacket
:
public
SrsPacket
{
protected
:
virtual
const
char
*
get_class_name
()
{
return
CLASS_NAME_STRING
(
SrsCallPacket
);
}
public
:
std
::
string
command_name
;
double
transaction_id
;
/**
* If there exists any command info this
* is set, else this is set to null type.
*/
SrsAmf0Any
*
command_object
;
// Any optional arguments to be provided
SrsAmf0Any
*
arguments
;
public
:
SrsCallPacket
();
virtual
~
SrsCallPacket
();
public
:
virtual
int
decode
(
SrsStream
*
stream
);
public
:
virtual
int
get_perfer_cid
();
public
:
virtual
int
get_message_type
();
protected
:
virtual
int
get_size
();
virtual
int
encode_packet
(
SrsStream
*
stream
);
};
/**
* response for SrsCallPacket.
*/
class
SrsCallResPacket
:
public
SrsPacket
{
protected
:
virtual
const
char
*
get_class_name
()
{
return
CLASS_NAME_STRING
(
SrsCallResPacket
);
}
public
:
std
::
string
command_name
;
double
transaction_id
;
// If there exists any command info this
// is set, else this is set to null type.
SrsAmf0Any
*
command_object
;
// Response from the method that was
// called.
SrsAmf0Any
*
response
;
public
:
SrsCallResPacket
(
double
_transaction_id
);
virtual
~
SrsCallResPacket
();
public
:
virtual
int
get_perfer_cid
();
public
:
virtual
int
get_message_type
();
protected
:
virtual
int
get_size
();
virtual
int
encode_packet
(
SrsStream
*
stream
);
};
/**
* 4.1.3. createStream
* The client sends this command to the server to create a logical
* channel for message communication The publishing of audio, video, and
...
...
@@ -592,6 +659,7 @@ protected:
virtual
int
get_size
();
virtual
int
encode_packet
(
SrsStream
*
stream
);
};
/**
* client close stream packet.
*/
...
...
请
注册
或
登录
后发表评论