module Skype::Call::Detect

Constants

VERSION

Public Class Methods

pactlExists?() click to toggle source
# File lib/skype/call/detect.rb, line 47
def self.pactlExists?
  system( "which pactl 1>/dev/null 2>&1" )
end
running?() click to toggle source
# File lib/skype/call/detect.rb, line 8
def self.running?
  raise PACTLError, "pactl not found on this system" unless pactlExists?

  outputs = sourceOutputs
  result = false
 
  unless outputs.empty?
    outputs.each do |output|
      result = true if output[:application_name] == 'Skype' and output[:corked] == 'no'
    end
  end

  result
end
sourceOutputs() click to toggle source

Borrowed with some modifications from github.com/kaspernj/pulseaudio

# File lib/skype/call/detect.rb, line 24
  def self.sourceOutputs
    list = %x[pactl list source-outputs]
    outputs = []
    
    list.scan(/(\n|^)Source Output #(\d+)\s+([\s\S]+?)(\n\n|\Z)/) do |match|
      props = {}
      match[2].scan(/(\s+|^)([A-z]+?): (.+?)\n/) do |match_prop|
        props[match_prop[1].downcase.to_sym] = match_prop[2]
      end

      match[2].scan(/(\t\t|^)([A-z\.]+?) = (.+?)\n/) do |match_prop|
        props[match_prop[1].downcase.gsub(/\./, "_").to_sym] = match_prop[2].gsub(/\"/, "")
      end

      output_id = match[1].to_i
      props[:output_id] = output_id

      outputs << props
    end
    
  outputs
end