Пример #1
0
  /** Example utility method useful to speed up the making of source clips. */
  public static final SourceClip makeSourceClip(
      String trackType,
      Package sourcePackage,
      int sourceTrackID,
      long startPosition,
      long componentLength) {

    if (sourcePackage != null) {
      return Forge.make(
          SourceClip.class,
          "ComponentDataDefinition",
          Warehouse.lookup(DataDefinition.class, trackType),
          "ComponentLength",
          componentLength,
          "StartPosition",
          0l,
          "SourceTrackID",
          sourceTrackID,
          "SourcePackageID",
          sourcePackage.getPackageID(),
          "StartPosition",
          startPosition);
    } else { // If no source package is provided, make an original source reference
      SourceClip clipReference = Forge.make(SourceClip.class);
      clipReference.setComponentDataDefinition(Warehouse.lookup(DataDefinition.class, trackType));
      clipReference.setComponentLength(componentLength);
      clipReference.setSourceReference(Forge.originalSource());
      return clipReference;
    }
  }
Пример #2
0
  /** Example utility method to tidy up the making of a WAVE PCM descriptor. */
  public static final WAVEPCMDescriptor makeWAVEPCMDescriptor(
      long essenceLength, int linledTrackID) {

    return Forge.make(
        WAVEPCMDescriptor.class,
        "SampleRate",
        "25/1",
        "ContainerFormat",
        "MXFGC_Clipwrapped_Broadcast_Wave_audio_data",
        "EssenceLength",
        essenceLength,
        "AudioSampleRate",
        Forge.makeRational(48000, 1),
        "QuantizationBits",
        16,
        "ChannelCount",
        1,
        "Locked",
        true,
        "AverageBytesPerSecond",
        96000,
        "BlockAlign",
        2,
        "ChannelAssignment",
        "urn:uuid:4b7093c0-c8d2-4f9a-aadc-c1a8d556d3e3",
        "LinkedTrackID",
        3);
  }
Пример #3
0
  public static final void writeAsBytes(PrimerPack primerPack, ByteBuffer buffer)
      throws NullPointerException, InsufficientSpaceException {

    if (primerPack == null)
      throw new NullPointerException("Cannot write a null primer pack to a buffer.");
    if (buffer == null)
      throw new NullPointerException("Cannot write a primer pack into a null buffer.");

    if (buffer.remaining() < lengthAsBytes(primerPack))
      throw new InsufficientSpaceException(
          "Insufficient space remaining to write primer pack into given buffer.");

    UL key =
        (UL)
            Forge.makeAUID(
                0x0d010201,
                (short) 0x0105,
                (short) 0x0100,
                new byte[] {0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01});
    MXFBuilder.writeKey(key, buffer);
    MXFBuilder.writeBERLength(18 * primerPack.countLocalTagEntries() + 8, 4, buffer);

    buffer.putInt(primerPack.countLocalTagEntries());
    buffer.putInt(18);

    for (LocalTagEntry entry : primerPack.getLocalTagEntryBatch()) {
      buffer.putShort(entry.getLocalTag());
      MXFBuilder.writeKey((UL) entry.getUID(), buffer);
    }
  }
Пример #4
0
  /** Example utility method to speed up making a timeline track. */
  public static final TimelineTrack makeTimelineTrack(
      String trackType,
      Package sourceChainReference,
      int sourceTrackID,
      long startPosition,
      int localTrackID,
      long componentLength) {

    SourceClip clipReference =
        makeSourceClip(
            trackType, sourceChainReference, sourceTrackID, startPosition, componentLength);

    return Forge.makeAAF(
        "TimelineMobSlot", // This examples uses AAF names
        "SlotID",
        localTrackID,
        "SlotName",
        "Slot" + localTrackID,
        "TimelineMobSlotEditRate",
        "25/1",
        "MobSlotSegment",
        clipReference);
  }
Пример #5
0
  /** Example utility method to tidy up making an IMX50 picture descriptor. */
  public static final CDCIDescriptor makeIMX50VideoDescriptor(
      long essenceLength, int linkedTrackID) {

    return Forge.make(
        CDCIDescriptor.class,
        "SampleRate",
        "25/1",
        "ContainerFormat",
        "MXFGC_Framewrapped_SMPTE_D10_625x50I_50Mbps_DefinedTemplate",
        "EssenceLength",
        essenceLength,
        "PictureCompression",
        "urn:smpte:ul:060e2b34.04010101.04010202.01020101",
        "FrameLayout",
        LayoutType.SeparateFields,
        "VideoLineMap",
        new int[] {7, 320},
        "ImageAspectRatio",
        Forge.makeRational(16, 9),
        "AlphaTransparency",
        AlphaTransparencyType.MinValueTransparent,
        "ImageAlignmentFactor",
        0,
        "TransferCharacteristic",
        TransferCharacteristicType.ITU470_PAL,
        "ImageStartOffset",
        0,
        "ImageEndOffset",
        0,
        "FieldDominance",
        FieldNumber.One,
        "DisplayF2Offset",
        0,
        "StoredF2Offset",
        0,
        "SignalStandard",
        SignalStandardType.ITU601,
        "DisplayHeight",
        288,
        "DisplayWidth",
        720,
        "DisplayXOffset",
        0,
        "DisplayYOffset",
        16,
        "SampledHeight",
        304,
        "SampledWidth",
        720,
        "SampledXOffset",
        0,
        "SampledYOffset",
        0,
        "StoredHeight",
        304,
        "StoredWidth",
        720,
        "AlphaSampleDepth",
        0,
        "BlackRefLevel",
        16,
        "ColorRange",
        225,
        "ColorSiting",
        ColorSitingType.Rec601,
        "ComponentDepth",
        8,
        "HorizontalSubsampling",
        2,
        "PaddingBits",
        0,
        "ReversedByteOrder",
        false,
        "VerticalSubsampling",
        1,
        "WhiteRefLevel",
        235,
        "LinkedTrackID",
        linkedTrackID);
  }
Пример #6
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}));
  }