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-05-08 12:12:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f6dd1371bf270328540fd1dfa52689187a517d6c
f6dd1371
1 parent
fa9870db
fix bug #36: never directly use *(int32_t*) to convert, for arm may not support
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
70 行增加
和
18 行删除
trunk/src/core/srs_core.hpp
trunk/src/kernel/srs_kernel_stream.cpp
trunk/src/kernel/srs_kernel_stream.hpp
trunk/src/rtmp/srs_protocol_handshake.cpp
trunk/src/rtmp/srs_protocol_rtmp.cpp
trunk/src/core/srs_core.hpp
查看文件 @
f6dd137
...
...
@@ -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 "9
1
"
#define VERSION_REVISION "9
2
"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "srs"
...
...
trunk/src/kernel/srs_kernel_stream.cpp
查看文件 @
f6dd137
...
...
@@ -232,3 +232,11 @@ void SrsStream::write_string(std::string value)
p
+=
value
.
length
();
}
void
SrsStream
::
write_bytes
(
char
*
data
,
int
size
)
{
srs_assert
(
require
(
size
));
memcpy
(
p
,
data
,
size
);
p
+=
size
;
}
...
...
trunk/src/kernel/srs_kernel_stream.hpp
查看文件 @
f6dd137
...
...
@@ -129,6 +129,10 @@ public:
* write string to stream
*/
virtual
void
write_string
(
std
::
string
value
);
/**
* write bytes to stream
*/
virtual
void
write_bytes
(
char
*
data
,
int
size
);
};
#endif
\ No newline at end of file
...
...
trunk/src/rtmp/srs_protocol_handshake.cpp
查看文件 @
f6dd137
...
...
@@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_protocol_io.hpp>
#include <srs_protocol_utility.hpp>
#include <srs_protocol_rtmp.hpp>
#include <srs_kernel_stream.hpp>
#ifdef SRS_AUTO_SSL
...
...
@@ -230,6 +231,26 @@ namespace srs
return
ret
;
}
// read/write stream using SrsStream.
void
__srs_stream_write_4bytes
(
char
*
pp
,
int32_t
value
)
{
static
SrsStream
stream
;
int
ret
=
stream
.
initialize
(
pp
,
4
);
srs_assert
(
ret
==
ERROR_SUCCESS
);
stream
.
write_4bytes
(
value
);
}
int32_t
__srs_stream_read_4bytes
(
char
*
pp
)
{
static
SrsStream
stream
;
int
ret
=
stream
.
initialize
(
pp
,
4
);
srs_assert
(
ret
==
ERROR_SUCCESS
);
return
stream
.
read_4bytes
();
}
// calc the offset of key,
// the key->offset cannot be used as the offset of key.
int
srs_key_block_get_offset
(
key_block
*
key
)
...
...
@@ -282,7 +303,7 @@ namespace srs
char
*
pp
=
c1s1_key_bytes
+
764
;
pp
-=
sizeof
(
int32_t
);
key
->
offset
=
*
(
int32_t
*
)
pp
;
key
->
offset
=
__srs_stream_read_4bytes
(
pp
)
;
key
->
random0
=
NULL
;
key
->
random1
=
NULL
;
...
...
@@ -373,7 +394,7 @@ namespace srs
char
*
pp
=
c1s1_digest_bytes
;
digest
->
offset
=
*
(
int32_t
*
)
pp
;
digest
->
offset
=
__srs_stream_read_4bytes
(
pp
)
;
pp
+=
sizeof
(
int32_t
);
digest
->
random0
=
NULL
;
...
...
@@ -416,13 +437,13 @@ namespace srs
void
__srs_time_copy_to
(
char
*&
pp
,
int32_t
time
)
{
// 4bytes time
*
(
int32_t
*
)
pp
=
time
;
__srs_stream_write_4bytes
(
pp
,
time
)
;
pp
+=
4
;
}
void
__srs_version_copy_to
(
char
*&
pp
,
int32_t
version
)
{
// 4bytes version
*
(
int32_t
*
)
pp
=
version
;
__srs_stream_write_4bytes
(
pp
,
version
)
;
pp
+=
4
;
}
void
__srs_key_copy_to
(
char
*&
pp
,
key_block
*
key
)
...
...
@@ -441,16 +462,17 @@ namespace srs
}
pp
+=
key
->
random1_size
;
*
(
int32_t
*
)
pp
=
key
->
offset
;
__srs_stream_write_4bytes
(
pp
,
key
->
offset
)
;
pp
+=
4
;
}
void
__srs_digest_copy_to
(
char
*&
pp
,
digest_block
*
digest
,
bool
with_digest
)
{
// 732bytes digest block without the 32bytes digest-data
// nbytes digest block part1
*
(
int32_t
*
)
pp
=
digest
->
offset
;
__srs_stream_write_4bytes
(
pp
,
digest
->
offset
)
;
pp
+=
4
;
// digest random padding.
if
(
digest
->
random0_size
>
0
)
{
memcpy
(
pp
,
digest
->
random0
,
digest
->
random0_size
);
}
...
...
@@ -720,8 +742,9 @@ namespace srs
destroy_blocks
();
time
=
*
(
int32_t
*
)
_c1s1
;
version
=
*
(
int32_t
*
)(
_c1s1
+
4
);
// client c1 version
time
=
__srs_stream_read_4bytes
(
_c1s1
);
version
=
__srs_stream_read_4bytes
(
_c1s1
+
4
);
// client c1 version
if
(
_schema
==
srs_schema0
)
{
if
((
ret
=
srs_key_block_parse
(
&
block0
.
key
,
_c1s1
+
8
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -766,9 +789,11 @@ namespace srs
destroy_blocks
();
// client c1 time and version
time
=
::
time
(
NULL
);
version
=
0x
00000000
;
// client c1 version
version
=
0x
80000702
;
// client c1 version
// generate signature by schema
if
(
_schema
==
srs_schema0
)
{
srs_key_block_init
(
&
block0
.
key
);
srs_digest_block_init
(
&
block1
.
digest
);
...
...
@@ -779,6 +804,7 @@ namespace srs
schema
=
_schema
;
// generate digest
char
*
digest
=
NULL
;
if
((
ret
=
calc_c1_digest
(
digest
))
!=
ERROR_SUCCESS
)
{
...
...
trunk/src/rtmp/srs_protocol_rtmp.cpp
查看文件 @
f6dd137
...
...
@@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_protocol_handshake.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_protocol_utility.hpp>
#include <srs_kernel_stream.hpp>
using
namespace
std
;
...
...
@@ -268,9 +269,13 @@ int SrsHandshakeBytes::create_c0c1()
srs_random_generate
(
c0c1
,
1537
);
// plain text required.
c0c1
[
0
]
=
0x03
;
*
(
int32_t
*
)(
c0c1
+
1
)
=
::
time
(
NULL
);
*
(
int32_t
*
)(
c0c1
+
1
+
4
)
=
0x00
;
static
SrsStream
stream
;
if
((
ret
=
stream
.
initialize
(
c0c1
,
9
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
stream
.
write_1bytes
(
0x03
);
stream
.
write_4bytes
(
::
time
(
NULL
));
stream
.
write_4bytes
(
0x00
);
return
ret
;
}
...
...
@@ -287,11 +292,15 @@ int SrsHandshakeBytes::create_s0s1s2(const char* c1)
srs_random_generate
(
s0s1s2
,
3073
);
// plain text required.
s0s1s2
[
0
]
=
0x03
;
*
(
int32_t
*
)(
s0s1s2
+
1
)
=
::
time
(
NULL
);
SrsStream
stream
;
if
((
ret
=
stream
.
initialize
(
s0s1s2
,
9
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
stream
.
write_1bytes
(
0x03
);
stream
.
write_4bytes
(
::
time
(
NULL
));
// s2 time2 copy from c1
if
(
c0c1
)
{
*
(
int32_t
*
)(
s0s1s2
+
1
+
4
)
=
*
(
int32_t
*
)(
c0c1
+
1
);
stream
.
write_bytes
(
c0c1
+
1
,
4
);
}
// if c1 specified, copy c1 to s2.
...
...
@@ -315,10 +324,14 @@ int SrsHandshakeBytes::create_c2()
srs_random_generate
(
c2
,
1536
);
// time
*
(
int32_t
*
)(
c2
)
=
::
time
(
NULL
);
SrsStream
stream
;
if
((
ret
=
stream
.
initialize
(
c2
,
8
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
stream
.
write_4bytes
(
::
time
(
NULL
));
// c2 time2 copy from s1
if
(
s0s1s2
)
{
*
(
int32_t
*
)(
c2
+
4
)
=
*
(
int32_t
*
)(
s0s1s2
+
1
);
stream
.
write_bytes
(
s0s1s2
+
1
,
4
);
}
return
ret
;
...
...
@@ -455,6 +468,7 @@ int SrsRtmpClient::connect_app(string app, string tc_url)
SrsConnectAppPacket
*
pkt
=
new
SrsConnectAppPacket
();
pkt
->
command_object
->
set
(
"app"
,
SrsAmf0Any
::
str
(
app
.
c_str
()));
pkt
->
command_object
->
set
(
"flashVer"
,
SrsAmf0Any
::
str
(
"WIN 12,0,0,41"
));
pkt
->
command_object
->
set
(
"swfUrl"
,
SrsAmf0Any
::
str
());
pkt
->
command_object
->
set
(
"tcUrl"
,
SrsAmf0Any
::
str
(
tc_url
.
c_str
()));
pkt
->
command_object
->
set
(
"fpad"
,
SrsAmf0Any
::
boolean
(
false
));
...
...
请
注册
或
登录
后发表评论