1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix #212, support publish aac adts raw stream. 2.0.31.

This commit is contained in:
winlin 2014-11-24 16:28:52 +08:00
parent 3d97048c3a
commit e492fa5353
15 changed files with 620 additions and 86 deletions

View file

@ -167,12 +167,12 @@ bool srs_avc_startswith_annexb(SrsStream* stream, int* pnb_start_code)
}
// not match
if (p[0] != 0x00 || p[1] != 0x00) {
if (p[0] != (char)0x00 || p[1] != (char)0x00) {
return false;
}
// match N[00] 00 00 01, where N>=0
if (p[2] == 0x01) {
if (p[2] == (char)0x01) {
if (pnb_start_code) {
*pnb_start_code = (int)(p - bytes) + 3;
}
@ -185,3 +185,21 @@ bool srs_avc_startswith_annexb(SrsStream* stream, int* pnb_start_code)
return false;
}
bool srs_aac_startswith_adts(SrsStream* stream)
{
char* bytes = stream->data() + stream->pos();
char* p = bytes;
if (!stream->require(p - bytes + 2)) {
return false;
}
// matched 12bits 0xFFF,
// @remark, we must cast the 0xff to char to compare.
if (p[0] != (char)0xff || (char)(p[1] & 0xf0) != (char)0xf0) {
return false;
}
return true;
}

View file

@ -96,5 +96,12 @@ extern bool srs_bytes_equals(void* pa, void* pb, int size);
*/
extern bool srs_avc_startswith_annexb(SrsStream* stream, int* pnb_start_code = NULL);
/**
* whether stream starts with the aac ADTS
* from aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS.
* start code must be '1111 1111 1111'B, that is 0xFFF
*/
extern bool srs_aac_startswith_adts(SrsStream* stream);
#endif