Skip to content

Commit

Permalink
implementaion for moqt draft7
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Nov 26, 2024
1 parent 5a80b74 commit b35d8a2
Show file tree
Hide file tree
Showing 29 changed files with 1,423 additions and 17 deletions.
26 changes: 13 additions & 13 deletions Examples/macOS/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="4Lp-xV-zxC">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="4Lp-xV-zxC">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
<capability name="NSView safe area layout guides" minToolsVersion="12.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -79,7 +79,7 @@
<action selector="selectAudio:" target="XfG-lQ-9wD" id="OFN-CV-EIr"/>
</connections>
</popUpButton>
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lB9-7R-daQ">
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lB9-7R-daQ">
<rect key="frame" x="20" y="20" width="300" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="beN-tf-ecK"/>
Expand Down Expand Up @@ -204,13 +204,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="3520"/>
<rect key="frame" x="0.0" y="0.0" width="154" height="3622"/>
<clipView key="contentView" id="TC0-20-xwt">
<rect key="frame" x="1" y="1" width="152" height="3518"/>
<rect key="frame" x="1" y="1" width="152" height="3620"/>
<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="3518"/>
<rect key="frame" x="0.0" y="0.0" width="152" height="3620"/>
<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 All @@ -232,7 +232,7 @@
<rect key="frame" x="8" y="0.0" width="135" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="nKL-O8-0aU">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="nKL-O8-0aU">
<rect key="frame" x="0.0" y="4" width="135" height="16"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="Lf1-hH-841">
<font key="font" usesAppearanceFont="YES"/>
Expand Down Expand Up @@ -261,7 +261,7 @@
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="5e8-aJ-U5N">
<rect key="frame" x="1" y="3401" width="152" height="16"/>
<rect key="frame" x="1" y="3503" 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 Expand Up @@ -378,7 +378,7 @@
<action selector="selectCamera:" target="dhX-nT-Doa" id="F16-Nj-MQi"/>
</connections>
</popUpButton>
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EUe-gL-Kfw">
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EUe-gL-Kfw">
<rect key="frame" x="20" y="20" width="300" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="zUM-Oo-BRX"/>
Expand Down Expand Up @@ -422,7 +422,7 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="muK-Fu-lNp">
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="muK-Fu-lNp">
<rect key="frame" x="16" y="419" width="300" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="onn-Pa-e0H"/>
Expand All @@ -436,23 +436,23 @@
<outlet property="delegate" destination="9vk-iW-BZX" id="TTT-Ka-3O4"/>
</connections>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="y43-vh-quB">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="y43-vh-quB">
<rect key="frame" x="14" y="448" width="73" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="RTMP URL:" id="a0O-iB-hpy">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WSq-ak-6dS">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WSq-ak-6dS">
<rect key="frame" x="14" y="395" width="87" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="StreamName:" id="2cu-1b-UVj">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YII-qB-iiW">
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YII-qB-iiW">
<rect key="frame" x="16" y="366" width="300" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="03D-Ul-Uui"/>
Expand Down
2 changes: 2 additions & 0 deletions Examples/macOS/FLVAnalyzerViewController.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AppKit
import Foundation
@testable import HaishinKit
import MoQTHaishinKit

