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
cd06f2da0c
commit
80985c7307
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)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,9 @@ class SrsRtpRawPayload;
|
|||
class SrsRtpFUAPayload2;
|
||||
class SrsSharedPtrMessage;
|
||||
|
||||
// Fast parse the SSRC from RTP packet. Return 0 if invalid.
|
||||
uint32_t srs_rtp_fast_parse_ssrc(char* buf, int size);
|
||||
|
||||
// The "distance" between two uint16 number, for example:
|
||||
// distance(prev_value=3, value=5) === (int16_t)(uint16_t)((uint16_t)3-(uint16_t)5) === -2
|
||||
// distance(prev_value=3, value=65534) === (int16_t)(uint16_t)((uint16_t)3-(uint16_t)65534) === 5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue