Skip to content

Commit

Permalink
Remove HLSService feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Oct 9, 2023
1 parent 06dc1b2 commit ba18943
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 852 deletions.
17 changes: 0 additions & 17 deletions Examples/iOS/NetStreamSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ final class NetStreamSwitcher {
enum Mode {
case rtmp
case srt
case http

func makeStream(_ swithcer: NetStreamSwitcher) -> NetStream {
switch self {
Expand All @@ -20,20 +19,12 @@ final class NetStreamSwitcher {
let connection = SRTConnection()
swithcer.connection = connection
return SRTStream(connection: connection)
case .http:
let service = HLSService(domain: "localhost", type: "_http._tcp", name: "HaishinKit", port: 8080)
swithcer.connection = service
return HTTPStream()
}
}
}

var uri = "" {
didSet {
if uri.contains("http://") {
mode = .http
return
}
if uri.contains("srt://") {
mode = .srt
return
Expand Down Expand Up @@ -65,12 +56,6 @@ final class NetStreamSwitcher {
}
connection.open(URL(string: uri))
stream.publish("")
case .http:
guard let connection = connection as? HLSService, let stream = stream as? HTTPStream else {
return
}
connection.addHTTPStream(stream)
connection.startRunning()
}
}

Expand All @@ -86,8 +71,6 @@ final class NetStreamSwitcher {
case .srt:
(stream as? SRTStream)?.close()
(connection as? SRTConnection)?.close()
case .http:
break
}
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/iOSSwiftUI/Model/ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ final class ViewModel: ObservableObject {
}

func changeVideoRate(level: CGFloat) {
rtmpStream.videoSettings.bitRate = UInt32(level * 1000)
rtmpStream.videoSettings.bitRate = Int(level * 1000)
}

func changeAudioRate(level: CGFloat) {
Expand Down
11 changes: 5 additions & 6 deletions Examples/macOS/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@
</connections>
</popUpButton>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wuc-0E-MpH">
<rect key="frame" x="18" y="227" width="126" height="24"/>
<rect key="frame" x="18" y="227" width="124" height="24"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="120" id="vPI-Ua-wua"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="uaP-H9-CqU">
<font key="font" metaFont="system"/>
<segments>
<segment label="RTMP" width="59" selected="YES"/>
<segment label="HLS" width="58" tag="1"/>
</segments>
</segmentedCell>
<connections>
Expand Down Expand Up @@ -223,13 +222,13 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="U7X-zB-Ct9">
<rect key="frame" x="0.0" y="0.0" width="154" height="1888"/>
<rect key="frame" x="0.0" y="0.0" width="154" height="1990"/>
<clipView key="contentView" id="TC0-20-xwt">
<rect key="frame" x="1" y="1" width="152" height="1886"/>
<rect key="frame" x="1" y="1" width="152" height="1988"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" viewBased="YES" id="Zf5-MB-jdh">
<rect key="frame" x="0.0" y="0.0" width="152" height="1886"/>
<rect key="frame" x="0.0" y="0.0" width="152" height="1988"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="17" height="0.0"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -280,7 +279,7 @@
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="5e8-aJ-U5N">
<rect key="frame" x="1" y="1769" width="152" height="16"/>
<rect key="frame" x="1" y="1871" width="152" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="eRz-M7-DJS">
Expand Down
16 changes: 0 additions & 16 deletions Examples/macOS/CameraPublishViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ final class CameraPublishViewController: NSViewController {
rtmpStream.addObserver(self, forKeyPath: "currentFPS", options: .new, context: nil)
return rtmpStream
}()
private var httpService = HLSService(
domain: "local", type: HTTPService.type, name: "", port: HTTPService.defaultPort
)
private var httpStream = HTTPStream()

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -89,10 +85,6 @@ final class CameraPublishViewController: NSViewController {
case 0:
rtmpConnection.addEventListener(.rtmpStatus, selector: #selector(rtmpStatusHandler), observer: self)
rtmpConnection.connect(urlField.stringValue)
case 1:
httpStream.publish("hello")
httpService.addHTTPStream(httpStream)
httpService.startRunning()
default:
break
}
Expand All @@ -105,10 +97,6 @@ final class CameraPublishViewController: NSViewController {
case 0:
rtmpConnection.removeEventListener(.rtmpStatus, selector: #selector(rtmpStatusHandler), observer: self)
rtmpConnection.close()
case 1:
httpService.removeHTTPStream(httpStream)
httpService.stopRunning()
httpStream.publish(nil)
default:
break
}
Expand Down Expand Up @@ -139,10 +127,6 @@ final class CameraPublishViewController: NSViewController {
currentStream = rtmpStream
lfView.attachStream(rtmpStream)
urlField.stringValue = Preference.defaultInstance.uri ?? ""
case 1:
currentStream = httpStream
lfView.attachStream(httpStream)
urlField.stringValue = "http://{ipAddress}:8080/hello/playlist.m3u8"
default:
break
}
Expand Down
32 changes: 0 additions & 32 deletions HaishinKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
29B8765D1CD70A7900FC07DA /* VideoCodec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876591CD70A7900FC07DA /* VideoCodec.swift */; };
29B876691CD70AB300FC07DA /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876631CD70AB300FC07DA /* Constants.swift */; };
29B8766D1CD70AB300FC07DA /* DataConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876671CD70AB300FC07DA /* DataConvertible.swift */; };
29B876761CD70ACE00FC07DA /* HTTPRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B8766F1CD70ACE00FC07DA /* HTTPRequest.swift */; };
29B876771CD70ACE00FC07DA /* HTTPResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876701CD70ACE00FC07DA /* HTTPResponse.swift */; };
29B876781CD70ACE00FC07DA /* HTTPService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876711CD70ACE00FC07DA /* HTTPService.swift */; };
29B876791CD70ACE00FC07DA /* HTTPStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876721CD70ACE00FC07DA /* HTTPStream.swift */; };
29B8767A1CD70ACE00FC07DA /* M3U.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876731CD70ACE00FC07DA /* M3U.swift */; };
29B876831CD70AE800FC07DA /* AudioSpecificConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B8767D1CD70AE800FC07DA /* AudioSpecificConfig.swift */; };
29B876841CD70AE800FC07DA /* AVCDecoderConfigurationRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B8767E1CD70AE800FC07DA /* AVCDecoderConfigurationRecord.swift */; };
29B876861CD70AE800FC07DA /* PacketizedElementaryStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B876801CD70AE800FC07DA /* PacketizedElementaryStream.swift */; };
Expand Down Expand Up @@ -191,7 +186,6 @@
BC558268240BB40E00011AC0 /* RTMPStreamInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC558267240BB40E00011AC0 /* RTMPStreamInfo.swift */; };
BC562DC7295767860048D89A /* AVCaptureDevice+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC562DC6295767860048D89A /* AVCaptureDevice+Extension.swift */; };
BC562DCB29576D220048D89A /* AVCaptureSession.Preset+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC562DCA29576D220048D89A /* AVCaptureSession.Preset+Extension.swift */; };
BC566F6E25D2ECC500573C4C /* HLSService.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC566F6D25D2ECC500573C4C /* HLSService.swift */; };
BC56765B2AD2AED800524F7E /* AudioCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC56765A2AD2AED800524F7E /* AudioCapture.swift */; };
BC56765D2AD2B24800524F7E /* VideoAdaptiveNetBitRateStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC1BC9032AC80531009005D3 /* VideoAdaptiveNetBitRateStrategy.swift */; };
BC570B4828E9ACC10098A12C /* IOUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC570B4728E9ACC10098A12C /* IOUnit.swift */; };
Expand Down Expand Up @@ -494,11 +488,6 @@
29B876591CD70A7900FC07DA /* VideoCodec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCodec.swift; sourceTree = "<group>"; };
29B876631CD70AB300FC07DA /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
29B876671CD70AB300FC07DA /* DataConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataConvertible.swift; sourceTree = "<group>"; };
29B8766F1CD70ACE00FC07DA /* HTTPRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPRequest.swift; sourceTree = "<group>"; };
29B876701CD70ACE00FC07DA /* HTTPResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPResponse.swift; sourceTree = "<group>"; };
29B876711CD70ACE00FC07DA /* HTTPService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPService.swift; sourceTree = "<group>"; };
29B876721CD70ACE00FC07DA /* HTTPStream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPStream.swift; sourceTree = "<group>"; };
29B876731CD70ACE00FC07DA /* M3U.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = M3U.swift; sourceTree = "<group>"; };
29B8767D1CD70AE800FC07DA /* AudioSpecificConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioSpecificConfig.swift; sourceTree = "<group>"; };
29B8767E1CD70AE800FC07DA /* AVCDecoderConfigurationRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AVCDecoderConfigurationRecord.swift; sourceTree = "<group>"; };
29B876801CD70AE800FC07DA /* PacketizedElementaryStream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PacketizedElementaryStream.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -607,7 +596,6 @@
BC558267240BB40E00011AC0 /* RTMPStreamInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RTMPStreamInfo.swift; sourceTree = "<group>"; };
BC562DC6295767860048D89A /* AVCaptureDevice+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVCaptureDevice+Extension.swift"; sourceTree = "<group>"; };
BC562DCA29576D220048D89A /* AVCaptureSession.Preset+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVCaptureSession.Preset+Extension.swift"; sourceTree = "<group>"; };
BC566F6D25D2ECC500573C4C /* HLSService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HLSService.swift; sourceTree = "<group>"; };
BC56765A2AD2AED800524F7E /* AudioCapture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioCapture.swift; sourceTree = "<group>"; };
BC570B4728E9ACC10098A12C /* IOUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOUnit.swift; sourceTree = "<group>"; };
BC6692F22AC2F717009EC058 /* NetBitRateStrategyConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetBitRateStrategyConvertible.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -898,7 +886,6 @@
290907CD1C3961AD00F2E80C /* Codec */,
29EA87D11E799EFF0043A5F8 /* Extension */,
295891081EEB8B1D00CE51E1 /* FLV */,
2960CD3E1CC0C7C900B4E877 /* HTTP */,
BCD1DCF62610751900A1C593 /* MPEG */,
29BDE0BD1C65BC2400D6A768 /* Media */,
297C16881CC5382600117ADF /* Net */,
Expand Down Expand Up @@ -934,19 +921,6 @@
path = FLV;
sourceTree = "<group>";
};
2960CD3E1CC0C7C900B4E877 /* HTTP */ = {
isa = PBXGroup;
children = (
BC566F6D25D2ECC500573C4C /* HLSService.swift */,
29B8766F1CD70ACE00FC07DA /* HTTPRequest.swift */,
29B876701CD70ACE00FC07DA /* HTTPResponse.swift */,
29B876711CD70ACE00FC07DA /* HTTPService.swift */,
29B876721CD70ACE00FC07DA /* HTTPStream.swift */,
29B876731CD70ACE00FC07DA /* M3U.swift */,
);
path = HTTP;
sourceTree = "<group>";
};
296543541D62FE3E00734698 /* macOS */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1713,7 +1687,6 @@
29B876941CD70AFE00FC07DA /* SoundTransform.swift in Sources */,
29DF20662312A436004057C3 /* RTMPSocketCompatible.swift in Sources */,
29B876861CD70AE800FC07DA /* PacketizedElementaryStream.swift in Sources */,
29B876761CD70ACE00FC07DA /* HTTPRequest.swift in Sources */,
29B876AD1CD70B2800FC07DA /* AMFFoundation.swift in Sources */,
296242611D8DB86500C451A3 /* TSReader.swift in Sources */,
29B8765D1CD70A7900FC07DA /* VideoCodec.swift in Sources */,
Expand All @@ -1740,7 +1713,6 @@
295891221EEB8EC500CE51E1 /* FLVAVCPacketType.swift in Sources */,
29B876B61CD70B2800FC07DA /* RTMPStream.swift in Sources */,
BC5019C12A6D266B0046E02F /* IOAudioRingBuffer.swift in Sources */,
BC566F6E25D2ECC500573C4C /* HLSService.swift in Sources */,
29EA87EA1E79A3B70043A5F8 /* CMBlockBuffer+Extension.swift in Sources */,
BC3004CE296B0A1700119932 /* Shape.swift in Sources */,
BC34FA0B286CB90A00EFAF27 /* PiPHKView.swift in Sources */,
Expand Down Expand Up @@ -1790,7 +1762,6 @@
BC1DC5062A02963600E928ED /* FLVTagType.swift in Sources */,
29B876691CD70AB300FC07DA /* Constants.swift in Sources */,
29B8766D1CD70AB300FC07DA /* DataConvertible.swift in Sources */,
29B876781CD70ACE00FC07DA /* HTTPService.swift in Sources */,
BC570B4828E9ACC10098A12C /* IOUnit.swift in Sources */,
2976A4861D4903C300B53EF2 /* DeviceUtil.swift in Sources */,
BC7C56BB299E595000C41A9B /* VideoCodecSettings.swift in Sources */,
Expand All @@ -1804,7 +1775,6 @@
BC4914B628DEC2FE009E2DF6 /* VTSessionMode.swift in Sources */,
BC2828AD2AA3225100741013 /* AVCaptureDevice.Format+Extension.swift in Sources */,
295891261EEB8EF300CE51E1 /* FLVAACPacket.swift in Sources */,
29B876791CD70ACE00FC07DA /* HTTPStream.swift in Sources */,
BC1DC50A2A039B4400E928ED /* HEVCDecoderConfigurationRecord.swift in Sources */,
BC6692F32AC2F717009EC058 /* NetBitRateStrategyConvertible.swift in Sources */,
BC6FC91E29609A6800A746EE /* ShapeFactory.swift in Sources */,
Expand All @@ -1821,9 +1791,7 @@
BC959EEF296EE4190067BA97 /* ImageTransform.swift in Sources */,
2942424D1CF4C01300D65DCB /* MD5.swift in Sources */,
29EA87D31E799F360043A5F8 /* ExpressibleByIntegerLiteral+Extension.swift in Sources */,
29B8767A1CD70ACE00FC07DA /* M3U.swift in Sources */,
29B876901CD70AFE00FC07DA /* IOAudioUnit.swift in Sources */,
29B876771CD70ACE00FC07DA /* HTTPResponse.swift in Sources */,
1A216F07B0BD8E05C8ECC8F1 /* AVAudioFormat+Extension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ Project name |Notes |License
- [x] ReplayKit Live as a Broadcast Upload Extension
- [x] [Enhanced RTMP](https://github.com/veovera/enhanced-rtmp)

### HLS
- [x] HTTPService
- [x] HLS Publish

### SRT(beta)
- [x] Publish and Recording (H264/AAC)
- [x] Playback(beta)
Expand Down Expand Up @@ -291,25 +287,6 @@ screen.startRunning()
stream.attachScreen(AVCaptureScreenInput(displayID: CGMainDisplayID()))
```

## 📓 HTTP Usage
HTTP Live Streaming (HLS). Your iPhone/Mac become a IP Camera. Basic snipet. You can see http://ip.address:8080/hello/playlist.m3u8
```swift
var stream = HTTPStream()
stream.attachCamera(AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back))
stream.attachAudio(AVCaptureDevice.default(for: .audio))
stream.publish("hello")

var hkView = MTHKView(frame: view.bounds)
hkView.attachStream(httpStream)

var httpService = HLSService(domain: "", type: "_http._tcp", name: "HaishinKit", port: 8080)
httpService.addHTTPStream(stream)
httpService.startRunning()

// add ViewController#view
view.addSubview(hkView)
```

## 💠 Sponsorship
Looking for sponsors. Sponsoring I will enable us to:
- Purchase smartphones or peripheral devices for testing purposes.
Expand Down
Loading

0 comments on commit ba18943

Please sign in to comment.