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

**URL:** https://community.wowza.com/t/how-to-publish-stream-on-ios-over-rtsp-via-rtp/46537
**Category:** Wowza Streaming Engine
**Created:** [January 26, 2016, 4:00pm UTC](https://community.wowza.com/t/how-to-publish-stream-on-ios-over-rtsp-via-rtp/46537 "2016-01-26T16:00:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Byeongwook\_Park](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@Byeongwook\_Park](https://community.wowza.com/u/Byeongwook_Park)
#### Post date: [January 26, 2016, 4:00pm UTC](https://community.wowza.com/t/how-to-publish-stream-on-ios-over-rtsp-via-rtp/46537/1 "2016-01-26T16:00:49Z")

</div>

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.

- 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.

- 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

```auto
#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.

---

<div class="post-metadata">

### Author: ![Michelle\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/michelle_b/32/394_2.png) [@Michelle\_B](https://community.wowza.com/u/Michelle_B)
#### Post date: [March 21, 2016, 9:12am UTC](https://community.wowza.com/t/how-to-publish-stream-on-ios-over-rtsp-via-rtp/46537/2 "2016-03-21T09:12:40Z")

</div>

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](https://www.wowza.com/docs/how-to-record-incoming-streams-for-debugging-purposes-mpeg-ts-rtp) for troubleshooting purposes, and send this recording to us via a [support ticket](https://www.wowza.com/support/open-ticket).

Michelle
