我正在使用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];
}
我的问题解决了。
在这一行中,而不是 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 视图充满了实时摄像机源。