status_t VideoRecorderCtrl::setFramerate(const android::sp<android::MetaData> &videoMetaData) {
    status_t    retval = OK ;
    int         fps ;
    
    F_LOG;
	videoMetaData->findInt32(kKeySampleRate, &fps) ;
    LOGV("fps:%d", fps);
    retval = m_cameraCtrl.setFramerate (fps);
    if (retval == OK) {        
	    retval = m_encoderCtrl.setFramerate (fps);
	} else {
	    LOGE("Failed to set camera frame rate !!!!!");
	}
	
	return retval ;
}
ECode Media_Utils::ConvertMessageToMap(
   /* [in] */ android::sp<android::AMessage>& msg,
   /* [out] */ IObjectStringMap** mymap)
{
    VALIDATE_NOT_NULL(mymap);
    *mymap = NULL;

    AutoPtr<IObjectStringMap> returnMap;
    CObjectStringMap::New( (IObjectStringMap**)&returnMap);

    for (Int32 i = 0; i < msg->countEntries(); i++) {
        android::AMessage::Type valueType;
        const char *key = msg->getEntryNameAt(i,&valueType);

        AutoPtr<IInterface> valueObj;
        switch (valueType){
            case android::AMessage::kTypeInt32: {
                Int32 val;
                msg->findInt32(key, &val);
                AutoPtr<IInteger32> value;
                CInteger32::New(val, (IInteger32**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeInt64: {
                Int64 val;
                msg->findInt64(key, &val);
                AutoPtr<IInteger64> value;
                CInteger64::New(val, (IInteger64**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeFloat: {
                Float val;
                msg->findFloat(key, &val);
                AutoPtr<IFloat> value;
                CFloat::New(val, (IFloat**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeString: {
                android::AString val;
                msg->findString(key, &val);
                AutoPtr<ICharSequence> value;
                CString::New(String(val.c_str()), (ICharSequence**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeBuffer: {
                android::sp<android::ABuffer> val;
                msg->findBuffer(key, &val);
                Int32 size = val->size();
                ArrayOf<Byte> bytes((Byte*)val->data(), size);

                AutoPtr<IByteBufferHelper> helper;
                CByteBufferHelper::AcquireSingleton((IByteBufferHelper**)&helper);
                AutoPtr<IByteBuffer> buffer;
                helper->Allocate(size, (IByteBuffer**)&buffer);
                buffer->PutBytes(bytes);
                valueObj = buffer->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeRect: {
                Int32 left, top, right, bottom;
                msg->findRect(key, &left, &top, &right, &bottom);

                AutoPtr<IInteger32> tmpInt;

                String strLeft;
                strLeft.AppendFormat("%s-left", key);
                CInteger32::New(left, (IInteger32**)&tmpInt);
                returnMap->Put(strLeft ,tmpInt->Probe(EIID_IInterface));

                String strTop;
                strLeft.AppendFormat("%s-top", key);
                tmpInt = NULL;
                CInteger32::New(top, (IInteger32**)&tmpInt);
                returnMap->Put(strTop ,tmpInt->Probe(EIID_IInterface));

                String strRight;
                strLeft.AppendFormat("%s-right", key);
                tmpInt = NULL;
                CInteger32::New(right, (IInteger32**)&tmpInt);
                returnMap->Put(strRight ,tmpInt->Probe(EIID_IInterface));

                String strBottom;
                strLeft.AppendFormat("%s-bottom", key);
                tmpInt = NULL;
                CInteger32::New(bottom, (IInteger32**)&tmpInt);
                returnMap->Put(strBottom ,tmpInt->Probe(EIID_IInterface));
                break;
            }

            default:
                break;
        }//end switch

        if (valueObj != NULL)  {
            String keyObj(key);
            returnMap->Put(keyObj ,valueObj);
        }
    }//end for

    *mymap = returnMap;
    REFCOUNT_ADD(*mymap);
    return NOERROR;
}