Note: Currently, the stream ingest SDK must lock the iPhone in Portrait mode in the Controller of the stream ingest interface (that is, only Portrait is allowed) because the stream ingest SDK rotates the collected video frames, view the rotation.

In landscape mode, you need to adjust the UI to the landscape mode if necessary. In the adjustment solution, you do not need to rotate the preview view. For example, if the preview screen is full screen but horizontal, view changes, all you need to do is make a frame change to other like buttons on the page.

Procedure

  1. Detect the display orientation of the device.

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDeviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
    					
  2. Set the landscape or portrait mode for stream ingest in the handleDeviceOrientationDidChange callback.

    - (void)handleDeviceOrientationDidChange:   (UIInterfaceOrientation)interfaceOrientation {
    
     UIDevice *device = [UIDevice currentDevice] ;
     switch (device.orientation) {
         case UIDeviceOrientationFaceUp:
             NSLog(@"Screen up");
             break;
    
         case UIDeviceOrientationFaceDown:
             NSLog(@"Screen down");
             break;
    
         case UIDeviceOrientationUnknown:
             NSLog(@"Unknown");
             break;
    
         case UIDeviceOrientationLandscapeLeft: {
             NSLog(@"Left side down");
             // Ingest a stream in the landscape mode.
             [self destroySession];     // Interrupt the current stream ingest.
             // We recommend that you add a loading method here. If you interrupt and then resume the current stream ingest, the system disables and then enables the camera to collect a stream.
             _isScreenHorizontal = YES;  // Specify whether to use the portrait mode or landscape mode. To use the landscape mode, set this parameter to YES.
             [self testPushCapture];    // Re-ingest a stream.
         }
             break;
    
         case UIDeviceOrientationLandscapeRight:
             NSLog(@"Right side down");
             break;
    
         case UIDeviceOrientationPortrait: {
             NSLog(@"Portrait");
             // Ingest a stream in the portrait mode.
             [self destroySession];     // Interrupt the current stream ingest.
             _isScreenHorizontal = NO;  // Specify whether to use the portrait mode or landscape mode. To use the landscape mode, set this parameter to NO.
             [self testPushCapture];    // Re-ingest a stream.
         }
             break;
    
         case UIDeviceOrientationPortraitUpsideDown:
             NSLog(@"Portrait with upside down");
             break;
    
         default:
             NSLog(@"Unknown");
             break;
     }
    
    }
    					
  3. Log off from the device.

    - (void)dealloc{
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[UIDevice currentDevice]endGeneratingDeviceOrientationNotifications];
    }