Skip to content

Commit

Permalink
ストリームIDだけリトルエンディアンなのにビッグで送ってた。
Browse files Browse the repository at this point in the history
  • Loading branch information
plonk committed Aug 19, 2020
1 parent aac2316 commit 75cba4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions rtmp-server/iohelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ namespace iohelpers
return res;
}

std::string
to_bytes_little_endian(int integer,
int nbytes)
{
std::string res;
for (int i = 0; i < nbytes; ++i)
{
res.push_back(integer & 0xff);
integer >>= 8;
}
return res;
}

void test()
{
if (to_integer_big_endian({ 0x01, 0x00 }) != 256)
Expand Down
2 changes: 1 addition & 1 deletion rtmp-server/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace rtmpserver

std::string t = to_bytes_big_endian(timestamp, 3);
std::string l = to_bytes_big_endian(length, 3);
std::string s = to_bytes_big_endian(stream_id, 4);
std::string s = to_bytes_little_endian(stream_id, 4);
return t + l + std::string({ (char)type }) + s;
}
};
Expand Down

0 comments on commit 75cba4e

Please sign in to comment.