Bug 1022008: Support max-fs & max-fr in SDP for H.264; clean up video codec fmtp generation r=ehugg

This commit is contained in:
Randell Jesup 2014-07-01 04:19:32 -04:00
parent fbce9e330c
commit 03a51e592d
4 changed files with 57 additions and 87 deletions

View File

@ -2802,6 +2802,17 @@ int vcmGetVideoMaxSupportedPacketizationMode()
return 1;
}
/**
* Get supported H.264 profile-level-id
* @return supported profile-level-id value
*/
uint32_t vcmGetVideoH264ProfileLevelID()
{
// constrained baseline level 1.2
// XXX make variable based on openh264 and OMX support
return 0x42E00C;
}
/**
* MEDIA control received from far end on signaling path
*
@ -3043,62 +3054,6 @@ cc_boolean vcmCheckAttribs(cc_uint32_t media_type, void *sdp_p, int level, void
}
}
/**
* Add Video attributes in the offer/answer SDP
*
* This method is called for video codecs only. This method should populate the
* Video SDP attributes using the SDP helper API
*
* @param [in] sdp_p - opaque SDP pointer to be used via SDP helper APIs
* @param [in] level - Parameter to be used with SDP helper APIs
* @param [in] media_type - codec for which the SDP attributes are to be populated
* @param [in] payload_number - RTP payload type used for the SDP
* @param [in] isOffer - cc_boolean indicating we are encoding an offer or an aswer
*
* @return void
*/
void vcmPopulateAttribs(void *sdp_p, int level, cc_uint32_t media_type,
cc_uint16_t payload_number, cc_boolean isOffer)
{
CSFLogDebug( logTag, "vcmPopulateAttribs(): media=%d PT=%d, isOffer=%d", media_type, payload_number, isOffer);
uint16_t a_inst;//, a_inst2, a_inst3, a_inst4;
int profile;
char profile_level_id[MAX_SPROP_LEN];
switch (media_type)
{
case RTP_H264_P0:
case RTP_H264_P1:
if ( ccsdpAddNewAttr(sdp_p, level, 0, SDP_ATTR_FMTP, &a_inst) != SDP_SUCCESS ) return;
(void) ccsdpAttrSetFmtpPayloadType(sdp_p, level, 0, a_inst, payload_number);
if (media_type == RTP_H264_P1) {
(void) ccsdpAttrSetFmtpPackMode(sdp_p, level, 0, a_inst, 1 /*packetization_mode*/);
}
//(void) sdp_attr_set_fmtp_parameter_sets(sdp_p, level, 0, a_inst, "J0KAFJWgUH5A,KM4H8n=="); // NAL units 27 42 80 14 95 a0 50 7e 40 28 ce 07 f2
//profile = 0x42E000 + H264ToSDPLevel( vt_GetClientProfileLevel() );
profile = 0x42E00C;
csf_sprintf(profile_level_id, MAX_SPROP_LEN, "%X", profile);
(void) ccsdpAttrSetFmtpProfileLevelId(sdp_p, level, 0, a_inst, profile_level_id);
//(void) sdp_attr_set_fmtp_max_mbps(sdp_p, level, 0, a_inst, max_mbps);
//(void) sdp_attr_set_fmtp_max_fs(sdp_p, level, 0, a_inst, max_fs);
//(void) sdp_attr_set_fmtp_max_cpb(sdp_p, level, 0, a_inst, max_cpb);
//(void) sdp_attr_set_fmtp_max_dpb(sdp_p, level, 0, a_inst, max_dpb);
//(void) sdp_attr_set_fmtp_max_br(sdp_p, level, 0, a_inst, max_br);
//(void) sdp_add_new_bw_line(sdp_p, level, &a_inst);
//(void) sdp_set_bw(sdp_p, level, a_inst, SDP_BW_MODIFIER_TIAS, tias_bw);
break;
default:
break;
}
}
/**
* Send a DTMF digit
*

View File

@ -1137,6 +1137,7 @@ gsmsdp_set_video_media_attributes (uint32_t media_type, void *cc_sdp_p, uint16_t
uint16_t payload_number)
{
uint16_t a_inst;
int added_fmtp = 0;
void *sdp_p = ((cc_sdp_t*)cc_sdp_p)->src_sdp;
int max_fs = 0;
int max_fr = 0;
@ -1170,21 +1171,56 @@ gsmsdp_set_video_media_attributes (uint32_t media_type, void *cc_sdp_p, uint16_t
SIPSDP_ATTR_ENCNAME_H264);
(void) sdp_attr_set_rtpmap_clockrate(sdp_p, level, 0, a_inst,
RTPMAP_VIDEO_CLOCKRATE);
// we know we haven't added it yet
if (sdp_add_new_attr(sdp_p, level, 0, SDP_ATTR_FMTP, &a_inst)
!= SDP_SUCCESS) {
GSM_ERR_MSG("Failed to add attribute");
return;
}
added_fmtp = 1;
{
char buffer[32];
uint32_t profile_level_id = vcmGetVideoH264ProfileLevelID();
snprintf(buffer, sizeof(buffer), "0x%x", profile_level_id);
(void) sdp_attr_set_fmtp_profile_level_id(sdp_p, level, 0, a_inst,
buffer);
}
if (media_type == RTP_H264_P1) {
(void) sdp_attr_set_fmtp_pack_mode(sdp_p, level, 0, a_inst,
1);
}
// TODO: other parameters we may want/need to set for H.264
//(void) sdp_attr_set_fmtp_max_mbps(sdp_p, level, 0, a_inst, max_mbps);
//(void) sdp_attr_set_fmtp_max_fs(sdp_p, level, 0, a_inst, max_fs);
//(void) sdp_attr_set_fmtp_max_cpb(sdp_p, level, 0, a_inst, max_cpb);
//(void) sdp_attr_set_fmtp_max_dpb(sdp_p, level, 0, a_inst, max_dpb);
//(void) sdp_attr_set_fmtp_max_br(sdp_p, level, 0, a_inst, max_br);
//(void) sdp_add_new_bw_line(sdp_p, level, &a_inst);
//(void) sdp_set_bw(sdp_p, level, a_inst, SDP_BW_MODIFIER_TIAS, tias_bw);
break;
case RTP_VP8:
(void) sdp_attr_set_rtpmap_encname(sdp_p, level, 0, a_inst,
SIPSDP_ATTR_ENCNAME_VP8);
(void) sdp_attr_set_rtpmap_clockrate(sdp_p, level, 0, a_inst,
RTPMAP_VIDEO_CLOCKRATE);
break;
}
switch (media_type) {
case RTP_H264_P0:
case RTP_H264_P1:
case RTP_VP8:
max_fs = config_get_video_max_fs((rtp_ptype) media_type);
max_fr = config_get_video_max_fr((rtp_ptype) media_type);
if (max_fs || max_fr) {
if (sdp_add_new_attr(sdp_p, level, 0, SDP_ATTR_FMTP, &a_inst)
!= SDP_SUCCESS) {
GSM_ERR_MSG("Failed to add attribute");
return;
if (!added_fmtp) {
if (sdp_add_new_attr(sdp_p, level, 0, SDP_ATTR_FMTP, &a_inst)
!= SDP_SUCCESS) {
GSM_ERR_MSG("Failed to add attribute");
return;
}
added_fmtp = 1;
}
(void) sdp_attr_set_fmtp_payload_type(sdp_p, level, 0, a_inst,
@ -1200,13 +1236,8 @@ gsmsdp_set_video_media_attributes (uint32_t media_type, void *cc_sdp_p, uint16_t
max_fr);
}
}
break;
}
GSM_DEBUG("gsmsdp_set_video_media_attributes- populate attribs %d", payload_number );
vcmPopulateAttribs(cc_sdp_p, level, media_type, payload_number, FALSE);
break;
default:

View File

@ -887,6 +887,12 @@ int vcmGetVideoCodecList(int request_type);
*/
int vcmGetVideoMaxSupportedPacketizationMode();
/**
* Get supported H.264 profile-level-id
* @return supported profile-level-id value
*/
uint32_t vcmGetVideoH264ProfileLevelID();
/**
* Get the rx/tx stream statistics associated with the call.
* The rx/tx stats are defined as comma seperated string as follows.

View File

@ -490,28 +490,6 @@ boolean vcmCheckAttribs(uint32_t media_type, void *sdp_p, int level, void **rcap
return TRUE;
}
/**
* Add Video attributes in the offer/answer SDP
*
* This method is called for video codecs only. This method should populate the
* Video SDP attributes using the SDP helper API
*
* @param [in] sdp_p - opaque SDP pointer to be used via SDP helper APIs
* @param [in] level - Parameter to be used with SDP helper APIs
* @param [in] media_type - codec for which the SDP attributes are to be populated
* @param [in] payload_number - RTP payload type used for the SDP
* @param [in] isOffer - boolean indicating we are encoding an offer or an aswer
*
* @return void
*/
void vcmPopulateAttribs(void *sdp_p, int level, uint32_t media_type,
uint16_t payload_number, boolean isOffer)
{
return;
}
/**
* Send a DTMF digit
*