本文整理汇总了C++中SrsStream::write_4bytes方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsStream::write_4bytes方法的具体用法?C++ SrsStream::write_4bytes怎么用?C++ SrsStream::write_4bytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrsStream
的用法示例。
在下文中一共展示了SrsStream::write_4bytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
int SrsHandshakeBytes::create_s0s1s2(const char* c1)
{
int ret = ERROR_SUCCESS;
if (s0s1s2) {
return ret;
}
s0s1s2 = new char[3073];
srs_random_generate(s0s1s2, 3073);
// plain text required.
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) {
stream.write_bytes(c0c1 + 1, 4);
}
// if c1 specified, copy c1 to s2.
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/46
if (c1) {
memcpy(s0s1s2 + 1537, c1, 1536);
}
return ret;
}
示例2:
// 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);
}
示例3: TEST
/**
* test the stream utility, write 34bytes
*/
VOID TEST(KernelStreamTest, StreamWrite4Bytes)
{
SrsStream s;
char data[1024];
EXPECT_TRUE(ERROR_SUCCESS == s.initialize(data, 1024));
s.write_4bytes(0x10111213);
s.write_4bytes(0x14151617);
s.write_4bytes(0x18192021);
s.skip(-1 * s.pos());
EXPECT_EQ(0x10, s.read_1bytes());
s.skip(2);
EXPECT_EQ(0x13, s.read_1bytes());
s.skip(5);
EXPECT_EQ(0x19, s.read_1bytes());
}
示例4:
int SrsHandshakeBytes::create_c0c1()
{
int ret = ERROR_SUCCESS;
if (c0c1) {
return ret;
}
c0c1 = new char[1537];
srs_random_generate(c0c1, 1537);
// plain text required.
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;
}