rmov 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.1.3 (October 3rd, 2008)
2
+
3
+ * some support for text tracks
4
+
5
+ * adding movie.new_video_track and movie.new_audio_track methods for creating new tracks
6
+
7
+ * changing Quicktime module name to QuickTime to match proper casing
8
+
1
9
  0.1.2 (October 3rd, 2008)
2
10
 
3
11
  * movie.poster_time and movie.poster_time=(seconds) for getting and setting a movie's poster time
data/README.rdoc CHANGED
@@ -56,7 +56,7 @@ the user with the dialog again.
56
56
  puts "#{percent}% complete"
57
57
  end
58
58
 
59
- See Quicktime::Movie in the RDoc for more information.
59
+ See QuickTime::Movie in the RDoc for more information.
60
60
 
61
61
  http://rmov.rubyforge.org
62
62
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('rmov', '0.1.2') do |p|
5
+ Echoe.new('rmov', '0.1.3') do |p|
6
6
  p.summary = "Ruby wrapper for the QuickTime C API."
7
7
  p.description = "Ruby wrapper for the QuickTime C API."
8
8
  p.url = "http://github.com/ryanb/rmov"
data/ext/exporter.c CHANGED
@@ -58,12 +58,12 @@ static VALUE exporter_export_to_file(VALUE obj, VALUE filepath)
58
58
 
59
59
  err = NativePathNameToFSSpec(RSTRING(filepath)->ptr, &fs, 0);
60
60
  if (err != fnfErr)
61
- rb_raise(eQuicktime, "Error %d occurred while opening file for export at %s.", err, RSTRING(filepath)->ptr);
61
+ rb_raise(eQuickTime, "Error %d occurred while opening file for export at %s.", err, RSTRING(filepath)->ptr);
62
62
 
63
63
  // TODO use exporter settings when converting movie
64
64
  err = ConvertMovieToFile(movie, 0, &fs, 'MooV', 'TVOD', 0, 0, 0, component);
65
65
  if (err != noErr)
66
- rb_raise(eQuicktime, "Error %d occurred while attempting to export movie to file %s.", err, RSTRING(filepath)->ptr);
66
+ rb_raise(eQuickTime, "Error %d occurred while attempting to export movie to file %s.", err, RSTRING(filepath)->ptr);
67
67
 
68
68
  if (rb_block_given_p())
69
69
  SetMovieProgressProc(movie, 0, 0);
@@ -93,14 +93,14 @@ static VALUE exporter_open_settings_dialog(VALUE obj)
93
93
  // Bring this process to the front
94
94
  err = TransformProcessType(&current_process, kProcessTransformToForegroundApplication);
95
95
  if (err != noErr) {
96
- rb_raise(eQuicktime, "Error %d occurred while brining this application to the forground.", err);
96
+ rb_raise(eQuickTime, "Error %d occurred while brining this application to the forground.", err);
97
97
  }
98
98
  SetFrontProcess(&current_process);
99
99
 
100
100
  // Show export dialog and save settings
101
101
  err = MovieExportDoUserDialog(component, movie, 0, 0, GetMovieDuration(movie), &canceled);
102
102
  if (err != noErr) {
103
- rb_raise(eQuicktime, "Error %d occurred while opening export dialog.", err);
103
+ rb_raise(eQuickTime, "Error %d occurred while opening export dialog.", err);
104
104
  }
105
105
 
