Permalink
Browse files

Add documentation

  • Loading branch information...
1 parent c0c982b commit 3c34260ba6298d9f00096b50656c58ee6ca29045 @ferrous26 ferrous26 committed Dec 9, 2012
Showing with 95 additions and 2 deletions.
  1. +7 −0 History.markdown
  2. +22 −1 README.markdown
  3. +66 −1 ext/screen_recorder/screen_recorder.c
View
@@ -2,3 +2,10 @@
* CRuby and MacRuby compatible
+ * Added `ScreenRecorder` class
+ * Added `ScreenRecorder#start` method
+ * Added `ScreenRecorder#started?` method
+ * Added `ScreenRecorder#stop` method
+ * Added `ScreenRecorder#length` method
+ * Added `ScreenRecorder#size` method
+ * Added `ScreenRecorder.record` method
View
@@ -9,7 +9,28 @@ runtimes.
## Examples
-TODO... :(
+ require 'screen_recorder'
+
+ # in block form
+ ScreenRecorder.record do
+ sleep 10 # go and do stuff
+ end
+ # now go check ~/Movies
+
+ # in "classic" form
+ recorder = ScreenRecorder.new
+ recorder.start
+ # go do stuff
+ recorder.stop
+ # now go check ~/Movies
+
+Both block and non-block forms take an optional string, which should
+be a path to save the recording (the default saves to `~/Movies`).
+
+
+## TODO
+
+* Expose recorder options at initialization (e.g. turn off mouse clicks)
## Copyright
@@ -43,6 +43,17 @@ rb_recorder_alloc(VALUE klass)
return OBJC_WRAP(recorder);
}
+/*
+ * Synchrnously start recording
+ *
+ * You can optionally specify a file name for the recording; if you do
+ * not then a default name will be provided in the form
+ * `~/Movies/TestRecording-20121017123230.mov`
+ * (the timestamp will be different for you).
+ *
+ * @param file_name [String] (__optional__)
+ * @return [Boolean]
+ */
static
VALUE
rb_recorder_start(int argc, VALUE* argv, VALUE self)
@@ -69,34 +80,64 @@ rb_recorder_start(int argc, VALUE* argv, VALUE self)
return (result ? Qtrue : Qfalse);
}
+/*
+ * Whether or not the recording has begun
+ *
+ * This will be `true` after calling {#start} until {#stop} is called.
+ */
static
VALUE
rb_recorder_started(VALUE self)
{
return ([OBJC_UNWRAP(self) isStarted] ? Qtrue : Qfalse);
}
+/*
+ * Duration of the recording, in seconds
+ *
+ * @return [Float]
+ */
static
VALUE
rb_recorder_length(VALUE self)
{
return DBL2NUM([OBJC_UNWRAP(self) length]);
}
+/*
+ * Size of the recording on disk, in bytes
+ *
+ * @return [Fixnum]
+ */
static
VALUE
rb_recorder_size(VALUE self)
{
return SIZET2NUM([OBJC_UNWRAP(self) size]);
}
+/*
+ * Synchronously stop recording and finish up commiting any data to disk
+ *
+ * A recording cannot be {#start}ed again after it has been stopped. You
+ * will need to start a new recording.
+ *
+ * @return [Boolean]
+ */
static
VALUE
rb_recorder_stop(VALUE self)
{
return ([OBJC_UNWRAP(self) stop] ? Qtrue : Qfalse);
}
+/*
+ * Path to the screen recording on disk
+ *
+ * This is `nil` until the screen recording begins.
+ *
+ * @return [String,nil]
+ */
static
VALUE
rb_recorder_file(VALUE self)
@@ -116,6 +157,19 @@ rb_recorder_yielder(VALUE self)
return rb_recorder_file(self);
}
+/*
+ * Record the screen while executing the given block
+ *
+ * You may optionally specify the path to save the recording to, just
+ * as when calling {#start}.
+ *
+ * The path to the recording will be returned. The recorder object is yielded.
+ *
+ * @yield
+ * @yieldparam recorder [ScreenRecorder]
+ * @param file_name [String] (__optional__)
+ * @return [String]
+ */
static
VALUE
rb_recorder_record(int argc, VALUE* argv, VALUE self)
@@ -134,7 +188,18 @@ Init_screen_recorder()
/*
* Document-class: ScreenRecorder
*
- * Record screens 'n shit.
+ * Screen recordings, easy as pi.
+ *
+ * Things that you need to be concerned about:
+ * - screen going to sleep (we can resolve this issue later)
+ * - short recordings (~1 second) don't work too well; it looks like
+ * the last bit of the buffer does not get saved so the last ~0.5
+ * seconds are not saved to disk (we could add a 0.5 second sleep)
+ * - small memory leak when a recording starts on Mountain Lion (GC)
+ * - constantly leaking memory during recording on Lion (GC)
+ * - run loop hack is not needed if code is already being called from
+ * in a run loop
+ * - pausing is not working...not sure why; so it is not exposed for now
*
*/
rb_cRecorder = rb_define_class("ScreenRecorder", rb_cObject);

0 comments on commit 3c34260

Please sign in to comment.