Ejemplo n.º 1
0
class AtomListAdapter(Con.Adapter):
    """An adapter for turning an Atom into a list of atoms.

    This works by parsing its data contents with Atom."""

    ATOM_LIST = Con.GreedyRepeater(Atom("atoms"))

    def _encode(self, obj, context):
        obj.data = self.ATOM_LIST.build(obj.data)
        return obj

    def _decode(self, obj, context):
        obj.data = self.ATOM_LIST.parse(obj.data)
        return obj
Ejemplo n.º 2
0
        return self.sub_atom.parse_stream(stream)

    def _build(self, obj, stream, context):
        data = self.sub_atom.build(obj)
        stream.write(
            self.header.build(
                Con.Container(type=self.atom_name, size=len(data) + 8)))
        stream.write(data)

    def _sizeof(self, context):
        return self.sub_atom.sizeof(context) + 8


ATOM_FTYP = Con.Struct("ftyp", Con.String("major_brand", 4),
                       Con.UBInt32("major_brand_version"),
                       Con.GreedyRepeater(Con.String("compatible_brands", 4)))

ATOM_MVHD = Con.Struct(
    "mvhd", Con.Byte("version"), Con.String("flags", 3),
    VersionLength("created_mac_UTC_date"),
    VersionLength("modified_mac_UTC_date"), Con.UBInt32("time_scale"),
    VersionLength("duration"), Con.UBInt32("playback_speed"),
    Con.UBInt16("user_volume"), Con.Padding(10),
    Con.Struct("windows", Con.UBInt32("geometry_matrix_a"),
               Con.UBInt32("geometry_matrix_b"),
               Con.UBInt32("geometry_matrix_u"),
               Con.UBInt32("geometry_matrix_c"),
               Con.UBInt32("geometry_matrix_d"),
               Con.UBInt32("geometry_matrix_v"),
               Con.UBInt32("geometry_matrix_x"),
               Con.UBInt32("geometry_matrix_y"),