source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/site_ruby/1.8/flv/meta_tag.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 2.6 KB
Line 
1# Copyright (c) 2005 Norman Timmler (inlet media e.K., Hamburg, Germany)
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions
6# are met:
7# 1. Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# 2. Redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the
11# documentation and/or other materials provided with the distribution.
12# 3. The name of the author may not be used to endorse or promote products
13# derived from this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26require 'flv/amf_string_buffer'
27require 'miyaml'
28
29module FLV
30
31 class FLVMetaTag < FLVTag
32
33 attr_accessor :meta_data, :event
34
35 def after_initialize(new_object)
36 @tag_type = META
37 unless new_object
38 meta_data_stream = AMFStringBuffer.new(@data)
39 @event = meta_data_stream.read__AMF_data
40 @meta_data = meta_data_stream.read__AMF_data
41 else
42 @event = 'onMetaData'
43 @meta_data = {}
44 end
45 end
46
47 def name
48 "Meta Tag (#{@event})"
49 end
50
51 def add_meta_data(meta_data)
52 return nil if meta_data.nil?
53 @metadata.update meta_data
54 end
55
56 def data
57 meta_data_stream = AMFStringBuffer.new('')
58 meta_data_stream.write__AMF_string @event
59 meta_data_stream.write__AMF_data @meta_data
60 meta_data_stream.to_s
61 end
62
63 def [](key)
64 @meta_data[key]
65 end
66
67 def []=(key, value)
68 @meta_data[key] = value
69 end
70
71 def inspect
72 out = super
73 out << "event: #{@event}"
74 out << "meta_data:\n #{MiYAML.dump(@meta_data, :indent => 2, :boundaries => false)}"
75 out
76 end
77 end
78end
Note: See TracBrowser for help on using the repository browser.