Upload Stream from iOS Device

Hi all,

I am newbie to Wowza. I am trying to upload the stream to Wowza server using rtmp protocol.

here is my Java code :

public void uploadStream( IClient client, RequestFunction function, AMFDataList params ) throws IOException

{

WMSLogger log = getLogger();

log.info( "WMSLogger ");

String streamName = params.getString(PARAM1);

log.info( "streamName : "+streamName);

BASE64Decoder decoder = new BASE64Decoder();

byte[] decodedBytes = decoder.decodeBuffer(streamName);

IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);

Publisher publisher = Publisher.createInstance(vhost, “ios”);

publisher.setFileExtension(“mp4”);

publisher.setStreamType(“live”);

publisher.publish(“myStream1”, “append”);

AMFPacket amfPacket = new AMFPacket();

amfPacket.addData(decodedBytes, amfPacket.getSize(), decodedBytes.length);

publisher.addVideoData(amfPacket.getData(), amfPacket.getSize(), amfPacket.getTimecode());

log.info( "publisher.getFileExtension : "+publisher.getFileExtension());

String streamName1 = params.getString(PARAM1);

String fileName = “”;

IApplicationInstance appInstance = client.getAppInstance();

MediaStreamMap streams = appInstance.getStreams();

IMediaStream stream = streams.getStream(streamName1);

if (stream != null)

{

log.info(“stram is not empty”);

}

}

Application.xml

true

live

${com.wowza.wms.context.VHostConfigHome}/content

${com.wowza.wms.context.VHostConfigHome}/keys

cupertinostreamingpacketizer,smoothstreamingpacketizer,sanjosestreamingpacketizer

MidRoll

mp4:Extremists.m4v

FeatureBreak

10000

Integer

forceInterleaved

true

Boolean

cupertinostreaming,smoothstreaming,sanjosestreaming

-1

*

*

*

*

digest

none

senderreport

12000

75

90000

0

0.0.0.0

127.0.0.1

*

My Module

This is My IPhoneWowzaStreamServer

com.wowza.iphone.IPhoneWowzaModule

And here are the server logs:

INFO session connect 0:0:0:0:0:0:0:1%0 -

INFO server comment - WMSLogger

INFO server comment - streamName : AAAAGGZ0eXBNNFYgAAACAGlzb21pc28yAAAACGZyZWUAAB50bWRhdAAAAbMAEAcAAAG2EGCxgpm38bbfxtt/G238bbfxtt/G2

INFO stream create - -

INFO stream publish myStream1 -

INFO stream record myStream1 -

INFO stream recordstop myStream1 -

INFO server comment - LiveStreamPacketizerSanJose.init[ios/definst/myStream1]: chunkDurationTarget: 10000

INFO server comment - LiveStreamPacketizerSanJose.init[ios/definst/myStream1]: chunkDurationTolerance: 500

INFO stream unpublish myStream1 -

INFO server comment - LiveStreamPacketizerSanJose.init[ios/definst/myStream1]: playlistChunkCount:4

INFO stream destroy myStream1 -

INFO server comment - MediaStreamMap.getLiveStreamPacketizer: Create live stream packetizer: sanjosestreamingpacketizer:myStream1

INFO server comment - stream : null

INFO server comment - LiveStreamPacketizerCupertino.init[ios/definst/myStream1]: chunkDurationTarget: 10000

INFO server comment - LiveStreamPacketizerCupertino.init[ios/definst/myStream1]: chunkDurationTolerance: 500

INFO server comment - SanJosePacketHandler.startStream[ios/definst/myStream1]

INFO server comment - LiveStreamPacketizerCupertino.init[ios/definst/myStream1]: audioGroupCount: 3

INFO server comment - LiveStreamPacketizerCupertino.init[ios/definst/myStream1]: playlistChunkCount:3

INFO server comment - MediaStreamMap.getLiveStreamPacketizer: Create live stream packetizer: cupertinostreamingpacketizer:myStream1

INFO server comment - CupertinoPacketHandler.startStream[ios/definst/myStream1]

INFO server comment - MediaStreamMap.getLiveStreamPacketizer: Create live stream packetizer: smoothstreamingpacketizer:myStream1

INFO server comment - SanJosePacketHandler.resetStream[ios/definst/myStream1]

