-
Notifications
You must be signed in to change notification settings - Fork 0
/
matroska.rb
43 lines (38 loc) · 982 Bytes
/
matroska.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/ruby
#
# Distributed under the MIT license
# see the file COPYING for details
# or visit http://www.opensource.org/licenses/mit-license.php
#
# $Id: matroska.rb 782 2004-09-11 18:13:43Z mosu $
#
# Extensions of the base Matroska classes.
#
# Written by Moritz Bunkus <moritz@bunkus.org>.
#
require "ebml"
require "matroska/baseclasses.rb"
module Matroska
class Seek
def target_id
e = find(SeekID)
return e.to_id if (e)
return Ebml::Id.none
end
def target_pos
e = find(SeekPosition)
return e.to_i if (e)
return nil
end
end # class Seek
class SeekID
def to_id
if ((@data_size > 4) or (@data_size < 1))
raise DataError, "Data size invalid for an Ebml::Id"
end
v = 0
@value.each { |b| v = (v << 8) + b }
return Ebml::Id.new(v, @data_size)
end
end # class SeekID
end # module Matroska