Solved

Help on streaming audio data with JMF !!

Posted on 1997-10-22
3
1,665 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
Comment Utility

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
Comment Utility

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
Comment Utility

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mapBully challenge 6 88
for i loop in grovy 1 32
Problem to start Neon 20 49
eclipse java  build path 6 18
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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now