INFO server comment - CupertinoPacketHandler.resetStream[ios/definst/myStream1]

INFO server comment - LiveStreamPacketizerSmoothStreaming.startStream[ios/definst/myStream1]

INFO server comment - LiveStreamPacketizerSmoothStreaming.resetStream[ios/definst/myStream1]

INFO server comment - MediaStreamMap.removeLiveStreamPacketizer[ios/definst/myStream1]: Destroy live stream packetizer: smoothstreamingpacketizer

INFO server comment - MediaStreamMap.removeLiveStreamPacketizer[ios/definst/myStream1]: Destroy live stream packetizer: cupertinostreamingpacketizer

INFO server comment - MediaStreamMap.removeLiveStreamPacketizer[ios/definst/myStream1]: Destroy live stream packetizer: sanjosestreamingpacketizer

iPhone-code:

NSString *method = [NSString stringWithString:@“uploadStream”];

NSString*pt = [[NSBundle mainBundle] pathForResource:@“Screen Recording 17” ofType:@“mp4”];

NSMutableData *videoData = [NSMutableData dataWithData:[NSData dataWithContentsOfFile:pt]];

NSMutableData *stringData = [NSMutableData dataWithData:[@“Screen Recording 17” dataUsingEncoding:NSUTF8StringEncoding]];

NSLog(@"%d",stringData.length);

Base64Transcoder *base64Transcoder = [[Base64Transcoder alloc] init];

NSString *base64String = [[base64Transcoder base64EncodedStringfromData:videoData

WithNewLineValidation:[NSNumber numberWithBool:YES]] copy];

// [args addObject:@“helloegkjvdsfnvkeljsnfbvekjrnbverggjknefnvkeljsnfbvekjrnbjkkerttrtnfgnregjknerkgjenrgkjerngkjsdasd”];

for (int length = 0; length < [base64String lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; length++) {

NSMutableArray *args = [NSMutableArray array];

int offset = length;

length = length+97;

[args addObject:[base64String substringWithRange:NSMakeRange(offset,length)]];

// NSLog(@“invoke : %@ %d”,args, length);

[socket invoke:method withArgs:args];

args = nil;

sleep(4);

}

But the streams are not getting publish.

Thanks in advance

You can’t make RTMP NetConnection.call from iOS device, as far as I know.

For a ready solution, take a look at Livu:

https://www.wowza.com/docs/how-to-use-livu-video-broadcasting-ios-app-with-wowza-media-server

Richard

Hi Ankit,

That URL: “http://[wowza-address]:8086/livestreamrecord?app=live&streamname=myStream&acti on=startRecording”

It just turns on recording for that stream name using the LiveStreamRecord addon.

If you can create an iOS app that can publish an RTMP stream to Wowza (and then played using the LiveVideoStreaming Wowza example) then you will be able to use the LiveStreamRecord addon.

However, troubleshooting custom iOS apps is beyond the scope of the Wowza support forums.

Hi Richard,

I have tried to follow up the Livu app. The main purpose is to broadcast the video from my iphone to my wowza server. I am trying to create the sample app.

Can you please share the Wowza based server side sample code, so that I could create the test app where we can use the http cupertino stream for uploading stream to wowza server and to download the same to our iphone app.

Thanks

Ankit

Hi Richard,

I was looking into livestream : “https://www.wowza.com/docs/how-to-record-live-streams-httplivestreamrecord”. In that reference app, they had provided the following url :

“http://[wowza-address]:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording”

But, I am not getting the idea, how could we upload the streams in Objective-c, as it is accepting the query format and there is no field where we can upload the video in binary format, and in general, we are uploading the videos in chunk in http body.

Please help.

Thanks

Ankit

Hi Randall,

Thanks for this information.

I have seen most of the examples with client-section written in Flash-ActionScript. I basically want to integrate the Wowza server video broadcasting from Mobile platforms like Android and IPhone where we are basically using HTTP protocol. And it could be great if we can get atleast a single sample application where we can do data communication from mobile devices to Server for broadcasting using HTTP Protocol.

It is quite easy to do streaming from Wowza to Mobile devices due to Cuppertino streaming, but we are facing issues in broadcasting.

Thanks

Ankit