Hoang Hai

+ Follow
since Dec 02, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hoang Hai

to send out media stream to any IPaddr+port, there are sample code in JMFSolutions, I guess you would have known this.
There's no specific to send them to DSS4, the problem is :
+ how to make DSS4 reflect/relay
( provoke DSS4 to send out the streams running into it ).
for media streams coming out of DSS4 (we have IP and port), we can use JMF to receive and play them
Until now, I just can send audio to DSS4 and use QuickTime to play it in the simplest way .
19 years ago
I post this for my specific case: use JMF to send/receive media streams and Darwin Streaming Server as an intermediate broadcaster.
I just work out a little how to create SDP file that DSS4 and QuickTime player can use to reflect my stream (just the JMF audio rtp transmitter is my own built application ;( )
SDP file : e.g : port6k.sdp
c=IN IP4
m=audio 6000 RTP/AVP
that will work in conditions :
1. audio stream format is those of DVI4(Mono, 8000/11025/22050Hz), ULAW2:1 8000Hz, Mono.
2.the transmitter send rtp audio streams of the above formats to port 6000 (this value is not important, you can change but should not cause conflict to known ports )
3. the sdp file must be placed in the movie directory (/usr/local/movies/ by default )
4. till now, I'm just able to play the reflected stream by QuickTime player or via an EMBED tag in a webpage that reference to the sdp above.
for QT player :
open URL :
rtsp://DSSdomain/port6k (the sdp file name, the extension .sdp is not important and obmittable )
But this is hand-editing, I'd like to know if there's a professional way to create SDP file ( use the sdp package of JMF )
19 years ago
Hi everybody,
I'm working with streaming audio, so I need to create a SDP file for every transmission.
I haven't found a tool in the JMF API documentation to do this.
Could any one tell me how to do it ?
Thanks in advance
19 years ago
Hi Tom,
- you can use Manager.createDataSource(URL) with URL is the URL of your media file.
- Then call getDuration() on the DataSource you've just created.
- see Duration API to use getSeconds() or getNanoseconds() methods.
- There's an easy way to get a File object (and then call toURL() to pass it to createDataSource method ), that's to use JFileChooser (swing).
experiment to get the correct duration of the media file, that's the thing you have to do after all above's done (I tried the above but the duration I got is not as I want, but I'm busy now to do further ;p )
good luck
19 years ago
Hi Tom,
I didn't try it, but I see that DataSource implements Duration, and Duration has method
getDuration : ( cut n paste from JMF2.1.1 API documentation )
public Time getDuration()
Get the duration of the media represented by this object. The value returned is the media's duration when played at the default rate. If the duration can't be determined (for example, the media object is presenting live video) getDuration returns DURATION_UNKNOWN.
A Time object representing the duration or DURATION_UNKNOWN.
Hope this helps
19 years ago
For the examples AVReceive2 and AVTransmit2 from JMF Solutions page :
The conflict happens when a rtpmanager tries initializing a SessionAddress with a port that's already used in an initialized rtpManager.
So I think if the transmitter for example, transmit to port 4000, if could make the receiver listen (connect) to that port through another port (e.g., 5000), the conflict won't happen
And I tried this way :
- The AVTransmit2 code remains unchanged.
- AVReceive2 : because the RTPManager mgrs[ i] initialize the localAddr, so I fixed the port (5000) in its construction lines.
so, when I run :
- java AVTransmit2 file:./sound.mp3 4000
so, localAddr=destAddr=,
DataPort=4000, ControlPort=4001 for both addresses
- java AVReceive2
the port 4000 just exists in the SessionAddress destAddr that's transfered in to addTarget method of mgrs[ i] in AVReceive2.
i.e: localAddr=destAddr=
local DataPort=5000
local ControlPort=5001
destination DataPort=4000,
destination ControlPort=4001
There's no more conflict , but... AVReceive2 can't regcognize any ReceiveStream or Participant ;((.
Anyone could tell me to connect to port 4000 indirectly though port 5000 like that, was I right or not ?
Thanks for reading
note : I post this message also in http://forum1.java.sun.com/thread.jsp?forum=28&thread=142384
...hoping for some help while working around n around n around.... ;D
19 years ago

Hi Stan,
I got a trouble with JMF that seems similar to your 1st problem in http://www.javaranch.com/ubb/Forum45/HTML/000120.html
But after seeing your solution, I couldn't resolve my problem ;((
I'm a newbie to JMF, and studying the book Java How to program, 4th edition.
There're some sample programs that I'll atach :
- a RTPServer that stream media to a host with a port. (RTPServerTest to run it)
- a SimplePlayer program to play either a media file or a media locator in general.
As I understand (follow the book), I can user RTPServer to streams a mp3 file to the localhost :, port 4000
and use the SimplePlayer to play that stream (with the media locator : "rtp://" )
But :
* When I run the 2 applications on the same machine :
- which applications that starts later will encounter the problem : Can't open local data port : 4000
* When I run them on 2 machines :
- Both run smoothly (i.e. no error messages displayed in the console ), but I can't hear any sound !!!
I tried to change the port to 49151 like your solution, but on the same machine, the " can't open port" error happens as usual (
I'm really confused.
Now I'll keep sudying JMF from the sun JMF'guide, but if you can give me some advice , or even test these programs for me, it'll help me much )
Many thanks in advance
I submit my problem here : JMF - RTPServer n Player - port problem
I'm also trying to use the Darwin Streaming Server (an Apple opensource RTP/RTSP server : http://www.publicsource.apple.com/projects/streaming/)
with the intention to make it receive the audio streams from my future Java application, then distribute it (multicast/unicast). then I'll build another
application to connect and play those streams
Any idea or experience would be appreciated )
Thanks again, Stanley
Hoang Hai
19 years ago
Hi evry body,
Did anyone read the book Java How to program, 4th edition,(chapter 22) or building the streaming Java applications ?
I run a sapmle program to stream a mp3 , and another to capture and play it.
* on the same machine :
- RTPServer streams the output to, port 4000
- Player open the locator : "rtp://"
but the program that starts later counter a problem while accessing port 4000: "can't open local data port: 4000"
* on 2 different machines :
- RTPServer streams the output to its local IP addr,, port 4000
- Player open locator : rtp://rtpservermachine_IPaddr:4000/audio
all the 2 run smoothly (i.e. no error messsages displayed), but I can't hear any sound ;(.
Any idea and advice would be appreciated )
Thanks for reading
Hoang Hai
20 years ago