سؤال

I am getting stream on iPad from an IP camera named Foscam. If I open IP in iPad browser then it is working good but when I fetch stream in my application then it gets on frist screen shot and stuck on it. App is not getting continuous streaming from cam. I am using this way

- (IBAction)powerChanged:(id)sender {
    UISwitch * s = (UISwitch *)sender;
    if( s.on == TRUE){
        [self initializeData];
        if(![deviceClient connect]){
            UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Can not connect to T-Rex device!"
                                                              message:[[NSString alloc] initWithFormat:@"Could not connec to %@ and %d port",deviceClient.host,deviceClient.port] 
                                                             delegate:nil
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil];
                                    [message show];
                                    [s setOn:FALSE animated:TRUE];
        } else {
           [self adjustLayout:TRUE]; 
            [self startFrequencyTimer];
        }
    }else {
        [self stopFrequencyTimer];
        [self adjustLayout:FALSE];
    }
}

-(void)initializeData {
    [cameraViewFront loadRequest:[NSURLRequest requestWithURL:[frontCameraClient getVideoStreamURL]]];
}
-(BOOL)connect {
    if (udpSocket == nil){
        udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    }
    NSLog(@"host %@ and port %i", self.host, self.port);
    return [udpSocket connectToHost:self.host onPort:self.port error:nil];
}
- (NSURL *) getURL:(NSString *)forPage {
    NSLog(@"front cam IP %@" ,self.host);
    return [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"http://%@/%@user=%@&pwd=%@",self.host,forPage,self.username, self.password]];
}

-(NSURL *)getVideoStreamURL{
    return [self getURL:@"videostream.cgi?"];
}
هل كانت مفيدة؟

المحلول

I figured it out. I am using foscam and foscam provides a list of URLs on this link so I searched my cam model and then tried all the given URLs for MPEG connection type and http://IPADDRESS/videostream.cgi?user=[USERNAME]&pwd=[PASSWORD]&resolution=32&rate=0 URL worked for my case. But still there is a problem that it is working awesome on iOS5 and on iOS6 it still stuck on first frame. To fix this problem this link helped me a lot. This method works for iOS5 and 6 both.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top