【问题标题】:Getting Red5Pro Live Streaming to function properly on iOS让 Red5Pro Live Streaming 在 iOS 上正常运行
【发布时间】:2017-02-10 00:19:57
【问题描述】:

所以我正在努力让用户从我们的应用程序开始直播(订阅者可以看到)。我们使用的是 Red5Pro 服务器。我按照 Red5 的 iOS 页面上的说明进行操作,当它在手机上运行时,相机屏幕出现,我们非常漂亮的 UI 出现了,一切看起来都很棒。

但是当我按下按钮开始录制直播时,应用程序要么

1) 突然崩溃

2) 声称它正在直播,但它不会显示在 Red5 的“检查您的服务器当前是否有正在广播的流”页面上。

任何有 Red5Pro 经验的人想要浏览我的代码并可能指出问题所在?目前我们仍在使用 Swift 2(不是我的选择),并且 Xcode 方面没有错误消息。谢谢!

import UIKit
import R5Streaming

class PublishViewController : R5VideoViewController, R5StreamDelegate{

var config : R5Configuration!
var stream : R5Stream!

override func viewDidLoad() {
    super.viewDidLoad()

    config = R5Configuration()
    config.host = Defaults.sharedDefaults.localHost
    config.port = Int32(Defaults.sharedDefaults.hostPort)
    config.contextName = "live"
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
    self.stop()
}

func preview(isBackCamera: Bool) {
    let cameraDevice: AVCaptureDevice = isBackCamera ? AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo).first as! AVCaptureDevice : AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo).last as! AVCaptureDevice
    let camera = R5Camera(device: cameraDevice, andBitRate: 512)
    camera?.orientation = (camera?.orientation)! + 90

    let audioDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
    let microphone = R5Microphone(device: audioDevice)

    let connection = R5Connection(config: config)

    stream = R5Stream.init(connection: connection)
    stream.attachVideo(camera)
    stream.attachAudio(microphone)

    stream.delegate = self
    self.attachStream(stream)
    self.showPreview(true)
}

func start() {
    self.showPreview(false)
    stream.publish("red5prostream", type:R5RecordTypeLive)
}

func stop() {
    stream.stop()
    stream.delegate = nil
}

func onR5StreamStatus(stream: R5Stream!, withStatus statusCode: Int32, withMessage msg: String!) {
    print("Stream: \(r5_string_for_status(statusCode)) - \(msg!)")
}
}

【问题讨论】:

  • 显示崩溃,使用异常断点让它停止。 :)
  • 你还没有调用 start() 方法!

标签: ios swift xcode http-live-streaming red5pro


【解决方案1】:

首先,确保您下载了最新的 iOS SDK 和 Red5 Pro 服务器。 Red5 Pro Accounts Site

您的代码看起来不错,只是 iOS 代码为您的配置指向“localhost”。

config.host = Defaults.sharedDefaults.localHost

这条线路试图做的是将你的 iOS 设备连接到它自己。您需要将其指向您的 Red5 Pro 服务器。您应该转到您的服务器正在运行的机器并发出ifconfig 以确定服务器的本地 IP 地址是什么或您部署服务器的 WAN IP 地址。然后将其用作 iOS 配置主机属性中的主机。

您还可以查看我们开发人员系列的“iOS 入门”部分,以了解我们如何设置类似的应用程序。 https://www.red5pro.com/docs/developerseries/03/gsios.html

您还可以从帐户页面加入我们的 Slack 频道,并针对您发现的任何问题提交工单。

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2011-09-20
    • 2014-01-21
    • 2012-01-07
    • 2021-03-20
    • 2012-05-02
    • 2016-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多