Solved

streams

Posted on 2001-06-28
23
386 Views
Last Modified: 2010-08-05
How can i pass the streams from one program to another program
0
Comment
Question by:anmadhu
  • 6
  • 6
  • 5
  • +5
23 Comments
 
LVL 3

Expert Comment

by:rjackman
ID: 6237065
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
 

Expert Comment

by:rameshnut
ID: 6237264
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
 
LVL 1

Expert Comment

by:gtloafer
ID: 6237319
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
 
LVL 1

Expert Comment

by:gtloafer
ID: 6237322
Sorry I dont think I was clear there ...when I said object I meant the stream object
0
 
LVL 2

Expert Comment

by:jorj
ID: 6237500
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
 

Author Comment

by:anmadhu
ID: 6237823
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
 
LVL 2

Expert Comment

by:jorj
ID: 6237913
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
 

Author Comment

by:anmadhu
ID: 6238058
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
 
LVL 2

Expert Comment

by:jorj
ID: 6238121
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
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6239645
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
 
LVL 1

Expert Comment

by:viswa081400
ID: 6239681
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:jorj
ID: 6240941
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
 

Author Comment

by:anmadhu
ID: 6247955
Mr Sghosh,  your correct Sir.
How can i do it? could  u please explain me with some simple program.
Thanking u
madhu
0
 
LVL 2

Expert Comment

by:jorj
ID: 6248095
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
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6250290
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
 

Author Comment

by:anmadhu
ID: 6252374
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
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6253821
Who is the addresse?
0
 

Author Comment

by:anmadhu
ID: 6254438
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
 
LVL 2

Expert Comment

by:jorj
ID: 6255465
:) 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
 
LVL 3

Accepted Solution

by:
sghosh092199 earned 300 total points
ID: 6256636
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
 

Author Comment

by:anmadhu
ID: 6258869
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
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6259534
You can reach me at sghosh@entigo.com
0
 

Expert Comment

by:CleanupPing
ID: 9062013
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

757 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