Do any one kown how to encoder pcm to alaw if you use jmf?

I'm have the problem about it how to encoder pcm to alaw?
I find some code about it, but not work in jmf.
A friend in forum tell me write it by myself , because jmf not support for alaw.
But i'm new about this, so i want whether somebody could help me if you have the same code about this.
code like this:
capture.java
* support : locator, datasource
public class Capture extends MainFrame {
    private static final long serialVersionUID = 1L;
    private Processor cp = null;
    private Boolean isMix = false;
    private Boolean isUlaw = false;
    private MainFrame mf = null;
    public Capture(MainFrame mf, boolean useVideo) {
        this.isMix = useVideo;
        this.mf = mf;
    public Capture(MainFrame mf) {
        this.mf = mf;
    public Capture(boolean useVideo) {
        this.isMix = false;
    //get video MediaLocator
    public MediaLocator getVideoLocator() {
        MediaLocator VideoLocator = null;
        Vector VideoCaptureList = null;
        CaptureDeviceInfo VideoCaptureDeviceInfo = null;
        VideoFormat videoFormat = new VideoFormat(VideoFormat.YUV);
        VideoCaptureList = CaptureDeviceManager.getDeviceList(videoFormat);
        if (VideoCaptureList.size() > 0) {
            VideoCaptureDeviceInfo = (CaptureDeviceInfo) VideoCaptureList.elementAt(0);
            VideoLocator = VideoCaptureDeviceInfo.getLocator();
        } else {
//--- Search video device
            VideoCaptureList = (Vector) CaptureDeviceManager.getDeviceList(null).clone();
            Enumeration getEnum = VideoCaptureList.elements();
            while (getEnum.hasMoreElements()) {
                VideoCaptureDeviceInfo = (CaptureDeviceInfo) getEnum.nextElement();
                String name = VideoCaptureDeviceInfo.getName();
                if (name.startsWith("vfw:")) {
                    CaptureDeviceManager.removeDevice(VideoCaptureDeviceInfo);
            int nDevices = 0;
            for (int i = 0; i < 10; i++) {
                String name = com.sun.media.protocol.vfw.VFWCapture.capGetDriverDescriptionName(i);
                if (name != null && name.length() > 1) {
                    System.err.println("Found device" + name);
                    System.err.println("Querying device.Please wait....");
                    com.sun.media.protocol.vfw.VFWSourceStream.autoDetect(i);
                    nDevices++;
            VideoCaptureDeviceInfo = (CaptureDeviceInfo) CaptureDeviceManager.getDeviceList(videoFormat).elementAt(0);
            VideoLocator = VideoCaptureDeviceInfo.getLocator();
        return VideoLocator;
    //get audio MediaLocator
    public MediaLocator getAudioLocator() {
        MediaLocator AudioLocator = null;
        Vector AudioCaptureList = null;
        CaptureDeviceInfo AudioCaptureDeviceInfo = null;
        AudioFormat audioFormat = new AudioFormat(AudioFormat.LINEAR);
        AudioCaptureList = CaptureDeviceManager.getDeviceList(audioFormat);
        if (AudioCaptureList.size() > 0) {
            AudioCaptureDeviceInfo = (CaptureDeviceInfo) AudioCaptureList.elementAt(0);
            AudioLocator = AudioCaptureDeviceInfo.getLocator();
            System.out.println("get audio locator");
        } else {
            System.out.println("empty");
            AudioLocator = null;
        return AudioLocator;
    public DataSource getDataSource() {
        try {
            DataSource[] source = new DataSource[2];    //audio 0; video 1;
            source[0] = Manager.createDataSource(getAudioLocator());
            if (isMix) {
                DataSource MixDataSource = null;
                source[1] = Manager.createDataSource(getVideoLocator());
                MixDataSource = Manager.createMergingDataSource(source);
                return MixDataSource;
            } else {
                return source[0];
        } catch (Exception ex) {
            System.out.println("---error0---" + ex);
            return null;
    public DataSource getDataSourceByProcessor() {
        StateHelper sh = null;
        DataSource OutDataSource = null;
        DataSource InputSource = null;
        InputSource = getDataSource();
        try {
            cp = Manager.createProcessor(InputSource);
        } catch (IOException ex) {
            System.out.println("---error1---" + ex);
        } catch (NoProcessorException ex) {
            System.out.println("---error2---" + ex);
        sh = new StateHelper(cp);
        if (!sh.configure(10000)) {
            System.out.println("Processor Configured Error!");
            System.exit(-1);
        ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
        cp.setContentDescriptor(cd);
        AudioFormat ulawFormat = new AudioFormat(AudioFormat.ULAW_RTP, 8000.0, 8, 1);
       // change encode to alaw here?
        TrackControl[] tracks = cp.getTrackControls();
        boolean encodingState = false;
        for (int i = 0; i < tracks.length; i++) {
            if (!encodingState && tracks[i] instanceof FormatControl) {
                if (tracks.setFormat(ulawFormat) == null) {
tracks[i].setEnabled(false);
} else {
encodingState = true;
//---- ptime set
               if (isUlaw) {
     try {
     System.out.println("Cambiando la lista de codecs...");
     Codec[] codec = new Codec[3];
     codec[0] = new com.ibm.media.codec.audio.rc.RCModule();
     codec[1] = new com.ibm.media.codec.audio.ulaw.JavaEncoder();
     //codec[2] = new com.ibm.media.codec.audio.ulaw.Packetizer();
     codec[2] = new com.sun.media.codec.audio.ulaw.Packetizer();
     ((com.sun.media.codec.audio.ulaw.Packetizer) codec[2]).setPacketSize(160);
     (tracks[i]).setCodecChain(codec);
     } catch (UnsupportedPlugInException ex) {
     } catch (NotConfiguredError ex) {
} else {
tracks[i].setEnabled(false);
if (!encodingState) {
System.out.println("Encode error");
System.exit(-1);
if (!sh.realize(10000)) {
System.out.println("Processor Realized Error!");
System.exit(-1);
OutDataSource = cp.getDataOutput();
return OutDataSource;
//run
public void start() {
cp.start();
//stop
public void close() {
cp.close();

test.java (get outputDatasource form capture.java)
package siphone.test;
import java.io.IOException;
import java.net.InetAddress;
import javax.media.Format;
import javax.media.Manager;
import javax.media.Player;
import javax.media.PlugInManager;
import javax.media.control.BufferControl;
import javax.media.format.UnsupportedFormatException;
import javax.media.protocol.DataSource;
import javax.media.protocol.PushBufferDataSource;
import javax.media.protocol.PushBufferStream;
import javax.media.rtp.InvalidSessionAddressException;
import javax.media.rtp.Participant;
import javax.media.rtp.RTPControl;
import javax.media.rtp.RTPManager;
import javax.media.rtp.ReceiveStream;
import javax.media.rtp.ReceiveStreamListener;
import javax.media.rtp.SendStream;
import javax.media.rtp.SendStreamListener;
import javax.media.rtp.SessionAddress;
import javax.media.rtp.SessionListener;
import javax.media.rtp.event.ByeEvent;
import javax.media.rtp.event.NewParticipantEvent;
import javax.media.rtp.event.NewReceiveStreamEvent;
import javax.media.rtp.event.NewSendStreamEvent;
import javax.media.rtp.event.ReceiveStreamEvent;
import javax.media.rtp.event.RemotePayloadChangeEvent;
import javax.media.rtp.event.SendStreamEvent;
import javax.media.rtp.event.SessionEvent;
import javax.media.rtp.rtcp.SourceDescription;
import siphone.decode.AlawRtpDecoder;
import siphone.device.Capture;
import siphone.gui.MainFrame;
* @author kaiser
public class Dial implements SessionListener, ReceiveStreamListener, SendStreamListener {
    private String ip = null;
    private int TargetPort;
    private int LocalPort;
    private MainFrame mf = null;
    private Capture capture = null;
    private DataSource oDataSource = null;
    private RTPManager rtp = null;
    private SendStream stream = null;
    private Player play = null;
    private Boolean LogStatu = false;
    static private Format AlawRtpFormat;
    public Dial(String ip, String rport, int lport, MainFrame mf) {
        this.ip = ip;
        this.TargetPort = Integer.parseInt(rport);
        this.LocalPort = lport;
        this.mf = mf;
        capture = new Capture(false);
        oDataSource = capture.getDataSourceByProcessor();
    public static void main(String[] args) throws IOException {
        Dial dial = new Dial("192.168.200.40", "40000", 10000, null);
        dial.Init();
        System.in.read();
        dial.stop();
    public synchronized void Init() {
        PushBufferDataSource pushDataSource = (PushBufferDataSource) oDataSource;
        PushBufferStream pushStream[] = pushDataSource.getStreams();
        SessionAddress localAddress, targetAddress;
        try {
            rtp = RTPManager.newInstance();
            rtp.addReceiveStreamListener(this);
            rtp.addSendStreamListener(this);
            rtp.addSessionListener(this);
            //port: TargetPort or LocalPort;
            localAddress = new SessionAddress(InetAddress.getLocalHost(), TargetPort);
            targetAddress = new SessionAddress(InetAddress.getByName(ip), TargetPort);
            rtp.initialize(localAddress);
            rtp.addTarget(targetAddress);
            BufferControl bc = (BufferControl) rtp.getControl("javax.media.control.BufferControl");
            if (bc != null) {
                bc.setBufferLength(100);
            stream = rtp.createSendStream(oDataSource, 0);
            stream.start();
            capture.start();
            System.out.println("voice starting...........\n");
        } catch (UnsupportedFormatException ex) {
            System.err.println("error0:\n" + ex);
        } catch (InvalidSessionAddressException ex) {
            System.err.println("error1:\n" + ex);
        } catch (IOException ex) {
            System.err.println("error2:\n" + ex);
    //stop
    public void stop() {
        capture.close();
        if (rtp != null) {
            rtp.removeTargets("close session");
            rtp.dispose();
            rtp = null;
        System.out.println("close session...........\n");
    public void update(SessionEvent evt) {
        if (evt instanceof NewParticipantEvent) {
            Participant sPart = ((NewParticipantEvent) evt).getParticipant();
            System.out.print("  - join: " + sPart.getCNAME());
    public void update(ReceiveStreamEvent rex) {
        ReceiveStream rStream = rex.getReceiveStream();
        Participant rPart = rex.getParticipant();
        if (rex instanceof NewReceiveStreamEvent) {
            try {
                DataSource rData = rStream.getDataSource();
                RTPControl rcl = (RTPControl) rData.getControl("javax.media.rtp.RTPControl");
                if (rcl != null) {
                    System.out.print("  - receive RTPControl info | the AudioFormat: " + rcl.getFormat());
                } else {
                    System.out.print("  - receive RTPControl info");
                if (rPart == null) {
                    System.out.print(" UNKNOWN");
                } else {
                    System.out.print("data form " + rPart.getCNAME());
                play = Manager.createRealizedPlayer(rData);
                if (play != null) {
                    play.start();
            } catch (Exception ex) {
                System.out.print("NewReceiveStreamEvent Exception " + ex.getMessage());
                return;
        } else if (rex instanceof ByeEvent) {
            System.out.print("  - receive bye message: " + rPart.getCNAME() + "   exit");
            stop();
            return;
}Anyone can tell me how to do?
Thank you very much!

Similar Messages

  • HT5002 I used Inkscape on Linux before moved to Mac. Now I am trying to install it using MacPorts, but libpixman has some problems that has been reported out there. Does any one know how to fix it without the need to use other way than MacPorts?

    I used Inkscape on Linux before moved to Mac. Now I am trying to install it
    using MacPorts, but libpixman has some problems that has been reported out there.
    Does any one know how to fix it without the need to use other way than MacPorts?

    Start with this comprehensive troubleshooting article:
    https://discussions.apple.com/docs/DOC-3521
    Look at this one for possible solutions:
    https://discussions.apple.com/docs/DOC-3353
    Ciao.

  • I have a DI-151RS, or DI-150RS (?) from DATAQ. Any one know how to program it in LabView?

    I have a DI-151RS, or DI-150RS (?) from DATAQ. Any one know how to program it in LabView?

    You will find it at:
    www.ultimaserial.com/classroom.html

  • Does any one know , how to delete the others in itunes. it takes lot of space

    does any one know , how to delete the others in itunes. it takes lot of space, i wanna delete that... Actually what it contains

    Those are the data of the installed apps. Don't listen if someone says that it's an iOS, because it is not. On your iPhone, go to general > usage. It will show you all the programs installed on your iPhone. If you click any of them you will see how much of "others" it has (documents and data)
    There's no way to delete it if you want to still have those apps. You can reinstal those which has the most "others" but after some time of usage, it will raise again.

  • Can any one tell how to create pivot table

    Hi ,
    Am trying to create a pivot tabel in the MDM Import Manager. Iam able to see the preview of the pivot table which i want to create. But when i try to click "OK" button, an error message getting displayed like...
    "The new table cannot be created because the data source is not updatable.You may need the data source to an updatable format such as Microsoft Access before proceeding".
    Due to the above error am not able to create pivot table, plz let me know if any one know how to solve this problem
    Thanks & regards
    Praveen k

    Hi Praveen ,
       The solution to your problem is -
    The data source must be updateable in order for MDM to
    create the new pivot or reverse pivot table. However, you can still
    perform the steps leading up to table creation – including the preview –
    even on a data source that is not updateable, so that you can explore
    pivoting or reverse pivoting as a transformation option. If you then
    decide you want to actually create the new table, convert the data
    source into a format that is updateable (such as Microsoft Access) and
    perform the pivot or reverse pivot on the new data source.
    To create a pivot table, you must identify the source fields that
    participate in the pivot, which ones contain metadata and which ones
    contain data, which ones must be combined, the one-to-one
    correspondence between metadata and data fields and/or field
    combinations, and the key field or fields.
    To create a pivot table:
    1. In the drop-down list of source tables, make sure the table you want to
    pivot is the current source table.
    2. In the Source Hierarchy tree, select all the field nodes corresponding to
    both the metadata fields and the data fields by which you want to pivot.
    3. Right-click on one of the nodes and choose Create Pivot Table from the
    context menu, or choose Source > Create Pivot Table from the main
    menu
    4. MDM opens the Create Pivot Table dialog
    5. In the Key Fields dual-list drop-down control, move one or more fields
    from the Available Fields list to the Selected Fields list to identify the
    key fields on which to perform the pivot
    6. In the dual-list control of fields, drag-and-drop the data fields from the
    Field Values Become Field Names list to the Field Values Become
    Field Values list
    7. If necessary, select two or more fields in either list that must be
    combined into a field combination, and click on the Combine button, or
    right-click on one of the fields and choose Combine from the context
    menu
    8. If necessary, drag-and-drop fields or field combinations within each list
    to create the one-to-one correspondence between metadata fields and
    data fields.
    9. Click on the Preview button to display a preview of the first ten records
    of the pivot table
    10. When you have verified that the pivot operation you have defined will
    have the desired effect, click OK to close the Create Pivot Table dialog.
    11. The MDM Import Manager creates a new table named “table <Pivot>”
    in the data source (where “table” is the name of the original source
    table).
    12. In the drop-down list of source tables, select the newly created pivot
    table on which to perform subsequent import processing.
    Hope that helps ...
    Regards
    Deepak Singh

  • How can I watch movies in germany with native tone, english? Any one knows how to switch the language when renting a movie?

    How can I watch movies in germany with native tone, english? Any one knows how to switch the language when renting a movie?

    I wonder the Format Tables macros on my site could be adapted?
    http://www.grainge.org/pages/authoring/word/word_macros.htm
    If not, I have used Macro Express to format tables in Rh. No reason it could not be used in Word.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • I need to delete the entire browsing history so when i type in a webpage it soes not bring up previuosly visited sites.  deleting the history does not do this.  any one know how to do this

    I need to delete the entire browsing history so when i type in a webpage it soes not bring up previuosly visited sites.  deleting the history does not do this.  any one know how to do this

    Judy-
    If Private Browsing doesn't do it, try Settings-Safari-Advanced-Website Data-Remove All Websitre Data.
    Or changing Settings-Safari-Autofill to OFF.
    You might also try Settings-Safari and Clear History and Clear Cookies and Data.
    As you can see, there are several controls for Safari.  Which one works depends on what your problem is.
    Fred

  • Can't use down key because it opens automator. Does any one know how to disable this short cut?

    Everytime I press down on down key it opens automator. It doesn't let me delete the app. I don't know what to do, it is very frustating to fill in a chart when I can't use the down key. Does any one know how to disable this short cut?

    Are you talking about the Down Arrow key? To my knowledge there is no way to use that key as a shortcut for anything. But look in the Keyboard section of System Preferences and the Keyboard shortcut tab.

  • Does any one know how to execute program in Jump developer desktop

    hi,
    Does any one know how to execute program in Jump developer desktop,
    actually i copied the hello world project from my eclipse workspace to jump
    developers workspace and once i run the program it asks for the main class
    and then i gave main class as my HelloWorld Class,it generates error as
    java.lang.NoSuchMethodError: main
    Exception in thread "main"
    Can any one help me to come out of this problem.....
    Thanks
    MRaj

    i solved it,
    thanks
    MRaj

  • Does any one know how to get smileys for Facebook on the mac,, i see people using them all the time and don't know how to do it,,,

    I know this is a bit of a strange question, but i have seen people using the smileys on face book, but every time i try to get them they dont work, i was just wondering if any one knew how, i thought i would put it on here as i have got a lot of helpful tips on here for alot of problems and you guys know what you are talking about,,,

    not 100% sure what you mean
    smileys are a sequence of chars like ;-¶ which the internet site or program like a chat program replace with an image typically a small gif image
    is your problem that you want to save those images to your harddisk?
    is your problem that you wish some other program then facebook to replace the smiley chars with the images that facebook use?
    is your problem that when you type on facebook your smileys are not replaced with the same images as others (in which case you should prob as which signs they type)

  • Does any one know how to arrange songs by location in itunes lybrary?

    I've ripped more than 100 CDs in different folder in my computer. After installing itunes, every songs is added to the library. But when I want to transpher some songs located in a specific folder, I can not find how? They only arrange by names, or album, or artist... They don't know if you got a collection of favourite songs in a folder, how can I find them, or I have to find each song manualy? Any one knows how to arragne songs by their location, pls help. Thanks alot

    I can not drag directy from my store folder to my Ipod, right?
    Correct.
    I dont want to select hundreds of songs one by one.
    Okay. You have already done that.
    But how do you find a specific song? You have to remember if it's in your favorites folder or in the artist folder or ???
    In iTunes, you create a playlist, put the music you want in the playlist, drag the playlist to your iPod in iTunes.
    Anytime you wan t, add or remove songs from this playlist and plug in the iPod to sync it up.
    iTunes is a music manager.
    You are simply using Windows Explorer/the desktop as a manager now.
    iTunes is so much more versatile. You can sort, group, exclude by Album, Artist, date of song, Genre, and a bunch of other criteria.
    Just as you don't care where a song is physically located on a CD, you don't need to be concerned (too much) with where it is on your HD. With iTunes, as long a syou know something about it (Artist or album), you can find it with one or two clicks.

  • In my iTunes on the iPad I've got 95 items that are stuck and I tried swiping them to delete them but it doesn't work dose any one know how to empty the download tab

    In my iTunes on the iPad I've got 95 things that are stuck and I tried swiping them to delete them but it doesn't work dose any one know how to empty the download tab

    Thanks, but, using the "free" version of Reader, there is no opportunity to open nor import the xml data - the menu options do not exist - there is no import listed.
    If we try to open the xml file directly, then we get an error - something to the effect of "unsupported file type, or the file is corrupted".
    I just noticed in my Pro version that there is the command File ->Form Data ->Import Data to Form... command. Is this what you are referring to?
    What do you recommend? Perhaps the easiest thing to do would be to purchase a few copies of Acrobat Pro for the reservations people to use? I was hoping that the free version of reader would do it, but perhaps not?
    Thanks again,
    Rob

  • In previous versions of Firefox I was able increase the display size on Flickr which remained unless I altered it again. Does any one know how to do this on Firefox 4?

    Question
    In previous versions of Firefox I was able increase the display size on Flickr which remained unless I altered it again. Does any one know how to do this on Firefox 4

    Make sure that you not run Firefox in (permanent) [[Private Browsing]] mode.
    * You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    * To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    * Uncheck: [ ] "Permanent Private Browsing mode"
    You can use one of these extensions to adjust the default font size and page zoom on web pages:
    * Default FullZoom Level - https://addons.mozilla.org/firefox/addon/6965
    * NoSquint - https://addons.mozilla.org/firefox/addon/2592

  • Iphone 4 is hiting in ios 5.1.1. any one know how to solve this problem??

    iphone 4 is hiting in ios 5.1.1. any one know how to solve this problem??

    This sounds like a hardware problem and should be taken to Apple if the heating / "hiting" becomes disturbing to you. If you feel that your iPhone has a heating / "hiting" problem and needs to be repaired, please contact Apple Support and they can further assist you in having it inspected, repaired, or even replaced. In the past, the overheating of Apple products has been known to cause harmful problems to a few particular users. Please evaluate your situation and take further action if you feel necessary.
    http://www.apple.com/support/contact/

  • I deleted all my playlist by mistake from itunes. tried copying the to on the go on ipod and thought it would copy it on to my itune but it didn't. does any one know how i can do this without redoing all my playlists. thanks

    I deleted all my playlist by mistake from itunes. tried copying them to on the go on ipod and thought it would copy it on to my itune but it didn't. does any one know how i can do this without redoing all my playlists. thanks

    Are the playlists still on the iPod? If so I can probably cook up a script to read them back into iTunes, or you can check the features of the various tools listed at the end of this user tip to see if you can find one that you want to use.
    tt2

Maybe you are looking for

  • HP Driver "Can't install because it is not available from Software Update Server"

    Proplem: Can't use my HP Officejet 6500 E709n on my MacBook Pro, even using USB connection.    I click on sign, get add printer window showing the HP 6500 printer as USB Multifunction.  I select and press 'add'.  I get 'setting up ...' window.  After

  • Apache+tomcat+env vars ..?

    I know this should proabably be posted in a tomcat-related forum, but it's worth a shot. I'm using apache 2.0.43, and tomcat 4.1.12, linked togeather with mod_jk on a linux-machine (redhat 8.0), and everything works just fine .. except for one thing.

  • Unable to install on any virtual machine

    Dear Sirs! I have download an original iso file these days to install Windows 10 from it when creating virtual machines.  I have tried to install it on Virtualbox Vmware player or Hyper-v. The result is the same.  The virtual drives are located on th

  • Bug in OraclePreparedStatement??

    I'm trying to execute a batch with a few of exactly the same statement. If I have 6 times the same statement and I make a batch of 3 statements, it is only executed twice. But when I have 6 diferent statements and batches of 3 statements, 6 statement

  • DBIF_RTAB_SQL_ERROR in RSA1

    Hi dear Gurus while performing an Infocube compresion there I'm facing this error: Message was edited by: Jose Luis Alamo Category               ABAP Server Installation and Administration Errors Runtime Errors         DBIF_RTAB_SQL_ERROR Date and Ti