2016-04-26 69 views
1

我使用VideoCore庫來捕獲視頻並將視頻直播到服務器。我正在使用一個方形uiview來監視我應用程序上的實時流。但我無法用我的直播視頻輸出完全填充視圖。很感謝任何形式的幫助。謝謝。我是iOS開發新手。使用VideoCore庫填充實時視頻流的UI視圖

這裏是我的代碼:

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

我得到了我我的問題解決了。

在這一行,而不是1280,720

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

我輸入480850

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

這引起了我的問題解決了。現在我的用戶界面充滿了現場攝像頭。