Codes for audio video receiver class

I am currently writting an audio and video receiver for my project based on AVReceive3, it works but i can only get Video only, everything seems to be normal, i dont see why i am not getting audio. My transmitter is working fine and sending both streams.
If anyone can spot the error or mistake i a making, pleaase let me know as soon as possible.
my email address is [email protected]
public class AudVidReceive extends Frame implements ActionListener,ReceiveStreamListener,SessionListener,ControllerListener
// Input MediaLocator
// Can be a file or http or capture source
private MediaLocator alocator;
MediaLocator vlocator,vloct,aloct;
private String ipAddress;
private int portBase;
Button transtop,transtart,recstop,recstart;
Component controlPanel, visualComponent;
//For Receiving Media Stream
String sessions[] = null;
SessionManager mgrs[] = null;
Vector playerWindows = null;
boolean dataReceived = false;
Object dataSync = new Object();
private Processor processor = null;
Player player=null;
Format fmt=null;
private SessionManager rtpMgrs[];
private DataSource dataOutput = null;
DataSource ads=null;
DataSource vds=null;
DataSource source[];
DataSource m=null;
public AudVidReceive()
super("Audio Video Receive");
recstart=new Button("StartReceiving");
//recstop=new Button("Stop Receiving");
add(recstart);
recstart.setBounds(80,250,100,30);
recstart.addActionListener(this);
setLayout(null);
setSize(400,300);
setVisible(true);
//this.sessions=sessions;
public void actionPerformed(ActionEvent e)
Button b=(Button)e.getSource();
String ac=e.getActionCommand();
if(ac.equalsIgnoreCase("StartReceiving"))
boolean flag;
boolean st=initialize();
if(!st)
System.err.println("Failed to Realize the Sessions ");
System.exit(-1);
flag=isDone();
try{
while(!flag)
Thread.sleep(1000);
}catch(Exception e1)
e1.printStackTrace();
//Initialize the Session for Receiving the Incomming Stream
protected boolean initialize() {
try {
InetAddress ipAddr;
SessionAddress localAddr = new SessionAddress();
SessionAddress destAddr;
String sessions[]={"192.168.2.143/42060"};
mgrs = new com.sun.media.rtp.RTPSessionMgr[sessions.length];
playerWindows = new Vector();
SessionLabel session;
// Open the RTP sessions.
for (int i = 0; i < sessions.length; i++) {
// Parse the session addresses.
try {
session = new SessionLabel(sessions);
} catch (IllegalArgumentException e) {
System.err.println("Failed to parse the session address given: " + sessions[i]);
return false;
System.err.println(" - Open RTP session for: addr: " + session.addr + " port: " + session.port + " ttl: " + session.ttl);
mgrs[i] = new com.sun.media.rtp.RTPSessionMgr();
mgrs[i].addSessionListener(this);
mgrs[i].addReceiveStreamListener(this);
ipAddr = InetAddress.getByName(session.addr);
destAddr = new SessionAddress(ipAddr, session.port,
ipAddr, session.port+1);
mgrs[i].initSession(localAddr, getSDES(mgrs[i]), .05, .25);
// You can try out some other buffer size to see
// if you can get better smoothness.
BufferControl bc = (BufferControl)mgrs[i].getControl("javax.media.control.BufferControl");
if (bc != null)
bc.setBufferLength(350);
mgrs[i].startSession(destAddr, session.ttl, null);
} catch (Exception e){
System.err.println("Cannot create the RTP Session: " + e.getMessage());
return false;
// Wait for data to arrive before moving on.
long then = System.currentTimeMillis();
long waitingPeriod = 120000; // wait for a maximum of 30 secs.
try{
synchronized (dataSync)
while (!dataReceived && System.currentTimeMillis() - then < waitingPeriod) {
if (!dataReceived)
System.err.println(" - Waiting for RTP data to arrive...");
dataSync.wait(1000);
}catch (Exception e) {}
if (!dataReceived) {
System.err.println("No RTP data was received.");
close();
return false;
return true;
* Find out the host info.
String cname = null;
private SourceDescription[] getSDES(SessionManager mgr)
SourceDescription[] desclist = new SourceDescription[3];
if (cname == null)
cname = mgr.generateCNAME();
desclist[0] = new
SourceDescription(SourceDescription.SOURCE_DESC_NAME,
System.getProperty("user.name"),
1,
false);
desclist[1] = new
SourceDescription(SourceDescription.SOURCE_DESC_CNAME,
cname,
1,
false);
desclist[2] = new
SourceDescription(SourceDescription.SOURCE_DESC_TOOL,
"AVReceive powered by JMF",
1,
false);
return desclist;
//Check Player window sizing
public boolean isDone() {
return playerWindows.size() == 0;
* Close the players and the session managers.
protected void close()
for (int i = 0; i < playerWindows.size(); i++)
try {
((PlayerWindow)playerWindows.elementAt(i)).close();
} catch (Exception e) {}
playerWindows.removeAllElements();
// close the RTP session.
for (int i = 0; i < mgrs.length; i++) {
if (mgrs[i] != null) {
mgrs[i].closeSession("Closing session from AudVidReceive");
mgrs[i] = null;
//Find the player
PlayerWindow find(Player p) {
for (int i = 0; i < playerWindows.size(); i++) {
PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
if (pw.player == p)
return pw;
return null;
//Find whether the Player is receiving the Stream
PlayerWindow find(ReceiveStream strm) {
for (int i = 0; i < playerWindows.size(); i++) {
PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
if (pw.stream == strm)
return pw;
return null;
* SessionListener.
public synchronized void update(SessionEvent evt) {
if (evt instanceof NewParticipantEvent) {
Participant p = ((NewParticipantEvent)evt).getParticipant();
System.err.println(" - A new participant had just joined: " + p.getCNAME());
* ReceiveStreamListener
public synchronized void update( ReceiveStreamEvent evt) {
SessionManager mgr = (SessionManager)evt.getSource();
Participant participant = evt.getParticipant(); // could be null.
ReceiveStream stream = evt.getReceiveStream(); // could be null.
if (evt instanceof RemotePayloadChangeEvent) {
System.err.println(" - Received an RTP PayloadChangeEvent.");
System.err.println("Sorry, cannot handle payload change.");
System.exit(0);
else if (evt instanceof NewReceiveStreamEvent) {
try {
stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
DataSource ds = stream.getDataSource();
// Find out the formats.
RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
if (ctl != null){
System.err.println(" - Recevied new RTP stream: " + ctl.getFormat());
} else
System.err.println(" - Recevied new RTP stream");
if (participant == null)
System.err.println(" The sender of this stream had yet to be identified.");
else {
System.err.println(" The stream comes from: " + participant.getCNAME());
// create a player by passing datasource to the Media Manager
Player p = javax.media.Manager.createPlayer(ds);
if (p == null)
return;
p.addControllerListener(this);
p.realize();
PlayerWindow pw = new PlayerWindow(p, stream);
playerWindows.addElement(pw);
// Notify intialize() that a new stream had arrived.
synchronized (dataSync) {
dataReceived = true;
dataSync.notifyAll();
} catch (Exception e) {
System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
return;
}//above catch closing if
else if (evt instanceof StreamMappedEvent) {
if (stream != null && stream.getDataSource() != null) {
DataSource ds = stream.getDataSource();
// Find out the formats.
RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
System.err.println(" - The previously unidentified stream ");
if (ctl != null)
System.err.println(" " + ctl.getFormat());
System.err.println(" had now been identified as sent by: " + participant.getCNAME());
else if (evt instanceof ByeEvent) {
System.err.println(" - Got \"bye\" from: " + participant.getCNAME());
PlayerWindow pw = find(stream);
if (pw != null) {
pw.close();
playerWindows.removeElement(pw);
}// end of this method
* ControllerListener for the Players.
public synchronized void controllerUpdate(ControllerEvent ce) {
Player p = (Player)ce.getSourceController();
if (p == null)
return;
// Get this when the internal players are realized.
if (ce instanceof RealizeCompleteEvent) {
PlayerWindow pw = find(p);
if (pw == null) {
// Some strange happened.
System.err.println("Internal error!");
System.exit(-1);
pw.initialize();
pw.setVisible(true);
p.start();
if (ce instanceof ControllerErrorEvent) {
p.removeControllerListener(this);
PlayerWindow pw = find(p);
if (pw != null) {
pw.close();
playerWindows.removeElement(pw);
System.err.println("AVReceive internal error: " + ce);
* A utility class to parse the session addresses.
class SessionLabel {
public String addr = null;
public int port;
public int ttl = 1;
SessionLabel(String session) throws IllegalArgumentException {
int off;
String portStr = null, ttlStr = null;
if (session != null && session.length() > 0) {
while (session.length() > 1 && session.charAt(0) == '/')
session = session.substring(1);
// Now see if there's a addr specified.
off = session.indexOf('/');
if (off == -1) {
if (!session.equals(""))
addr = session;
} else {
addr = session.substring(0, off);
session = session.substring(off + 1);
// Now see if there's a port specified
off = session.indexOf('/');
if (off == -1) {
if (!session.equals(""))
portStr = session;
} else {
portStr = session.substring(0, off);
session = session.substring(off + 1);
// Now see if there's a ttl specified
off = session.indexOf('/');
if (off == -1) {
if (!session.equals(""))
ttlStr = session;
} else {
ttlStr = session.substring(0, off);
if (addr == null)
throw new IllegalArgumentException();
if (portStr != null) {
try {
Integer integer = Integer.valueOf(portStr);
if (integer != null)
port = integer.intValue();
} catch (Throwable t) {
throw new IllegalArgumentException();
} else
throw new IllegalArgumentException();
if (ttlStr != null) {
try {
Integer integer = Integer.valueOf(ttlStr);
if (integer != null)
ttl = integer.intValue();
} catch (Throwable t) {
throw new IllegalArgumentException();
* GUI classes for the Player.
class PlayerWindow extends Frame {
Player player;
ReceiveStream stream;
PlayerWindow(Player p, ReceiveStream strm) {
player = p;
stream = strm;
public void initialize() {
add(new PlayerPanel(player));
public void close() {
player.close();
setVisible(false);
dispose();
public void addNotify() {
super.addNotify();
pack();
* GUI classes for the Player.
class PlayerPanel extends Panel {
Component vc, cc;
PlayerPanel(Player p) {
setLayout(new BorderLayout());
if ((vc = p.getVisualComponent()) != null)
add("Center", vc);
if ((cc = p.getControlPanelComponent()) != null)
add("South", cc);
public Dimension getPreferredSize() {
int w = 0, h = 0;
if (vc != null) {
Dimension size = vc.getPreferredSize();
w = size.width;
h = size.height;
if (cc != null) {
Dimension size = cc.getPreferredSize();
if (w == 0)
w = size.width;
h += size.height;
if (w < 160)
w = 160;
return new Dimension(w, h);
public static void main(String [] args) {
Format fmt = null;
int i = 0;
AudVidReceive at1 = new AudVidReceive();
System.err.println("Start Receiving incoming Streams ");
try {
Thread.currentThread().sleep(60000);
} catch (InterruptedException ie) {
ie.printStackTrace();

I have to use RTP and RTSP for transferring the
audio/video streams in real time.
How I can sen and receive RTP packets.
How can I make the RTP Player.
What is the role of JMF in it.
Please suggest me and provide me the codes if
possible.
Thanks alot
shobhit vermaThere are two ways using which you can send and recieve packets using rtp. One without using the SessionManager and the other with.
1.) Not using the SessionManager makes things easy for you but it offers very little flexibility to you. You can do this by just specifying a medialocator pointing to the specific url
2.) Using the SessionManager is what is usually suggested. This process is more complex. First you have to instantiate a RTPSessionMgr to a SessionManager reference using which you can send and receive streams to and from the network. The process is more involved than this and is suggest you read some tutorials to get a better understanding, than me explaining to you the entire process.
Message was edited by:
qUesT_foR_knOwLeDge

Similar Messages

  • Source code for audio- video conferencing using JMF

    i am doing a project on VIDEO CONFERNCING using JMF. i am using the HP WEBCAM of my laptop. guys i desperately need help. plz give me the code if any of has it.plz plz its urgent

    i am doing a project on VIDEO CONFERNCING using JMF. i am using the HP WEBCAM of my laptop. guys i desperately need help. plz give me the code if any of has it.plz plz its urgentYou can't get the code for the whole application.....
    but you can get plenty of code to get started on making your own video conf. application using JMF here .
    Also, there is a [JMF Forum|http://forums.sun.com/forum.jspa?forumID=28] here. If you face any problems while coding, you can post your queries there.
    Thanks!

  • Does anybody have the source code for playing video..?

    Hi i am new to J2ME. Does any body have the source code for playing video?

    The WTK includes a video player example. I would start by looking there. In addtion SE and Nokia (if I remember correctly) both have video examples on their developer web sites.
    The developer sites are
    http://forum.nokia.com
    http://developer.sonyericsson.com
    For some of my midlets I use a utility class. You can view the source here:
    http://hostj2me.cliqcafe.com/www/forumtopicview.html?fid=46&categoryId=36&fpn=0
    Works for my needs;

  • How can I connect my '07 MBP to an HDTV via HDMI for audio/video?

    How can I connect my '07 MBP to an HDTV via HDMI for audio/video?

    About Mini DisplayPort to HDMI adapters
    Stefan

  • Set up Company Codes for Contract Accounts Receivable and Payable

    HI,
    I need clarification on "Set up Company Codes for Contract Accounts Receivable and Payable"
    When a company code "ABCD" isn't set up for contract accounts receivable and payable (Menu path:
    SAP Insurance -> Collections/Disbursements -> Organizational Units -> Set up Company Codes for Contract Accounts Receivable and Payable), are postings on this company code "ABCD" within FS-CD not allowed and blocked ?
    Is it mandetory to specify company codes to post in Contract Accounts Receivable and Payable in SAP FS-CD.

    Yes .  It is mandatory to extend company code chart of accounts to CA/CR and FSCD.
    Srinivas

  • Example codes for each and every class in API

    hi,
    Is there any place where i can get example code for eacha and every class in java API.
    for eample...if i wanna find sample codes for all the clases in java.lang.*
    please let me know ASAP.
    thanks in advance

    Try this
    http://www.javaalmanac.com/egs/
    It's almost complete, but you could help mr. Patrick Chan to write more samples for the few classes left in the Java API...

  • How can i watch native code for hashCode() in Object class?

    How can i watch native code for hashCode() in Object class?

    Those are two different requirements. You still haven't told us why you want the first one.
    The second one is called JNI - Java Native Interface. There is a forum here, and a large amount of documentation, and a book about it.

  • No sound connecting Qosmio G30 via HDMI to audio/video receiver

    When I connect my Qosmio G30-177 via HDMI cable to my audio/video receiver using Windows Vista Ultimate I get no sound but excellent video.
    When I connect the DVD recorder to the receiver (also via HDMI-cable) the sound is o.k.
    Do I have to use the s/pdif interface instead of HDMI to transmit the sound to the receiver or is it also possible via HDMI?
    Sound driver:
    Sigma tel high definition audio codec
    15.12.2006
    6.10.5324.0

    Hi
    Im not a audio expert but in my knowledge the HDMI transmit the audio and video signals.
    The HDMI 1.0 and 1.1 support Dolby DigitalDTS audio format
    The HDMI 1.2 supports Dolby DigitalDTS and DVD-Audio format
    The HDMI 1.3 supports Dolby DigitalDTS, DVD-Audio and SACD audio formats.
    All HDMI standards support a Typ A (19pol) jacks

  • Example code for each and every class in java API

    hi,
    Is there any place where i can get example code for eacha and every class in java API.
    for eample...if i wanna find sample codes for all the clases in java.lang.*
    please let me know ASAP.
    thanks in advance

    Crossposted here: http://forum.java.sun.com/thread.jsp?thread=570264&forum=54&message=2820774

  • WHY? 3 out of 4 of my vimeo videos coming up with 'oops the embed code for this video isn't valid'!

    I have inserted my showreel, its working fine, but now I have tried to embed 3 others videos, they all come up with 'oops the embed code for this video isn't working'
    I really don't understand why?
    Holly

    Hello,
    How are you trying to preview the page ? "Preview"tab in Muse or Preview Page in Browser.
    Do you have any URL for us to see ? Please share the codes that you are using to embed the video.
    Regards
    Vivek

  • Ipad2-ipod4 cable options for audio/video out

    Trying to find the best option for playing music/video from iPad2/ipod touch G4 through my home theater receiver.can I use one cable for both? Receiver does have HDMI inputs/output to tv, but will sound play through to tv or just on surround. Also do any options play audio in 7.1 sound, or at least 5.1?

    Sorry you were having issues w/ audio sync. Try bypassing Onkyo system and going directly to TV w/ component cables. Sync issue could be a result of HDMI firmware hand shake problem. Then from TV you can use the optical out to Onkyo system.
    Jerrold_Vz
    Jerrold_VZ
    Verizon Support
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or Plan.

  • What's wrong with my code for a video embed?

    Hi all,
    I've embedded a video using Dreamweaver CS5 onto my site and the code is:
    <object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,1,1,0" width="176" height="158" title="MyVideoTitle">
    <param name="src" value="videos/TheNameOfMyVideoHere.3gp" />
    <param name="BGCOLOR" value="#FFFFFF" />
    <embed src="videos/TheNameOfMyVideoHere.3gp" width="176" height="158" pluginspage="http://www.adobe.com/shockwave/download/"></embed>
    </object>
    I made the video on iMovie and saved it as a .3gp file (the default for tiny videos) for the small file size (176x158.)
    It works great live online in the browsers I've tested (Mac FF, Safari, Camino, GoogChrome, Windows FF), EXCEPT it doesn't load on Safari for Windows (works fine on Mac) and IE8 (and probably IE7, which I don't have.) Perhaps there are others where it won't work, too.
    The spot for the video comes up on the site, and says the words, "Adobe Shockwave..", but never loads.
    What is the problem here?
    Thanks for any help on this!
    Also taking suggestions for the best way (method, format, file type, etc..) to embed a tiny video on my site, that isn't YouTube, etc..I want it clean and simple and no advertising. P.S. I'm not a designer...just a guy with a website and CS5.

    Didn't you understand what BalusC said? You're closing the connection and then trying to use the ResultSet. The ResultSet will be closed when you close the connection so you can't use it anymore.
    You should close the connection last thing in your code, probably in a finally. And after you close your ResultSet and Statement.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • Reason code for short payment received from Customers

    Hello
    We are on ECC 6.0 without application of any enhancement package.
    Requirement is to capture reasons of short payment received from customer and generate a report based on such reason codes.
    Reasons of short payment received could be - Adhoc payment; Excess billed; Tax deducted at source (TDS) on freight / service charges and Bank charges etc.
    Let me know relevant configuration required.
    Would reason codes be captured during incoming payment entry or customer account clearing?
    Thanks.
    Vimal, India

    Hi Vimal
    Following is the configuration for Reason code for customer payments. It can be short payment, over payment or discount not allowed.
    First step is to define reason code. You do this in Financial Accounting (New >Accounts Receivable and Accounts Payable>Incoming Payments>Incoming Payments Global Settings>Overpayment/Underpayment>Define Reason Codes
    Define reason code , short text, long text and assign it to correspondence type. (please note correspondence type settings needs to be done first).  There is a column c which is Indicator: Charge off difference via separate account set this if you want to post the difference to seperate account during clearing customer open item.
    The second step is to define accounts for payment difference.
    Financial Accounting (New >Accounts Receivable and Accounts Payable>Incoming Payments>Incoming Payments Global Settings>Overpayment/Underpayment>Define Accounts for Payment Differences
    Assign G/L accounts against reason codes.
    The third step is Define Reason Code Conversion Version
    Financial Accounting (New >Accounts Receivable and Accounts Payable>Incoming Payments>Incoming Payments Global Settings>Overpayment/Underpayment>Define Reason Code Conversion Version
    In this step, you make the default settings you need for the manual incoming payment processing via payment advice notes. If differences between the payment advice item and the total of the allocated open items occur after selecting the open items, you can enter a reason code in the payment advice item. This represents the reason for the reduction of the payment amount specified by the paying person.
    Create version 001 and name for it.
    For correspondence type create or assign relevant form and print program in global settings> correspondence
    Once you have these settings you can insert appropriate reason code while clearing customer open item .
    You can print correspondence via T-ode F.62 on a monthly basis or wekly basis.
    Hope this helps.
    Thanks
    Sanjeev

  • How can i change the setting for audio-video for my face time to built in only so i can have my skype camera ?

    Good evening,
    The last few days my I lost the ability on Skype to be seen by the other party ... I can see them but they cannot see me. At the same time my Face Time sent me some messages error.
    When I open my Skype and go to Preference and go to audio/video I see my image ... and when I go back to make a call the camera is off (no light). When I look at the bottom where I can have a drop  down arrow I have Face Time (built in).
    On my other Macpro  (that work well) I have at the same place  built-in only.
    Cannot change anything on my MacBook air ... no drop in.
    Please Help and thank you !

    There are no settings for video resolution or frame rate.
    Regarding iOS developer policies:
    https://developer.apple.com/devcenter/ios/index.action

  • If any one has java code for any video compression algorithm

    i need a complete java code for video compression step by step

    i need a complete java code for video compression step by step

Maybe you are looking for