Open AshishLogs opened 1 year ago
Hi, I have tried the code and the live stream is not working. I am attaching the code below. PLEASE HELP ME WITH THIS, I AM STUCK
#import <UIKit/UIKit.h> #import "ViewController.h" @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _mediaSession = [[INSCameraMediaSession alloc] init]; _previewPlayer = [[INSCameraPreviewPlayer alloc] initWithFrame:self.view.bounds renderType:INSRenderTypeSphericalPanoRender]; [_previewPlayer playWithGyroTimestampAdjust:30.f]; _previewPlayer.delegate = self; [self.view addSubview:_previewPlayer.renderView]; [_mediaSession plug:self.previewPlayer]; _mediaSession.expectedVideoResolution = INSVideoResolution1440x720x30; _mediaSession.expectedVideoResolutionSecondary = INSVideoResolution1440x720x30; _mediaSession.previewStreamType = INSPreviewStreamTypeMain; _mediaSession.expectedAudioSampleRate = INSAudioSampleRate48000Hz; _mediaSession.gyroPlayMode = INSGyroPlayModeDefault; _mediaSession.videoStreamEncode = INSVideoEncodeH264; NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(sendHeartBeats) userInfo:nil repeats:YES]; [timer fire]; } - (void)sendHeartBeats { [[INSCameraManager socketManager].commandManager sendHeartbeatsWithOptions:nil]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidLayoutSubviews { [self.view bringSubviewToFront:self.liveStream]; } - (IBAction)livrStreaming:(UIButton *)sender { __weak typeof(self)weakSelf = self; [_mediaSession stopRunningWithCompletion:^(NSError * _Nullable error) { [weakSelf runMediaSession]; [weakSelf startLive]; }]; } - (void)startLive { NSInteger bitrate = 10 * 1024 * 1024; NSURL *url = [[NSURL alloc] initWithString:@"rtmp://65.109.2.79:1935/live/"]; _streamer = [[INSFlatRTMPStreamer alloc] initWithURL:url width:self.view.frame.size.width height:self.view.frame.size.height fps:30 bitrate:bitrate]; _streamer.delegate = self; [_streamer startLive]; } - (void)runMediaSession { if ([INSCameraManager sharedManager].cameraState != INSCameraStateConnected) { return ; } __weak typeof(self)weakSelf = self; if (_mediaSession.running) { self.view.userInteractionEnabled = NO; [_mediaSession commitChangesWithCompletion:^(NSError * _Nullable error) { NSLog(@"commitChanges media session with error: %@",error); weakSelf.view.userInteractionEnabled = YES; }]; } else { self.view.userInteractionEnabled = NO; [_mediaSession startRunningWithCompletion:^(NSError * _Nullable error) { NSLog(@"start running media session with error: %@",error); weakSelf.view.userInteractionEnabled = YES; if (error) { [weakSelf.previewPlayer playWithSmoothBuffer:NO]; } }]; } } #pragma mark INSCameraPreviewPlayerDelegate - (NSString *)offsetToPlay:(INSCameraPreviewPlayer *)player { NSString *mediaOffset = [INSCameraManager sharedManager].currentCamera.settings.mediaOffset; if ([[INSCameraManager sharedManager].currentCamera.name isEqualToString:kInsta360CameraNameOneX] && [INSLensOffset isValidOffset:mediaOffset]) { return [INSOffsetCalculator convertOffset:mediaOffset toType:INSOffsetConvertTypeOneX3040_2_2880]; } return mediaOffset; } - (void)streamerOnError:(NSError *)error { NSLog(@"streamerOnError: %@",error); } - (void)streamerOnUpdateStitchFps:(double)stitchFps pushFps:(double)pushFps duration:(double)duration { NSLog(@"streamerOnUpdateStitchFps stitchFps: %f",stitchFps); NSLog(@"streamerOnUpdateStitchFps pushFps: %f",pushFps); NSLog(@"streamerOnUpdateStitchFps duration : %f",duration); } @end
Hi, I have tried the code and the live stream is not working. I am attaching the code below. PLEASE HELP ME WITH THIS, I AM STUCK