2013-05-07 16:33:37 +00:00
|
|
|
#import "ViewController.h"
|
|
|
|
#import "GStreamerBackend.h"
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
|
|
|
@interface ViewController () {
|
|
|
|
GStreamerBackend *gst_backend;
|
2013-05-09 09:47:56 +00:00
|
|
|
int media_width;
|
|
|
|
int media_height;
|
2013-05-07 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ViewController
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Methods from UIViewController
|
|
|
|
*/
|
|
|
|
|
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2013-05-07 16:33:37 +00:00
|
|
|
play_button.enabled = FALSE;
|
|
|
|
pause_button.enabled = FALSE;
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2013-05-09 09:47:56 +00:00
|
|
|
/* Make these constant for now, later tutorials will change them */
|
|
|
|
media_width = 320;
|
|
|
|
media_height = 240;
|
2013-05-07 16:33:37 +00:00
|
|
|
|
2013-05-08 09:22:17 +00:00
|
|
|
gst_backend = [[GStreamerBackend alloc] init:self videoView:video_view];
|
2013-05-07 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning
|
|
|
|
{
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called when the Play button is pressed */
|
|
|
|
-(IBAction) play:(id)sender
|
|
|
|
{
|
|
|
|
[gst_backend play];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called when the Pause button is pressed */
|
|
|
|
-(IBAction) pause:(id)sender
|
|
|
|
{
|
|
|
|
[gst_backend pause];
|
|
|
|
}
|
|
|
|
|
2013-05-09 09:47:56 +00:00
|
|
|
- (void)viewDidLayoutSubviews
|
|
|
|
{
|
|
|
|
CGFloat view_width = video_container_view.bounds.size.width;
|
|
|
|
CGFloat view_height = video_container_view.bounds.size.height;
|
|
|
|
|
|
|
|
CGFloat correct_height = view_width * media_height / media_width;
|
|
|
|
CGFloat correct_width = view_height * media_width / media_height;
|
|
|
|
|
|
|
|
if (correct_height < view_height) {
|
|
|
|
video_height_constraint.constant = correct_height;
|
|
|
|
video_width_constraint.constant = view_width;
|
|
|
|
} else {
|
|
|
|
video_width_constraint.constant = correct_width;
|
|
|
|
video_height_constraint.constant = view_height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-07 16:33:37 +00:00
|
|
|
/*
|
|
|
|
* Methods from GstreamerBackendDelegate
|
|
|
|
*/
|
|
|
|
|
|
|
|
-(void) gstreamerInitialized
|
|
|
|
{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
play_button.enabled = TRUE;
|
|
|
|
pause_button.enabled = TRUE;
|
|
|
|
message_label.text = @"Ready";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) gstreamerSetUIMessage:(NSString *)message
|
|
|
|
{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
message_label.text = message;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|