Ejemplo n.º 1
0
// -----------------------------------------------------------------------------
// TSdpRtpmapValue::DecodeL
// Decodes string and puts it into parts
// -----------------------------------------------------------------------------
//
EXPORT_C TSdpRtpmapValue TSdpRtpmapValue::DecodeL( 
    const TDesC8& aText )
    {
    __ASSERT_ALWAYS(aText.Length() > 0 && 
                    aText.Locate( KSlashChar ) != KErrNotFound, 
        User::Leave(KErrSdpCodecMediaAttributeField));

    TInt length( aText.Length() );
    if ( aText[length - 1] == KLFChar )
        {
        if ( length > 1 && aText[length - 2] == KCRChar )
            {
            length--;
            }
        length--;
        }  
    TPtrC8 restValue( aText.Left( length ) );

    __ASSERT_ALWAYS(SdpUtil::IsByteString(restValue), 
                    User::Leave(KErrSdpCodecMediaAttributeField)); 

    TInt pos = restValue.Locate( KSlashChar );
    
    // <encoding name>
    TPtrC8 encName( restValue.Left( pos ) );    
    
    restValue.Set( restValue.Right( restValue.Length() - pos - 1 ) );
    pos = restValue.Locate( KSlashChar );

    // <clock rate> <encoding parameters>
    TPtrC8 encParam( KNullDesC8 );
    TPtrC8 clockRate( KNullDesC8 );
   
    if ( pos == KErrNotFound )
        {              
        clockRate.Set( restValue );      
        
        __ASSERT_ALWAYS( clockRate.Length() > 0 && encParam.Length() == 0,
                         User::Leave( KErrSdpCodecMediaAttributeField ) );          
        }
    else
        {
        clockRate.Set( restValue.Left( pos ) );      
        encParam.Set( restValue.Right( restValue.Length() - pos - 1 ) );

        __ASSERT_ALWAYS( clockRate.Length() > 0 && encParam.Length() > 0,
                         User::Leave( KErrSdpCodecMediaAttributeField ) );
        }
   
    return TSdpRtpmapValue( encName, clockRate, encParam );
    }
Ejemplo n.º 2
0
/*
 * Generate the XML for a type.
 */
static void xmlType(sipSpec *pt, moduleDef *mod, argDef *ad, int out,
        KwArgs kwargs, FILE *fp)
{
    const char *type_name;
    classDef *type_scope;
    typeHintDef *thd;

    fprintf(fp, " typename=\"");

    /* Handle the argument name. */
    if (!out && ad->name != NULL)
    {
        if (kwargs == AllKwArgs || (kwargs == OptionalKwArgs && ad->defval != NULL))
            fprintf(fp, "%s: ", ad->name->text);
    }

    /* Use any explicit type hint unless the argument is constrained. */
    thd = (out ? ad->typehint_out : (isConstrained(ad) ? NULL : ad->typehint_in));

    if (thd != NULL)
    {
        pyiTypeHint(pt, thd, mod, out, NULL, FALSE, TRUE, fp);
    }
    else
    {
        switch (ad->atype)
        {
        case class_type:
            restPyClass(ad->u.cd, fp);
            break;

        case enum_type:
            if (ad->u.ed->pyname != NULL)
                restPyEnum(ad->u.ed, fp);
            else
                fprintf(fp, "int");

            break;

        case qobject_type:
            restPyClass(pt->qobject_cd, fp);
            break;

        case mapped_type:
            /* There would normally be a type hint. */
            fprintf(fp, "unknown-type");
            break;

        default:
            if ((type_name = pyType(pt, ad, &type_scope)) != NULL)
                prScopedPythonName(fp, type_scope, type_name);
        }
    }

    if (!out && ad->name != NULL && ad->defval != NULL)
    {
        fprintf(fp, " = ");

        /*
         * Try and convert the value to a reST reference.  We don't try very
         * hard but will get most cases.
         */
        if (!restValue(pt, ad->defval, fp))
            prDefaultValue(ad, FALSE, fp);
    }

    fprintf(fp, "\"");
}