Frames | No Frames |
1: /* GStreamerMixer.java -- Mixer implementation. 2: Copyright (C) 2007, 2012 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: package gnu.javax.sound.sampled.gstreamer; 39: 40: import gnu.javax.sound.sampled.gstreamer.lines.GstSourceDataLine; 41: 42: import javax.sound.sampled.AudioFormat; 43: import javax.sound.sampled.Control; 44: import javax.sound.sampled.DataLine; 45: import javax.sound.sampled.Line; 46: import javax.sound.sampled.LineListener; 47: import javax.sound.sampled.LineUnavailableException; 48: import javax.sound.sampled.Mixer; 49: import javax.sound.sampled.SourceDataLine; 50: import javax.sound.sampled.Control.Type; 51: 52: /** 53: * @author Mario Torre <neugens@limasoftware.net> 54: */ 55: public class GStreamerMixer 56: implements Mixer 57: { 58: public static class GstInfo extends Info 59: { 60: /* Mixer Properties */ 61: 62: /** Name */ 63: private static final String name = "Classpath GStreamer Sound Audio Engine"; 64: 65: /** Vendor */ 66: private static final String vendor = "GNU Classpath"; 67: 68: /** Description */ 69: private static final String desc = "GStreamer-based software mixer"; 70: 71: /** Version */ 72: private static final String vers = "0.0.1"; 73: 74: protected GstInfo() 75: { 76: super(name, vendor, desc, vers); 77: } 78: } 79: 80: public static final String GST_BACKEND = GstInfo.name; 81: public static final String GST_DECODER = "decoder"; 82: public static final String GST_TYPE_NAME = "type"; 83: public static final String GST_FILE_EXTENSION = "ext"; 84: 85: /** Mixer Info */ 86: private static final Mixer.Info INFO = new GStreamerMixer.GstInfo(); 87: 88: public Line getLine(Line.Info info) 89: throws LineUnavailableException 90: { 91: // get all the lines formats supported by this mixer and 92: // and see if there is one matching the given line 93: // if the format comes from the gstreamer backend 94: // gstreamer will be able to deal with it 95: Class<?> clazz = info.getLineClass(); 96: DataLine.Info _info = (DataLine.Info) info; 97: 98: if (clazz == SourceDataLine.class) 99: { 100: for (AudioFormat format : _info.getFormats()) 101: { 102: // see if we are a gstreamer child :) 103: if (format.properties().containsKey(GST_BACKEND)); 104: { 105: // we got it 106: return new GstSourceDataLine(format); 107: } 108: } 109: } 110: 111: // TODO: we also support basic PCM 112: 113: throw new LineUnavailableException("Cannot open a line"); 114: } 115: 116: public int getMaxLines(Line.Info info) 117: { 118: // TODO 119: return 1; 120: } 121: 122: public Info getMixerInfo() 123: { 124: return INFO; 125: } 126: 127: public javax.sound.sampled.Line.Info[] getSourceLineInfo() 128: { 129: // TODO Auto-generated method stub 130: return null; 131: } 132: 133: public Line.Info[] getSourceLineInfo(Line.Info info) 134: { 135: // TODO Auto-generated method stub 136: return null; 137: } 138: 139: public Line[] getSourceLines() 140: { 141: // TODO Auto-generated method stub 142: return null; 143: } 144: 145: public javax.sound.sampled.Line.Info[] getTargetLineInfo() 146: { 147: // TODO Auto-generated method stub 148: return null; 149: } 150: 151: public Line.Info[] getTargetLineInfo(Line.Info info) 152: { 153: // TODO Auto-generated method stub 154: return null; 155: } 156: 157: public Line[] getTargetLines() 158: { 159: // TODO Auto-generated method stub 160: return null; 161: } 162: 163: public boolean isLineSupported(Line.Info info) 164: { 165: // We support any kind of mixer that comes 166: // from our gstreamer backend. 167: // In addition, we support PCM based audio streams for 168: // direct playback. 169: if (info instanceof DataLine.Info) 170: { 171: DataLine.Info _dinfo = (DataLine.Info) info; 172: _dinfo.getFormats(); 173: } 174: 175: return true; 176: } 177: 178: public boolean isSynchronizationSupported(Line[] lines, boolean sync) 179: { 180: // TODO Auto-generated method stub 181: return false; 182: } 183: 184: public void synchronize(Line[] lines, boolean sync) 185: { 186: // TODO Auto-generated method stub 187: 188: } 189: 190: public void unsynchronize(Line[] lines) 191: { 192: // TODO Auto-generated method stub 193: 194: } 195: 196: public void addLineListener(LineListener listener) 197: { 198: // TODO Auto-generated method stub 199: 200: } 201: 202: public void close() 203: { 204: // TODO Auto-generated method stub 205: 206: } 207: 208: public Control getControl(Type what) 209: { 210: // TODO Auto-generated method stub 211: return null; 212: } 213: 214: public Control[] getControls() 215: { 216: // TODO Auto-generated method stub 217: return null; 218: } 219: 220: public javax.sound.sampled.Line.Info getLineInfo() 221: { 222: // TODO Auto-generated method stub 223: return null; 224: } 225: 226: public boolean isControlSupported(Type what) 227: { 228: // TODO Auto-generated method stub 229: return false; 230: } 231: 232: public boolean isOpen() 233: { 234: // TODO Auto-generated method stub 235: return false; 236: } 237: 238: public void open() throws LineUnavailableException 239: { 240: // TODO Auto-generated method stub 241: 242: } 243: 244: public void removeLineListener(LineListener listener) 245: { 246: // TODO Auto-generated method stub 247: } 248: }