Live Streaming to Swift

I need to create a live streaming application in SWIFT

Tried many ways using AVFoundation framework (AVPLayer and AVPlayeritem) but didn't work

This is audio only, so I don't want to do this while browsing the web.

Thank you in advance

+3


source to share


1 answer


You can try to use the VideoCore library , which will combine these frameworks into a complete streaming package. With this package, you can easily get started publishing with minimal effort. Take the following considerations (replicated from their projects):

To initiate a connection (Obj-C):

VCSimpleSession *sess = [[VCSimpleSession alloc] initWithVideoSize:CGSizeMake(width, height) frameRate:frameRate bitrate:bitrate] useInterfaceOrientation:YES];
sess.delegate = self;

      

To initiate a connection (Swift):

var sess:VCSimpleSession = VCSimpleSession(videoSize: CGSize(width: width, height: height), frameRate: frameRate, bitrate: bitRate, useInterfaceOrientation: false)
sess.delegate = self;

      

Use event handler (Obj-C):



- (void) connectionStatusChanged:(VCSessionState) state{
   if(state==VCSessionStateStarting){
      // connecting to destination host
   }
   else if(state==VCSessionStateStarted){
     // connected, streaming has begun
   }
   // ... etc
}

      

Use event handler (Swift):

func connectionStatusChanged(sessionState: VCSessionState) {
        switch session.rtmpSessionState {
        case .Starting:
            // initiating connection

        case .Started:
            // connected

        default:
           // connect
        }
    }

      

In addition, there is a paid SDK that can get support, for example the Wowza GoCoder SDK . Lots of options and stable infrastructure.

thank

Matt

0


source







All Articles