Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

Not able to send RTP packets

Thread view: 
Aakansha - 22 Aug 2007 07:02 GMT
The code given below is not sending RTP packets using JMF.
can any one suggest how can i enable below code for sending RTP
Packets.

import javax.media.*;
import javax.media.control.*;
import javax.media.datasink.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.control.TrackControl;

import jmapps.util.StateHelper;

import javax.media.rtp.*;
import javax.media.rtp.rtcp.*;
import javax.media.rtp.event.*;
import com.sun.media.rtp.*;
import com.sun.media.ui.*;

import java.io.*;
import java.util.*;
import java.awt.*;
import java.net.InetAddress;
import java.applet.*;

public class RTPSender extends Applet{

   public void init() {
       doSendProcessor();
   }

   private void doSendProcessor(){
       CaptureDeviceInfo di = null;
       Processor processor = null;
       di = getDeviceInfo();

       // create a processor for this capturedevice and exit if we
cann't create it
       try{
           processor =
Manager.createProcessor(di.getLocator());
       }catch(IOException ioEX){
           ioEX.printStackTrace();
       }catch(Exception e){
           e.printStackTrace();
       }

       //configure the processor
       processor.configure();
       while(processor.getState()!=processor.Configured){
           //System.out.println(processor.getState()+" state
"+processor.Configured);
       }

       processor.setContentDescriptor(new
ContentDescriptor(ContentDescriptor.RAW));
       TrackControl track[] = processor.getTrackControls();
       //value of encodingOK determine we can send GSM data or not
       //if value of encodingOK is true means we can send GSM data
       boolean encodingOK = false;
       //go through the tracks and try to program one of them to
       //output GSM Data
       for(int i=0;i<track.length;i++){
           //System.out.println("track:-> "+track[i]);
           if(!encodingOK && track[i] instanceof FormatControl){
               boolean abc = track[i] instanceof FormatControl;
               //System.out.println("track[i] instanceof
FormatControl:-> "+abc);

               if((track[i]).setFormat(new
AudioFormat(AudioFormat.GSM_RTP,8000,8,1))==null){
                   track[i].setEnabled(false);
               }else{
                   encodingOK = true;
               }
           }else{
               track[i].setEnabled(false);
           }
       }

       //System.out.println("encodingOK:-> "+encodingOK);

       //realize the processor
       if(encodingOK){
           processor.realize();
           while(processor.getState()!=Processor.Realized){
               //System.out.println(processor.getState()+" real
"+processor.Configured);
           }
       }

       // get the output datasource of the processor and exit if we
fail
       DataSource ds = null;
       try{
           ds = processor.getDataOutput();
       }catch(NotRealizedError e){
           e.printStackTrace();
       }

       // use datasource fot creating an RTP datasink
       //our RTP datasink will multicast the audio.
       /*
       try{
           String url = "rtp://192.168.1.7:5000/audio/1";
           MediaLocator m = new MediaLocator(url);
           DataSink d = Manager.createDataSink(ds,m);

           d.open();

           d.start();

           processor.start();

       }catch(Exception e){
           System.out.println("");
           e.printStackTrace();
       }
       */

       //create a SessionManager and hand over the
       //datasource for SendStream creation

       try{
           SessionManager rtpsm = new RTPSessionMgr();

           SessionAddress localaddr = new SessionAddress();
           InetAddress destaddr =
InetAddress.getByName("192.168.1.2");
           SessionAddress sessaddr = new SessionAddress(destaddr,
5000,destaddr,5000+1);
           //ask RTPSM to generetion the local participant CName
           String cname = rtpsm.generateCNAME();
           SourceDescription[] userdesclist = new SourceDescription[]
{new
SourceDescription(SourceDescription.SOURCE_DESC_EMAIL,"a...@sun.com",
1,false) ,new
SourceDescription(SourceDescription.SOURCE_DESC_CNAME,cname,
1,false),new SourceDescription(SourceDescription.SOURCE_DESC_TOOL,"JMF
RTP Player v2.0",1,false)};

           // the session manager then needs to be initialized and
started:
           rtpsm.initSession(localaddr,userdesclist,0.05,0.25);
           rtpsm.startSession(sessaddr,1,null);
           SendStream sendStream = rtpsm.createSendStream(ds, 0);
           sendStream.start();
       }catch(IOException io){
           //System.out.println("");
           io.printStackTrace();
       }catch(UnsupportedFormatException e){
           //System.out.println("");
           e.printStackTrace();
       }catch(Exception e){
           //System.out.println("");
           e.printStackTrace();
       }
   }

   private CaptureDeviceInfo getDeviceInfo(){
       CaptureDeviceInfo di = null;
       AudioFormat a = new AudioFormat (AudioFormat.LINEAR, 8000, 16,
1);
               Vector deviceList =
CaptureDeviceManager.getDeviceList(a);

       if(deviceList!=null){
           if(deviceList.size()>0)
               di = (CaptureDeviceInfo) deviceList.elementAt(0);
           else
              System.out.println("no device is captured");
       }else{
           //g.drawString("Vector not Initialized",50,25);
           System.out.println("Vector not Initialized");
       }
       return di;
   }

}
Graham - 22 Aug 2007 09:44 GMT
> The code given below is not sending RTP packets using JMF.
> can any one suggest how can i enable below code for sending RTP
> Packets.
>
> [code snipped]

How do you know that RTP packets are not being sent?

Capturing audio and communicating with a computer which does not have
the address of the computer from which the applet originated are
privileged actions and are denied by the default security policy.

See http://java.sun.com/sfaq/

You can grant an applet these privileges if you digitally sign it.
Amit Jain - 22 Aug 2007 10:26 GMT
> How do you know that RTP packets are not being sent?
 Using Ethereal http://www.ethereal.com/download.html

> You can grant an applet these privileges if you digitally sign it.
 yes my applet is signed
Roedy Green - 22 Aug 2007 12:02 GMT
>  Using Ethereal http://www.ethereal.com/download.html
now renamed Wireshark.
See http://mindprod.com/jgloss/wireshark.html

Oddly the Ethereal site does not mention the flip.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Graham - 22 Aug 2007 15:17 GMT
> Oddly the Ethereal site does not mention the flip.

Yep, that confused me when it happened too.

Amit wrote:
>> How do you know that RTP packets are not being sent?
> Using Ethereal http://www.ethereal.com/download.html

Are there any exceptions on the Java console? (If you are using IE I
think it is Tools -> Sun Java Console)
Amit Jain - 23 Aug 2007 06:54 GMT
> Are there any exceptions on the Java console? (If you are using IE I
 think it is Tools -> Sun Java Console)

No..., I didn't got any exception at console

Thanks
Aakansha - 23 Aug 2007 14:20 GMT
Can any one help...
why program is not able to send RTP Packets...
please...
Thanks...
Andrew Thompson - 23 Aug 2007 15:59 GMT
>Can any one help...

"Is that a question?"

Search the group on that phrase for a protracted
discussion on English usage, and communicating a
question to people.  It might help you in future.

Assuming it is a question.

Perhaps, perhaps not.  JMF and applets
do not mix well.  Even after the matter of the
applet being signed and 'trusted' by the end client,
there is also an option to 'allow capture from applets'
that is by default *disabled* in JMF installations.

Do you have an URL for this applet (working
or otherwise)?  I might be able to determine
more by looking at the output, and playing
with the options of my local JMF installation.

>why program is not able to send RTP Packets...

(and ..mostly to irritate Roedy)
Note that sentences in English usually end with a
single full stop (.).  After the full-stop, the next letter
should always be Upper Case, since it is the start of
a new sentence.  Using full-stops as people expect
to see them, followed by the obligatory Capital at
the start of the next sentecce, helps people to quickly
scan the text of a message, looking for important
points.
(OK.. no, I put that more in the hope it will help
you in future - could not resist the jab at Roedy,
though - see the thread mentioned above, for the
reasons why.)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Aakansha - 24 Aug 2007 06:25 GMT
Thanks for reply and in future I will follow your guide line for
posting any message,

> Do you have an URL for this applet
No, I don't have url for this applet

Thanks
Aakansha
Andrew Thompson - 24 Aug 2007 09:01 GMT
...
>> Do you have an URL for this applet

>No, I don't have url for this applet

That is unfortunate.  

Why?  Is it because this applet..
1) Is a private applet, not availabe to the
general public, or ..
2) It has just not been uploaded *yet*.  Or..
3) Something else?

