Live Broadcast era-IOS live client SDK, glamorous live broadcast [Open Source], and iossdk

Source: Internet
Author: User

Live Broadcast era-IOS live client SDK, glamorous live broadcast [Open Source], and iossdk

Currently, live video broadcast is very popular, and live video on mobile phones is also very popular. The live video broadcast thresholds of PGC and UGC are greatly reduced.

This article introduces an IOS client live video SDK with fully open source code.

Live video era: allows common IOS developers to create an RTMP live video client within one day, with the glamorous live video function. (The github Source Code address is at the bottom of the article)

Includes the following functions:

1. Provides RTMP streaming for IOS mobile phones;

Enter the RTMP service address to directly push the stream.

2. Face filter live

Apsaravideo live can be installed in both the United States and the ios opengl is accelerated, and the mobile phone is not hot at all.

3. The front and rear cameras can be switched over at any time. 4. Callback of RTMP connection status is provided.

First, simple literacy

Currently, RTMP is used for live streaming to RTMP servers.

The RTMP server then provides the RTMP video service;

Of course, the RTMP server also provides HLS to slice the video and audio streams into ts streams, and then the user can directly play the xxx. m3u8 streaming media.

 

Ii. SDK usage

1. Initialization

[LiveVideoCoreSDK sharedinstance]: a globally independent SDK instance. You do not need to manage the application and release of objects;

Initialize the RTMP connection and video parameters, which are very simple:

[[LiveVideoCoreSDK sharedinstance] LiveInit: RtmpUrl Preview: self. view VideSize: LIVE_VIEDO_SIZE_CIF BitRate: LIVE_BITRATE_500Kbps FrameRate: LIVE_FRAMERATE_20];

Parameters:

RtmpUrl: rtmp server address parameter, such as rtmp: // 192.168.30.191/live/123456

Preview: The UIVIEW object displayed in IOS local Preview. Now all users like the full-screen live video mode. self. view is directly used here.

VideSize: Specifies the video resolution. Several video resolutions are provided, including CIF (320*640), D1 (540*960), and 720 P (720*1280)

BitRate: Specifies the video bit rate. 720 kbps corresponds to CIF, kbps corresponds to D1, 2 Mbps corresponds to p, how to configure it depends on the current bandwidth of your mobile phone.

FrameRate: Specifies the video frame rate. This determines the smoothness of the video. The higher the frame rate, the smoother the video. Provided here: 15 frames/s, 20 frames/s, 25 frames/s, 20 frames/s

2. Connect to the RTMP Video Server

[[LiveVideoCoreSDK sharedinstance] connect];

After calling this interface, start to preview the iphone's local phone and connect to the RTMP server.

If there is no problem with the network and there is no problem with the RTMP server, the live broadcast will start. It's easy!

3. Set the filter to provide the glamorous effect.

-(Void) setFilter :( LIVE_FILTER_TYPE) type;

Currently, we provide a whitening effect. Set the LIVE_FILTER_BEAUTY parameter to see how much skin whitening you have.

4. Set the front and rear cameras

-(Void) setCameraFront :( Boolean) bCameraFrontFlag;

The front and rear cameras can be switched dynamically at any time.

5. Set RTMP connection status callback

[LiveVideoCoreSDK sharedinstance]. delete = self;

Implement the Protocol in your viewcontroller: LIVEVCSessionDelegate, as shown below, so that you can know the RTMP connection status at any time.

// Rtmp status delegate:

-(Void) LiveConnectionStatusChanged: (LIVE_VCSessionState) sessionState {

Dispatch_async (dispatch_get_main_queue (), ^ {

Switch (sessionState ){

Case LIVE_VCSessionStatePreviewStarted:

_ RtmpStatusLabel. text = @ "RTMP status: preview not connected ";

Break;

Case LIVE_VCSessionStateStarting:

_ RtmpStatusLabel. text = @ "RTMP status: connection ...";

Break;

Case LIVE_VCSessionStateStarted:

_ RtmpStatusLabel. text = @ "RTMP status: connected ";

Break;

Case LIVE_VCSessionStateEnded:

_ RtmpStatusLabel. text = @ "RTMP Status: Not connected ";

Break;

Case LIVE_VCSessionStateError:

_ RtmpStatusLabel. text = @ "RTMP status: error ";

Break;

Default:

Break;

}

});

}

6. the live video ends and the rtmp connection is disconnected.

[[LiveVideoCoreSDK sharedinstance] disconnect]; simple, no explanation.

 

GitHub address: https://github.com/runner365/LiveVideoCoreSDK

Finally, if you think the code is helpful to you, please help "star" in github and add a little star. If you have any questions, please contact us in my issue area.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.