Search code examples
ioscordovavideo-streamingcocoahttpserver

Can I deploy Cocoa http server with my phonegap/cordova IOS app


I have an IOS app built with phonegap/cordova 2.1.0 and I would like to use a cocoahttpserver running with the app so that encrypted locally stored video can be streamed from the cocoahttpserver to the app.

This may seem like overkill and please advise me if it is but the reason I want to do this is so that I can stream encrypted segmented video which has been prepared using Apple's mediafilesegmenter and which is locally stored on the device.

I have already tried to play the encrypted video by using a video tag to call the .m3u8 file but this only works over http and not from the local filesystem.

Could you please point me in the right direction to deploy the cocoahttpserver with my app.

Many thanks


Solution

  • I have now successfully integrated phonegap/cordova and cocoahttpserver into one ios App. These were the steps:

    1) place the cocoahttpserver project in the phonegap project, for example in Externals/cocoahttpserver and keep the whole project there so it can be easily updated from the master repository at a later date if needed.

    2) Open the phonegap project in Xcode and add the Externals directory to the header search paths by clicking on the phonegap project target, and adding 'Externals' as a recursive path in 'Header Search Paths'

    3) In the target build phases for the phonegap app add all needed .m files from cocoahttpserver in 'Compile Sources'. These are all the files in Core, Vendor and Samples/iPhoneHTTPServer. Do not add iPhoneHTTPServerAppDelegate.m or iPhoneHTTPServerViewController.m

    4) By looking at the iPhoneHTTPServerAppDelegate.m and the phonegap AppDelegate.m side by side try to merge the two together so that the server is instantiated in phonegap's AppDelegate.m Do not instantiate a iPhoneHTTPServerViewController.m as you won't need this blank view. Also I had to include standard Libraries libxml2.dlyb and Security.framework to my phonegap build phases

    5) In your AppDelegate.m you can set the server web path to any directory you like. Make sure this directory is copied on build

    Hope this helps someone :)