Results 1 to 2 of 2

Thread: How to publish stream on iOS over RTSP via RTP?

  1. #1
    Join Date
    Jan 2016
    Posts
    1

    Default How to publish stream on iOS over RTSP via RTP?

    I'm developing publish video app for iOS
    H264 / AAC Encoder is developed using VideoToolbox and AudioToolbox
    I was checked RTP transport is correctly run.

    I was found some issue.

    <RTP transport>
    - We must transport stream encapsulate format "MPEG4" or "MPEG2-TS". Raw H264 or AAC is not playable in other player. But server is successfully receive the stream packet.

    <RTSP>
    - This is my question.
    - I'm trying RECORD method. Server has successfully created stream. But not received stream yet.
    - How to transport stream? Is there some parameter exist on RTSP?

    This is my code


    #pragma mark - RTSP Handshake
    
    - (void)sendANNOUNCE
    {
        NSString* rtpHeader = [NSString stringWithFormat:@"ANNOUNCE %@ RTSP/1.0\r\n", [NSString stringWithFormat:@"rtsp://%@:%ld/live/mp4:%@", self.address, self.port, self.streamName]];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"CSeq: %d\r\n",cseq++];
        if(self.sessionid != nil) rtpHeader = [rtpHeader stringByAppendingFormat:@"Session: %@\r\n", self.sessionid];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"Content-Type: application/sdp\r\n"];
    //    rtpHeader = [rtpHeader stringByAppendingFormat:@"Content-Length: 0\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"\r\n"];
        NSLog(@"%@", rtpHeader);
        rtspSeq = SEQ_ANNOUNCE;
        [self sendMessage:[rtpHeader dataUsingEncoding:NSUTF8StringEncoding] tag:SEQ_ANNOUNCE];
    }
    
    - (void)sendSETUP
    {
        NSString* rtpHeader = [NSString stringWithFormat:@"SETUP %@ RTSP/1.0\r\n", [NSString stringWithFormat:@"rtsp://%@:%ld/live/mp4:%@", self.address, self.port, self.streamName]];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"CSeq: %d\r\n",cseq++];
        if(self.sessionid != nil) rtpHeader = [rtpHeader stringByAppendingFormat:@"Session: %@\r\n", self.sessionid];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"Transport: RTP/AVP;unicast;client_port=%d\r\n", RTP_PORT];
    //    rtpHeader = [rtpHeader stringByAppendingFormat:@"Content-Base: %@\r\n", [NSString stringWithFormat:@"rtsp://%@:%ld/live/mp4:%@", self.address, self.port, self.streamName]];
        rtpHeader = [rtpHeader stringByAppendingString:@"Content-Type: application/sdp\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"m=video 0 RTP/AVP 96\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=control:streamid=0\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=rtpmap:96 MP4V-ES/5544\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=mimetype:string;\"video/MP4V-ES\"\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=AvgBitRate:integer;550000\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"m=audio 0 RTP/AVP 97\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=control:streamid=1\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=rtpmap:97 mpeg4-generic/32000/2\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=mimetype:string;\"audio/mpeg4-generic\"\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"a=AvgBitRate:integer;64000\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"\r\n"];
        NSLog(@"%@", rtpHeader);
        rtspSeq = SEQ_SETUP;
        [self sendMessage:[rtpHeader dataUsingEncoding:NSUTF8StringEncoding] tag:SEQ_SETUP];
    }
    
    - (void)sendRECORD
    {
        NSString* rtpHeader = [NSString stringWithFormat:@"RECORD %@ RTSP/1.0\r\n", [NSString stringWithFormat:@"rtsp://%@:%ld/live/mp4:%@", self.address, self.port, self.streamName]];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"CSeq: %d\r\n",cseq++];
        if(self.sessionid != nil) rtpHeader = [rtpHeader stringByAppendingFormat:@"Session: %@\r\n", self.sessionid];
        rtpHeader = [rtpHeader stringByAppendingString:@"Content-Type: application/sdp\r\n"];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"\r\n"];
        NSLog(@"%@", rtpHeader);
        rtspSeq = SEQ_RECORD;
        [self sendMessage:[rtpHeader dataUsingEncoding:NSUTF8StringEncoding] tag:SEQ_RECORD];
    }
    
    - (void)sendTEARDOWN
    {
        NSString* rtpHeader = [NSString stringWithFormat:@"TEARDOWN %@ RTSP/1.0\r\n", [NSString stringWithFormat:@"rtsp://%@:%ld/live/mp4:%@", self.address, self.port, self.streamName]];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"CSeq: %d\r\n",cseq++];
        if(self.sessionid != nil) rtpHeader = [rtpHeader stringByAppendingFormat:@"Session: %@\r\n", self.sessionid];
        rtpHeader = [rtpHeader stringByAppendingFormat:@"\r\n"];
        NSLog(@"%@", rtpHeader);
        rtspSeq = SEQ_TEARDOWN;
        [self sendMessage:[rtpHeader dataUsingEncoding:NSUTF8StringEncoding] tag:SEQ_TEARDOWN];
    }
    I think some rtsp header is wrong.
    I will transport real video/audio data via RTP.

  2. #2
    Join Date
    Jan 2015
    Posts
    357

    Default

    Hi,

    - I'm trying RECORD method. Server has successfully created stream. But not received stream yet.
    - How to transport stream? Is there some parameter exist on RTSP?
    In your Incoming Stream page, do you see inbound network data for your stream? You may also want to get a debug recording of the incoming stream for troubleshooting purposes, and send this recording to us via a support ticket.

    Michelle

Similar Threads

  1. RTSP over RTP over HTTP with rtp-live connection not closed
    By Moonlightt in forum Live Streaming and Encoders
    Replies: 2
    Last Post: 02-20-2014, 06:32 AM
  2. record streaming from android phone with a sdp file via rtp over tcp
    By luliangfeng in forum Live Streaming and Encoder Discussion
    Replies: 1
    Last Post: 11-20-2012, 06:19 AM

Posting Permissions

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