The reason I ask is that I am still not clear on
whether you might be able to give us an URL
to the applet, at some time in the *future*.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Amit Jain - 24 Aug 2007 09:16 GMT
> Why?  Is it because this applet..
> 1) Is a private applet, not availabe to the
> general public, or ..
> 2) It has just not been uploaded *yet*.  Or..
> 3) Something else?

Not uploaded.

> The reason I ask is that I am still not clear on
> whether you might be able to give us an URL
> to the applet, at some time in the *future*.

In future applet will be for public.
Andrew Thompson - 24 Aug 2007 11:06 GMT
...
>> 2) It has just not been uploaded *yet*.  Or..
...
>Not uploaded.
...
>In future applet will be for public.

Great.  Please get let to us know when it is
available.  Not so much for 'public' as at least
for 'testing'.

It might be possible someone can solve the
problem in the meantime, but I really doubt it.
Having the applet on-screen can be a real
help in solving problems.

BTW.  Are you aware of 'web start' or JWS?
I am not sure if I've ever mentioned it to you,
but it is a much better way to launch JMF
based projects (gets around most of the
'applet' problems we have talked about in
this thread).

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Amit Jain - 24 Aug 2007 11:13 GMT
> Great.  Please get let to us know when it is
> available.  Not so much for 'public' as at least
> for 'testing'.
sure

> BTW.  Are you aware of 'web start' or JWS?
> I am not sure if I've ever mentioned it to you,
> but it is a much better way to launch JMF
> based projects (gets around most of the
> 'applet' problems we have talked about in
> this thread).
Yes I am using JWS.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.