From fc89b01980032e41d8fcc6aa064276f43d1264ff Mon Sep 17 00:00:00 2001 From: olivierapivideo Date: Mon, 20 Nov 2023 16:17:34 +0000 Subject: [PATCH] README to documentation synchro --- sdks/livestream/swift-livestream-library.md | 121 ++++++++++++-------- 1 file changed, 73 insertions(+), 48 deletions(-) diff --git a/sdks/livestream/swift-livestream-library.md b/sdks/livestream/swift-livestream-library.md index d85480db..74cc44f5 100644 --- a/sdks/livestream/swift-livestream-library.md +++ b/sdks/livestream/swift-livestream-library.md @@ -3,24 +3,50 @@ title: Swift live stream library meta: description: The official Swift live stream library for api.video. [api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app. --- + -Swift Live stream library -============================ +# Swift Live stream library -## [api.video Swift Live stream Library](https://github.com/apivideo/LiveStreamIos/blob/master/README.md) +[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app. -This module is an easy way to broadcast live stream on api.video platform +## Project description + +This module is an easy way to broadcast RTMP live stream to [api.video](https://api.video) platform + +## Getting started ### Installation -#### With Cocoapods +#### Swift Package Manager + +In the Project Navigator select your own project. Then select the project in the Project section and click on the Package Dependencies tab. Click on the "+" button at the bottom. Paste the below url on the search bar on the top right. Finaly click on "Add package" button. + +``` +https://github.com/api.video-swift-live-stream +``` +Or add this in your Package.swift +``` + dependencies: [ + .package(url: "https://github.com/api.video-swift-live-stream.git", from: "1.3.5"), + ], +``` + +#### Cocoapods 1. Add the following entry to your Podfile: - ```swift - pod ‘LiveStreamIos’ - ``` -3. Then run `pod install` -4. Don’t forget to import LiveStreamIos in every file you’d like to use api.video livestream library +```swift +pod 'ApiVideoLiveStream', '1.3.5' +``` +2. Then run `pod install` +3. Don’t forget to import `ApiVideoLiveStream` in every file you’d like to use api.video live stream library + +#### Carthage +``` +github "apivideo/ApiVideoLiveStream.swift" ~> 1.3.5 +``` ### Permissions To be able to broadcast, you must update Info.plist with a usage description for camera and microphone @@ -34,53 +60,52 @@ To be able to broadcast, you must update Info.plist with a usage description for ... ``` -### Quick Start -1. In your ViewController.swift file import the library -2. Add a viariable apiVideo -3. Intenciate your variable with a view (or not if you dont want a preview of your stream) -4. to start your stream use startLiveStreamFlux() function - - if you're broadcasting on api.video you only have to add your stream key to liveStreamKey, and nil for rtmpServerUrl) - - if not add your rtmp server url to rtmpServerUrl - - ```swift - class ViewController: UIViewController { - var apiVideo: ApiVideoLiveStream? - @IBOutlet var viewCamera: UIView! - override func viewDidLoad() { - super.viewDidLoad() - apiVideo = ApiVideoLiveStream(view: viewCamera) - apiVideo?.startLiveStreamFlux(liveStreamKey: "Your_stream_key", rtmpServerUrl: nil) - } - } - ``` - -By default your stream will be - -- 720p -- 30 fps -- back camera -- landscape -- microphone : on - -### Plugins - -API.Video sdk is using external library +### Code sample +1. In ViewController.swift import the library +```swift +import ApiVideoLiveStream +``` +2. Create a `ApiVideoLiveStream` object with your default audio and video configuration +```swift +class ViewController: UIViewController { + var liveStream: ApiVideoLiveStream? + @IBOutlet var viewCamera: UIView! + override func viewDidLoad() { + super.viewDidLoad() + let audioConfig = AudioConfig(bitrate: 32 * 1000) + let videoConfig = VideoConfig(bitrate: 2 * 1024 * 1024, resolution: Resolutions.RESOLUTION_720, fps: 30) + do { + liveStream = try ApiVideoLiveStream(initialAudioConfig: audioConfig, initialVideoConfig: videoConfig, preview: preview) + } catch { + print (error) + } + } +} +``` +3. Start your live stream with `startStreaming` +```swift +liveStream?.startStreaming(streamKey: "YOUR_STREAM_KEY") +``` +Alternatively, you can use `startStreaming` `url` parameter to set the URL of your RTMP server. + +## Plugins + +api.video sdk is using external library | Plugin | README | | ------ | ------ | | HaishinKit | [https://github.com/shogo4405/HaishinKit.swift][HaishinKit] | -#### FAQ +## FAQ If you have any questions, ask us here: https://community.api.video . Or use [Issues]. -License ----- - -MIT License Copyright (c) 2021 api.video - +Also feel free to test our [Sample app]. [//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax) -[Issues]: +[Issues]: [HaishinKit]: +[Sample app]: + +