Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Palm
committed
Aug 16, 2008
0 parents
commit 338badc
Showing
35 changed files
with
2,918 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Autotest.add_hook :initialize do |at| | ||
at.add_mapping(/ext\/.*\/(.*)\.[ch]/) do |_, m| | ||
["spec/#{m[1]}_spec.rb"] | ||
end | ||
end | ||
|
||
Autotest.add_hook :run_command do |at| | ||
system "rake compile" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Makefile | ||
*.o | ||
*.bundle | ||
*.so | ||
*.dll | ||
pkg | ||
doc | ||
.DS_Store | ||
ext/qtvr/stuff/** | ||
*.mov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
== 0.0.1 2008-08-16 | ||
|
||
* 1 major enhancement: | ||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008 David Palm | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
History.txt | ||
License.txt | ||
Manifest.txt | ||
PostInstall.txt | ||
README.txt | ||
Rakefile | ||
config/hoe.rb | ||
config/requirements.rb | ||
lib/qtvr.rb | ||
lib/qtvr/version.rb | ||
ext/qtvr/extconf.rb | ||
ext/qtvr/qtvr.c | ||
ext/qtvr/qtvr.h | ||
script/console | ||
script/destroy | ||
script/generate | ||
script/txt2html | ||
setup.rb | ||
spec/qtvr_spec.rb | ||
spec/spec.opts | ||
spec/spec_helper.rb | ||
tasks/deployment.rake | ||
tasks/environment.rake | ||
tasks/rspec.rake | ||
tasks/website.rake | ||
website/index.html | ||
website/index.txt | ||
website/javascripts/rounded_corners_lite.inc.js | ||
website/stylesheets/screen.css | ||
website/template.html.erb |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
= qtvr | ||
|
||
== DESCRIPTION: | ||
|
||
QTVR manipulation. | ||
|
||
== FEATURES/PROBLEMS: | ||
|
||
Very very few features. | ||
|
||
== SYNOPSIS: | ||
|
||
QTVR::Movie.new('path/to/qtvr/movie.mov') | ||
|
||
== REQUIREMENTS: | ||
|
||
* Mac OS X | ||
* QuickTime 7.5+ | ||
* Apple Developer Tools | ||
|
||
== INSTALL: | ||
|
||
sudo gem install | ||
|
||
== LICENSE: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2008 David Palm | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'config/requirements' | ||
require 'config/hoe' # setup Hoe + all gem configuration | ||
|
||
Dir['tasks/**/*.rake'].each { |rake| load rake } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'qtvr/version' | ||
|
||
AUTHOR = 'FIXME full name' # can also be an array of Authors | ||
EMAIL = "FIXME email" | ||
DESCRIPTION = "description of gem" | ||
GEM_NAME = 'qtvr' # what ppl will type to install your gem | ||
RUBYFORGE_PROJECT = 'qtvr' # The unix name for your project | ||
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" | ||
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" | ||
EXTRA_DEPENDENCIES = [ | ||
# ['activesupport', '>= 1.3.1'] | ||
] # An array of rubygem dependencies [name, version] | ||
|
||
@config_file = "~/.rubyforge/user-config.yml" | ||
@config = nil | ||
RUBYFORGE_USERNAME = "unknown" | ||
def rubyforge_username | ||
unless @config | ||
begin | ||
@config = YAML.load(File.read(File.expand_path(@config_file))) | ||
rescue | ||
puts <<-EOS | ||
ERROR: No rubyforge config file found: #{@config_file} | ||
Run 'rubyforge setup' to prepare your env for access to Rubyforge | ||
- See http://newgem.rubyforge.org/rubyforge.html for more details | ||
EOS | ||
exit | ||
end | ||
end | ||
RUBYFORGE_USERNAME.replace @config["username"] | ||
end | ||
|
||
|
||
REV = nil | ||
# UNCOMMENT IF REQUIRED: | ||
# REV = YAML.load(`svn info`)['Revision'] | ||
VERS = QTVR::VERSION::STRING + (REV ? ".#{REV}" : "") | ||
RDOC_OPTS = ['--quiet', '--title', 'qtvr documentation', | ||
"--opname", "index.html", | ||
"--line-numbers", | ||
"--main", "README", | ||
"--inline-source"] | ||
|
||
class Hoe | ||
def extra_deps | ||
@extra_deps.reject! { |x| Array(x).first == 'hoe' } | ||
@extra_deps | ||
end | ||
end | ||
|
||
# Generate all the Rake tasks | ||
# Run 'rake -T' to see list of generated tasks (from gem root directory) | ||
$hoe = Hoe.new(GEM_NAME, VERS) do |p| | ||
p.developer(AUTHOR, EMAIL) | ||
p.description = DESCRIPTION | ||
p.summary = DESCRIPTION | ||
p.url = HOMEPATH | ||
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT | ||
p.test_globs = ["test/**/test_*.rb"] | ||
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean. | ||
|
||
# == Optional | ||
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") | ||
#p.extra_deps = EXTRA_DEPENDENCIES | ||
|
||
#p.spec_extras = {} # A hash of extra values to set in the gemspec. | ||
end | ||
|
||
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n") | ||
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}" | ||
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc') | ||
$hoe.rsync_args = '-av --delete --ignore-errors' | ||
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'fileutils' | ||
include FileUtils | ||
|
||
require 'rubygems' | ||
%w[rake hoe newgem rubigen].each do |req_gem| | ||
begin | ||
require req_gem | ||
rescue LoadError | ||
puts "This Rakefile requires the '#{req_gem}' RubyGem." | ||
puts "Installation: gem install #{req_gem} -y" | ||
exit | ||
end | ||
end | ||
|
||
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'mkmf' | ||
extension_name = 'qtvr' | ||
|
||
dir_config("qtvr") | ||
|
||
$INCFLAGS += " -I/System/Library/Frameworks/QuickTime.framework/Headers/ -I/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/" | ||
$LIBS += "-framework QuickTime" | ||
|
||
create_makefile("qtvr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#include "qtvr.h" | ||
|
||
VALUE mQTVR = Qnil; | ||
VALUE cMovie = Qnil; | ||
|
||
static VALUE rbMovieAttrs_alloc(VALUE klass){ | ||
rbMovieAttrs *attrs = malloc(sizeof(rbMovieAttrs)); | ||
attrs->movie = NULL; | ||
return Data_Wrap_Struct(klass, 0, free, attrs); | ||
} | ||
|
||
void Init_qtvr(){ | ||
// QTVR class | ||
mQTVR = rb_define_module("QTVR"); | ||
rb_define_module_function(mQTVR, "qt_version", rb_GetQTVersion,0); | ||
|
||
// QTVR::Movie class | ||
cMovie = rb_define_class_under(mQTVR, "Movie", rb_cObject); | ||
rb_define_alloc_func(cMovie, rbMovieAttrs_alloc); | ||
rb_define_method(cMovie, "initialize", Movie_initialize, 1); | ||
rb_define_method(cMovie, "filename", get_filename, 0); | ||
rb_define_method(cMovie, "filename=", set_filename, 1); | ||
rb_define_method(cMovie, "active?", is_active, 0); | ||
} | ||
|
||
static VALUE rb_GetQTVersion(VALUE self){ | ||
long version = 0L; | ||
if(Gestalt(gestaltQuickTime, &version) == noErr){ | ||
char version_str[8]; | ||
sprintf(version_str, "%x", ((version >> 16) & 0xFFFF)); | ||
return INT2FIX(atoi(version_str)); | ||
}else{ | ||
rb_raise(rb_eRuntimeError, "Cannot determine QuickTime version"); | ||
} | ||
} | ||
/* | ||
static VALUE rb_FlattenMovieFile(VALUE self){ //, Movie theMovie, FSSpec *theFile) | ||
OSErr anErr = noErr; | ||
FSSpec tempFile; | ||
char tempFileName[255]; | ||
char error_msg[100]; | ||
rbMovieAttrs* mov; | ||
Data_Get_Struct(self, rbMovieAttrs, mov); | ||
DebugAssert(mov->movie != NULL); if(mov->movie == NULL) return invalidMovie; | ||
// Create the needed temp file. | ||
// NumToString(TickCount(), tempFileName); | ||
numtostring(TickCount(), tempFileName); | ||
anErr = FSMakeFSSpec(tempFile->vRefNum, tempFile->parID, tempFileName, &tempFile); | ||
extern OSErr FSMakeFSRefUnicode(const FSRef *parentRef, UniCharCount nameLength, const UniChar *name, TextEncoding textEncodingHint, FSRef *newRef) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; | ||
if(anErr != fnfErr){ | ||
sprintf(error_msg, "Cannot create reference to temp file \"%s\". Error: %d", tempFileName, anErr); | ||
rb_raise(rb_eRuntimeError, error_msg); | ||
} | ||
// Flatten the movie. | ||
FlattenMovie(mov->movie, flattenAddMovieToDataFork, &tempFile, QTVRFlattenerType, smSystemScript, createMovieFileDeleteCurFile, 0, NULL); | ||
anErr = GetMoviesError(); | ||
if(anErr != noErr){ | ||
FSpDelete(&tempFile); // remove the temp file | ||
sprintf(error_msg, "Cannot flatten movie. Error: %d", tempFileName, anErr); | ||
rb_raise(rb_eRuntimeError, error_msg); | ||
} | ||
DisposeMovie(mov->movie); | ||
// anErr = FSpDelete(theFile); ReturnIfError(anErr); | ||
// anErr = FSpRename(&tempFile, theFile->name); ReturnIfError(anErr); | ||
return Qtrue; | ||
} | ||
*/ | ||
static VALUE Movie_initialize(VALUE self, VALUE filename){ | ||
OSErr err = 0; | ||
char error_msg[100]; | ||
OSType myDataRefType; | ||
Handle myDataRef = NULL; | ||
short actualResId = DoTheRightThing; | ||
|
||
rb_iv_set(self, "@filename", filename); | ||
rbMovieAttrs* mov; | ||
Data_Get_Struct(self, rbMovieAttrs, mov); | ||
|
||
// Initialize MovieToolbox | ||
if ((err = EnterMovies())){ | ||
sprintf(error_msg, "Could not initialize QuickTime. Error: %d\n", err); | ||
rb_raise(rb_eRuntimeError, error_msg); | ||
} | ||
|
||
// Convert movie path to CFString | ||
if(!(mov->inPth = CFStringCreateWithCString(NULL, RSTRING_PTR(filename), CFStringGetSystemEncoding()))){ | ||
rb_raise(rb_eRuntimeError, "Could not get CFString from \"%s\"\n", RSTRING_PTR(filename)); | ||
} | ||
|
||
// create the data reference | ||
if ((err = QTNewDataReferenceFromFullPathCFString(mov->inPth, kQTNativeDefaultPathStyle, 0, &myDataRef, &myDataRefType))){ | ||
sprintf(error_msg, "Could not get DataRef from path \"%s\". Error: %d\n", RSTRING_PTR(filename), err); | ||
rb_raise(rb_eRuntimeError, error_msg); | ||
} | ||
|
||
// printf("MOVIE before: %d\n", mov->movie); | ||
|
||
// get the Movie | ||
if ((err = NewMovieFromDataRef(&mov->movie, newMovieDontInteractWithUser | newMovieDontAskUnresolvedDataRefs, &actualResId, myDataRef, myDataRefType))){ | ||
sprintf(error_msg, "Could not get Movie from DataRef %d\n", err); | ||
rb_raise(rb_eRuntimeError, error_msg); | ||
} | ||
|
||
// dispose the data reference handle - we no longer need it | ||
DisposeHandle(myDataRef); | ||
|
||
// printf("MOVIE: %d\n", mov->movie); | ||
// printf("Active? %d\n", GetMovieActive(mov->movie)); | ||
return self; | ||
} | ||
|
||
Movie get_movie(VALUE self){ | ||
rbMovieAttrs* mov; | ||
Data_Get_Struct(self, rbMovieAttrs, mov); | ||
// printf("MOVIE %d\n", mov->movie); | ||
// return INT2FIX(mov->movie); | ||
return mov->movie; | ||
} | ||
|
||
static VALUE get_filename(VALUE self){ | ||
rb_iv_get(self, "@filename"); | ||
} | ||
|
||
static VALUE set_filename(VALUE self, VALUE filename){ | ||
rb_iv_set(self, "@filename", filename); | ||
} | ||
|
||
static VALUE is_active(VALUE self){ | ||
// int is_active; | ||
// rbMovieAttrs* mov; | ||
// Data_Get_Struct(self, rbMovieAttrs, mov); | ||
// is_active = GetMovieActive(mov->movie); | ||
|
||
if(GetMovieActive(get_movie(self))) | ||
return Qtrue; | ||
else | ||
return Qfalse; | ||
} |
Oops, something went wrong.