Using Kaltura APIs in Native iOS Apps

by Eran.Kornblau

We have launched a new Objective C / Cocoa client library!

As you know, the Kaltura server provides an API that can be used to access all its functionality. These APIs are REST based (or REST-ful), this means that in order to execute an API call, you can just retrieve a URL, like you’d open a webpage.
Any language that can retrieve data from a URL can work with our system, meaning almost all possible programming languages.

However, in practice it would require a fair amount of effort to put together the correct URLs and to interpret the results that come back. This is where client libraries come in. These libraries are created by Kaltura in a variety of programming languages, to make it easier to use the Kaltura API.  Also, as experts in our own APIs, we create these in the best possible way, so everything should work faster and better.

All our client libraries are available to download here (or under http://[YourKalturaServer]/api_v3/testme/client-libs.php).

The new objective C library enables native iOS / Mac-OS applications to use the Kaltura API. As all other client libraries, this library is auto-generated, and therefore always updated with the latest API changes. This library is bundled with a static library Xcode project, for easy integration with existing projects.

Kaltura on iPhone

 


This is probably one of the best Kaltura client libraries to date, for the following reasons:

  1. Performance
    • The server response is parsed as it arrives rather than waiting for the entire response to arrive before parsing. For example, let’s assume the library is used to execute an API request asking for a big list of video titles. The response will be delivered back in several chunks. When the first chunk arrives, the client library can immediately start processing it, rather than waiting for the complete list. Depending on the size of the list this could result in a dramatic improvement in the speed experienced by the end user.
    • Support for asynchronous mode – allows the processing of API requests to occur in the background while the application UI remains active (without the need to spawn additional threads)
    • Support for multi-request – like all other Kaltura client libraries, this library has built-in support for multi-request. Multi-requests enable the client application to pack several API calls together, reducing the number of round trips to Kaltura.
    • Optimized to perform the bare minimum of memory copy operations, for maximum performance and minimum CPU utilization
  2. Bandwidth
    • Supports gzip compressed responses – the gzip compression significantly reduces the response size, saving both bandwidth and time (especially when using a slow connection)
  3. Memory usage
    • The library was optimized to reduce its memory consumption to the minimum, both the request and response parameters are stored in memory only once, while executing the API call
  4. Testing
    • Thoroughly tested with over 40 different test cases, including instrumentation for memory leak detection

Here you can download the library and create your first Kaltura powered iPhone application.

Stay tuned for more news and updates on the mobile front.

21 Responses to “Using Kaltura APIs in Native iOS Apps”

  1. Integrated this with my app, have some issues with tracking progress of uploads/downloads…

    Where is the forum for IOS Library?

  2. I Try a lot, I wants to get VideoID or Image ID which has genersting after uploading video & Images onto Kaltura Server, so Please help which method inside the Objective C code get Video & Images ID..?????????????

    • In the test code included with the objective C client library, there is a method that uploads an image / video – search for uploadEntryWithFileName in KalturaClientTester.m. This method returns the newly created Kaltura entry object, to get its id simply read the id property, for example:
      KalturaBaseEntry* imageEntry = [[self uploadEntryWithFileName:@"DemoImage" withFileExt:@"jpg" withMediaType:[KalturaMediaType IMAGE]];
      NSLog(@”Id is %@”, imageEntry.id);

  3. does this work on kaltura CE edition? I’m trying to get the kalturaclienttester to run in the simulator but it won’t start

    I’m kind of a noob at iOS dev

    • In general, the client library can work against a CE version, but some of the APIs we have on our SaaS environment may not be available yet on Kaltura CE. APIs that are supported in the CE version you are using, will work from the Objective C client (or any other client for that matter). Regarding the second question, try closing xCode, delete all the temporary folders it created (like xcuserdata) and start it again.

  4. nope still won’t start the simulator, it build’s successfully though.
    Ideally I would like to get the Kaltura.xcodeproj to login against my CE version but I keep getting login failures. I have changed all references to kaltura.com to my CE server.

    I’m using CE3 and iOS SDK for 5.1

    Thanks Eran

  5. I tested on iOS SDK 4.x, although I don’t think that’s the issue here. I already bumped into this issue of the simulator not starting, but after closing everything deleting the temp files and starting over, it worked for me.
    I didn’t understand though – how come you get login failures if you couldn’t get the simulator to launch ?

    Eran

  6. it’s a different xcode project, I figured it out it was set up to run the library not the application lol
    but the main project “Kaltura.xcodeproj” in the objc_client_library_02-04-2012 is set up to login against kaltura.com I’m trying to login to my CE server. it seems like it’s the administrator app for the server.

    the client tester project “KalturaClientTester.xcodeproj” just uploads a flv movie file to your server now I’m getting error

    KalturaClientTester[5442:f803] api call took 0.94 seconds
    Assertion failed: (self->_client.error == nil)

    it stops there, no video uploaded to the server
    url to server is correct

    :(

  7. Please check what the error code is, and on which line the assertion fails (there are many such error==nil assertions in the test code)
    My guess is that the client library tester uses APIs that are not yet available on CE…

  8. I think the media file is not being importet into the app, when I go through the files in the application’s folders I don’t see DemoVideo.flv anywhere
    though it’s in the Resources folder in the xocde project.

    seems to be this line:

    - (KalturaBaseEntry*)uploadEntryWithFileName:(NSString*)fileBase withFileExt:(NSString*)fileExt withMediaType:(int)mediaType
    {
    NSString* fileName = [NSString stringWithFormat:@"%@.%@", fileBase, fileExt];

    // return: object, params: object
    KalturaUploadToken* token = [[[KalturaUploadToken alloc] init] autorelease];
    token.fileName = fileName;
    token = [self->_client.uploadToken addWithUploadToken:token];
    assert(self->_client.error == nil);

    // return: object, params: object
    KalturaMediaEntry* entry = [[[KalturaMediaEntry alloc] init] autorelease];
    entry.name = fileName;
    entry.mediaType = mediaType;
    entry = [self->_client.media addWithEntry:entry];
    assert(self->_client.error == nil);<——————————this one

    thanks for helping Eran

  9. The media.add API is a pretty new API, it may not exist on your environment. You can check it by inspecting the value of self->_client.error in the debugger when the assertion fails. Or, by going to the testme console on your environment (URL is: /api_v3/testmeDoc/index.php, like http://www.kaltura.com/api_v3/testmeDoc/index.php). If you don’t have this API, you can still use the older APIs to upload entries, for example, invoke the media.upload action and then media.addFromUploadedFile.

  10. Ok I installed CE5 from SVN because the download package and the VMware packages are completely FUBAR. SVN version installs fine. I am able to upload but on some check after it upload it fails with:
    [KalturaClientTester testUnknownNestedArrayObjectReturned]

    in this method:

    - (void)testUnknownNestedArrayObjectReturned
    {
    self->_client.config.serviceUrl = KALTURA_CLIENT_TEST_URL;
    [self->_client.params addIfDefinedKey:@"responseBuffer" withString:@"KalturaBaseEntryListResponseUnknownObjectTypeabcdef"];
    KalturaBaseEntryListResponse* result = [self->_client.baseEntry list];
    assert(self->_client.error == nil); <—————————–this line
    assert(result.objects.count == 1);
    KalturaBaseEntry* entry = [result.objects objectAtIndex:0];
    assert([entry isKindOfClass:[KalturaBaseEntry class]]);
    assert([entry.id compare:@"abcdef"] == NSOrderedSame);
    }

    on the iphone textbox says:
    Running
    testUnknownNestedArrayObjectReturned (3/50)

  11. Hi all,

    I badly requires this library integrated for live video streaming from iphone to our server.Please help me with some samples and documents.Our requirement is live video streaming from iphone to our server

  12. Hi everyone,

    Just to inform you that I’ve tested KalturaClientTester on Xcode 4.5 and iOS 6 on Kaltura CE v5.0 and it worked. It successfully uploaded the video on my self-hosted Kaltura which I installed on VMware on my laptop.

    The only problem here is I don’t know what this #define KALTURA_CLIENT_TEST_URL means. It shows me an error which I will paste it here but I think it’s because I don’t know what should I write in test URL. But everything on a server is good. It’s been uploaded and convert it. (only no thumbnail, it has error on that part).

    Thanks for any help.

    Error:

    2012-10-20 17:53:19.466 kalturavideo[13156:c07] request url: http://mykalturavideo.com/api_v3/index.php?service=playlist&action=executeFromFilters
    2012-10-20 17:53:19.773 kalturavideo[13156:c07] api call took 0.31 seconds
    2012-10-20 17:53:19.773 kalturavideo[13156:c07] Running testSyncMultiReqFlow (2/50)…
    2012-10-20 17:53:19.875 kalturavideo[13156:c07] request url: http://mykalturavideo.com/api_v3/index.php?service=multirequest
    2012-10-20 17:53:21.212 kalturavideo[13156:c07] api call took 1.34 seconds
    2012-10-20 17:53:21.212 kalturavideo[13156:c07] -[NSError status]: unrecognized selector sent to instance 0x757cf60
    2012-10-20 17:53:21.214 kalturavideo[13156:c07] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSError status]: unrecognized selector sent to instance 0x757cf60′

    • Hi,

      The default settings are:
      #define DEFAULT_SERVICE_URL (@”http://www.kaltura.com”)
      #define KALTURA_CLIENT_TEST_URL (@”http://www.kaltura.com/clientTest”)

      So, it should probably be http:///api_v3/web/clientTest.php. An apache rewrite rule redirects /clientTest/api_v3/index.php to api_v3/web/clientTest.php. Since this is a standalone script that is not related the Kaltura server installation, if you don’t have it, you can just run against the default URL on kaltura.com.

      Eran

      • Hi Eran,

        Thanks for the reply,

        So is it OK to just change the Service URL to my own server and comment out the “[self startNextTest];”? Seems here only use TEST URL. Is it OK to not perform this or is it mandatory?

        And another question is about the thumbnail that every time I upload from iPhone it says error in Kaltura Server in thumbnail section. (it uploads both image and video)

        Is it possible that I miss something in my server? (Ubuntu Server 12.04 64-bit)

        Thank you

        • Don’t think you can comment it out, it will most likely break quite a few tests. I think it would be easier either to use the kaltura.com version (as I previously wrote) or set it up locally:
          1. paste the following in api_v3/web/clientTest.php under your Kaltura installation (by default it will be /opt/kaltura/app/api_v3/web/clientTest.php):
          300)
          die(‘responseBuffer too big !’);

          if ($responseBuffer == ” ||
          (substr($responseBuffer, 0, 13) == ” && substr($responseBuffer, -15) == ”))
          echo $responseBuffer;

          2. add the following apache rewrite rule:
          RewriteRule clientTest/api_v3/index.php /api_v3/web/clientTest.php [L]
          3. verify that it works by building a URL such as:
          http://www.kaltura.com/clientTest/api_v3/index.php?responseBuffer=
          and make sure you get back the value of responseBuffer ( in this case)

          Regarding the thumbnail problem, I will need some more information – what is the error, the relevant Kaltura log section etc.

          Eran

  13. It appears the PHP code got stripped while pasting it in the comment ;(.
    So, I guess we can use option #1:
    #define KALTURA_CLIENT_TEST_URL (@”http://www.kaltura.com/clientTest”)

    Eran

  14. Does this library supports live video streaming from IOS device to RTMP server? I have tested the code but in it we can record the video and then can upload it. Video is not being streamed live.

    Kindly reply ASAP.

    Thanks a lot.

  15. Trackbacks

Leave a Reply