Commit fc570408 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add discontinuity check in rfc3984 unpacker.

parent c944c0b0
......@@ -37,9 +37,10 @@ typedef struct Rfc3984Context{
mblk_t *m;
int maxsz;
uint32_t last_ts;
uint16_t ref_cseq;
uint8_t mode;
bool_t stap_a_allowed;
uint8_t reserved;
bool_t initialized_ref_cseq;
} Rfc3984Context;
MS2_PUBLIC Rfc3984Context *rfc3984_new(void);
......@@ -55,8 +56,11 @@ MS2_PUBLIC void rfc3984_enable_stap_a(Rfc3984Context *ctx, bool_t yesno);
/*process NALUs and pack them into rtp payloads */
MS2_PUBLIC void rfc3984_pack(Rfc3984Context *ctx, MSQueue *naluq, MSQueue *rtpq, uint32_t ts);
/*process incoming rtp data and output NALUs, whenever possible*/
MS2_PUBLIC void rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *naluq);
* Process incoming rtp data and output NALUs, whenever possible.
* @return 0 if everything was ok, -1 on error.
MS2_PUBLIC int rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *naluq);
void rfc3984_uninit(Rfc3984Context *ctx);
......@@ -243,11 +243,13 @@ static mblk_t * aggregate_fua(Rfc3984Context *ctx, mblk_t *im){
/*process incoming rtp data and output NALUs, whenever possible*/
void rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *out){
int rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *out){
uint8_t type=nal_header_get_type(im->b_rptr);
uint8_t *p;
int marker = mblk_get_marker_info(im);
uint32_t ts=mblk_get_timestamp_info(im);
uint16_t cseq=mblk_get_cseq(im);
int res = 0;
if (ctx->last_ts!=ts){
/*a new frame is arriving, in case the marker bit was not set in previous frame, output it now*/
......@@ -258,6 +260,7 @@ void rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *out){
out_without_marker = TRUE;
res = -1;
if (out_without_marker) ms_warning("Incomplete H264 frame (missing marker bit)");
......@@ -265,6 +268,18 @@ void rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *out){
if (im->b_cont) msgpullup(im,-1);
if (!ctx->initialized_ref_cseq) {
ctx->initialized_ref_cseq = TRUE;
ctx->ref_cseq = cseq;
} else {
if (ctx->ref_cseq != cseq) {
ms_message("sequence inconsistency detected (diff=%i)",(int)(cseq - ctx->ref_cseq));
ctx->ref_cseq = cseq;
res = -1;
if (type==TYPE_STAP_A){
/*split into nalus*/
uint16_t sz;
......@@ -312,6 +327,8 @@ void rfc3984_unpack(Rfc3984Context *ctx, mblk_t *im, MSQueue *out){
return res;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment