// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "FCPXML/FCPXMLNode.h" #include "MovieScene.h" #include "MovieSceneTranslator.h" #include "Tracks/MovieSceneAudioTrack.h" #include "Sections/MovieSceneCinematicShotSection.h" #include "Tracks/MovieSceneCinematicShotTrack.h" /** The FFCPXMLExportVisitor class exports from Sequencer data into the FCP 7 XML structure. This class will eventually be used to merge the data with an existing XML structure representing previously imported material. This is intended to preserve metadata roundtrip between Sequencer and the FCP XML format. Currently the VisitNode functions are mostly empty. This is where the merge data functionality will be implemented. */ class FFCPXMLExportVisitor : public FFCPXMLNodeVisitor { public: /** Constructor */ FFCPXMLExportVisitor(FString InSaveFilename, TSharedRef InExportData, TSharedRef InExportContext); /** Destructor */ virtual ~FFCPXMLExportVisitor(); public: /** Called when visiting a FFCPXMLBasicNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InBasicNode) override final; /** Called when visiting a FFCPXMLXmemlNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InXmemlNode) override final; /** Called when visiting a FFCPXMLSequenceNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InSequenceNode) override final; /** Called when visiting a FFCPXMLVideoNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InVideoNode) override final; /** Called when visiting a FFCPXMLAudioNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InAudioNode) override final; /** Called when visiting a FFCPXMLTrackNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InTrackNode) override final; /** Called when visiting a FFCPXMLClipNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InClipNode) override final; /** Called when visiting a FFCPXMLClipItemNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InClipItemNode) override final; /** Called when visiting a FFCPXMLFileNode during visitor traversal. */ virtual bool VisitNode(TSharedRef InFileNode) override final; public: /** Creates project node. */ bool ConstructProjectNode(TSharedRef InParentNode); /** Creates master video clip nodes. */ virtual bool ConstructMasterVideoClipNodes(TSharedRef InParentNode); /** Creates master audio clip nodes. */ bool ConstructMasterAudioClipNodes(TSharedRef InParentNode); /** Creates master video clip node. */ bool ConstructMasterClipNode(TSharedRef InParentNode, const TSharedPtr InCinematicSectionData, const TSharedPtr InCinematicData); /** Creates master audio clip node. */ bool ConstructMasterClipNode(TSharedRef InParentNode, const TSharedPtr InAudioSectionData, const TSharedPtr InCinematicData); /** Creates colorinfo node. */ bool ConstructColorInfoNode(TSharedRef InParentNode); /** Creates logginginfo node. */ bool ConstructLoggingInfoNode(TSharedRef InParentNode, const UMovieSceneSection* InMovieSceneSection); /** Creates logginginfo node. */ bool ConstructLoggingInfoNode(TSharedRef InParentNode, const TSharedPtr InSectionData); /** Creates sequence node. */ bool ConstructSequenceNode(TSharedRef InParentNode); /** Creates video node. */ bool ConstructVideoNode(TSharedRef InParentNode); /** Creates audio node. */ bool ConstructAudioNode(TSharedRef InParentNode); /** Creates video track node. */ virtual bool ConstructVideoTrackNode(TSharedRef InParentNode, const TSharedPtr InCinematicTrackData, const TSharedPtr InCinematicData); /** Creates audio track node. */ bool ConstructAudioTrackNode(TSharedRef InParentNode, const TSharedPtr InAudioTrackData, const TSharedPtr InAudioData, uint32 InTrackIndex, uint32 OutNumTracks); /** Creates video clip item node. */ bool ConstructVideoClipItemNode(TSharedRef InParentNode, const TSharedPtr InCinematicSectionData, const TSharedPtr InCinematicData, bool bInMasterClip); /** Creates audio clip item node. */ bool ConstructAudioClipItemNode(TSharedRef InParentNode, const TSharedPtr InAudioSectionData, const TSharedPtr InAudioData, int32 InChannel, bool bInMasterClip, const FString& InClipItemIdName1, const FString& InClipItemIdName2, int32 InClipIndex1, int32 InClipIndex2, int32 InTrackIndex1, int32 InTrackIndex2); /** Creates video file node. */ bool ConstructVideoFileNode(TSharedRef InParentNode, const TSharedPtr InCinematicSectionData, int32 InDuration, bool bInMasterClip); /** Creates audio file node. */ bool ConstructAudioFileNode(TSharedRef InParentNode, const TSharedPtr InAudioSectionData, int32 InChannel); /** Creates video sample characteristics node */ bool ConstructVideoSampleCharacteristicsNode(TSharedRef InParentNode, int InWidth, int InHeight); /** Creates audio video sample characteristics node */ bool ConstructAudioSampleCharacteristicsNode(TSharedRef InParentNode, int InDepth, int InSampleRate); /** Creates rate node. */ bool ConstructRateNode(TSharedRef InParentNode); /** Creates timecode node. */ bool ConstructTimecodeNode(TSharedRef InParentNode); /** Creates logginginfo elements. */ void ConstructLoggingInfoElements(TSharedRef InLoggingInfoNode, const UObject* InObject = nullptr); /** Set logginginfo element value. */ void SetLoggingInfoElementValue(TSharedPtr InNode, const UObject* InObject, const FString& InElement); /** Get cinematic duration, start, end, in, out frames for a given cinematic shot section */ bool GetCinematicSectionFrames(const TSharedPtr InCinematicSectionData, int32& OutDuration, int32& OutStartFrame, int32& OutEndFrame, int32& OutInFrame, int32& OutOutFrame); /** Get audio duration, start, end, in, out frames for a given cinematic shot section */ bool GetAudioSectionFrames(const TSharedPtr InAudioSectionData, int32& OutDuration, int32& OutStartFrame, int32& OutEndFrame, int32& OutInFrame, int32& OutOutFrame); protected: /** Has master clip id for given section */ bool HasMasterClipIdName(const TSharedPtr InSection, FString& OutName, bool& bOutMasterClipExists); /** Get master clip id name for section */ bool GetMasterClipIdName(const TSharedPtr InSection, FString& OutName); /** Get file id name for section, adds to file map if a new id name is created */ bool GetFileIdName(const TSharedPtr InSection, FString& OutName, bool& bFileExists); /** Get next clip item name */ void GetNextClipItemIdName(FString& OutName); /** Compose key for section file */ bool ComposeFileKey(const TSharedPtr InSection, FString& OutName); /** Returns true if audio track data contains sections with 2 channels */ bool HasStereoAudioSections(const TArray>& InAudioTrackData) const; /** Get metadata section name from sequencer shot name - format is "[UESection=sectionobjectname]", whitespace ok. */ bool CreateCinematicSectionMetadata(const UMovieSceneCinematicShotSection* InSection, FString& OutMetadata) const; /** Get metadata section name from sequencer shot name - format is "[UESoundWave=soundwaveobjectname]", whitespace ok. */ bool CreateSoundWaveMetadata(const USoundWave* InSoundWave, const TArray InAudioSections, FString& OutMetadata) const; /** Get id for audio top level section */ static FString GetAudioSectionTopLevelName(const UMovieSceneAudioSection* InAudioSection); /** Get audio section group name */ static FString GetAudioSectionName(const UMovieSceneSection* InAudioSection); protected: TSharedRef ExportData; TSharedRef ExportContext; FString SaveFilePath; uint32 SequenceId; uint32 MasterClipId; uint32 ClipItemId; uint32 FileId; /** Map section's unique key string to the id used for masterclip element names */ TMap MasterClipIdMap; /** Map section's source file name to its file element name */ TMap FileIdMap; };