예제 #1
0
String ASF::Attribute::parse(ASF::File &f, int kind)
{
  uint size, nameLength;
  String name;
  d->pictureValue = Picture::fromInvalid();
  // extended content descriptor
  if(kind == 0) {
    nameLength = f.readWORD();
    name = f.readString(nameLength);
    d->type = ASF::Attribute::AttributeTypes(f.readWORD());
    size = f.readWORD();
  }
  // metadata & metadata library
  else {
    int temp = f.readWORD();
    // metadata library
    if(kind == 2) {
      d->language = temp;
    }
    d->stream = f.readWORD();
    nameLength = f.readWORD();
    d->type = ASF::Attribute::AttributeTypes(f.readWORD());
    size = f.readDWORD();
    name = f.readString(nameLength);
  }

  if(kind != 2 && size > 65535) {
    debug("ASF::Attribute::parse() -- Value larger than 64kB");
  }

  switch(d->type) {
  case WordType:
    d->shortValue = f.readWORD();
    break;

  case BoolType:
    if(kind == 0) {
      d->boolValue = f.readDWORD() == 1;
    }
    else {
      d->boolValue = f.readWORD() == 1;
    }
    break;

  case DWordType:
    d->intValue = f.readDWORD();
    break;

  case QWordType:
    d->longLongValue = f.readQWORD();
    break;

  case UnicodeType:
    d->stringValue = f.readString(size);
    break;

  case BytesType:
  case GuidType:
    d->byteVectorValue = f.readBlock(size);
    break;
  }

  if(d->type == BytesType && name == "WM/Picture") {
    d->pictureValue.parse(d->byteVectorValue);
    if(d->pictureValue.isValid()) {
      d->byteVectorValue.clear();
    }
  }

  return name;
}
예제 #2
0
String
ASF::Attribute::parse(ASF::File &f, int kind)
{
  int size, nameLength;
  String name;

  // extended content descriptor
  if(kind == 0) {
    nameLength = f.readWORD();
    name = f.readString(nameLength);
    d->type = ASF::Attribute::AttributeTypes(f.readWORD());
    size = f.readWORD();
  }
  // metadata & metadata library
  else {
    int temp = f.readWORD();
    // metadata library
    if(kind == 2) {
      d->language = temp;
    }
    d->stream = f.readWORD();
    nameLength = f.readWORD();
    d->type = ASF::Attribute::AttributeTypes(f.readWORD());
    size = f.readDWORD();
    name = f.readString(nameLength);
  }

  switch(d->type) {
  case WordType:
    d->shortValue = f.readWORD();
    break;

  case BoolType:
    if(kind == 0) {
      d->boolValue = f.readDWORD() == 1;
    }
    else {
      d->boolValue = f.readWORD() == 1;
    }
    break;

  case DWordType:
    d->intValue = f.readDWORD();
    break;

  case QWordType:
    d->longLongValue = f.readQWORD();
    break;

  case UnicodeType:
    d->stringValue = f.readString(size);
    break;

  case BytesType:
  case GuidType:
    d->byteVectorValue = f.readBlock(size);
    break;
  }

  return name;
}