1

I'm trying to make a video player that can play various video format with ffmpeg and sdl2, and I need to display video frames inside a UIView. After looking into SDL api and its samples i couldnt find a way to do it. SDL use SDL_Renderer to render image in to a SDL_Window, which holds a reference to a UIWindow (the main UIWindow of the app), not a particular UIView.

Any suggestion?

Martin G
  • 17,357
  • 9
  • 82
  • 98
jAckOdE
  • 2,402
  • 8
  • 37
  • 67

1 Answers1

1

hmm... thats a lot of ground to cover here but I'll try.

I suspect not to many devs besides us have done this.

First of all I don't know of any solutions that use sdl2, but its certainly possible with sdl 1.3 .

https://github.com/mooncatventures-group/RTSPPlay

Notice the app delegate , it creates a view controller that creates an sdl window and launches the player.

Notice the folder uikit, uikit is the portion of sdl that interfaces with sdl. The app delegate here can be modified, this one is set up to use two windows and swap between, but we also have used the following methods to swap views.

-(void) swapViews {
    UIWindow *windows = [[UIApplication sharedApplication] keyWindow];
    NSLog(@"the app has %d views ",[windows.subviews count]);
    //toggle_pause();
    UIView *view = [window.subviews objectAtIndex:0];
    [view removeFromSuperview];
    [windows addSubview:view];
}



-(void) swapViewsWithTransition {
    UIWindow *windows = [[UIApplication sharedApplication] keyWindow];
    UIView *firstView = [window.subviews objectAtIndex:0];
    UIView *secondView = [window.subviews objectAtIndex:1];       
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:([secondView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:firstView cache:YES];
    [firstView removeFromSuperview];
    [windows addSubview:firstView];
    [UIView commitAnimations];




}

Some time ago , I wrote a thread on this on the sdl forum here.

http://forums.libsdl.org/viewtopic.php?t=7352&sid=6b714337317597eaca026ae6be968b3e

There are some caveats with using these techniques

RTSPPlay can play almost any video you throw it well, but sdl event loops don't play to well with apple runloops, tableviews are especially troublesome, they tend to get sluggish, if you code an app with sdl limitations in mind like rtspplay you get a nice video player but adding to an existing app can be problematic.

There are examples of native apps in the same git. Working sdl can be a painful experience at times good luck

Michelle Cannon
  • 1,341
  • 8
  • 8
  • did you get your app uploaded to iTune app store? – jAckOdE Oct 18 '12 at 04:53
  • 1
    If the question is concerning can sdl apps be sold on the app store, absolutely , I know several people who have. As for us, no , but only because we came up with ways to use the apple api to accomplish the same thing – Michelle Cannon Oct 18 '12 at 14:09
  • thanks for the answer. I'm making video player using ffmpeg and struggling at the decision whether to use SDL or ios's api. Since you have experience in both of these, can you give me an advice? I know it is little off the topic, but i hope you dont mind. – jAckOdE Oct 19 '12 at 01:22
  • Here is a discussion about how mature SDL id in IOS http://stackoverflow.com/questions/597459/how-mature-is-sdl-for-iphone, but it was three years ago. I saw your posts in dsl forum,i guess you also involve in SDL development, so how about it now, especially in new SDL2.0? – jAckOdE Oct 19 '12 at 01:33
  • 1
    I used to be a lot more into it, and I know the developer. I tend to not recommend using sdl on iOS projects unless 1) its a brand new project built with sdl limitations in mind 2) it doesn't make heavy use of apple api elements, look at my webstreamX for instance , the heaviest api control it uses is a uiwebview. There is a patch (may be in trunk for sdl2) that adds a function iphoneSetAnimationCallback that breaks the monolithic event loop of sdl and runs most of the code in a separate runloop , but I think this could make it difficult to build a decent player . – Michelle Cannon Oct 19 '12 at 13:31