/*! * Method loads standard settings like brightness, contrast etc (with source_settings). */ bool V4L::loadFrameGrabber(int version, const CameraProps & props) { if (version > 0) { /// \todo: use CameraProps if (version == 1) { setWinProperty(-1, 0); setWinProperty(0, props.width); setWinProperty(1, props.height); setWinProperty(2, props.palette); } else { if (!setWinProperty(-1, 0)) return false; if (!setVideoProperty(-1, 0)) return false; if (!setVideoProperty(1, 0)) return false; if (!setVideoProperty(1, props.standard)) return false; if (!setWinProperty(0, props.width)) return false; if (!setWinProperty(1, props.height)) return false; if (!setWinProperty(2, props.palette)) return false; if (!setPicProperty(0, props.brightness)) return false; if (!setPicProperty(1, props.whiteness)) return false; if (!setPicProperty(2, props.contrast)) return false; if (!setPicProperty(3, props.hue)) return false; } } if (!setMemBuf()) return false; if (!setMemMap()) return false; return true; }
Item::e_sercode Item::deserialize( Stream *file, VMachine *vm ) { byte type = FLC_ITEM_NIL; if ( file->read((byte *) &type, 1 ) == 0 ) return sc_eof; if( ! file->good() ) return sc_ferror; switch( type ) { case FLC_ITEM_NIL: setNil(); return sc_ok; case FLC_ITEM_UNB: setUnbound(); return sc_ok; case FLC_ITEM_BOOL: { byte bval; file->read( (byte *) &bval, sizeof( bval ) ); if ( file->good() ) { setBoolean( bval != 0 ); return sc_ok; } return sc_ferror; } return sc_ok; case FLC_ITEM_INT: { int64 val; file->read( (byte *) &val, sizeof( val ) ); if ( file->good() ) { setInteger(endianInt64(val) ); return sc_ok; } return sc_ferror; } break; case FLC_ITEM_RANGE: { int64 val1; int64 val2; int64 val3; //byte isOpen; file->read( (byte *) &val1, sizeof( val1 ) ); file->read( (byte *) &val2, sizeof( val2 ) ); file->read( (byte *) &val3, sizeof( val3 ) ); //file->read( (byte *) &isOpen, sizeof( isOpen ) ); val1 = endianInt64( val1 ); val2 = endianInt64( val2 ); val3 = endianInt64( val3 ); if ( file->good() ) { setRange( new CoreRange( val1, val2, val3 ) ); return sc_ok; } return sc_ferror; } break; case FLC_ITEM_NUM: { numeric val; file->read( (byte *) &val, sizeof( val ) ); if ( file->good() ) { setNumeric( endianNum( val ) ); return sc_ok; } return sc_ferror; } break; case FLC_ITEM_LBIND: { int32 id; file->read( (byte*) &id, sizeof(id) ); String name; if ( ! name.deserialize( file ) ) return file->bad() ? sc_ferror : sc_invformat; setLBind( new CoreString( name ) ); } break; case FLC_ITEM_STRING: { CoreString *cs = new CoreString; setString( cs ); if ( ! cs->deserialize( file ) ) { return file->bad() ? sc_ferror : sc_invformat; } if ( file->good() ) { return sc_ok; } return sc_ferror; } break; case FLC_ITEM_MEMBUF |0x80: { // get the function pointer in the stream /*MemBuf *(*deserializer)( VMachine *, Stream * ); file->read( &deserializer, sizeof( deserializer ) ); if ( ! file->good() ) { return sc_ferror; } MemBuf *mb = deserializer( vm, file ); if( mb == 0 ) { return sc_invformat; }*/ MemBuf* mb; if( file->read( &mb, sizeof( mb ) ) == sizeof(mb) ) { setMemBuf( mb ); return sc_ok; } return sc_eof; } case FLC_ITEM_MEMBUF: { MemBuf *mb = MemBuf::deserialize( vm, file ); if ( file->good() && mb != 0 ) { setMemBuf( mb ); return sc_ok; } return sc_ferror; } break; case FLC_ITEM_ARRAY: { int32 val; file->read( (byte *) &val, sizeof( val ) ); e_sercode retval = sc_ok; if ( file->good() ) { val = endianInt32(val); CoreArray *array = new CoreArray(); array->resize(val); for( int i = 0; i < val; i ++ ) { retval = array->items()[i].deserialize( file, vm ); if( retval != sc_ok ) { break; } } if ( retval == sc_ok ) { setArray( array ); return sc_ok; } return retval; } } break; case FLC_ITEM_DICT: { byte blessed; file->read( &blessed, 1 ); int32 val; file->read( (byte *) &val, sizeof( val ) ); if ( file->good() ) { val = endianInt32(val); LinearDict *dict = new LinearDict( val ); LinearDictEntry *elems = dict->entries(); e_sercode retval = sc_ok; for( int i = 0; i < val; i ++ ) { LinearDictEntry *entry = elems + i; retval = entry->key().deserialize( file, vm ); if( retval == sc_ok ) retval = entry->value().deserialize( file, vm ); if ( retval != sc_ok ) break; dict->length( i + 1 ); } if( retval == sc_ok ) { CoreDict* cdict = new CoreDict( dict ); cdict->bless( blessed ? true : false ); setDict( cdict ); return sc_ok; } else delete dict; return retval; } } break; case FLC_ITEM_FUNC | 0x80: case FLC_ITEM_FUNC: { if( vm == 0 ) return sc_missvm; return deserialize_function( file, vm ); } break; case FLC_ITEM_METHOD: { if( vm == 0 ) return sc_missvm; Item obj; Item func; e_sercode sc; sc = obj.deserialize( file, vm ); if ( sc != sc_ok ) return sc; sc = func.deserialize( file, vm ); if ( sc != sc_ok ) return sc; if ( func.isFunction() ) setMethod( obj, func.asMethodFunc() ); else if ( func.isArray() && func.isCallable() ) { setMethod( obj, func.asArray() ); } else return sc_invformat; return sc_ok; } case FLC_ITEM_OBJECT | 0x80: case FLC_ITEM_OBJECT: { bool bLive = type != FLC_ITEM_OBJECT; if( vm == 0 ) return sc_missvm; // read the module name Symbol *sym; LiveModule *lmod; e_sercode sc = deserialize_symbol( file, vm, &sym, &lmod ); if ( sc != sc_ok ) return sc; Item *clitem = &lmod->globals()[ sym->itemId() ]; // Create the core object, but don't fill attribs. CoreObject *object = clitem->dereference()->asClass()->createInstance(0, true); if ( ! object->deserialize( file, bLive ) ) { return sc_missclass; } setObject( object ); return file->good() ? sc_ok : sc_ferror; } break; case FLC_ITEM_CLASS: return deserialize_class( file, vm ); case FLC_ITEM_CLSMETHOD: { e_sercode sc = deserialize_class( file, vm ); if ( sc != sc_ok ) return sc; return deserialize_function( file, vm ); } break; default: return sc_invformat; } return sc_ferror; }