×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    RTSP streaming(This Thread is closed)

    This thread has been closed.
    Last edited by curious316; 2008-05-08 at 06:27.

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Re: RTSP streaming problem!!!!!!

    class RTPSourceStream implements SourceStream {

    private RTSPProtocolHandler handler;

    private InputStream is;
    private OutputStream os;

    private DatagramConnection socket;

    public RTPSourceStream(String address) throws IOException {

    // create the protocol handler and set it up so that the
    // application is ready to read data

    // create a socketconnection to the remote host
    // (in this case I have set it up so that its localhost, you can
    // change it to wherever your server resides)
    SocketConnection sc =
    (SocketConnection)Connector.open("socket://localhost:554");

    // open the input and output streams
    is = sc.openInputStream();
    os = sc.openOutputStream();

    // and initialize the handler
    handler = new RTSPProtocolHandler(address, is, os);

    // send the basic signals to get it ready
    handler.doDescribe();
    handler.doSetup();
    }

    public void start() throws IOException {

    // open a local socket on port 8080 to read data to
    socket = (DatagramConnection)Connector.open("datagram://:8080");

    // and send the PLAY command
    handler.doPlay();
    }

    public void close() throws IOException {

    if(handler != null) handler.doTeardown();

    is.close();
    os.close();
    }

    public int read(byte[] buffer, int offset, int length)
    throws IOException {

    // create a byte array which will be used to read the datagram
    byte[] fullPkt = new byte[length];

    // the new Datagram
    Datagram packet = socket.newDatagram(fullPkt, length);

    // receive it
    socket.receive(packet);

    // extract the actual RTP Packet's media data in the requested buffer
    RTPPacket rtpPacket = getRTPPacket(packet, packet.getData());
    buffer = rtpPacket.getData();

    // debug
    System.err.println(rtpPacket + " with media length: " + buffer.length);

    // and return its length
    return buffer.length;
    }

    // extracts the RTP packet from each datagram packet received
    private RTPPacket getRTPPacket(Datagram packet, byte[] buf) {

    // SSRC
    long SSRC = 0;

    // the payload type
    byte PT = 0;

    // the time stamp
    int timeStamp = 0;

    // the sequence number of this packet
    short seqNo = 0;


    // see http://www.networksorcery.com/enp/protocol/rtp.htm
    // for detailed description of the packet and its data
    PT =
    (byte)((buf[1] & 0xff) & 0x7f);

    seqNo =
    (short)((buf[2] << 8) | ( buf[3] & 0xff));

    timeStamp =
    (((buf[4] & 0xff) << 24) | ((buf[5] & 0xff) << 16) |
    ((buf[6] & 0xff) << 8) | (buf[7] & 0xff)) ;

    SSRC =
    (((buf[8] & 0xff) << 24) | ((buf[9] & 0xff) << 16) |
    ((buf[10] & 0xff) << 8) | (buf[11] & 0xff));


    // create an RTPPacket based on these values
    RTPPacket rtpPkt = new RTPPacket();

    // the sequence number
    rtpPkt.setSequenceNumber(seqNo);

    // the timestamp
    rtpPkt.setTimeStamp(timeStamp);

    // the SSRC
    rtpPkt.setSSRC(SSRC);

    // the payload type
    rtpPkt.setPayloadType(PT);

    // the actual payload (the media data) is after the 12 byte header
    // which is constant
    byte payload[] = new byte [packet.getLength() - 12];

    for(int i=0; i < payload.length; i++) payload [i] = buf[i+12];

    // set the payload on the RTP Packet
    rtpPkt.setData(payload);

    // and return the payload
    return rtpPkt;

    }

    public long seek(long where) throws IOException {
    throw new IOException("cannot seek");
    }

    public long tell() { return -1; }

    public int getSeekType() { return NOT_SEEKABLE; }

    public Control[] getControls() { return null; }

    public Control getControl(String controlType) { return null; }

    public long getContentLength() { return -1; }

    public int getTransferSize() { return -1; }

    public ContentDescriptor getContentDescriptor() {
    return new ContentDescriptor("audio/rtp");
    }
    }

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: RTSP streaming problem!!!!!!

    What's the exact problem with your code? Do you get Exceptions?

    Pit

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Re: RTSP streaming problem!!!!!!

    This thread had been closed.
    Last edited by curious316; 2008-05-08 at 06:21.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Re: RTSP streaming problem!!!!!!

    this thread has been closed.
    Last edited by curious316; 2008-05-08 at 06:21.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Re: RTSP streaming problem!!!!!!

    This thread has been closed.
    Last edited by curious316; 2008-05-08 at 06:21.

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    11

    Thread has been closed

    this thread has been closed
    Last edited by curious316; 2008-05-08 at 06:25.

Similar Threads

  1. Full-duplex audio streaming problem.
    By sadkes in forum Symbian
    Replies: 26
    Last Post: 2009-10-31, 08:48
  2. Handsets that support rtsp Video Streaming
    By dodsworthtx in forum Streaming and Video
    Replies: 3
    Last Post: 2008-04-22, 04:28
  3. RTSP streaming server problems
    By koveraasen in forum Streaming and Video
    Replies: 1
    Last Post: 2008-03-14, 09:18
  4. Streaming Player Stop/Start problem
    By finesoft in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2007-05-02, 12:22
  5. 3G : problem with RTSP on Nokia
    By taricola in forum Streaming and Video
    Replies: 2
    Last Post: 2007-04-19, 13:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×