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

Using Java to record RTP Streams to file

I am looking for a way to record RTP streams using Java. I am not an experienced Java programmer, mostly .net. I have been looking at the AvReceive2.java program and it works well for receiving RTP streams however, I cannot see a way for recording that stream into a file. Can anyone advise?

  • 2
1 Solution
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
I think here is a complete working solution for the same

Below is a program to store RTP stream from network to a file

 public void update(ReceiveStreamEvent event) {
         // find the source session manager for this event
         SessionManager source = (SessionManager)event.getSource();
         // create a filewriter datasink if a new ReceiveStream
         // is detected
         if (event instanceof NewReceiveStreamEvent) {
             String cname = "Java Media Player";
             ReceiveStream stream = null;
             try {
                 // get the ReceiveStream
                 stream =((NewReceiveStreamEvent)event)
                 Participant part = stream.getParticipant();
                 // get the ReceiveStream datasource
                 DataSource dsource = stream.getDataSource();
                 // hand this datasource over to a file datasink
                 MediaLocator f = new MediaLocator("file://foo.au");
                 Manager.createDataSink(dsource, f);    
             } catch (Exception e) {
                 System.err.println("newReceiveStreamEvent exception " 
                                    + e.getMessage());

for more information u can see this tutorial
pHOdATAuthor Commented:
Thanks for the info I couldn't find a code example to save myself and this is exactly what I needed.
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now