使用VideoCore库使用直播视频填充ui视图

时间:2016-04-26 09:07:36

标签: ios uiview streaming live videocore

我正在使用VideoCore库来捕获和直播视频到服务器。我正在使用方形uiview来监控我的应用上的直播。但我无法用我的直播视频输出完全填满视图。很感谢任何形式的帮助。谢谢。我是iOS开发的新手。

这是我的代码:

ViewController.h

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <AVFoundation/AVFoundation.h>
#import "VCSimpleSession.h"
#import <CoreMedia/CoreMedia.h>

@interface ViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UIView *previewview;

ViewController.m:

#import "ViewController.h"
#import "VCSimpleSession.h"
@interface ViewController ()<VCSessionDelegate>


@end

VCSimpleSession *mysession;

UIImagePickerController *picker;

int *flag;

@implementation ViewController

@synthesize mybutton;

- (void)viewDidLoad
{
    [super viewDidLoad];
    flag = 0;
    self.textfield.autocorrectionType = UITextAutocorrectionTypeNo;

    mysession.delegate = self;

    self.previewview.hidden = NO;
    self.mybutton.hidden = NO;
    self.textfield.hidden = NO;

    [self.mybutton setBackgroundColor:[UIColor greenColor]];
    [self.mybutton setTitle:@"Start streaming" forState:UIControlStateNormal];
    mysession = [[VCSimpleSession alloc]initWithVideoSize:CGSizeMake(1280, 720) frameRate:30 bitrate:100000 useInterfaceOrientation:YES];

    mysession.previewView.frame = self.previewview.bounds;

    [self.previewview addSubview:mysession.previewView];
}

1 个答案:

答案 0 :(得分:1)

我解决了我的问题。

在这一行而不是1280,720

mysession = [[VCSimpleSession alloc]initWithVideoSize:CGSizeMake(1280,720) frameRate:30 bitrate:100000 useInterfaceOrientation: YES];

我输入了480,850

mysession = [[VCSimpleSession alloc]initWithVideoSize:CGSizeMake(480,850) frameRate:30 bitrate:100000 useInterfaceOrientation: YES];

这解决了我的问题。现在,我的ui视图充满了实时相机输入。