Example #1
0
  /** Create all the AAF objects required to represent the example top level composition. */
  public static final Preface makeExamplePreface() throws Exception {

    // Start at the top ... a top-level composition
    CompositionPackage rootComposition =
        Forge.make(
            CompositionPackage.class,
            "PackageName",
            "RootPackage",
            "PackageID",
            Forge.dCinemaUMID(),
            "PackageUsage",
            UsageType.TopLevel);

    int sourceVideoTrackID = 2;
    int sourceAudioTrackID = 3;
    int sourceEssenceLength = 5 * 25; // Five seconds of material at 25 fps

    TapeDescriptor tapeDescription = Forge.make(TapeDescriptor.class);
    tapeDescription.setSignalType(VideoSignalType.PALSignal);
    tapeDescription.setTapeBatchNumber("PL/1234/12");
    tapeDescription.setTapeManufacturer("Sony");
    tapeDescription.setTapeFormulation("Digibeta");
    tapeDescription.setTapeFormat(TapeFormatType.BetacamFormat);
    tapeDescription.setTapeCapacity(30);

    SourcePackage sourceTape =
        Forge.make(
            SourcePackage.class,
            "PackageName",
            "SourceTape",
            "PackageID",
            Forge.randomUMID(),
            "PackageTracks",
            new Track[] {
              makeTimelineTrack("Picture", null, 0, 0l, 1, 30 * 60 * 60 * 25), // 30 minute tape
              makeTimelineTrack("Sound", null, 0, 0l, 2, 30 * 60 * 60 * 25)
            },
            "EssenceDescription",
            tapeDescription);

    // To be made from the following source file - external essence so no essence data
    SourcePackage sourceFile =
        Forge.makeAAF(
            "SourceMob", // Can use AAF names with the factory
            "PackageName",
            "SourceFile",
            "PackageID",
            Forge.randomUMID(),
            "PackageTracks",
            new Track[] {
              makeTimelineTrack("Picture", sourceTape, 1, 36000l * 25l, sourceVideoTrackID, 125l),
              makeTimelineTrack("Sound", sourceTape, 2, 36000l * 25l, sourceAudioTrackID, 125l)
            },
            "EssenceDescription",
            Forge.make(
                MultipleDescriptor.class,
                "FileDescriptors",
                new AAFFileDescriptor[] {
                  makeIMX50VideoDescriptor(sourceEssenceLength, sourceVideoTrackID),
                  makeWAVEPCMDescriptor(sourceEssenceLength, sourceAudioTrackID)
                },
                "Locators",
                new Locator[] {
                  Forge.make(NetworkLocator.class, "URL", "file://library/media/imx50-example.mxf")
                }));

    MaterialPackage masterPackage =
        Forge.make(
            MaterialPackage.class,
            "PackageName",
            "MasterMaterial",
            "PackageID",
            Forge.randomUMID(),
            "PackageTracks",
            new Track[] {
              makeTimelineTrack(
                  "Picture", sourceFile, sourceVideoTrackID, 0l, sourceVideoTrackID, 125l),
              makeTimelineTrack(
                  "Sound", sourceFile, sourceAudioTrackID, 0l, sourceAudioTrackID, 125)
            });

    Sequence videoSequence = Forge.make(Sequence.class, "ComponentDataDefinition", "Picture");
    Sequence audioSequence = Forge.make(Sequence.class, "ComponentDataDefinition", "Sound");

    OperationGroup videoDissolve =
        Forge.make(
            OperationGroup.class, "ComponentDataDefinition", "Picture", "ComponentLength", 12);
    videoDissolve.setOperationDefinition(
        Warehouse.lookup(OperationDefinition.class, OperationConstant.VideoDissolve));
    Parameter parameter =
        Forge.make(
            ConstantValue.class,
            "ParameterDefinitionReference",
            ParameterConstant.Level,
            "Value",
            Forge.makeRational(1, 2));
    videoDissolve.addParameter(parameter);

    Transition videoTranstion =
        Forge.make(
            Transition.class,
            "ComponentDataDefinition",
            "Picture",
            "ComponentLength",
            12,
            "TransitionOperation",
            videoDissolve);

    OperationGroup audioDissolve =
        Forge.make(
            OperationGroup.class,
            "ComponentDataDefinition",
            "Sound",
            "ComponentLength",
            12,
            "Operation",
            "MonoAudioDissolve",
            "Parameters",
            new Parameter[] {
              Forge.make(
                  ConstantValue.class,
                  "ParameterDefinitionReference",
                  ParameterConstant.Level,
                  "Value",
                  Forge.makeRational(1, 2))
            });

    Transition audioTransition =
        Forge.make(
            Transition.class,
            "ComponentDataDefinition",
            "Sound",
            "ComponentLength",
            12,
            "TransitionOperation",
            audioDissolve);

    videoSequence.appendComponentObject(
        makeSourceClip("Picture", masterPackage, sourceVideoTrackID, 0, 50));
    videoSequence.appendComponentObject(videoTranstion);
    videoSequence.appendComponentObject(
        makeSourceClip("Picture", masterPackage, sourceVideoTrackID, 75, 50));

    audioSequence.appendComponentObject(
        makeSourceClip("Sound", masterPackage, sourceAudioTrackID, 0, 50));
    audioSequence.appendComponentObject(audioTransition);
    audioSequence.appendComponentObject(
        makeSourceClip("Sound", masterPackage, sourceAudioTrackID, 75, 50));

    rootComposition.appendNewTimelineTrack(
        Forge.makeRational(25, 1), videoSequence, sourceVideoTrackID, "VideoTrack", 0);
    rootComposition.appendNewTimelineTrack(
        Forge.makeRational(25, 1), audioSequence, sourceAudioTrackID, "AudioTrack", 0);

    return Forge.make(
        Preface.class,
        "ContentStorageObject",
        Forge.make(
            ContentStorage.class,
            "Packages",
            new Package[] {sourceTape, sourceFile, rootComposition, masterPackage}));
  }