KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > media > engine > JmfAbstractMediaPlugin


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.media.engine;
9
10 import java.util.Vector JavaDoc;
11
12 import javax.media.Buffer;
13 import javax.media.Control;
14 import javax.media.Effect;
15 import javax.media.Format;
16 import javax.media.ResourceUnavailableException;
17
18 /**
19  * @version <tt>$Revision: 1.3 $</tt>
20  * @author <a HREF="mailto:spyridon_samothrakis@yahoo.com">Spyridon Samothrakis</a>
21  */

22 public abstract class JmfAbstractMediaPlugin implements Effect
23 {
24
25    Vector JavaDoc m_mediaPlugins = new Vector JavaDoc();
26
27    /**
28     * @see javax.media.Codec#getSupportedInputFormats()
29     */

30    public Format[] getSupportedInputFormats()
31    {
32       return getSupportedFormats();
33    }
34
35    /**
36     * @see javax.media.Codec#getSupportedOutputFormats(Format)
37     */

38    public Format[] getSupportedOutputFormats(Format in)
39    {
40       if (in == null)
41          return getSupportedFormats();
42       else
43       {
44          Format outs[] = new Format[1];
45          outs[0] = in;
46          return outs;
47
48       }
49    }
50
51    /**
52     * @see javax.media.Codec#process(Buffer, Buffer)
53     */

54    public int process(Buffer input, Buffer output)
55    {
56       // Swap the data between the input & output.
57

58       output.setData(input.getData());
59
60       // Copy the input attributes to the output
61
output.setFormat(input.getFormat());
62       output.setLength(input.getLength());
63       output.setOffset(input.getOffset());
64
65       // call the plugins
66

67       for (int i = 0; i < m_mediaPlugins.size(); i++)
68       {
69          // process output
70
((MediaPlugin) m_mediaPlugins.elementAt(i)).process(output);
71       }
72
73       return BUFFER_PROCESSED_OK;
74    }
75
76    /**
77     * @see javax.media.Codec#setInputFormat(Format)
78     */

79    public Format setInputFormat(Format format)
80    {
81       return format;
82    }
83
84    /**
85     * @see javax.media.Codec#setOutputFormat(Format)
86     */

87    public Format setOutputFormat(Format format)
88    {
89       return format;
90    }
91
92    /**
93     * @see javax.media.PlugIn#close()
94     */

95    public void close()
96    {
97    }
98
99    /**
100     * @see javax.media.PlugIn#getName()
101     */

102    public String JavaDoc getName()
103    {
104       return getClass().getName();
105    }
106
107    /**
108     * @see javax.media.PlugIn#open()
109     */

110    public void open() throws ResourceUnavailableException
111    {
112    }
113
114    /**
115     * @see javax.media.PlugIn#reset()
116     */

117    public void reset()
118    {
119    }
120
121    /**
122     * @see javax.media.Controls#getControl(String)
123     */

124    public Object JavaDoc getControl(String JavaDoc arg0)
125    {
126       return null;
127    }
128
129    /**
130     * @see javax.media.Controls#getControls()
131     */

132    public Object JavaDoc[] getControls()
133    {
134       return (Object JavaDoc[]) (new Control[0]);
135    }
136
137    /**
138     * Method getSupportedFormats.
139     * @return Format[] An array of the supported formats
140     * for this plugin
141     */

142    public abstract Format[] getSupportedFormats();
143
144    public void setPluginGraph(MediaPluginGraph graph)
145    {
146       m_mediaPlugins = graph.getPluginVector();
147    }
148
149    public Vector JavaDoc getPluginGraph()
150    {
151       return m_mediaPlugins;
152    }
153 }
154
Popular Tags