Results 1 to 6 of 6

Thread: Upload Stream from iOS Device

  1. #1
    Join Date
    Dec 2011
    Posts
    6

    Default 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

    <Root>
    <Application>
    <Connections>
    <AutoAccept>true</AutoAccept>
    <AllowDomains></AllowDomains>
    </Connections>

    <Streams>
    <StreamType>live</StreamType>
    <StorageDir>${com.wowza.wms.context.VHostConfigHome}/content</StorageDir>
    <KeyDir>${com.wowza.wms.context.VHostConfigHome}/keys</KeyDir>
    <!-- LiveStreamPacketizers (separate with commas): cupertinostreamingpacketizer, smoothstreamingpacketizer, sanjosestreamingpacketizer, cupertinostreamingrepeater, smoothstreamingrepeater, sanjosestreamingrepeater -->
    <LiveStreamPacketizers>cupertinostreamingpacketizer,smoothstreamingpacketizer,sanjosestreamingpacket izer</LiveStreamPacketizers>
    <!-- Properties defined here will override any properties defined in conf/Streams.xml for any streams types loaded by this application -->
    <Properties>

    <Property>
    <Name>MidRoll</Name>
    <Value>mp4:Extremists.m4v</Value>
    </Property>

    <Property>
    <Name>FeatureBreak</Name>
    <Value>10000</Value>
    <Type>Integer</Type>
    </Property>

    <Property>
    <Name>forceInterleaved</Name>
    <Value>true</Value>
    <Type>Boolean</Type>
    </Property>

    </Properties>
    </Streams>
    <!-- HTTPStreamers (separate with commas): cupertinostreaming, smoothstreaming, sanjosestreaming, dvrchunkstreaming -->
    <HTTPStreamers>cupertinostreaming,smoothstreaming,sanjosestreaming</HTTPStreamers>

    <SharedObjects>
    <StorageDir></StorageDir>
    </SharedObjects>
    <Client>
    <IdleFrequency>-1</IdleFrequency>
    <Access>
    <StreamReadAccess>*</StreamReadAccess>
    <StreamWriteAccess>*</StreamWriteAccess>
    <StreamAudioSampleAccess></StreamAudioSampleAccess>
    <StreamVideoSampleAccess></StreamVideoSampleAccess>
    <SharedObjectReadAccess>*</SharedObjectReadAccess>
    <SharedObjectWriteAccess>*</SharedObjectWriteAccess>
    </Access>
    </Client>
    <RTP>

    <Authentication>
    <PublishMethod>digest</PublishMethod>
    <PlayMethod>none</PlayMethod>
    </Authentication>
    <!-- RTP/Authentication/[type]Methods defined in Authentication.xml. Default setup includes; none, basic, digest -->

    <!-- RTP/AVSyncMethod. Valid values are: senderreport, systemclock, rtptimecode -->
    <AVSyncMethod>senderreport</AVSyncMethod>
    <MaxRTCPWaitTime>12000</MaxRTCPWaitTime>
    <IdleFrequency>75</IdleFrequency>
    <RTSPSessionTimeout>90000</RTSPSessionTimeout>
    <RTSPMaximumPendingWriteBytes>0</RTSPMaximumPendingWriteBytes>
    <RTSPBindIpAddress></RTSPBindIpAddress>
    <RTSPConnectionIpAddress>0.0.0.0</RTSPConnectionIpAddress>
    <RTSPOriginIpAddress>127.0.0.1</RTSPOriginIpAddress>
    <IncomingDatagramPortRanges>*</IncomingDatagramPortRanges>
    <!-- Properties defined here will override any properties defined in conf/RTP.xml for any depacketizers loaded by this application -->
    <Properties>
    </Properties>
    </RTP>

    <Modules>
    <Module>
    <Name>My Module</Name>
    <Description>This is My IPhoneWowzaStreamServer</Description>
    <Class>com.wowza.iphone.IPhoneWowzaModule</Class>
    </Module>
    </Modules>
    </Application>
    </Root>

    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 dataWithContentsOfFilet]];
    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:@"helloegkjvdsfnvkeljsnfbvekjrnbverggjknefnvkeljsnfbvekjrnbjkkerttrtnfgnregjknerkgjenrgkje rngkjsdasd"];

    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

  2. #2
    Join Date
    Dec 2007
    Posts
    21,962

    Default

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

    For a ready solution, take a look at Livu:
    http://www.wowza.com/forums/content....h-Wowza-Server

    Richard

  3. #3
    Join Date
    Dec 2011
    Posts
    6

    Default

    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

  4. #4
    Join Date
    Dec 2011
    Posts
    6

    Default

    Hi Richard,

    I was looking into livestream : "http://www.wowza.com/forums/content.php?123". 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

  5. #5

    Default

    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.

  6. #6
    Join Date
    Dec 2011
    Posts
    6

    Default

    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

Similar Threads

  1. iOS Device Failing to Start Mid Stream
    By glennolsen in forum Live Streaming and Encoders
    Replies: 2
    Last Post: 05-25-2014, 01:23 PM
  2. Replies: 1
    Last Post: 02-21-2014, 07:43 AM
  3. Determine upload bandwidth to ios
    By kmax1940 in forum General Forum
    Replies: 2
    Last Post: 09-23-2013, 09:09 AM
  4. iOS device plays HLS stream encoded on DM365 only if it receives the first segment
    By zzzZzzz in forum Live Streaming and Encoder Discussion
    Replies: 1
    Last Post: 11-08-2011, 07:48 PM

Posting Permissions

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