ext/movie.c in rmov-0.1.0 vs ext/movie.c in rmov-0.1.1

- old
+ new

@@ -18,32 +18,30 @@ static void movie_mark(struct RMovie *rMovie) { } /* + call-seq: new() -> movie + Creates a new movie instance. Generally you want to go through Movie.open or Movie.empty to load or create a new movie respectively. If you do no then you will need to load the movie with load_empty or load_from_file before you can accomplish anything. - -call-seq: - new() -> movie */ static VALUE movie_new(VALUE klass) { struct RMovie *rMovie; return Data_Make_Struct(klass, struct RMovie, movie_mark, movie_free, rMovie); } /* + call-seq: dispose() + Dispose of the loaded QuickTime movie. This will automatically be done when this movie instance is garbage collected. However if you are iterating through many movies it is often helpful to dispose of it as soon as you're done with it. - -call-seq: - dispose() */ static VALUE movie_dispose(VALUE obj) { if (MOVIE(obj)) { DisposeMovie(MOVIE(obj)); @@ -51,16 +49,15 @@ } return obj; } /* + call-seq: load_from_file(filepath) + Loads a new, empty QuickTime movie at given filepath. Should only be called if no movie has been loaded (or it has been disposed). Usually you go through Movie.open. - -call-seq: - load_from_file(filepath) */ static VALUE movie_load_from_file(VALUE obj, VALUE filepath) { if (MOVIE(obj)) { rb_raise(eQuicktime, "Movie has already been loaded."); @@ -92,16 +89,15 @@ return obj; } } /* + call-seq: load_empty() + Loads a new, empty QuickTime movie. Should only be called if no movie has been loaded (or it has been disposed). Usually you go through Movie.empty. - -call-seq: - load_empty() */ static VALUE movie_load_empty(VALUE obj) { if (MOVIE(obj)) { rb_raise(eQuicktime, "Movie has already been loaded."); @@ -110,38 +106,36 @@ return obj; } } /* + call-seq: raw_duration() -> duration_int + Returns the raw duration of the movie. Combine this with time_scale to reach the duration in seconds. - -call-seq: - raw_duration() -> duration_int */ static VALUE movie_raw_duration(VALUE obj) { return INT2NUM(GetMovieDuration(MOVIE(obj))); } /* + call-seq: time_scale() -> scale_int + Returns the time scale of the movie. Usually only needed when working with raw_duration. - -call-seq: - time_scale() -> scale_int */ static VALUE movie_time_scale(VALUE obj) { return INT2NUM(GetMovieTimeScale(MOVIE(obj))); } /* - Returns the number of tracks in the movie. - -call-seq: - track_count() -> count + call-seq: bounds() -> bounds_hash + + Returns a hash of boundaries. The hash contains four keys: :left, :top, + :right, :bottom. Each holds an integer representing the pixel value. */ static VALUE movie_bounds(VALUE obj) { VALUE bounds_hash = rb_hash_new(); Rect bounds; @@ -152,29 +146,27 @@ rb_hash_aset(bounds_hash, ID2SYM(rb_intern("bottom")), INT2NUM(bounds.bottom)); return bounds_hash; } /* + call-seq: track_count() -> count + Returns the number of tracks in the movie. - -call-seq: - track_count -> count */ static VALUE movie_track_count(VALUE obj) { return INT2NUM(GetMovieTrackCount(MOVIE(obj))); } /* + call-seq: composite_movie(movie, position) + Adds the tracks of given movie into called movie at given position (in seconds). You can track the progress of this operation by passing a block to this method. It will be called regularly during the process and pass the percentage complete (0.0 to 1.0) as an argument to the block. - -call-seq: - composite_movie(movie, position) */ static VALUE movie_composite_movie(VALUE obj, VALUE src, VALUE position) { if (rb_block_given_p()) SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc()); @@ -187,18 +179,17 @@ return obj; } /* + call-seq: append_movie(movie, position) + Inserts given movie into called movie at given position (in seconds). You can track the progress of this operation by passing a block to this method. It will be called regularly during the process and pass the percentage complete (0.0 to 1.0) as an argument to the block. - -call-seq: - append_movie(movie, position) */ static VALUE movie_insert_movie(VALUE obj, VALUE src, VALUE position) { if (rb_block_given_p()) SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc()); @@ -211,18 +202,17 @@ return obj; } /* + call-seq: append_movie(movie) + Adds given movie to the end of movie which this method is called on. You can track the progress of this operation by passing a block to this method. It will be called regularly during the process and pass the percentage complete (0.0 to 1.0) as an argument to the block. - -call-seq: - append_movie(movie) */ static VALUE movie_append_movie(VALUE obj, VALUE src) { if (rb_block_given_p()) SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc()); @@ -235,34 +225,32 @@ return obj; } /* + call-seq: delete_section(start_time, duration) + Deletes given section from movie. Both start_time and duration should be floats representing seconds. - -call-seq: - delete_section(start_time, duration) */ static VALUE movie_delete_section(VALUE obj, VALUE start, VALUE duration) { SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, start), MOVIE_TIME(obj, duration)); ClearMovieSelection(MOVIE(obj)); return obj; } /* + call-seq: clone_section(start_time, duration) -> movie + Returns a new movie in the given section. Does not modify original movie. Both start_time and duration should be floats representing seconds. You can track the progress of this operation by passing a block to this method. It will be called regularly during the process and pass the percentage complete (0.0 to 1.0) as an argument to the block. - -call-seq: - clone_section(start_time, duration) -> movie */ static VALUE movie_clone_section(VALUE obj, VALUE start, VALUE duration) { VALUE new_movie_obj = rb_obj_alloc(cMovie); @@ -277,20 +265,19 @@ return new_movie_obj; } /* + call-seq: clip_section(start_time, duration) -> movie + Deletes given section on movie and returns a new movie with that section. Both start_time and duration should be floats representing seconds. You can track the progress of this operation by passing a block to this method. It will be called regularly during the process and pass the percentage complete (0.0 to 1.0) as an argument to the block. - -call-seq: - clip_section(start_time, duration) -> movie */ static VALUE movie_clip_section(VALUE obj, VALUE start, VALUE duration) { VALUE new_movie_obj = rb_obj_alloc(cMovie); @@ -305,15 +292,14 @@ return new_movie_obj; } /* + call-seq: changed?() -> bool + Determine if a movie has changed since opening. Returns true/false. See reset_changed_status to reset this value. - -call-seq: - changed?() -> bool */ static VALUE movie_changed(VALUE obj) { if (HasMovieChanged(MOVIE(obj))) { return Qtrue; @@ -321,29 +307,26 @@ return Qfalse; } } /* + call-seq: clear_changed_status() + Resets the "changed?" status. Does not revert the movie itself. - -call-seq: - clear_changed_status() */ static VALUE movie_clear_changed_status(VALUE obj) { ClearMovieChanged(MOVIE(obj)); return Qnil; } /* + call-seq: flatten(filepath) + Saves the movie to the given filepath by flattening it. - -call-seq: - flatten(filepath) */ - static VALUE movie_flatten(VALUE obj, VALUE filepath) { OSErr err; FSSpec fs; VALUE new_movie_obj = rb_obj_alloc(cMovie); @@ -361,16 +344,14 @@ &fs, 'TVOD', smSystemScript, createMovieFileDontCreateResFile); return new_movie_obj; } /* + call-seq: export_pict(filepath, time) + Exports a PICT file to given filepath (should end in .pct) at the given time. Time should be a floating point in seconds. - -call-seq: - export_pict(filepath, time) - */ static VALUE movie_export_pict(VALUE obj, VALUE filepath, VALUE frame_time) { GraphicsImportComponent component; @@ -411,9 +392,11 @@ return Qnil; } void Init_quicktime_movie() { + VALUE mQuicktime; + mQuicktime = rb_define_module("Quicktime"); cMovie = rb_define_class_under(mQuicktime, "Movie", rb_cObject); rb_define_alloc_func(cMovie, movie_new); rb_define_method(cMovie, "load_from_file", movie_load_from_file, 1); rb_define_method(cMovie, "load_empty", movie_load_empty, 0); rb_define_method(cMovie, "raw_duration", movie_raw_duration, 0);