01: /*
02: *
03: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
04: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License version
08: * 2 only, as published by the Free Software Foundation.
09: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * General Public License version 2 for more details (a copy is
14: * included at /legal/license.txt).
15: *
16: * You should have received a copy of the GNU General Public License
17: * version 2 along with this work; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
22: * Clara, CA 95054 or visit www.sun.com if you need additional
23: * information or have any questions.
24: */
25: package com.sun.mmedia;
26:
27: import javax.microedition.media.Player;
28: import com.sun.j2me.app.AppModel;
29: import java.lang.*;
30: import java.lang.reflect.*;
31:
32: /**
33: * Abstraction for the video renderer for the particular application model
34: */
35: public class ModelVideoRenderer {
36:
37: /** Guard from 'new' operator */
38: private ModelVideoRenderer() {
39: }
40:
41: public static VideoRenderer getVideoRenderer(BasicPlayer player,
42: int sourceWidth, int sourceHeight) {
43: int appModel = AppModel.getAppModel();
44: String className;
45: VideoRenderer ret = null;
46:
47: if (appModel == AppModel.XLET) {
48: className = "com.sun.mmedia.AWTVideoRenderer";
49: } else if (appModel == AppModel.MIDLET) {
50: className = "com.sun.mmedia.MIDPVideoRenderer";
51: } else {
52: return null;
53: }
54: try {
55: Class clazz = Class.forName(className);
56: Integer w = new Integer(sourceWidth);
57: Integer h = new Integer(sourceHeight);
58: /*
59: Constructor constructor = clazz.getConstructor(new Class[] {Player.class, int.class, int.class} );
60: ret = (VideoRenderer)constructor.newInstance( new Object[] {player, w, h});
61: */
62: Constructor constructor[] = clazz.getConstructors();
63: ret = (VideoRenderer) constructor[0]
64: .newInstance(new Object[] { player, w, h });
65: } catch (Exception ex) {
66: ex.printStackTrace();
67: return null;
68: }
69: return ret;
70: }
71:
72: }
|