本文整理汇总了C++中SrsStream::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsStream::pos方法的具体用法?C++ SrsStream::pos怎么用?C++ SrsStream::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrsStream
的用法示例。
在下文中一共展示了SrsStream::pos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
/**
* test the stream utility, access pos
*/
VOID TEST(KernelStreamTest, StreamPos)
{
SrsStream s;
char data[1024];
EXPECT_TRUE(s.pos() == 0);
EXPECT_TRUE(ERROR_SUCCESS == s.initialize(data, 1024));
EXPECT_TRUE(s.pos() == 0);
s.read_bytes(data, 1024);
EXPECT_TRUE(s.pos() == 1024);
}
示例2:
srs_amf0_t srs_amf0_parse(char* data, int size, int* nparsed)
{
int ret = ERROR_SUCCESS;
srs_amf0_t amf0 = NULL;
SrsStream stream;
if ((ret = stream.initialize(data, size)) != ERROR_SUCCESS) {
return amf0;
}
SrsAmf0Any* any = NULL;
if ((ret = SrsAmf0Any::discovery(&stream, &any)) != ERROR_SUCCESS) {
return amf0;
}
stream.reset();
if ((ret = any->read(&stream)) != ERROR_SUCCESS) {
srs_freep(any);
return amf0;
}
*nparsed = stream.pos();
amf0 = (srs_amf0_t)any;
return amf0;
}
示例3: TEST
VOID TEST(AMF0Test, ApiAnyAssert)
{
SrsStream s;
SrsAmf0Any* o = NULL;
char buf[1024];
memset(buf, 0, sizeof(buf));
EXPECT_EQ(ERROR_SUCCESS, s.initialize(buf, sizeof(buf)));
// read any
if (true) {
s.reset();
s.current()[0] = 0x12;
EXPECT_NE(ERROR_SUCCESS, srs_amf0_read_any(&s, &o));
EXPECT_TRUE(NULL == o);
srs_freep(o);
}
// any convert
if (true) {
o = SrsAmf0Any::str();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_string());
}
if (true) {
o = SrsAmf0Any::number();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_number());
}
if (true) {
o = SrsAmf0Any::boolean();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_boolean());
}
if (true) {
o = SrsAmf0Any::null();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_null());
}
if (true) {
o = SrsAmf0Any::undefined();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_undefined());
}
if (true) {
o = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_object());
}
if (true) {
o = SrsAmf0Any::ecma_array();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_ecma_array());
}
if (true) {
o = SrsAmf0Any::strict_array();
SrsAutoFree(SrsAmf0Any, o);
EXPECT_TRUE(o->is_strict_array());
}
// empty object
if (true) {
o = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Any, o);
s.reset();
EXPECT_EQ(ERROR_SUCCESS, o->write(&s));
EXPECT_EQ(1+3, s.pos());
}
// empty ecma array
if (true) {
o = SrsAmf0Any::ecma_array();
SrsAutoFree(SrsAmf0Any, o);
s.reset();
EXPECT_EQ(ERROR_SUCCESS, o->write(&s));
EXPECT_EQ(1+4+3, s.pos());
}
// strict array
if (true) {
o = SrsAmf0Any::strict_array();
SrsAutoFree(SrsAmf0Any, o);
s.reset();
EXPECT_EQ(ERROR_SUCCESS, o->write(&s));
EXPECT_EQ(1+4, s.pos());
}
}