Ignore:
Timestamp:
Mar 31, 2011 5:29:54 PM (13 years ago)
Author:
nanang
Message:

Re #1219:

  • Initial version of H264 implementation (codec & packetization).
  • Added vid_codec_util.h/c for video codec utilities (e.g: fmtp parser).
  • Updated video RTP packetizations to be configurable and have internal state (to be more resilient to packet lost, etc).
  • Fixed wrong SPF calculation in PJMEDIA_SPF2.
  • Updated vid_codec_test.c to also have RTP packetization test.
  • Updated sdp_neg.c to verify H.264 capability match.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/sdp_neg.c

    r3347 r3493  
    5353}; 
    5454 
    55 #define GET_FMTP_IVAL(ival, fmtp, param, default_val) \ 
     55#define GET_FMTP_IVAL_BASE(ival, base, fmtp, param, default_val) \ 
    5656    do { \ 
    5757        pj_str_t s; \ 
     
    6464        pj_strset(&s, p + param.slen, fmtp.fmt_param.slen - \ 
    6565                  (p - fmtp.fmt_param.ptr) - param.slen); \ 
    66         ival = pj_strtoul(&s); \ 
     66        ival = pj_strtoul2(&s, NULL, base); \ 
    6767    } while (0) 
     68 
     69#define GET_FMTP_IVAL(ival, fmtp, param, default_val) \ 
     70        GET_FMTP_IVAL_BASE(ival, 10, fmtp, param, default_val) 
     71 
    6872 
    6973/* 
     
    679683 
    680684 
     685/* Matching H.264 between offer and answer. */ 
     686static pj_bool_t match_h264( const pjmedia_sdp_media *offer, 
     687                             unsigned o_fmt_idx, 
     688                             const pjmedia_sdp_media *answer, 
     689                             unsigned a_fmt_idx) 
     690{ 
     691    const pjmedia_sdp_attr *attr_ans; 
     692    const pjmedia_sdp_attr *attr_ofr; 
     693    pjmedia_sdp_fmtp fmtp; 
     694    pj_uint32_t profile1, profile2; 
     695    unsigned pack_mode1, pack_mode2; 
     696    const pj_str_t STR_PROFILE   = {"profile-level-id=", 17}; 
     697    const pj_str_t STR_PACK_MODE = {"packetization-mode=", 19}; 
     698 
     699    /* Parse offer */ 
     700    attr_ofr = pjmedia_sdp_media_find_attr2(offer, "fmtp",  
     701                                            &offer->desc.fmt[o_fmt_idx]); 
     702    if (!attr_ofr) 
     703        return PJ_FALSE; 
     704 
     705    if (pjmedia_sdp_attr_get_fmtp(attr_ofr, &fmtp) != PJ_SUCCESS) 
     706        return PJ_FALSE; 
     707 
     708    GET_FMTP_IVAL_BASE(profile1, 16, fmtp, STR_PROFILE, 0x42000A); 
     709    GET_FMTP_IVAL(pack_mode1, fmtp, STR_PACK_MODE, 0); 
     710 
     711    /* Parse answer */ 
     712    attr_ans = pjmedia_sdp_media_find_attr2(answer, "fmtp",  
     713                                            &answer->desc.fmt[a_fmt_idx]); 
     714    if (!attr_ans) 
     715        return PJ_FALSE; 
     716 
     717    if (pjmedia_sdp_attr_get_fmtp(attr_ans, &fmtp) != PJ_SUCCESS) 
     718        return PJ_FALSE; 
     719 
     720    GET_FMTP_IVAL_BASE(profile2, 16, fmtp, STR_PROFILE, 0x42000A); 
     721    GET_FMTP_IVAL(pack_mode2, fmtp, STR_PACK_MODE, 0); 
     722 
     723    /* Compare bitrate in answer and offer. */ 
     724    return ((profile1 == profile2) && (pack_mode1 == pack_mode2)); 
     725} 
     726 
     727 
    681728/* Toggle AMR octet-align setting in the fmtp. 
    682729 */ 
     
    877924                        { 
    878925                            /* Further check for G7221, negotiate bitrate. */ 
    879                             if (pj_stricmp2(&or_.enc_name, "G7221") == 0) { 
     926                            if (pj_stricmp2(&or_.enc_name, "G7221") == 0) 
     927                            { 
    880928                                if (match_g7221(offer, i, answer, j)) 
    881929                                    break; 
     
    887935                                if (match_amr(offer, i, answer, j, PJ_FALSE,  
    888936                                              NULL)) 
     937                                    break; 
     938                            } else 
     939                            /* Further check for H264, negotiate fmtp. */ 
     940                            if (pj_stricmp2(&or_.enc_name, "H264") == 0) 
     941                            { 
     942                                if (match_h264(offer, i, answer, j)) 
    889943                                    break; 
    890944                            } else { 
     
    12001254                                                   PJ_TRUE, &pt_amr_need_adapt)) 
    12011255                                        continue; 
     1256                                } else 
     1257                                if (pj_stricmp2(&or_.enc_name, "H264") == 0 && 
     1258                                    !match_h264(master, i, slave, j)) 
     1259                                { 
     1260                                    continue; 
    12021261                                } 
    12031262                                found_matching_codec = 1; 
Note: See TracChangeset for help on using the changeset viewer.