mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Kernel: Buffer supports little-endian
This commit is contained in:
parent
ab2d15d524
commit
2bd0e1ce43
4 changed files with 139 additions and 0 deletions
|
@ -2226,11 +2226,18 @@ srs_error_t SrsRtcSession::start_publish()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: err process.
|
// FIXME: err process.
|
||||||
if ((err = publisher_->initialize(video_ssrc, audio_ssrc, twcc_ext_id, req)) != srs_success) {
|
if ((err = publisher_->initialize(video_ssrc, audio_ssrc, twcc_ext_id, req)) != srs_success) {
|
||||||
return srs_error_wrap(err, "rtc publisher init");
|
return srs_error_wrap(err, "rtc publisher init");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_srs_rtc_hijacker) {
|
||||||
|
if ((err = _srs_rtc_hijacker->on_start_publish(this, publisher_, req)) != srs_success) {
|
||||||
|
return srs_error_wrap(err, "on start publish");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2319,3 +2326,13 @@ srs_error_t SrsRtcSession::on_binding_request(SrsStunPacket* r)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISrsRtcHijacker::ISrsRtcHijacker()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ISrsRtcHijacker::~ISrsRtcHijacker()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ISrsRtcHijacker* _srs_rtc_hijacker = NULL;
|
||||||
|
|
||||||
|
|
|
@ -391,5 +391,17 @@ private:
|
||||||
srs_error_t on_binding_request(SrsStunPacket* r);
|
srs_error_t on_binding_request(SrsStunPacket* r);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ISrsRtcHijacker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ISrsRtcHijacker();
|
||||||
|
virtual ~ISrsRtcHijacker();
|
||||||
|
public:
|
||||||
|
// When start publisher by RTC.
|
||||||
|
virtual srs_error_t on_start_publish(SrsRtcSession* session, SrsRtcPublisher* publisher, SrsRequest* req) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern ISrsRtcHijacker* _srs_rtc_hijacker;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,18 @@ int16_t SrsBuffer::read_2bytes()
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t SrsBuffer::read_le2bytes()
|
||||||
|
{
|
||||||
|
srs_assert(require(2));
|
||||||
|
|
||||||
|
int16_t value;
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
pp[0] = *p++;
|
||||||
|
pp[1] = *p++;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t SrsBuffer::read_3bytes()
|
int32_t SrsBuffer::read_3bytes()
|
||||||
{
|
{
|
||||||
srs_assert(require(3));
|
srs_assert(require(3));
|
||||||
|
@ -141,6 +153,19 @@ int32_t SrsBuffer::read_3bytes()
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SrsBuffer::read_le3bytes()
|
||||||
|
{
|
||||||
|
srs_assert(require(3));
|
||||||
|
|
||||||
|
int32_t value = 0x00;
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
pp[0] = *p++;
|
||||||
|
pp[1] = *p++;
|
||||||
|
pp[2] = *p++;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t SrsBuffer::read_4bytes()
|
int32_t SrsBuffer::read_4bytes()
|
||||||
{
|
{
|
||||||
srs_assert(require(4));
|
srs_assert(require(4));
|
||||||
|
@ -155,6 +180,20 @@ int32_t SrsBuffer::read_4bytes()
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SrsBuffer::read_le4bytes()
|
||||||
|
{
|
||||||
|
srs_assert(require(4));
|
||||||
|
|
||||||
|
int32_t value;
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
pp[0] = *p++;
|
||||||
|
pp[1] = *p++;
|
||||||
|
pp[2] = *p++;
|
||||||
|
pp[3] = *p++;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t SrsBuffer::read_8bytes()
|
int64_t SrsBuffer::read_8bytes()
|
||||||
{
|
{
|
||||||
srs_assert(require(8));
|
srs_assert(require(8));
|
||||||
|
@ -173,6 +212,24 @@ int64_t SrsBuffer::read_8bytes()
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t SrsBuffer::read_le8bytes()
|
||||||
|
{
|
||||||
|
srs_assert(require(8));
|
||||||
|
|
||||||
|
int64_t value;
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
pp[0] = *p++;
|
||||||
|
pp[1] = *p++;
|
||||||
|
pp[2] = *p++;
|
||||||
|
pp[3] = *p++;
|
||||||
|
pp[4] = *p++;
|
||||||
|
pp[5] = *p++;
|
||||||
|
pp[6] = *p++;
|
||||||
|
pp[7] = *p++;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
string SrsBuffer::read_string(int len)
|
string SrsBuffer::read_string(int len)
|
||||||
{
|
{
|
||||||
srs_assert(require(len));
|
srs_assert(require(len));
|
||||||
|
@ -210,6 +267,15 @@ void SrsBuffer::write_2bytes(int16_t value)
|
||||||
*p++ = pp[0];
|
*p++ = pp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsBuffer::write_le2bytes(int16_t value)
|
||||||
|
{
|
||||||
|
srs_assert(require(2));
|
||||||
|
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
*p++ = pp[0];
|
||||||
|
*p++ = pp[1];
|
||||||
|
}
|
||||||
|
|
||||||
void SrsBuffer::write_4bytes(int32_t value)
|
void SrsBuffer::write_4bytes(int32_t value)
|
||||||
{
|
{
|
||||||
srs_assert(require(4));
|
srs_assert(require(4));
|
||||||
|
@ -221,6 +287,17 @@ void SrsBuffer::write_4bytes(int32_t value)
|
||||||
*p++ = pp[0];
|
*p++ = pp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsBuffer::write_le4bytes(int32_t value)
|
||||||
|
{
|
||||||
|
srs_assert(require(4));
|
||||||
|
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
*p++ = pp[0];
|
||||||
|
*p++ = pp[1];
|
||||||
|
*p++ = pp[2];
|
||||||
|
*p++ = pp[3];
|
||||||
|
}
|
||||||
|
|
||||||
void SrsBuffer::write_3bytes(int32_t value)
|
void SrsBuffer::write_3bytes(int32_t value)
|
||||||
{
|
{
|
||||||
srs_assert(require(3));
|
srs_assert(require(3));
|
||||||
|
@ -231,6 +308,16 @@ void SrsBuffer::write_3bytes(int32_t value)
|
||||||
*p++ = pp[0];
|
*p++ = pp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsBuffer::write_le3bytes(int32_t value)
|
||||||
|
{
|
||||||
|
srs_assert(require(3));
|
||||||
|
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
*p++ = pp[0];
|
||||||
|
*p++ = pp[1];
|
||||||
|
*p++ = pp[2];
|
||||||
|
}
|
||||||
|
|
||||||
void SrsBuffer::write_8bytes(int64_t value)
|
void SrsBuffer::write_8bytes(int64_t value)
|
||||||
{
|
{
|
||||||
srs_assert(require(8));
|
srs_assert(require(8));
|
||||||
|
@ -246,6 +333,21 @@ void SrsBuffer::write_8bytes(int64_t value)
|
||||||
*p++ = pp[0];
|
*p++ = pp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsBuffer::write_le8bytes(int64_t value)
|
||||||
|
{
|
||||||
|
srs_assert(require(8));
|
||||||
|
|
||||||
|
char* pp = (char*)&value;
|
||||||
|
*p++ = pp[0];
|
||||||
|
*p++ = pp[1];
|
||||||
|
*p++ = pp[2];
|
||||||
|
*p++ = pp[3];
|
||||||
|
*p++ = pp[4];
|
||||||
|
*p++ = pp[5];
|
||||||
|
*p++ = pp[6];
|
||||||
|
*p++ = pp[7];
|
||||||
|
}
|
||||||
|
|
||||||
void SrsBuffer::write_string(string value)
|
void SrsBuffer::write_string(string value)
|
||||||
{
|
{
|
||||||
srs_assert(require((int)value.length()));
|
srs_assert(require((int)value.length()));
|
||||||
|
|
|
@ -136,12 +136,16 @@ public:
|
||||||
int8_t read_1bytes();
|
int8_t read_1bytes();
|
||||||
// Read 2bytes int from buffer.
|
// Read 2bytes int from buffer.
|
||||||
int16_t read_2bytes();
|
int16_t read_2bytes();
|
||||||
|
int16_t read_le2bytes();
|
||||||
// Read 3bytes int from buffer.
|
// Read 3bytes int from buffer.
|
||||||
int32_t read_3bytes();
|
int32_t read_3bytes();
|
||||||
|
int32_t read_le3bytes();
|
||||||
// Read 4bytes int from buffer.
|
// Read 4bytes int from buffer.
|
||||||
int32_t read_4bytes();
|
int32_t read_4bytes();
|
||||||
|
int32_t read_le4bytes();
|
||||||
// Read 8bytes int from buffer.
|
// Read 8bytes int from buffer.
|
||||||
int64_t read_8bytes();
|
int64_t read_8bytes();
|
||||||
|
int64_t read_le8bytes();
|
||||||
// Read string from buffer, length specifies by param len.
|
// Read string from buffer, length specifies by param len.
|
||||||
std::string read_string(int len);
|
std::string read_string(int len);
|
||||||
// Read bytes from buffer, length specifies by param len.
|
// Read bytes from buffer, length specifies by param len.
|
||||||
|
@ -151,12 +155,16 @@ public:
|
||||||
void write_1bytes(int8_t value);
|
void write_1bytes(int8_t value);
|
||||||
// Write 2bytes int to buffer.
|
// Write 2bytes int to buffer.
|
||||||
void write_2bytes(int16_t value);
|
void write_2bytes(int16_t value);
|
||||||
|
void write_le2bytes(int16_t value);
|
||||||
// Write 4bytes int to buffer.
|
// Write 4bytes int to buffer.
|
||||||
void write_4bytes(int32_t value);
|
void write_4bytes(int32_t value);
|
||||||
|
void write_le4bytes(int32_t value);
|
||||||
// Write 3bytes int to buffer.
|
// Write 3bytes int to buffer.
|
||||||
void write_3bytes(int32_t value);
|
void write_3bytes(int32_t value);
|
||||||
|
void write_le3bytes(int32_t value);
|
||||||
// Write 8bytes int to buffer.
|
// Write 8bytes int to buffer.
|
||||||
void write_8bytes(int64_t value);
|
void write_8bytes(int64_t value);
|
||||||
|
void write_le8bytes(int64_t value);
|
||||||
// Write string to buffer
|
// Write string to buffer
|
||||||
void write_string(std::string value);
|
void write_string(std::string value);
|
||||||
// Write bytes to buffer
|
// Write bytes to buffer
|
||||||
|
|
Loading…
Reference in a new issue