Module: RCS::CallEvidence

Defined in:
lib/rcs-common/evidence/call.rb

Constant Summary collapse

LOG_VOICE_VERSION =
2008121901
CHANNEL =
{ 0 => :incoming, 1 => :outgoing }
CALL_PROGRAM =
{ 0x0141 => :skype,
  0x0142 => :gtalk,
  0x0143 => :yahoo,
  0x0144 => :msn,
  0x0145 => :phone,
  0x0146 => :skype,
  0X0147 => :msn,
  0x0148 => :viber,
  0x0149 => :wechat,
  0x014a => :line,
}

Instance Method Summary collapse

Instance Method Details

#decode_additional_header(data) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rcs-common/evidence/call.rb', line 22

def decode_additional_header(data)

  raise EvidenceDeserializeError.new("incomplete evidence") if data.nil? or data.bytesize == 0
  
  stream = StringIO.new data
  version = read_uint32 stream
  
  raise EvidenceDeserializeError.new("invalid log version for voice call") unless version == LOG_VOICE_VERSION
  
  ret = Hash.new
  ret[:data] = Hash.new

  channel = read_uint32 stream
  ret[:data][:channel] = CHANNEL[channel]

  software = read_uint32 stream
  ret[:data][:program] = CALL_PROGRAM[software]

  ret[:data][:sample_rate] = read_uint32 stream
  ret[:data][:incoming] = read_uint32 stream

  low, high = stream.read(8).unpack 'L2'
  ret[:data][:start_time] = Time.from_filetime high, low
  low, high = stream.read(8).unpack 'L2'
  ret[:data][:stop_time] = Time.from_filetime high, low
  
  caller_len = read_uint32 stream
  callee_len = read_uint32 stream
  
  ret[:data][:peer] = "<unknown>" if callee_len == 0

  ret[:data][:caller] ||= stream.read(caller_len).utf16le_to_utf8.lstrip.rstrip if caller_len != 0
  ret[:data][:peer] ||= stream.read(callee_len).utf16le_to_utf8.lstrip.rstrip if callee_len != 0

  ret
end

#decode_content(common_info, chunks) {|info| ... } ⇒ Object

Yields:

  • (info)


59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rcs-common/evidence/call.rb', line 59

def decode_content(common_info, chunks)
  info = Hash[common_info]
  info[:data] ||= Hash.new

  info[:data][:grid_content] = chunks.join

  info[:end_call] = true if info[:data][:grid_content] == "\xff\xff\xff\xff".force_encoding("ASCII-8BIT")
  info[:end_call] ||= false

  yield info if block_given?
  :keep_raw
end