Search code examples
iosswiftvideocore

VideoCore use of Variables Issue


I'm trying to use variables with my VCSimpleSession. I currently have the width and height set up, and they are working fine, but I cannot get the framerate and bitrate ones to work.

Heres a look:

var session: VCSimpleSession!

var streamWidth:Int = Int(NSUserDefaults.standardUserDefaults().stringForKey("settingsWidth")!)!
var streamHeight:Int = Int(NSUserDefaults.standardUserDefaults().stringForKey("settingsHeight")!)!
var streamFramerate:Int = Int(NSUserDefaults.standardUserDefaults().stringForKey("settingsFramerate")!)!
var streamBitrate:Int = Int(NSUserDefaults.standardUserDefaults().stringForKey("settingsBitrate")!)!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    session = VCSimpleSession(videoSize: CGSize(width: streamWidth, height: streamHeight), frameRate: streamFramerate, bitrate: streamBitrate, useInterfaceOrientation: false)
    previewView.addSubview(session.previewView)
    session.previewView.frame = previewView.bounds
    session.delegate = self

}

I'm getting an error on frameRate and bitrate that is Cannot invoke initializer for type 'VCSimpleSession' with an argument list of type '(videoSize: CGSize, frameRate: Int, bitrate: Int, useInterfaceOrientation: Bool)'

I looked at the VCSimpleSession.h file and seen that frameRate and bitrate are both int values, so I'm confused why I'm getting this error. (Language is Swift by the way)

Here's a link to VideoCore on GitHub: https://github.com/jgh-/VideoCore

Thanks!


Solution

  • I was close to solving my problem. The issue lies down to the frameRate and bitrate needs to be Int32() not Int().

    So this is what the final product should look like:

    session = VCSimpleSession(videoSize: CGSize(width: streamWidth, height: streamHeight), frameRate: Int32(streamFramerate), bitrate: Int32(streamBitrate), useInterfaceOrientation: false)