ilaunchpad 0 Newbie Poster

I'm trying to make a camera app using AVCaptureSession. For now I just want to see if the video input works or not. But it looks like there is no input and I can't seem to understand why.

- (void)viewDidLoad
    [super viewDidLoad];

    session = [[AVCaptureSession alloc] init];

    [self addVideoPreviewLayer];

    CGRect layerRect = [[[self view] layer] bounds];

    [[self  previewLayer] setBounds:layerRect];
    [[self  previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect),
    [[[self view] layer] addSublayer:[self previewLayer]];

    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    myButton.frame = CGRectMake(80, 320, 200, 44);
    [myButton setTitle : @"Click Me!" forState:UIControlStateNormal];
    [myButton addTarget:self action: @selector(scanButtonPressed) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:myButton];



    [self setPreviewLayer:[[[AVCaptureVideoPreviewLayer alloc] initWithSession:[self session]] autorelease]];
    [[self previewLayer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];


-(void) addVideoInput{

    AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];   
    if (videoDevice) {
        NSError *error;
        AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
        if (!error) {
            if ([[self session] canAddInput:videoIn])
                [[self session] addInput:videoIn];
                NSLog(@"Couldn't add video input");     
            NSLog(@"Couldn't create video input");
        NSLog(@"Couldn't create video capture device");


    [self addVideoInput];