Revision: 20e1b6247ebd
Author: yulian oifa <[email protected]>
Date: Wed Jul 25 12:00:02 2012
Log: Verified Mgcp Demoes
Resolved Wav file accessing over http
http://code.google.com/p/mediaserver/source/detail?r=20e1b6247ebd
Added:
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/AbstractDtmfEvent.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf0.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf1.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf2.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf3.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf4.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf5.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf6.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf7.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf8.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf9.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfA.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfB.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfC.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfD.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfHash.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfStar.java
Modified:
/bootstrap/src/main/config/mgcp-conf.xml
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/controller/Request.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/controller/signal/MgcpPackage.java
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/au/Play.java
/resources/mediaplayer/src/main/java/org/mobicents/media/server/impl/resource/mediaplayer/audio/wav/WavTrackImpl.java
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/AbstractDtmfEvent.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.mgcp.controller.signal.NotifyImmediately;
+import org.mobicents.media.server.mgcp.controller.signal.Signal;
+import org.mobicents.media.server.spi.Connection;
+import org.mobicents.media.server.spi.Endpoint;
+import org.mobicents.media.server.spi.MediaType;
+import org.mobicents.media.server.spi.dtmf.DtmfDetector;
+import org.mobicents.media.server.spi.dtmf.DtmfDetectorListener;
+import org.mobicents.media.server.spi.dtmf.DtmfEvent;
+import org.mobicents.media.server.spi.listener.TooManyListenersException;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public abstract class AbstractDtmfEvent extends Signal implements
DtmfDetectorListener{
+
+ private DtmfDetector dtmfDetector;
+ protected Event tone;
+
+ public AbstractDtmfEvent(String name) {
+ super(name);
+ this.tone = getTone();
+ this.tone.add(new NotifyImmediately("N"));
+ }
+
+ @Override
+ public void execute() {
+ dtmfDetector = this.getDetector();
+
+ if (dtmfDetector == null) {
+ return;
+ }
+
+ try {
+ dtmfDetector.removeListener(this);
+ dtmfDetector.addListener(this);
+ } catch (TooManyListenersException e) {
+ }
+
+ }
+
+ @Override
+ public boolean doAccept(Text event) {
+ boolean b= !tone.isActive() && tone.matches(event);
+ if(b)
+ {
+ execute();
+ }
+ return b;
+ }
+
+ @Override
+ public void cancel() {
+ if (dtmfDetector != null) {
+ dtmfDetector.removeListener(this);
+ }
+ }
+
+ public void process(DtmfEvent event) {
+ this.onEvent(event.getTone());
+ }
+
+ @Override
+ public void reset() {
+ tone.reset();
+ }
+
+ public abstract void onEvent(String tone);
+
+ protected abstract Event getTone();
+
+ private DtmfDetector getDetector() {
+ if (getTrigger().getConnectionID() == null) {
+ Endpoint endpoint = getEndpoint();
+ return (DtmfDetector)
getEndpoint().getResource(MediaType.AUDIO, DtmfDetector.class);
+ }
+
+ String connectionID = getTrigger().getConnectionID().toString();
+ Connection connection = getConnection(connectionID);
+
+ if (connection == null) {
+ return null;
+ }
+
+ return null;
+ }
+
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf0.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.mgcp.controller.signal.NotifyImmediately;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf0 extends AbstractDtmfEvent {
+ private final static Event dtmf_0 = new Event(new Text("0"));
+
+ public Dtmf0(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("0")) {
+ dtmf_0.fire(this, null);
+ }
+ }
+
+ @Override
+ protected Event getTone() {
+ return dtmf_0;
+ }
+
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf1.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf1 extends AbstractDtmfEvent {
+ private final static Event dtmf_1 = new Event(new Text("1"));
+
+ public Dtmf1(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("1")) {
+ dtmf_1.fire(this, null);
+ }
+ }
+
+ @Override
+ protected Event getTone() {
+ return dtmf_1;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf2.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf2 extends AbstractDtmfEvent {
+ private final static Event dtmf_2 = new Event(new Text("2"));
+
+ public Dtmf2(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("2")) {
+ dtmf_2.fire(this, null);
+ }
+ }
+
+ @Override
+ protected Event getTone() {
+ return dtmf_2;
+ }
+
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf3.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf3 extends AbstractDtmfEvent {
+ private final static Event dtmf_3 = new Event(new Text("3"));
+
+ public Dtmf3(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("3")) {
+ dtmf_3.fire(this, null);
+ }
+ }
+
+ @Override
+ protected Event getTone() {
+ return dtmf_3;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf4.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf4 extends AbstractDtmfEvent {
+ private final static Event dtmf_4 = new Event(new Text("4"));
+
+ public Dtmf4(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("4")) {
+ dtmf_4.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_4;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf5.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf5 extends AbstractDtmfEvent {
+ private final static Event dtmf_5 = new Event(new Text("5"));
+
+ public Dtmf5(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("5")) {
+ dtmf_5.fire(this, null);
+ }
+ }
+
+ @Override
+ protected Event getTone() {
+ return dtmf_5;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf6.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf6 extends AbstractDtmfEvent {
+ private final static Event dtmf_6 = new Event(new Text("6"));
+
+ public Dtmf6(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("6")) {
+ dtmf_6.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_6;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf7.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf7 extends AbstractDtmfEvent {
+ private final static Event dtmf_7 = new Event(new Text("7"));
+
+ public Dtmf7(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("7")) {
+ dtmf_7.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_7;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf8.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf8 extends AbstractDtmfEvent {
+ private final static Event dtmf_8 = new Event(new Text("8"));
+
+ public Dtmf8(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("8")) {
+ dtmf_8.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_8;
+ }
+
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/Dtmf9.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class Dtmf9 extends AbstractDtmfEvent {
+ private final static Event dtmf_9 = new Event(new Text("9"));
+
+ public Dtmf9(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("9")) {
+ dtmf_9.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_9;
+ }
+
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfA.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DtmfA extends AbstractDtmfEvent {
+ private final static Event dtmf_A = new Event(new Text("A"));
+
+ public DtmfA(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("A")) {
+ dtmf_A.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_A;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfB.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DtmfB extends AbstractDtmfEvent {
+ private final static Event dtmf_B = new Event(new Text("B"));
+
+ public DtmfB(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("B")) {
+ dtmf_B.fire(this, null);
+ }
+ }
+
+ @Override
+ protected Event getTone() {
+ return dtmf_B;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfC.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DtmfC extends AbstractDtmfEvent {
+ private final static Event dtmf_C = new Event(new Text("C"));
+
+ public DtmfC(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("C")) {
+ dtmf_C.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_C;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfD.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DtmfD extends AbstractDtmfEvent {
+ private final static Event dtmf_D = new Event(new Text("D"));
+
+ public DtmfD(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("D")) {
+ dtmf_D.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_D;
+ }
+
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfHash.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DtmfHash extends AbstractDtmfEvent {
+ private final static Event dtmf_hash = new Event(new Text("#"));
+
+ public DtmfHash(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("#")) {
+ dtmf_hash.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_hash;
+ }
+}
=======================================
--- /dev/null
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/dmtf/DtmfStar.java
Wed Jul 25 12:00:02 2012
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.media.server.mgcp.pkg.dtmf;
+
+import org.mobicents.media.server.mgcp.controller.signal.Event;
+import org.mobicents.media.server.utils.Text;
+
+/**
+ *
+ * @author kulikov
+ */
+public class DtmfStar extends AbstractDtmfEvent {
+ private final static Event dtmf_star = new Event(new Text("*"));
+
+ public DtmfStar(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onEvent(String tone) {
+ if (tone.equals("*")) {
+ dtmf_star.fire(this, null);
+ }
+ }
+ @Override
+ protected Event getTone() {
+ return dtmf_star;
+ }
+}
=======================================
--- /bootstrap/src/main/config/mgcp-conf.xml Sat Jul 21 16:40:27 2012
+++ /bootstrap/src/main/config/mgcp-conf.xml Wed Jul 25 12:00:02 2012
@@ -14,7 +14,7 @@
<signal name="aupc"
handler="org.mobicents.media.server.mgcp.pkg.au.PlayCollect"/>
<signal name="pr"
handler="org.mobicents.media.server.mgcp.pkg.au.PlayRecord"/>
<signal name="aupr"
handler="org.mobicents.media.server.mgcp.pkg.au.PlayRecord"/>
- <signal name="es"
handler="org.mobicents.media.server.mgcp.pkg.au.EndSignal"/>
+ <signal name="es"
handler="org.mobicents.media.server.mgcp.pkg.au.EndSignal"/>
<signal name="aues"
handler="org.mobicents.media.server.mgcp.pkg.au.EndSignal"/>
</package>
@@ -24,12 +24,31 @@
<signal name="lp"
handler="org.mobicents.media.server.mgcp.pkg.trunk.Loopback"/>
<signal name="ct"
handler="org.mobicents.media.server.mgcp.pkg.trunk.ContinuityTransporder"/>
</package>
+
+ <package name="D">
+ <signal name="0"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf0"/>
+ <signal name="1"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf1"/>
+ <signal name="2"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf2"/>
+ <signal name="3"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf3"/>
+ <signal name="4"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf4"/>
+ <signal name="5"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf5"/>
+ <signal name="6"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf6"/>
+ <signal name="7"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf7"/>
+ <signal name="8"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf8"/>
+ <signal name="9"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.Dtmf9"/>
+ <signal name="A"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.DtmfA"/>
+ <signal name="B"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.DtmfB"/>
+ <signal name="C"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.DtmfC"/>
+ <signal name="D"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.DtmfD"/>
+ <signal name="#"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.DtmfHash"/>
+ <signal name="*"
handler="org.mobicents.media.server.mgcp.pkg.dtmf.DtmfStar"/>
+ </package>
</packages>
<!-- Mapping packages to endpoints -->
<endpoints>
- <endpoint local-name="mobicents/aap/$" packages="A,AU"/>
- <endpoint local-name="mobicents/ivr/$" packages="A,AU"/>
+ <endpoint local-name="mobicents/aap/$" packages="A,AU,D"/>
+ <endpoint local-name="mobicents/ivr/$" packages="A,AU,D"/>
<endpoint local-name="mobicents/ds0/$" packages="T"/>
</endpoints>
</mgcp>
=======================================
---
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/controller/Request.java
Fri Feb 17 05:07:24 2012
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/controller/Request.java
Wed Jul 25 12:00:02 2012
@@ -179,7 +179,7 @@
event.divide('/', evt);
MgcpPackage p = this.getPackage(pkgName);
if (p == null) {
- throw new UnknownPackageException(eventName.toString());
+ throw new UnknownPackageException(eventName.toString());
}
p.accept(eventName);
}
=======================================
---
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/controller/signal/MgcpPackage.java
Wed Jul 11 09:28:19 2012
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/controller/signal/MgcpPackage.java
Wed Jul 25 12:00:02 2012
@@ -101,7 +101,7 @@
eventName.trim();
*/
for (Signal signal : signals) {
- accepted |= signal.accept(event);
+ accepted |= signal.accept(event);
}
if (!accepted) {
throw new UnknownEventException(event.toString());
=======================================
---
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/au/Play.java
Sat Jul 21 16:40:27 2012
+++
/controls/mgcp/src/main/java/org/mobicents/media/server/mgcp/pkg/au/Play.java
Wed Jul 25 12:00:02 2012
@@ -60,13 +60,12 @@
private String uri;
private Iterator<Text> segments;
-
private final static Logger logger = Logger.getLogger(Play.class);
public Play(String name) {
super(name);
oc.add(new NotifyImmediately("N"));
- of.add(new NotifyImmediately("N"));
+ of.add(new NotifyImmediately("N"));
}
@Override
@@ -136,7 +135,7 @@
//starting
player.start();
- }
+ }
@Override
public boolean doAccept(Text event) {
@@ -153,10 +152,7 @@
@Override
public void cancel() {
- if (player != null) {
- player.removeListener(this);
- player.stop();
- }
+ terminate();
}
private Player getPlayer() {
@@ -180,19 +176,23 @@
// return source.getInterface(Player.class);
return null;
}
-
+
@Override
public void reset() {
super.reset();
- if (player != null) {
- player.removeListener(this);
- player.stop();
- }
+ terminate();
oc.reset();
of.reset();
}
+
+ private void terminate() {
+ if (player != null) {
+ player.removeListener(this);
+ player.stop();
+ }
+ }
private void repeat(long delay) {
this.delay = delay;
@@ -223,15 +223,15 @@
return;
}
- player.removeListener(this);
+ terminate();
oc.fire(this, new Text("rc=100"));
this.complete();
break;
case PlayerEvent.FAILED :
- player.removeListener(this);
+ terminate();
oc.fire(this, null);
this.complete();
}
- }
-}
+ }
+}
=======================================
---
/resources/mediaplayer/src/main/java/org/mobicents/media/server/impl/resource/mediaplayer/audio/wav/WavTrackImpl.java
Sat Jul 21 16:40:27 2012
+++
/resources/mediaplayer/src/main/java/org/mobicents/media/server/impl/resource/mediaplayer/audio/wav/WavTrackImpl.java
Wed Jul 25 12:00:02 2012
@@ -47,13 +47,12 @@
public class WavTrackImpl implements Track {
/** audio stream */
- private transient AudioInputStream stream = null;
private InputStream inStream;
private AudioFormat format;
private int period = 20;
private int frameSize;
private boolean eom;
-// private long timestamp;
+ //private long timestamp;
private long duration;
private boolean first = true;
@@ -63,18 +62,11 @@
public WavTrackImpl(URL url) throws UnsupportedAudioFileException,
IOException {
inStream=url.openStream();
- stream = AudioSystem.getAudioInputStream(inStream);
-
- //measure in nanoseconds
- duration =
(long)(stream.getFrameLength()/stream.getFormat().getFrameRate() * 1000L) *
1000000L;
-
- format = getFormat(stream);
+
+ getFormat(inStream);
if (format == null) {
throw new UnsupportedAudioFileException();
- }
-
- frameSize = (int) (period * format.getChannels() *
format.getSampleSize() *
- format.getSampleRate() / 8000);
+ }
}
public void setPeriod(int period) {
@@ -109,25 +101,57 @@
try {
long offset = frameSize * (timestamp / period/ 1000000L);
byte[] skip = new byte[(int)offset];
- stream.read(skip);
+ inStream.read(skip);
} catch (IOException e) {
logger.error(e);
}
}
- private AudioFormat getFormat(AudioInputStream stream) {
- Encoding encoding = stream.getFormat().getEncoding();
- if (encoding == Encoding.ALAW) {
- return FormatFactory.createAudioFormat("pcma", 8000, 8, 1);
- } else if (encoding == Encoding.ULAW) {
- return FormatFactory.createAudioFormat("pcmu", 8000, 8, 1);
- } else if (encoding == Encoding.PCM_SIGNED) {
- int sampleSize = stream.getFormat().getSampleSizeInBits();
- int sampleRate = (int) stream.getFormat().getSampleRate();
- int channels = stream.getFormat().getChannels();
- return FormatFactory.createAudioFormat("linear", sampleRate,
sampleSize, channels);
- }
- return null;
+ private void getFormat(InputStream stream) throws IOException {
+ byte[] header=new byte[44];
+ int bytesRead=0;
+ while (bytesRead < 44) {
+ int len = stream.read(header, bytesRead, 44 - bytesRead);
+ if (len == -1) {
+ return;
+ }
+ bytesRead += len;
+ }
+
+ //format 20,21
+ int formatValue=(header[20]&0xFF) | ((header[21]&0xFF)<<8);
+ //channels 22,23
+ int channels=(header[22]&0xFF) | ((header[23]&0xFF)<<8);
+ //bits per sample 34,35
+ int bitsPerSample=(header[34]&0xFF) | ((header[35]&0xFF)<<8);
+ //sample rate 24,25,26,27
+ int sampleRate=(header[24]&0xFF) | ((header[25]&0xFF)<<8) |
((header[26]&0xFF)<<16) | ((header[27]&0xFF)<<24);
+ //size of data bytes 4,5,6,7
+ int sizeOfData=(header[4]&0xFF) | ((header[5]&0xFF)<<8) |
((header[6]&0xFF)<<16) | ((header[7]&0xFF)<<24);
+ sizeOfData-=36;
+
+ format=null;
+ switch(formatValue)
+ {
+ case 1:
+ //PCM
+ format=FormatFactory.createAudioFormat("linear", sampleRate,
bitsPerSample, channels);
+ break;
+ case 6:
+ //ALAW
+ format=FormatFactory.createAudioFormat("pcma", sampleRate,
bitsPerSample, channels);
+ break;
+ case 7:
+ //ULAW
+ format=FormatFactory.createAudioFormat("pcmu", sampleRate,
bitsPerSample, channels);
+ break;
+ }
+
+ if(format!=null)
+ {
+ frameSize = (int) (period * format.getChannels() *
format.getSampleSize() * format.getSampleRate() / 8000);
+ duration=sizeOfData*period*1000000L/frameSize;
+ }
}
/**
@@ -144,9 +168,9 @@
int length = 0;
try {
while (length < psize) {
- int len = stream.read(packet, offset + length, psize -
length);
- if (len == -1) {
- return length;
+ int len = inStream.read(packet, offset + length, psize -
length);
+ if (len == -1) {
+ return length;
}
length += len;
}
@@ -180,11 +204,11 @@
int len = readPacket(data, 0, frameSize);
if (len == 0) {
- eom = true;
+ eom = true;
}
if (len < frameSize) {
- padding(data, frameSize - len);
+ padding(data, frameSize - len);
eom = true;
}
@@ -199,7 +223,6 @@
public void close() {
try {
- stream.close();
inStream.close();
} catch (Exception e) {
}