Closed Goule closed 3 years ago
Hello, Please try this code.
import AVFoundation
import HaishinKit
import Photos
import UIKit
import VideoToolbox
class ViewController: UIViewController {
@IBOutlet private weak var previewView: MTHKView!
var httpStream = HTTPStream()
// Please use httpService as property.
var httpService = HTTPService()
// Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
httpStream.attachAudio(AVCaptureDevice.default(for: AVMediaType.audio)) { error in
print(error)
}
httpStream.attachCamera(DeviceUtil.device(withPosition: .back)) { error in
print(error)
}
previewView.attachStream(httpStream)
}
// Methods
@IBAction func startStream(_ sender: Any) {
httpService.addHTTPStream(httpStream)
httpService.startRunning()
// Please startRunning after publish.
httpStream.publish("hello")
}
}
Hello @shogo4405 thanks for your reply.
I'v tested with :
class HLSPublisherViewController: UIViewController {
@IBOutlet private weak var previewView: MTHKView!
var httpStream = HTTPStream()
var httpService = HLSService(domain: "", type: "_http._tcp", name: "HaishinKit", port: 8080)
// Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
httpStream.attachAudio(AVCaptureDevice.default(for: AVMediaType.audio)) { error in
print(error)
}
httpStream.attachCamera(DeviceUtil.device(withPosition: .back)) { error in
print(error)
}
previewView.attachStream(httpStream)
}
// Methods
@IBAction func startStream(_ sender: Any) {
httpService.addHTTPStream(httpStream)
httpService.startRunning()
httpStream.publish("hello")
}
}
But I have the same issue.
I got. the same issue here. after I called startStream, I saw these errors in console: (running on iOS 14.2)
[Warn] [com.haishinkit.HaishinKit] [TSWriter.swift:347] rotateFileHandle(_:) > Error Domain=NSCocoaErrorDomain Code=4 "“13041.ts” couldn’t be removed." UserInfo={NSUserStringVariant=( Remove ), NSFilePath=/private/var/mobile/Containers/Data/Application/16A246A4-970E-4F46-A934-55B407D097FF/tmp/13041.ts, NSUnderlyingError=0x2818095f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
This log is normal. It's not releated that you can't show a stream on your safari. Please show me Safari's JavaScript console log.
[Warn] [com.haishinkit.HaishinKit] [TSWriter.swift:347] rotateFileHandle(_:) > Error Domain=NSCocoaErrorDomain Code=4 "“13041.ts” couldn’t be removed." UserInfo={NSUserStringVariant=( Remove ), NSFilePath=/private/var/mobile/Containers/Data/Application/16A246A4-970E-4F46-A934-55B407D097FF/tmp/13041.ts, NSUnderlyingError=0x2818095f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Thanks for the reply. it turned out to be an ip address issue, not related the HaishinKit.swift. I tested by setting up 2 other http servers, they both have the same issue(can't access by ip address like 192.168.1.60), then I found out I can access m3u8 with bonjour name, something like http://iphonename.local:8080/hello/playlist.m3u8. if I ping iphonename.local, it is an address like 169.254.95.189. it seems to be a reserved ip address you get when dhcp doesn't work. but if I set my iphone ip manually, it doesn't help. if I check the ip address when the app launches, it is still 192.168.1.x, not sure why it changes to 168.254 when creating a http server. anyway, it doesn't seem to be related to the lib.
Hello,
Describe the bug I have a sample iOS project with HLS steaming but when the stream is ON I have some issue :
To Reproduce
Here is the iOS code :
Expected behavior See the stream at http://192.168.1.57:8080/hello/playlist.m3u8 (192.168.1.57 is the IP displayed in my iPhone wifi settings on the same wifi my Mac).
Desktop (please complete the following information):
Additional context I can provide you the sample project if needed.
Thanks