Difference between revisions of "Movie cocoaqt"
Line 7: | Line 7: | ||
===Class Declaration=== | ===Class Declaration=== | ||
− | We want | + | We want our class to create a movie object, so we inherit from [[Movie:_Server_basics#Sample_Methods|CLxImpl_Movie]]. Our class includes all the basic methods of a movie class. First, our mov_BeginMovie class initiates the saving and provides the file path and the size of the frame. Next, our mov_SetFrameRate function sets the frame rate. After that, our mov_AddImage appends an image to the movie every time it is called. After that, the mov_AddAudio function adds an audio track to the movie file. Finally, our EndMovie function closes the movies file and cleans up the temp files. |
class CCocoaQuickTimeMovie : public CLxImpl_Movie | class CCocoaQuickTimeMovie : public CLxImpl_Movie | ||
Line 29: | Line 29: | ||
===[[Server_Tags|Server Tags]]=== | ===[[Server_Tags|Server Tags]]=== | ||
− | The tags here indicate that the main class will be a server of the movie type that will have the extension .mov named Express Quicktime | + | Servers tags are examined when the server is initialized, and give information about the server. This is accomplished here by taking a descinfo[] array and associating the relevant data with the corresponding flags. The tags here indicate that the main class will be a server of the movie type that will have the extension .mov named Express Quicktime. |
LXtTagInfoDesc CCocoaQuickTimeMovie::descInfo[] = { | LXtTagInfoDesc CCocoaQuickTimeMovie::descInfo[] = { | ||
Line 41: | Line 41: | ||
===[[Initialize_(index)|Initialize]]=== | ===[[Initialize_(index)|Initialize]]=== | ||
− | + | Intialize is called when we add the plugin to modo, and is the utility that exports the server. In this Initialize() we export a server of the movie type dependent on the CCocoaQuickTimeMovie class with the "quicktime" name. The LXx_ADD_SERVER method is simply a wrapper that is identical to normal method of adding a server, with the arguments being (interface_to_be_added, class_you_depend_on, server_name). In this case we add the Movie interface, depend on the CCocoaQuickTimeMove, and name our server "quicktime". | |
void | void | ||
Line 51: | Line 51: | ||
===Helper Functions=== | ===Helper Functions=== | ||
− | + | Apple uses the NS image format for its movie frames, so we need to have some function to convert our format(CGImage) to NS. This function does exactly that. We call this function in our mov_AddImage function in order to convert the CGImage we have constructed. | |
static NSImage * | static NSImage * | ||
Line 57: | Line 57: | ||
CGImageRef image) | CGImageRef image) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | This function creates a temporary audio file with the audio object. | + | This function creates a temporary audio file with the audio object. Most importantly, if the function is unable to read or write the audio object, it returns an error code. This function is called in mov_AddAudio in order to verify that the audio object passed in is valid. |
static LxResult | static LxResult | ||
Line 85: | Line 67: | ||
CLxUser_Audio *audio) | CLxUser_Audio *audio) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
Line 180: | Line 81: | ||
int flags) | int flags) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
Line 232: | Line 90: | ||
int frate) | int frate) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
} | } | ||
Line 243: | Line 99: | ||
ILxUnknownID img) | ILxUnknownID img) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
Line 322: | Line 108: | ||
ILxUnknownID au) | ILxUnknownID au) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
Line 359: | Line 116: | ||
CCocoaQuickTimeMovie::mov_EndMovie (void) | CCocoaQuickTimeMovie::mov_EndMovie (void) | ||
{ | { | ||
− | + | ... | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } |
Revision as of 23:09, 10 September 2013
Movie_CocoaQT is a basic example plugin. This wiki page is intended as a walkthrough of the code in order to help you better understand the SDK.
When installed, the Movie_CocoaQT plugin adds Cocoa QuickTime saver utility for movies.
Contents
Code Walkthrough
Class Declaration
We want our class to create a movie object, so we inherit from CLxImpl_Movie. Our class includes all the basic methods of a movie class. First, our mov_BeginMovie class initiates the saving and provides the file path and the size of the frame. Next, our mov_SetFrameRate function sets the frame rate. After that, our mov_AddImage appends an image to the movie every time it is called. After that, the mov_AddAudio function adds an audio track to the movie file. Finally, our EndMovie function closes the movies file and cleans up the temp files.
class CCocoaQuickTimeMovie : public CLxImpl_Movie { public: LxResult mov_BeginMovie (const char*,int, int, int); LxResult mov_SetFramerate (int); LxResult mov_AddImage (ILxUnknownID); LxResult mov_EndMovie (void); LxResult mov_AddAudio (ILxUnknownID); static LXtTagInfoDesc descInfo[]; int frameRate; NSString *nsStringPath; QTMovie *mMovie; NSDictionary *myDict; NSString *audioFileName; };
Server Tags
Servers tags are examined when the server is initialized, and give information about the server. This is accomplished here by taking a descinfo[] array and associating the relevant data with the corresponding flags. The tags here indicate that the main class will be a server of the movie type that will have the extension .mov named Express Quicktime.
LXtTagInfoDesc CCocoaQuickTimeMovie::descInfo[] = { { LXsLOD_CLASSLIST, LXa_MOVIE }, { LXsLOD_DOSPATTERN, "*.mov" }, { LXsSAV_DOSTYPE, "mov" }, { LXsSRV_USERNAME, "Express Quicktime" }, { 0 } };
Initialize
Intialize is called when we add the plugin to modo, and is the utility that exports the server. In this Initialize() we export a server of the movie type dependent on the CCocoaQuickTimeMovie class with the "quicktime" name. The LXx_ADD_SERVER method is simply a wrapper that is identical to normal method of adding a server, with the arguments being (interface_to_be_added, class_you_depend_on, server_name). In this case we add the Movie interface, depend on the CCocoaQuickTimeMove, and name our server "quicktime".
void initialize () { LXx_ADD_SERVER (Movie, CCocoaQuickTimeMovie, "quicktime"); }
Helper Functions
Apple uses the NS image format for its movie frames, so we need to have some function to convert our format(CGImage) to NS. This function does exactly that. We call this function in our mov_AddImage function in order to convert the CGImage we have constructed.
static NSImage * cgImageToNSImage ( CGImageRef image) { ... }
This function creates a temporary audio file with the audio object. Most importantly, if the function is unable to read or write the audio object, it returns an error code. This function is called in mov_AddAudio in order to verify that the audio object passed in is valid.
static LxResult CreateAudioTempFile ( NSString *filePath, CLxUser_Audio *audio) { ... }
Implementations
Creates a movie file and starts writing to it.
LxResult CCocoaQuickTimeMovie::mov_BeginMovie ( const char *fname, int w, int h, int flags) { ... }
This function sets the framerate for the movie.
LxResult CCocoaQuickTimeMovie::mov_SetFramerate ( int frate) { ... }
This functions adds another frame to the movie.
LxResult CCocoaQuickTimeMovie::mov_AddImage ( ILxUnknownID img) { ... }
This function adds the temp audio file to the movie.
LxResult CCocoaQuickTimeMovie::mov_AddAudio ( ILxUnknownID au) { ... }
This function stops the writing to the movie file and cleans up the temp files.
LxResult CCocoaQuickTimeMovie::mov_EndMovie (void) { ... }