Sha256: 18b3dce4222001655d5d83095de2affdcab41ba615536756017ceea7d8a42c32

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

module Camtasy
  class PhotoServer
    attr_reader :request, :response

    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
      Thread.new do
        AVCapture::Session.new.run_with(AVCapture.devices.find(&:video?)) do |connection|
          while server.request.pop
            server.response.push(connection.capture)
          end
        end
      end

      DRb.start_service('druby://localhost:8787', server)
      DRb.thread.join
    end
  end
end

PhotoServer.new.run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
camtasy-0.0.1 lib/camtasy/server.rb