• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

streams

How can i pass the streams from one program to another program
0
anmadhu
Asked:
anmadhu
  • 6
  • 6
  • 5
  • +5
1 Solution
 
rjackmanCommented:
hi
u can pass the stream object like a param to method for e.g
if i have 2 classes class1 and class2
in class1 i am using stream object and i ma passing it to class2 which is another prog as parameters

import java.io.*;

public class1
{
  private BufferedReader reader;
  public class1()
{
  reader = new BufferedReader(new FileReader(new File("path of the file")));
  //call other class and pass this to other class
   new class2(reader);
 
}


}

cheers
RJackman
public class2
{
  private BufferedReader reader;
public class2(Reader reader)
{
  this.reader=reader;
}
}
0
 
rameshnutCommented:
Hi anmadhu

Can you please be more specific when you say from "program" to "program".
if i am not mistaken,did you mean from one class to another class or from one function to an other?? Is it so?
Please be clear


 
0
 
gtloaferCommented:
Within the same application you should be able pass a reference no problem. But now if you are thinking of say serializing the object ? Well thats a different story altogether - i.e. no can do.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
gtloaferCommented:
Sorry I dont think I was clear there ...when I said object I meant the stream object
0
 
jorjCommented:
Do a pipe. Use Server/client and TCP connection on the same computer. You will get egt streams which only had to be connected using pipe mechanism.
0
 
anmadhuAuthor Commented:
No still there is problem.  If i speak in the mic i shold hear the voice in the speaker.The speaking in mic shold convert into a bytes in one program , and the hearing the sound in speakers is in another program .
How can do it? Can u catch my point?EXPERTS please clarify my problem?
0
 
jorjCommented:
Java ? You cannot do this. C++ ? Maybe, with some hacking.
So the answer is no or very hard in Java. You must somehow to do a program which catch the incomming stream and redirect it.

I'm affraid your problem hasn't a pleasant solution for you.
0
 
anmadhuAuthor Commented:
Mr Ori Why can't do in JAVA. and

How Can i don in C++?Please Can u explain?
Thanking you for your better co-operation
0
 
jorjCommented:
Java provide weak support for accessing physical resources on host machines, so C is a solution for you.
But, in order to accesss low-level resources as you'll have to do, you need to write a special kind of driver if you're using Windows systems.
So the easyer solution for you will be do to such things from DOS where you can get access to any resources you want. I don't think this is what do you want.
 
another thing is how to access the incomming stream. You will have to do the entire software regarding the audio-board programming.

If you still want to do this you'll need many programming knowledges and ask for this at the C experts.

0
 
sghosh092199Commented:
Well, bit late in the Thread!

What I can understand is, your Program 1 is responsible for converting voice to bytes and Program 2 will receive them to do further processing.

It can be acheived through Java Sockets. Visualize the programs in a Client/Server mechanism.

As a connection is established, each of the Socket is associated with I/O Streams. Data can be read from and written to them.

0
 
viswa081400Commented:
Yeah!
You can achieve it using sockets and JMF which has an API for audio and vedio devices. That should be real helpful for this.

Visit this link on JMF
http://java.sun.com/products/java-media/jmf/index.html

so that should be possible.

good luck
0
 
jorjCommented:
I think the other experts missunderstood the point: anmadhu has two written programs and want to link the streams together, NOT writing the programs again. In this case Java wouldn't help him and with C has small chances. Please correct me if I'm wrong.
0
 
anmadhuAuthor Commented:
Mr Sghosh,  your correct Sir.
How can i do it? could  u please explain me with some simple program.
Thanking u
madhu
0
 
jorjCommented:
anmadhu,
please be more specific with your needs: what do you have and what are do you intend to do. Linking streams is one thing (means you have two programs and you want them to communicate), programming for handling audio sources and manipulating them is another.
0
 
sghosh092199Commented:
If you choose to pass the data via sockets, you need to do the following:

Program 1 (Receiver): Processing of bytes
It will open a Server Socket at a certain port and wait for the bytes from program that does the voice to bytes conversion.

ServerSocket serverSocket = new ServerSocket(9000);
InputStream in = serverSocket.getInputStream();
OutputStream out = serverSocket.getOutputStream();

while (true)
{
// Bytes have arrived
if (serverSocket.accept())
{
  // Read the Bytes and do processing
  byte[] b = new byte[1000];
  in.read(b);
  // The bytes are available in byte array b
}

}
Program 2(Transmitter): Conversion of voice to bytes
It will establish connection with the Receiver program through Socket too.

Socket socket = new Socket("156.65.124.39", 9000);
// 156.65.124.39 denotes the host of Server Program
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();

// Conversion of voice to bytes
// in byte[] b
// Write to the Stream
out.write(b);
out.flush();

You can try the code with a small chunk of byte array and see how it works. Once you have made your client and server programs to communicate, you can work on the voice to byte array conversion which can be achieved by Java Media API.

Good luck!

0
 
anmadhuAuthor Commented:
Hello
This is madhusudhanan .Can u give me your  personnal mail id  I want to discuss with this things
Thanking you for your best cooperation
Bye
madhu
0
 
sghosh092199Commented:
Who is the addresse?
0
 
anmadhuAuthor Commented:
Mr Sqhosh,
I used your code in my program. I got the compilation error.That is, the first line is working perfectly.
1. ServerSocket serverSocket = new ServerSocket(9000);
 
 In the second line i got the compilation error that is,there is no method getInputStream().
2.InputStream in = serverSocket.getInputStream();
Could you correct this one.
Thanking you for your best co-operation
bye
madhu



0
 
jorjCommented:
:) First, I don't want to be bad.
But,
anmadhu, (and others) what do you think you'll split the points when a general problem like yours need so many replys ? You want to connect streams, do the two applications you'll need to connect but you got blocked in the second line of a program and ask elementary questions, which are also very poor in details (as is the problem itself). Would you do something ? Explain your needs in detail, we'll give you the source code or links so you'll only need to compile them.
Sorry, but I am bored of this thread. Try to read more and ask less if you'll ever want to do something.
0
 
sghosh092199Commented:
anmadhu,

Incorporate the following changes:

ServerSocket serverSocket = new ServerSocket(9000);
while (true)
{
// Bytes have arrived. The accept() blocks itself till
// no connection is made
Socket socket = serverSocket.accept();
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();
// Read the Bytes and do processing
 byte[] b = new byte[1000];
 in.read(b);
 // The bytes are available in byte array b
}



0
 
anmadhuAuthor Commented:
Mr Sqhosh, May i get your personal mail id.
My mail id: anmadhu@yahoo.com
May i get your mail id?
Thanking u for your Best Cooperation
madhu
0
 
sghosh092199Commented:
You can reach me at sghosh@entigo.com
0
 
CleanupPingCommented:
anmadhu:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 6
  • 5
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now