final class FLVAnalyzerViewController: NSViewController {
@IBOutlet private weak var textView: NSTextView!
Expand All @@ -10,6 +11,7 @@ final class FLVAnalyzerViewController: NSViewController {

private var tags: [any FLVTag] = []
private var reader: FLVReader?
private var client: MoxygenChatClient = .init("moqt://localhost:4433/moq-chat")

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
32 changes: 32 additions & 0 deletions Examples/macOS/MoxygenChatClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import HaishinKit
import MoQTHaishinKit

public actor MoxygenChatClient {
public private(set) var isRunning: Bool = false
private let uri: String
private lazy var connection = MoQTConnection(.pubSub)

public init(_ uri: String) {
self.uri = uri
}
}

extension MoxygenChatClient: AsyncRunner {
public func startRunning() {
Task {
do {
let setUp = try await connection.connect(uri)
print(try await connection.annouce(["shogo4405/1000/0"], authInfo: "test"))
print(try await connection.subscribeAnnouces(["shogo4405/1000/0"], authInfo: "test"))
} catch {
print(error)
}
}
}

public func stopRunning() {
Task {
await connection.close()
}
}
}
42 changes: 42 additions & 0 deletions HaishinKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/* Begin PBXBuildFile section */
2915EC541D85BDF100621092 /* ReplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2915EC531D85BDF100621092 /* ReplayKit.framework */; };
BC0C81EF2CE8868E00DEA9E6 /* HaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC0C81EE2CE8868E00DEA9E6 /* HaishinKit */; };
BC0C81F12CE8868E00DEA9E6 /* MoQTHaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC0C81F02CE8868E00DEA9E6 /* MoQTHaishinKit */; };
BC0C81F32CE8868E00DEA9E6 /* SRTHaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC0C81F22CE8868E00DEA9E6 /* SRTHaishinKit */; };
BC2902352AA0E66A004821D2 /* Screencast.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2915EC521D85BDF100621092 /* Screencast.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
BC33A1192CDF523E0016EEA0 /* HaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC33A1182CDF523E0016EEA0 /* HaishinKit */; };
BC33A11B2CDF523E0016EEA0 /* SRTHaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC33A11A2CDF523E0016EEA0 /* SRTHaishinKit */; };
Expand All @@ -19,6 +22,7 @@
BC33A1272CDF52630016EEA0 /* SRTHaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC33A1262CDF52630016EEA0 /* SRTHaishinKit */; };
BC33A1292CDF526C0016EEA0 /* HaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC33A1282CDF526C0016EEA0 /* HaishinKit */; };
BC33A12B2CDF526C0016EEA0 /* SRTHaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC33A12A2CDF526C0016EEA0 /* SRTHaishinKit */; };
BC47FA352CE61FCF002900AE /* MoQTHaishinKit in Frameworks */ = {isa = PBXBuildFile; productRef = BC47FA342CE61FCF002900AE /* MoQTHaishinKit */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -130,6 +134,14 @@
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
BC0C81EC2CE8856000DEA9E6 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Tests/MoQTPayLoadTests.swift,
Tests/MoQTStreamHeaderSubgroupTests.swift,
);
target = BCB798882CE06AEC0059DFE9 /* Tests */;
};
BC82CA7F2CD763F4003F99C9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Expand Down Expand Up @@ -170,6 +182,7 @@
macOS/MainSplitViewController.swift,
macOS/MainWindowController.swift,
macOS/MenuViewController.swift,
macOS/MoxygenChatClient.swift,
macOS/PlaybackViewController.swift,
macOS/PreferenceViewController.swift,
macOS/SCStreamPublishViewController.swift,
Expand Down Expand Up @@ -263,6 +276,7 @@
BC82C98F2CD76325003F99C9 /* SRTHaishinKit */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = SRTHaishinKit; sourceTree = "<group>"; };
BC82CA0E2CD76338003F99C9 /* DebugDescription */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = DebugDescription; sourceTree = "<group>"; };
BC82CA4B2CD763F4003F99C9 /* Examples */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (BC82CA7F2CD763F4003F99C9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, BC82CA802CD763F4003F99C9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, BC82CA812CD763F4003F99C9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, BC82CA822CD763F4003F99C9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, BC82CA832CD763F4003F99C9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = Examples; sourceTree = "<group>"; };
BCB79DBF2CE070C90059DFE9 /* MoQTHaishinKit */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (BC0C81EC2CE8856000DEA9E6 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = MoQTHaishinKit; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -289,6 +303,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BC47FA352CE61FCF002900AE /* MoQTHaishinKit in Frameworks */,
BC33A11F2CDF52550016EEA0 /* SRTHaishinKit in Frameworks */,
BC33A11D2CDF52550016EEA0 /* HaishinKit in Frameworks */,
);
Expand Down Expand Up @@ -316,6 +331,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BC0C81EF2CE8868E00DEA9E6 /* HaishinKit in Frameworks */,
BC0C81F12CE8868E00DEA9E6 /* MoQTHaishinKit in Frameworks */,
BC0C81F32CE8868E00DEA9E6 /* SRTHaishinKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -342,6 +360,7 @@
BC33A1452CDF55040016EEA0 /* HaishinKit */,
29F04FF21F3388B000172706 /* HaishinKit.podspec */,
2927A2991E7ED2D70044AF91 /* LICENSE.md */,
BCB79DBF2CE070C90059DFE9 /* MoQTHaishinKit */,
29F39BE72335F8010055F9BB /* Package.swift */,
2945CBBE1B4BE66000104112 /* Products */,
2997BDD31D50D31B000AF900 /* README.md */,
Expand Down Expand Up @@ -482,6 +501,9 @@
);
name = Tests;
packageProductDependencies = (
BC0C81EE2CE8868E00DEA9E6 /* HaishinKit */,
BC0C81F02CE8868E00DEA9E6 /* MoQTHaishinKit */,
BC0C81F22CE8868E00DEA9E6 /* SRTHaishinKit */,
);
productName = Tests;
productReference = BCB798892CE06AEC0059DFE9 /* Tests.xctest */;
Expand Down Expand Up @@ -1348,6 +1370,21 @@
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
BC0C81EE2CE8868E00DEA9E6 /* HaishinKit */ = {
isa = XCSwiftPackageProductDependency;
package = BC33A1172CDF51620016EEA0 /* XCLocalSwiftPackageReference "../HaishinKit.swift" */;
productName = HaishinKit;
};
BC0C81F02CE8868E00DEA9E6 /* MoQTHaishinKit */ = {
isa = XCSwiftPackageProductDependency;
package = BC33A1172CDF51620016EEA0 /* XCLocalSwiftPackageReference "../HaishinKit.swift" */;
productName = MoQTHaishinKit;
};
BC0C81F22CE8868E00DEA9E6 /* SRTHaishinKit */ = {
isa = XCSwiftPackageProductDependency;
package = BC33A1172CDF51620016EEA0 /* XCLocalSwiftPackageReference "../HaishinKit.swift" */;
productName = SRTHaishinKit;
};
BC33A1182CDF523E0016EEA0 /* HaishinKit */ = {
isa = XCSwiftPackageProductDependency;
package = BC33A1172CDF51620016EEA0 /* XCLocalSwiftPackageReference "../HaishinKit.swift" */;
Expand Down Expand Up @@ -1398,6 +1435,11 @@
package = BC33A1172CDF51620016EEA0 /* XCLocalSwiftPackageReference "../HaishinKit.swift" */;
productName = SRTHaishinKit;
};
BC47FA342CE61FCF002900AE /* MoQTHaishinKit */ = {
isa = XCSwiftPackageProductDependency;
package = BC33A1172CDF51620016EEA0 /* XCLocalSwiftPackageReference "../HaishinKit.swift" */;
productName = MoQTHaishinKit;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 2945CBB41B4BE66000104112 /* Project object */;
Expand Down
3 changes: 3 additions & 0 deletions MoQTHaishinKit/MoQTHaishinKit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT double MoQTHaishinKitVersionNumber;
FOUNDATION_EXPORT const unsigned char MoQTHaishinKitVersionString[];
30 changes: 30 additions & 0 deletions MoQTHaishinKit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# MoQTHaishinKit
- This is a Swift implementation of MoQT, based on draft7. It is being developed for research and testing purposes.
- The features for live streaming and viewing have not been implemented yet, so testing is not possible at this time.

## Control Messages
- [x] 6.2. CLIENT_SETUP
- [x] 6.2. SERVER_SETUP
- [ ] 6.3. GOAWAY
- [x] 6.4. SUBSCRIBE
- [x] 6.5. SUBSCRIBE_UPDATE
- [ ] 6.6. UNSUBSCRIBE
- [ ] 6.7. FETCH
- [ ] 6.8. FETCH_CANCEL
- [x] 6.9. ANNOUNCE_OK
- [x] 6.10. ANNOUNCE_ERROR
- [ ] 6.11. ANNOUNCE_CANCEL
- [ ] 6.12. TRACK_STATUS_REQUEST
- [ ] 6.13. SUBSCRIBE_ANNOUNCES
- [ ] 6.14. UNSUBSCRIBE_ANNOUNCES
- [x] 6.15. SUBSCRIBE_OK
- [x] 6.16. SUBSCRIBE_ERROR
- [ ] 6.17. FETCH_OK
- [ ] 6.18. FETCH_ERROR
- [ ] 6.19. SUBSCRIBE_DONE
- [ ] 6.20. MAX_SUBSCRIBE_ID
- [x] 6.21. ANNOUNCE
- [ ] 6.22. UNANNOUNCE
- [ ] 6.23. TRACK_STATUS
- [x] 6.24. SUBSCRIBE_ANNOUNCES_OK
- [x] 6.25. SUBSCRIBE_ANNOUNCES_ERROR
3 changes: 3 additions & 0 deletions MoQTHaishinKit/Sources/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Logboard

nonisolated(unsafe) let logger = LBLogger.with("com.haishinkit.SRTHaishinKit")
13 changes: 13 additions & 0 deletions MoQTHaishinKit/Sources/Extension/Data+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import CoreMedia
import Foundation

extension Data {
var bytes: [UInt8] {
withUnsafeBytes {
guard let pointer = $0.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return []
}
return [UInt8](UnsafeBufferPointer(start: pointer, count: count))
}
}
}
Loading

0 comments on commit b35d8a2

Please sign in to comment.