106
106
  if (!canceled) {
@@ -132,7 +132,7 @@ static VALUE exporter_load_settings(VALUE obj, VALUE filepath)
132
132
 
133
133
  file = fopen(RSTRING(filepath)->ptr, "r+b");
134
134
  if (!file) {
135
- rb_raise(eQuicktime, "Unable to open file for loading at %s.", RSTRING(filepath)->ptr);
135
+ rb_raise(eQuickTime, "Unable to open file for loading at %s.", RSTRING(filepath)->ptr);
136
136
  }
137
137
 
138
138
  // obtain file size:
@@ -149,7 +149,7 @@ static VALUE exporter_load_settings(VALUE obj, VALUE filepath)
149
149
  REXPORTER(obj)->settings = (QTAtomContainer)NewHandleClear(length);
150
150
  read_length = fread(*(Handle)REXPORTER(obj)->settings, 1, length, file);
151
151
  if (read_length != length) {
152
- rb_raise(eQuicktime, "Unable to read entire file at %s.", RSTRING(filepath)->ptr);
152
+ rb_raise(eQuickTime, "Unable to read entire file at %s.", RSTRING(filepath)->ptr);
153
153
  }
154
154
 
155
155
  fclose(file);
@@ -169,12 +169,12 @@ static VALUE exporter_save_settings(VALUE obj, VALUE filepath)
169
169
  QTAtomContainer settings = REXPORTER(obj)->settings;
170
170
 
171
171
  if (!settings) {
172
- rb_raise(eQuicktime, "Unable to save settings because no settings are specified.");
172
+ rb_raise(eQuickTime, "Unable to save settings because no settings are specified.");
173
173
  }
174
174
 
175
175
  file = fopen(RSTRING(filepath)->ptr, "wb");
176
176
  if (!file) {
177
- rb_raise(eQuicktime, "Unable to open file for saving at %s.", RSTRING(filepath)->ptr);
177
+ rb_raise(eQuickTime, "Unable to open file for saving at %s.", RSTRING(filepath)->ptr);
178
178
  }
179
179
  fwrite(&settings, GetHandleSize((Handle)settings), 1, file);
180
180
  fclose(file);
@@ -184,9 +184,9 @@ static VALUE exporter_save_settings(VALUE obj, VALUE filepath)
184
184
 
185
185
  void Init_quicktime_exporter()
186
186
  {
187
- VALUE mQuicktime;
188
- mQuicktime = rb_define_module("Quicktime");
189
- cExporter = rb_define_class_under(mQuicktime, "Exporter", rb_cObject);
187
+ VALUE mQuickTime;
188
+ mQuickTime = rb_define_module("QuickTime");
189
+ cExporter = rb_define_class_under(mQuickTime, "Exporter", rb_cObject);
190
190
  rb_define_alloc_func(cExporter, exporter_new);
191
191
  rb_define_method(cExporter, "export", exporter_export_to_file, 1);
192
192
  rb_define_method(cExporter, "open_settings_dialog", exporter_open_settings_dialog, 0);
data/ext/extconf.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'mkmf'
2
2
 
3
- $LDFLAGS = '-framework Quicktime'
3
+ $LDFLAGS = '-framework QuickTime'
4
4
  create_makefile('rmov_ext')
data/ext/movie.c CHANGED
@@ -60,7 +60,7 @@ static VALUE movie_dispose(VALUE obj)
60
60
  static VALUE movie_load_from_file(VALUE obj, VALUE filepath)
61
61
  {
62
62
  if (MOVIE(obj)) {
63
- rb_raise(eQuicktime, "Movie has already been loaded.");
63
+ rb_raise(eQuickTime, "Movie has already been loaded.");
64
64
  } else {
65
65
  OSErr err;
66
66
  FSSpec fs;
@@ -70,19 +70,19 @@ static VALUE movie_load_from_file(VALUE obj, VALUE filepath)
70
70
 
71
71
  err = NativePathNameToFSSpec(RSTRING(filepath)->ptr, &fs, 0);
72
72
  if (err != 0)
73
- rb_raise(eQuicktime, "Error %d occurred while reading file at %s", err, RSTRING(filepath)->ptr);
73
+ rb_raise(eQuickTime, "Error %d occurred while reading file at %s", err, RSTRING(filepath)->ptr);
74
74
 
75
75
  err = OpenMovieFile(&fs, &frefnum, fsRdPerm);
76
76
  if (err != 0)
77
- rb_raise(eQuicktime, "Error %d occurred while opening movie at %s", err, RSTRING(filepath)->ptr);
77
+ rb_raise(eQuickTime, "Error %d occurred while opening movie at %s", err, RSTRING(filepath)->ptr);
78
78
 
79
79
  err = NewMovieFromFile(movie, frefnum, &movie_resid, 0, newMovieActive, 0);
80
80
  if (err != 0)
81
- rb_raise(eQuicktime, "Error %d occurred while loading movie at %s", err, RSTRING(filepath)->ptr);
81
+ rb_raise(eQuickTime, "Error %d occurred while loading movie at %s", err, RSTRING(filepath)->ptr);
82
82
 
83
83
  err = CloseMovieFile(frefnum);
84
84
  if (err != 0)
85
- rb_raise(eQuicktime, "Error %d occurred while closing movie file at %s", err, RSTRING(filepath)->ptr);
85
+ rb_raise(eQuickTime, "Error %d occurred while closing movie file at %s", err, RSTRING(filepath)->ptr);
86
86
 
87
87
  RMOVIE(obj)->movie = *movie;
88
88
 
@@ -100,7 +100,7 @@ static VALUE movie_load_from_file(VALUE obj, VALUE filepath)
100
100
  static VALUE movie_load_empty(VALUE obj)
101
101
  {
102
102
  if (MOVIE(obj)) {
103
- rb_raise(eQuicktime, "Movie has already been loaded.");
103
+ rb_raise(eQuickTime, "Movie has already been loaded.");
104
104
  } else {
105
105
  RMOVIE(obj)->movie = NewMovie(0);
106
106
  return obj;
@@ -333,7 +333,7 @@ static VALUE movie_flatten(VALUE obj, VALUE filepath)
333
333
 
334
334
  err = NativePathNameToFSSpec(RSTRING(filepath)->ptr, &fs, 0);
335
335
  if (err != fnfErr)
336
- rb_raise(eQuicktime, "Error %d occurred while opening file for export at %s", err, RSTRING(filepath)->ptr);
336
+ rb_raise(eQuickTime, "Error %d occurred while opening file for export at %s", err, RSTRING(filepath)->ptr);
337
337
 
338
338
  // TODO make these flags settable through an options hash
339
339
  RMOVIE(new_movie_obj)->movie = FlattenMovieData(MOVIE(obj),
@@ -364,26 +364,26 @@ static VALUE movie_export_pict(VALUE obj, VALUE filepath, VALUE frame_time)
364
364
 
365
365
  err = NativePathNameToFSSpec(RSTRING(filepath)->ptr, &fs, 0);
366
366
  if (err != fnfErr)
367
- rb_raise(eQuicktime, "Error %d occurred while opening file for export at %s.", err, RSTRING(filepath)->ptr);
367
+ rb_raise(eQuickTime, "Error %d occurred while opening file for export at %s.", err, RSTRING(filepath)->ptr);
368
368
 
369
369
  // Convert the picture handle into a PICT file (still in a handle)
370
370
  // by adding a 512-byte header to the start.
371
371
  handle = NewHandleClear(512);
372
372
  err = HandAndHand((Handle)picture, handle);
373
373
  if (err != noErr)
374
- rb_raise(eQuicktime, "Error %d occurred while converting handle for pict export %s.", err, RSTRING(filepath)->ptr);
374
+ rb_raise(eQuickTime, "Error %d occurred while converting handle for pict export %s.", err, RSTRING(filepath)->ptr);
375
375
 
376
376
  err = OpenADefaultComponent(GraphicsImporterComponentType, kQTFileTypePicture, &component);
377
377
  if (err != noErr)
378
- rb_raise(eQuicktime, "Error %d occurred while opening picture component for %s.", err, RSTRING(filepath)->ptr);
378
+ rb_raise(eQuickTime, "Error %d occurred while opening picture component for %s.", err, RSTRING(filepath)->ptr);
379
379
 
380
380
  err = GraphicsImportSetDataHandle(component, handle);
381
381
  if (err != noErr)
382
- rb_raise(eQuicktime, "Error %d occurred while setting graphics importer data handle for %s.", err, RSTRING(filepath)->ptr);
382
+ rb_raise(eQuickTime, "Error %d occurred while setting graphics importer data handle for %s.", err, RSTRING(filepath)->ptr);
383
383
 
384
384
  err = GraphicsImportExportImageFile(component, 0, 0, &fs, smSystemScript);
385
385
  if (err != noErr)
386
- rb_raise(eQuicktime, "Error %d occurred while exporting pict to file %s.", err, RSTRING(filepath)->ptr);
386
+ rb_raise(eQuickTime, "Error %d occurred while exporting pict to file %s.", err, RSTRING(filepath)->ptr);
387
387
 
388
388
  CloseComponent(component);
389
389
  DisposeHandle(handle);
@@ -413,11 +413,27 @@ static VALUE movie_set_poster_time(VALUE obj, VALUE seconds)
413
413
  return Qnil;
414
414
  }
415
415
 
416
+ /*
417
+ call-seq: new_track(width, height) -> track
418
+
419
+ Creates a new track with the given width/height on the movie and returns it.
420
+
421
+ This method is generally not called directly. Instead you should call
422
+ new_video_track or new_audio_track. If you call method make sure to
423
+ call new_media on track to setup the media.
424
+ */
425
+ static VALUE movie_new_track(VALUE obj, VALUE width, VALUE height)
426
+ {
427
+ VALUE track_obj = rb_obj_alloc(cTrack);
428
+ RTRACK(track_obj)->track = NewMovieTrack(MOVIE(obj), NUM2INT(width), NUM2INT(height), kFullVolume);
429
+ return track_obj;
430
+ }
431
+
416
432
  void Init_quicktime_movie()
417
433
  {
418
- VALUE mQuicktime;
419
- mQuicktime = rb_define_module("Quicktime");
420
- cMovie = rb_define_class_under(mQuicktime, "Movie", rb_cObject);
434
+ VALUE mQuickTime;
435
+ mQuickTime = rb_define_module("QuickTime");
436
+ cMovie = rb_define_class_under(mQuickTime, "Movie", rb_cObject);
421
437
  rb_define_alloc_func(cMovie, movie_new);
422
438
  rb_define_method(cMovie, "load_from_file", movie_load_from_file, 1);
423
439
  rb_define_method(cMovie, "load_empty", movie_load_empty, 0);
@@ -438,4 +454,5 @@ void Init_quicktime_movie()
438
454
  rb_define_method(cMovie, "dispose", movie_dispose, 0);
439
455
  rb_define_method(cMovie, "poster_time", movie_get_poster_time, 0);
440
456
  rb_define_method(cMovie, "poster_time=", movie_set_poster_time, 1);
457
+ rb_define_method(cMovie, "new_track", movie_new_track, 2);
441
458
  }
data/ext/rmov_ext.c CHANGED
@@ -1,15 +1,15 @@
1
1
  #include "rmov_ext.h"
2
2
 
3
- VALUE eQuicktime;
3
+ VALUE eQuickTime;
4
4
 
5
5
  void Init_rmov_ext()
6
6
  {
7
- VALUE mQuicktime;
7
+ VALUE mQuickTime;
8
8
 
9
9
  EnterMovies(); // Enables the QuickTime framework
10
10
 
11
- mQuicktime = rb_define_module("Quicktime");
12
- eQuicktime = rb_define_class_under(mQuicktime, "Error", rb_eStandardError);
11
+ mQuickTime = rb_define_module("QuickTime");
12
+ eQuickTime = rb_define_class_under(mQuickTime, "Error", rb_eStandardError);
13
13
  Init_quicktime_movie();
14
14
  Init_quicktime_track();
15
15
  Init_quicktime_exporter();
data/ext/rmov_ext.h CHANGED
@@ -1,7 +1,7 @@
1
1
  #include <ruby.h>
2
2
  #include <QuickTime/QuickTime.h>
3
3
 
4
- extern VALUE eQuicktime, cMovie, cTrack, cExporter;
4
+ extern VALUE eQuickTime, cMovie, cTrack, cExporter;
5
5
 
6
6
  /*** MOVIE ***/
7
7
 
data/ext/track.c CHANGED
@@ -32,7 +32,7 @@ static VALUE track_load(VALUE obj, VALUE movie_obj, VALUE index_obj)
32
32
  {
33
33
  RTRACK(obj)->track = GetMovieIndTrack(MOVIE(movie_obj), NUM2INT(index_obj));
34
34
  if (!RTRACK(obj)->track)
35
- rb_raise(eQuicktime, "Unable to fetch track for movie at index %d", NUM2INT(index_obj));
35
+ rb_raise(eQuickTime, "Unable to fetch track for movie at index %d", NUM2INT(index_obj));
36
36
 
37
37
  return obj;
38
38
  }
@@ -83,6 +83,8 @@ static VALUE track_media_type(VALUE obj)
83
83
  return ID2SYM(rb_intern("audio"));
84
84
  } else if (media_type == VideoMediaType) {
85
85
  return ID2SYM(rb_intern("video"));
86
+ } else if (media_type == TextMediaType) {
87
+ return ID2SYM(rb_intern("text"));
86
88
  } else {
87
89
  return Qnil;
88
90
  }
@@ -188,12 +190,53 @@ static VALUE track_set_offset(VALUE obj, VALUE seconds)
188
190
  return Qnil;
189
191
  }
190
192
 
193
+ /*
194
+ call-seq: new_video_media
195
+
196
+ Creates a new video media for this track.
197
+
198
+ Generally this method is not called directly, instead you can make a
199
+ new video track using Movie#new_video_track.
200
+ */
201
+ static VALUE track_new_video_media(VALUE obj)
202
+ {
203
+ NewTrackMedia(TRACK(obj), VideoMediaType, 600, 0, 0);
204
+ return obj;
205
+ }
206
+
207
+ /*
208
+ call-seq: new_audio_media
209
+
210
+ Creates a new audio media for this track.
211
+
212
+ Generally this method is not called directly, instead you can make a
213
+ new audio track using Movie#new_audio_track.
214
+ */
215
+ static VALUE track_new_audio_media(VALUE obj)
216
+ {
217
+ NewTrackMedia(TRACK(obj), SoundMediaType, 44100, 0, 0);
218
+ return obj;
219
+ }
220
+
221
+ /*
222
+ call-seq: new_text_media
223
+
224
+ Creates a new text media for this track.
225
+
226
+ Generally this method is not called directly, instead you can make a
227
+ new text track using Movie#new_text_track.
228
+ */
229
+ static VALUE track_new_text_media(VALUE obj)
230
+ {
231
+ NewTrackMedia(TRACK(obj), TextMediaType, 600, 0, 0);
232
+ return obj;
233
+ }
191
234
 
192
235
  void Init_quicktime_track()
193
236
  {
194
- VALUE mQuicktime;
195
- mQuicktime = rb_define_module("Quicktime");
196
- cTrack = rb_define_class_under(mQuicktime, "Track", rb_cObject);
237
+ VALUE mQuickTime;
238
+ mQuickTime = rb_define_module("QuickTime");
239
+ cTrack = rb_define_class_under(mQuickTime, "Track", rb_cObject);
197
240
  rb_define_alloc_func(cTrack, track_new);
198
241
  rb_define_method(cTrack, "load_from_movie", track_load, 2);
199
242
  rb_define_method(cTrack, "raw_duration", track_raw_duration, 0);
@@ -209,4 +252,7 @@ void Init_quicktime_track()
209
252
  rb_define_method(cTrack, "volume=", track_set_volume, 1);
210
253
  rb_define_method(cTrack, "offset", track_get_offset, 0);
211
254
  rb_define_method(cTrack, "offset=", track_set_offset, 1);
255
+ rb_define_method(cTrack, "new_video_media", track_new_video_media, 0);
256
+ rb_define_method(cTrack, "new_audio_media", track_new_audio_media, 0);
257
+ rb_define_method(cTrack, "new_text_media", track_new_text_media, 0);
212
258
  }
@@ -1,4 +1,4 @@
1
- module Quicktime
1
+ module QuickTime
2
2
  # see ext/exporter.c for additional methods
3
3
  class Exporter
4
4
  attr_reader :movie
@@ -1,4 +1,4 @@
1
- module Quicktime
1
+ module QuickTime
2
2
  # see ext/movie.c for additional methods
3
3
  class Movie
4
4
  # Opens a movie at filepath.
@@ -44,6 +44,11 @@ module Quicktime
44
44
  tracks.select { |t| t.video? }
45
45
  end
46
46
 
47
+ # Returns an array of text tracks in this movie.
48
+ def text_tracks
49
+ tracks.select { |t| t.text? }
50
+ end
51
+
47
52
  # Returns an Exporter instance for this movie.
48
53
  def exporter
49
54
  Exporter.new(self)
@@ -53,5 +58,26 @@ module Quicktime
53
58
  def export(*args, &block)
54
59
  exporter.export(*args, &block)
55
60
  end
61
+
62
+ # Creates a new video track with given width/height on movie and returns it.
63
+ def new_video_track(width, height)
64
+ track = new_track(width, height)
65
+ track.new_video_media
66
+ track
67
+ end
68
+
69
+ # Creates a new audio track with given width/height on movie and returns it.
70
+ def new_audio_track(width, height)
71
+ track = new_track(width, height)
72
+ track.new_audio_media
73
+ track
74
+ end
75
+
76
+ # Creates a new text track with given width/height on movie and returns it.
77
+ def new_text_track(width, height)
78
+ track = new_track(width, height)
79
+ track.new_text_media
80
+ track
81
+ end
56
82
  end
57
83
  end
@@ -1,4 +1,4 @@
1
- module Quicktime
1
+ module QuickTime
2
2
  # see ext/track.c for additional methods
3
3
  class Track
4
4
  # Returns the length of this track in seconds
@@ -21,5 +21,10 @@ module Quicktime
21
21
  def video?
22
22
  media_type == :video
23
23
  end
24
+
25
+ # Returns true/false depending on if track is a text track.
26
+ def text?
27
+ media_type == :text
28
+ end
24
29
  end
25
30
  end
data/lib/rmov.rb CHANGED
@@ -7,6 +7,6 @@ require 'quicktime/track'
7
7
  require 'quicktime/exporter'
8
8
 
9
9
 
10
- # RMov is made up of several parts. To start, see Quicktime::Movie.
11
- module Quicktime
10
+ # RMov is made up of several parts. To start, see QuickTime::Movie.
11
+ module QuickTime
12
12
  end
data/rmov.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
 
2
- # Gem::Specification for Rmov-0.1.2
2
+ # Gem::Specification for Rmov-0.1.3
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: rmov
7
7
  version: !ruby/object:Gem::Version
8
- version: 0.1.2
8
+ version: 0.1.3
9
9
  platform: ruby
10
10
  authors:
11
11
  - Ryan Bates
Binary file
@@ -1,18 +1,18 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
- describe Quicktime::Exporter do
3
+ describe QuickTime::Exporter do
4
4
  it "should raise error when saving with no settings" do
5
- lambda { Quicktime::Exporter.new(nil).save_settings('foo') }.should raise_error(Quicktime::Error)
5
+ lambda { QuickTime::Exporter.new(nil).save_settings('foo') }.should raise_error(QuickTime::Error)
6
6
  end
7
7
 
8
8
  it "should raise error when atempting to load no file" do
9
- lambda { Quicktime::Exporter.new(nil).load_settings('foo/bar/baz') }.should raise_error(Quicktime::Error)
9
+ lambda { QuickTime::Exporter.new(nil).load_settings('foo/bar/baz') }.should raise_error(QuickTime::Error)
10
10
  end
11
11
 
12
12
  describe "loaded settings.st" do
13
13
  before(:each) do
14
14
  @load_path = File.dirname(__FILE__) + '/../fixtures/settings.st'
15
- @exporter = Quicktime::Exporter.new(nil)
15
+ @exporter = QuickTime::Exporter.new(nil)
16
16
  @exporter.load_settings(@load_path)
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ describe Quicktime::Exporter do
23
23
  end
24
24
 
25
25
  it "should complain when attempting to save to an invalid file" do
26
- lambda { @exporter.save_settings('foo/bar/baz') }.should raise_error(Quicktime::Error)
26
+ lambda { @exporter.save_settings('foo/bar/baz') }.should raise_error(QuickTime::Error)
27
27
  end
28
28
  end
29
29
  end
@@ -1,17 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
- describe Quicktime::Movie do
3
+ describe QuickTime::Movie do
4
4
  it "should raise an exception when attempting to open a nonexisting file" do
5
- lambda { Quicktime::Movie.open('foo.mov') }.should raise_error(Quicktime::Error)
5
+ lambda { QuickTime::Movie.open('foo.mov') }.should raise_error(QuickTime::Error)
6
6
  end
7
7
 
8
8
  it "should raise an exception when attempting to open a non movie file" do
9
- lambda { Quicktime::Movie.open(__FILE__) }.should raise_error(Quicktime::Error)
9
+ lambda { QuickTime::Movie.open(__FILE__) }.should raise_error(QuickTime::Error)
10
10
  end
11
11
 
12
12
  describe "example.mov" do
13
13
  before(:each) do
14
- @movie = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
14
+ @movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
15
15
  end
16
16
 
17
17
  it "duration should be 3.1 seconds" do
@@ -31,7 +31,7 @@ describe Quicktime::Movie do
31
31
  end
32
32
 
33
33
  it "should have 2 tracks" do
34
- @movie.tracks.map { |t| t.class }.should == [Quicktime::Track, Quicktime::Track]
34
+ @movie.tracks.map { |t| t.class }.should == [QuickTime::Track, QuickTime::Track]
35
35
  @movie.tracks.map { |t| t.id }.should == [1, 2]
36
36
  end
37
37
 
@@ -43,7 +43,7 @@ describe Quicktime::Movie do
43
43
  @movie.export(path) { |p| progress = p }
44
44
  progress.should == 1.0
45
45
 
46
- exported_movie = Quicktime::Movie.open(path)
46
+ exported_movie = QuickTime::Movie.open(path)
47
47
  exported_movie.duration.should == @movie.duration
48
48
  exported_movie.tracks.size == @movie.tracks.size
49
49
  end
@@ -57,19 +57,19 @@ describe Quicktime::Movie do
57
57
  end
58
58
 
59
59
  it "composite should add another movie's tracks at a given location" do
60
- m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
60
+ m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
61
61
  @movie.composite_movie(m2, 2)
62
62
  @movie.duration.should == 5.1
63
63
  end
64
64
 
65
65
  it "insert should insert another movie's tracks at a given location" do
66
- m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
66
+ m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
67
67
  @movie.insert_movie(m2, 2)
68
68
  @movie.duration.should == 6.2
69
69
  end
70
70
 
71
71
  it "append_movie should insert movie at the end" do
72
- m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
72
+ m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
73
73
  @movie.append_movie(m2)
74
74
  @movie.duration.should == 6.2
75
75
  end
@@ -93,7 +93,7 @@ describe Quicktime::Movie do
93
93
 
94
94
  it "should have an exporter with this movie" do
95
95
  exporter = @movie.exporter
96
- exporter.should be_kind_of(Quicktime::Exporter)
96
+ exporter.should be_kind_of(QuickTime::Exporter)
97
97
  exporter.movie.should == @movie
98
98
  end
99
99
 
@@ -113,7 +113,7 @@ describe Quicktime::Movie do
113
113
  path = File.dirname(__FILE__) + '/../output/flattened_example.mov'
114
114
  File.delete(path) rescue nil
115
115
  @movie.flatten(path)
116
- mov = Quicktime::Movie.open(path)
116
+ mov = QuickTime::Movie.open(path)
117
117
  mov.duration.should == 3.1
118
118
  end
119
119
 
@@ -135,7 +135,7 @@ describe Quicktime::Movie do
135
135
 
136
136
  describe "empty movie" do
137
137
  before(:each) do
138
- @movie = Quicktime::Movie.empty
138
+ @movie = QuickTime::Movie.empty
139
139
  end
140
140
 
141
141
  it "should have 0 duration" do
@@ -143,14 +143,41 @@ describe Quicktime::Movie do
143
143
  end
144
144
 
145
145
  it "should be able to append an existing movie" do
146
- m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
146
+ m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
147
147
  @movie.append_movie(m2)
148
148
  @movie.duration.should == 3.1
149
149
  end
150
150
 
151
151
  it "should raise MovieAlreadyLoaded exception when attempting to load it again" do
152
- lambda { @movie.load_empty }.should raise_error(Quicktime::Error)
153
- lambda { @movie.load_from_file('example.mov') }.should raise_error(Quicktime::Error)
152
+ lambda { @movie.load_empty }.should raise_error(QuickTime::Error)
153
+ lambda { @movie.load_from_file('example.mov') }.should raise_error(QuickTime::Error)
154
+ end
155
+
156
+ it "should be able to create a new track" do
157
+ track = @movie.new_track(300, 500)
158
+ track.should be_kind_of(QuickTime::Track)
159
+ @movie.tracks.should have(1).record
160
+ end
161
+
162
+ it "should be able to create a new video track" do
163
+ track = @movie.new_video_track(300, 500)
164
+ track.should be_kind_of(QuickTime::Track)
165
+ track.should be_video
166
+ @movie.video_tracks.should have(1).record
167
+ end
168
+
169
+ it "should be able to create a new audio track" do
170
+ track = @movie.new_audio_track(300, 500)
171
+ track.should be_kind_of(QuickTime::Track)
172
+ track.should be_audio
173
+ @movie.audio_tracks.should have(1).record
174
+ end
175
+
176
+ it "should be able to create a new text track" do
177
+ track = @movie.new_text_track(300, 500)
178
+ track.should be_kind_of(QuickTime::Track)
179
+ track.should be_text
180
+ @movie.text_tracks.should have(1).record
154
181
  end
155
182
  end
156
183
  end
@@ -1,9 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
- describe Quicktime::Track do
3
+ describe QuickTime::Track do
4
4
  describe "example.mov" do
5
5
  before(:each) do
6
- @movie = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
6
+ @movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
7
7
  end
8
8
 
9
9
  describe "example.mov video track" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bates