mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
move the annexb decode utility to protocol.
This commit is contained in:
parent
bd25626f0e
commit
72ad6894ca
8 changed files with 128 additions and 69 deletions
|
|
@ -28,6 +28,7 @@ using namespace std;
|
|||
|
||||
#include <srs_kernel_log.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_kernel_stream.hpp>
|
||||
|
||||
void srs_discovery_tc_url(
|
||||
string tcUrl,
|
||||
|
|
@ -155,3 +156,32 @@ bool srs_bytes_equals(void* pa, void* pb, int size)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool srs_avc_startswith_annexb(SrsStream* stream, int* pnb_start_code)
|
||||
{
|
||||
char* bytes = stream->data() + stream->pos();
|
||||
char* p = bytes;
|
||||
|
||||
for (;;) {
|
||||
if (!stream->require(p - bytes + 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// not match
|
||||
if (p[0] != 0x00 || p[1] != 0x00) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// match N[00] 00 00 01, where N>=0
|
||||
if (p[2] == 0x01) {
|
||||
if (pnb_start_code) {
|
||||
*pnb_start_code = (int)(p - bytes) + 3;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_kernel_consts.hpp>
|
||||
|
||||
class SrsStream;
|
||||
|
||||
/**
|
||||
* parse the tcUrl, output the schema, host, vhost, app and port.
|
||||
* @param tcUrl, the input tcUrl, for example,
|
||||
|
|
@ -85,5 +87,14 @@ extern std::string srs_generate_tc_url(
|
|||
*/
|
||||
extern bool srs_bytes_equals(void* pa, void* pb, int size);
|
||||
|
||||
/**
|
||||
* whether stream starts with the avc NALU in "AnnexB"
|
||||
* from H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
* start code must be "N[00] 00 00 01" where N>=0
|
||||
* @param pnb_start_code output the size of start code, must >=3.
|
||||
* NULL to ignore.
|
||||
*/
|
||||
extern bool srs_avc_startswith_annexb(SrsStream* stream, int* pnb_start_code = NULL);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue