Solved

Help on streaming audio data with JMF !!

Posted on 1997-10-22
3
1,675 Views
Last Modified: 2008-03-06
We are simulating an Audio Conferencing System in java.
We are using java native methods to capture audio samples. We want to send these samples through Sockets (TCP/IP or UDP) while it is being captured, and play it using JMF player at the other end. But JMF player requires URL (of audio ) to be specified to play it.We want to know whether JMF supports playing audio samples from inputstream of a Socket.
     

Thanking You,

ECS Development Team
DSQ S/W Ltd, Chennai,
India.

0
Comment
Question by:ecsdsq
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
rembo earned 70 total points
ID: 1229377

You can't actually do this directly because the only
two constructors for MediaLocators are URLs and
Strings.  However, you could be sneaky about it.  

You could subclass URL and create:

public class MyURL extends URL
{
  Socket s;
  //In your constructor, set up your socket connection
  //
  public MyURL(String host, int port)
  {
    s = new Socket(host, port);
  }

  // Then you just need to override the openStream()
  // method since this is most likely the only one that
  // will get used.  If you get errors from other methods
  // go ahead and implement those.  This is not the cleanest
  // solution, but it should work.

// Hope that helps,


-Tony

0
 

Author Comment

by:ecsdsq
ID: 1229378

Thanks for your  answer.

Actuallly we have done creating new URL and implemented openStream() and it is working fine.

But the problem is while sending wav samples it needs wav header,
in which we need to specify the file length( wave file size)which is unknown while we are recording online. If we specify some size
say 1MB, it accepts only 1MB of samples and plays. It is not accepting the rest of the samples that we are sending continuously. Is it possible to send the wave header without specifying the file length or whether we can specify the  
file length as unknown.

Thanking You

Regards
ECS Team Members
DSQ Software Ltd.,
Chennai - 35
India.
0
 
LVL 4

Expert Comment

by:rembo
ID: 1229379

I do not believe there is a way to specify that the
filesize is unknown, but you could set it to an
arbitrarily large number, say 1GB.  Then, since you've
overriden your URL class, you can send a stop to the
player when you've reached the end of your Stream.

-Tony

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JUnit 4 @Before and @BeforeClass differences 3 59
use lov values 2 50
What's wrong with this code? 4 23
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 33
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question