mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Fast parse ssrc and find the publisher
This commit is contained in:
parent
5f31868ce6
commit
dffbebfe6f
3 changed files with 39 additions and 10 deletions
|
@ -33,6 +33,37 @@ using namespace std;
|
|||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_kernel_flv.hpp>
|
||||
|
||||
uint32_t srs_rtp_fast_parse_ssrc(char* buf, int size)
|
||||
{
|
||||
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|V=2|P|X| CC |M| PT | sequence number |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| timestamp |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| synchronization source (SSRC) identifier |
|
||||
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
|
||||
| contributing source (CSRC) identifiers |
|
||||
| .... |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
if (size < 12) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t value = 0;
|
||||
char* pp = (char*)&value;
|
||||
|
||||
char* p = buf + 8;
|
||||
pp[3] = *p++;
|
||||
pp[2] = *p++;
|
||||
pp[1] = *p++;
|
||||
pp[0] = *p++;
|
||||
return value;
|
||||
}
|
||||
|
||||
// If value is newer than pre_value,return true; otherwise false
|
||||
bool srs_seq_is_newer(uint16_t value, uint16_t pre_value)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue