Sha256: f0ec681a83d820c165342af8b8d6cd0a302b0fc0e586f0f83d91e8ea80ff71ea

Contents?: true

Size: 570 Bytes

Versions: 2

Compression:

Stored size: 570 Bytes

Contents

module Camtasy
  class PhotoServer
    def initialize
      @request = Queue.new
      @response = Queue.new
      @mutex = Mutex.new
    end

    def take_photo
      @mutex.synchronize do
        @request << "x"
        @response.pop
      end
    end

    def run(uri)
      Thread.new do
        AVCapture::Session.new.run_with(AVCapture.devices.find(&:video?)) do |connection|
          while @request.pop
            @response.push(connection.capture)
          end
        end
      end

      DRb.start_service(uri, self)
      DRb.thread.join
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
camtasy-0.0.3 lib/camtasy/server.rb
camtasy-0.0.2 lib/camtasy/server.rb