Skip to content

HPRTMP is a Swift library for RTMP streaming, with an easy-to-use API, efficient message handling, and robust error recovery.

License

Notifications You must be signed in to change notification settings

huiping192/HPRTMP

Repository files navigation

HPRTMP

CI License: MIT Twitter

Goals

The main goals of this library are:

  • Easy-to-use: Provide a simple and intuitive API for RTMP streaming that abstracts away the complexities of the underlying protocol.
  • Efficient: Handle different message types and chunk sizes for efficient streaming.
  • Extensible: Allow developers to customize the library and extend its functionality.
  • Robust: Handle various network conditions and recover from errors gracefully.

Features

  • Connect to RTMP servers and authenticate using various methods
    • RTMP
    • RTMPS
  • Publish and play streams with different media types (audio, video, data)
  • Send and receive metadata and event messages
  • Handle different message types and chunk sizes for efficient streaming
  • Support for multiple streams and different message header types (Type 0, 1, 2, 3)
  • Support AMF0 and AMF3 codec

Requirements

  • iOS 14.0+ / macOS 11+
  • Swift 5.5+

Installation

You can install HPRTMP using Swift Package Manager by adding the following line to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/huiping192/HPRTMP.git", from: "0.0.1")
]

Alternatively, you can clone this repository and use the included HPRTMP.xcodeproj file, or you can copy the source files directly into your project.

Usage

Publishing Example

let session = RTMPPublishSession()
session.delegate = self

// Configure the session
let configure = PublishConfigure()
session.publish(url: "rtmp://your.rtmp.server/app/key", configure: configure)

// Send audio and video headers
session.publishAudioHeader(data: audioHeaderData)
session.publishVideoHeader(data: videoHeaderData, time: 0)

// Publish audio and video data
session.publishAudio(data: audioData, delta: delta)
session.publishVideo(data: videoData, delta: delta)

// Invalidate the session when done
session.invalidate()

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

HPRTMP is available under the MIT license. See the LICENSE file for more information.

About

HPRTMP is a Swift library for RTMP streaming, with an easy-to-use API, efficient message handling, and robust error recovery.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published