ffi-hdhomerun

http://bitbucket.org/dmlary/ffi-hdhomerun

Description

Ruby-FFI bindings and wrappers for libhdhomerun.

Features

Allows the user to capture video from an HDHomeRun device within Ruby.

What's missing

  • Channel scan
  • Documentation

Usage

require 'ffi-hdhomerun'

# Dump the list of tuners on the network
HDHomeRun.discover.each do |hash|
  puts "hdhomerun device %s found at %s" % [ hash[:id], hash[:ip_addr] ]
end

# Allocate a tuner
tuner = HDHomeRun::Tuner.new(:id => 'FFFFFFFF', :tuner => 0)

# Set the channel and optionally the program
tuner.channel = 20
tuner.program = 3

# Capture some data
File.open("capture.ts", "w") do |file|
  puts "Capturing (^C to stop):"
  tuner.capture do |buf|
    file.write(buf)
    STDOUT.write(buf.size > 0 ? "." : "?")
    STDOUT.flush
  end
end

Requirements

  • libhdhomerun >= 1.0
  • ffi >= 1.0

FFI_HDHOMERUN_OLD_DEVICE_STRUCT

libhdhomerun made a change to the device structure used for discovery sometime between version 20100121 and 20110323. They added a new field caller tuner_count, but the filename of the hdhomerun library was not incremented in ubuntu. As a result, on older releases such as Lucid, users of this gem will have to set FFI_HDHOMERUN_OLD_DEVICE_STRUCT in their environment to get proper results from the HDHomeRun.discover() method. This environment variable only needs to be set if you're planning on using the discovery method.

Copyright (c) 2011,2012 David M. Lary All rights reserved.

License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.