Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

rtp/rtsp - mp3 on demand ?

[es] :: Java :: rtp/rtsp - mp3 on demand ?

[ Pregleda: 2901 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

rapidlord
Vladan Markovic
dev
KG

Član broj: 10145
Poruke: 428
*.vdial.verat.net



+1 Profil

icon rtp/rtsp - mp3 on demand ?23.09.2004. u 17:54 - pre 238 meseci
Zdravo,

Dali neko moze da mi pomogne u ovome.
Treba da napravim server za striming mp3 muzike, java ima podrsku za to u Java Media Framework (JMF), RTP server/klijent i RTSP samo klijent podrsku.
RTSP za razliku od RTP ima kontrolu vracanja pauze ubrzavanja audio/videa ..., dali je sa RTP moguce da se uradi nesto slicno ili ste ograniceni samo na slusanje/gledanje bez ikakve kontrole.
Negde sam nalazio i slucaj RTP Server/RSTP klijent dali je ovaj slucaj bolji od RTP/RTP i u kom smislu.
Takodje me zanima dali moze da se strimuje MP3 fajl, dali RTP ima podrsku za njega.
Ako ima jos nesto da se doda rado bih cuo bilo sta sto bi malo razjasnilo ovu pricu.

Hvala.
 
Odgovor na temu

Sanjin_JMF
Mostar

Član broj: 130048
Poruke: 7
*.panorama.sth.ac.at.



Profil

icon Re: rtp/rtsp - mp3 on demand ?17.01.2007. u 23:35 - pre 210 meseci
Code:

import javax.media.*;
import javax.media.protocol.*;
import javax.media.control.*;

public class DKRTPServer implements ControllerListener {
    
    private String serverURL;
    private DataSource ds = null;
    private MediaLocator destination;
    private Processor p = null;
 
    
    DKRTPServer (String _serverURL, DataSource _ds){
        serverURL = _serverURL;
        ds = _ds;
        try {
            p = Manager.createProcessor(ds);
            p.addControllerListener(this);

            p.configure();
            
        }
         catch (Exception e){
             System.out.println(e);
        }
        
        String destinationURL = serverURL;
        destination = new MediaLocator(destinationURL);
    
    }


    public synchronized void controllerUpdate(ControllerEvent evt){
        if (evt instanceof ConfigureCompleteEvent) {
            setTrackFormat(p);
            p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW_RTP));

            p.realize(); 
        } 
        else if (evt instanceof RealizeCompleteEvent) {
            transmit(p);
        } 
        else if (evt instanceof EndOfMediaEvent) {
            // System.exit(0);
        } 
        else {

        }
        
    }
    
    private void setTrackFormat(Processor p) {
        // Get the tracks from the processor
        TrackControl [] tracks = p.getTrackControls();
        
        // Do we have atleast one track?
        if (tracks == null || tracks.length < 1) {
            System.out.println("Couldn't find tracks in processor");
            System.exit(1);
        }
        
        // Set the output content descriptor to RAW_RTP
        // This will limit the supported formats reported from
        // Track.getSupportedFormats to only valid RTP formats.
        ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
        p.setContentDescriptor(cd);
        
        Format supported[];
        Format chosen;
        boolean atLeastOneTrack = false;
        
        // Program the tracks.
        for (int i = 0; i < tracks.length; i++) {
            Format format = tracks[i].getFormat();
            if (tracks[i].isEnabled()) {
            
            supported = tracks[i].getSupportedFormats();
            for (int n = 0; n < supported.length; n++)
                System.out.println("Supported format: " + supported[n]);
            
            // We've set the output content to the RAW_RTP.
            // So all the supported formats should work with RTP.
            // We'll just pick the first one.
            
            if (supported.length > 0) {
                chosen = supported[0];
                tracks[i].setFormat(chosen);
                System.err.println("Track " + i + " is set to transmit as:");
                System.err.println("  " + chosen);
                atLeastOneTrack = true;
            } else
                tracks[i].setEnabled(false);
            } else
            tracks[i].setEnabled(false);
        }
    }
 
    private void transmit(Processor p) {
        try {
            DataSource output = p.getDataOutput();
            DataSink rtpSink;
            rtpSink = Manager.createDataSink(output, destination);
            System.out.println("Sink content type: " + rtpSink.getContentType());
            System.out.println("Sink media type: " + rtpSink.getOutputLocator().toString());
            rtpSink.open();
            rtpSink.start();
            p.start();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}


[Ovu poruku je menjao hyle dana 18.01.2007. u 00:46 GMT+1]
 
Odgovor na temu

[es] :: Java :: rtp/rtsp - mp3 on demand ?

[ Pregleda: 2901 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.