Skip to content

Commit

Permalink
Add api documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Jun 25, 2022
1 parent b8f0699 commit e233e0a
Show file tree
Hide file tree
Showing 203 changed files with 5,250 additions and 4,516 deletions.
8 changes: 4 additions & 4 deletions HaishinKit.podspec
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Pod::Spec.new do |s|

s.name = "HaishinKit"
s.version = "1.2.3"
s.summary = "Camera and Microphone streaming library via RTMP, HLS for iOS, macOS, tvOS."
s.version = "1.2.4"
s.summary = "Camera and Microphone streaming library via RTMP, HLS for iOS, macOS and tvOS."
s.swift_version = "5.5"

s.description = <<-DESC
HaishinKit. Camera and Microphone streaming library via RTMP, HLS for iOS, macOS, tvOS.
HaishinKit. Camera and Microphone streaming library via RTMP, HLS for iOS, macOS and tvOS.
DESC

s.homepage = "https://github.com/shogo4405/HaishinKit.swift"
s.license = "New BSD"
s.author = { "shogo4405" => "[email protected]" }
s.authors = { "shogo4405" => "[email protected]" }
s.source = { :git => "https://github.com/shogo4405/HaishinKit.swift.git", :tag => "#{s.version}" }
s.social_media_url = "http://twitter.com/shogo4405"
s.social_media_url = "https://twitter.com/shogo4405"

s.ios.deployment_target = "9.0"
s.ios.source_files = "Platforms/iOS/*.{h,swift}"
Expand Down
28 changes: 14 additions & 14 deletions HaishinKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@
29798E751CE614FE00F5CBD0 /* SampleVideo_360x240_5mb in Resources */ = {isa = PBXBuildFile; fileRef = 29B876D71CD70CE700FC07DA /* SampleVideo_360x240_5mb */; };
29798E761CE614FE00F5CBD0 /* SampleVideo_360x240_5mb.m3u8 in Resources */ = {isa = PBXBuildFile; fileRef = 29B876D81CD70CE700FC07DA /* SampleVideo_360x240_5mb.m3u8 */; };
29798E771CE614FE00F5CBD0 /* SampleVideo_360x240_5mb.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 29B876D91CD70CE700FC07DA /* SampleVideo_360x240_5mb.mp4 */; };
297E69122324E38800D418AB /* AudioCodec.Destination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297E69112324E38800D418AB /* AudioCodec.Destination.swift */; };
297E69132324E38800D418AB /* AudioCodec.Destination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297E69112324E38800D418AB /* AudioCodec.Destination.swift */; };
297E69142324E38800D418AB /* AudioCodec.Destination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297E69112324E38800D418AB /* AudioCodec.Destination.swift */; };
297E69122324E38800D418AB /* AudioCodec.Format.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297E69112324E38800D418AB /* AudioCodec.Format.swift */; };
297E69132324E38800D418AB /* AudioCodec.Format.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297E69112324E38800D418AB /* AudioCodec.Format.swift */; };
297E69142324E38800D418AB /* AudioCodec.Format.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297E69112324E38800D418AB /* AudioCodec.Format.swift */; };
298BCF331DD4C44A007FF86A /* AnyUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 298BCF321DD4C44A007FF86A /* AnyUtil.swift */; };
2992D1541ED04A2C008D9DC1 /* AVVideoIOUnit+Extension-macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2992D1521ED04A1B008D9DC1 /* AVVideoIOUnit+Extension-macOS.swift */; };
2999C3752071138F00892E55 /* MTHKView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2999C3742071138F00892E55 /* MTHKView.swift */; };
Expand Down Expand Up @@ -750,7 +750,7 @@
2976A4851D4903C300B53EF2 /* DeviceUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceUtil.swift; sourceTree = "<group>"; };
29798E591CE60E5300F5CBD0 /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
29798E5D1CE60E5300F5CBD0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
297E69112324E38800D418AB /* AudioCodec.Destination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioCodec.Destination.swift; sourceTree = "<group>"; };
297E69112324E38800D418AB /* AudioCodec.Format.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioCodec.Format.swift; sourceTree = "<group>"; };
2981E1301D646E3F00E8F7CA /* Cartfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Cartfile; sourceTree = "<group>"; };
298BCF321DD4C44A007FF86A /* AnyUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyUtil.swift; sourceTree = "<group>"; };
2992D1521ED04A1B008D9DC1 /* AVVideoIOUnit+Extension-macOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AVVideoIOUnit+Extension-macOS.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1019,7 +1019,7 @@
isa = PBXGroup;
children = (
BC44A1A823D31E92002D4297 /* AudioCodec.AudioBuffer.swift */,
297E69112324E38800D418AB /* AudioCodec.Destination.swift */,
297E69112324E38800D418AB /* AudioCodec.Format.swift */,
29B876571CD70A7900FC07DA /* AudioCodec.swift */,
29B876581CD70A7900FC07DA /* H264Decoder.swift */,
29B876591CD70A7900FC07DA /* VideoCodec.swift */,
Expand Down Expand Up @@ -2081,7 +2081,7 @@
BCC1A7172647F3E000661156 /* DecoderSpecificInfo.swift in Sources */,
29B8765B1CD70A7900FC07DA /* AudioCodec.swift in Sources */,
29EA87D51E799F670043A5F8 /* Mirror+Extension.swift in Sources */,
297E69122324E38800D418AB /* AudioCodec.Destination.swift in Sources */,
297E69122324E38800D418AB /* AudioCodec.Format.swift in Sources */,
2942A4F821A9418A004E1BEE /* Running.swift in Sources */,
BCC1A72F264FAC4E00661156 /* ElementaryStreamType.swift in Sources */,
29F6F4851DFB83E200920A3A /* RTMPHandshake.swift in Sources */,
Expand Down Expand Up @@ -2214,7 +2214,7 @@
29D3D4D31ED04D9600DD4AA6 /* NetStream+Extension-macOS.swift in Sources */,
29EA87D61E799F6A0043A5F8 /* Mirror+Extension.swift in Sources */,
BC7A23F525171C8F0089F77C /* MTHKView.swift in Sources */,
297E69132324E38800D418AB /* AudioCodec.Destination.swift in Sources */,
297E69132324E38800D418AB /* AudioCodec.Format.swift in Sources */,
BCA97BFB263C4F980027213C /* MP4EditListBox.swift in Sources */,
BCC1A6D4264461FE00661156 /* MP4HandlerBox.swift in Sources */,
BCA97C01263C599C0027213C /* MP4SyncSampleBox.swift in Sources */,
Expand Down Expand Up @@ -2448,7 +2448,7 @@
29EB3DF71ED05797001CAE8B /* URL+Extension.swift in Sources */,
29DF20682312A436004057C3 /* RTMPSocketCompatible.swift in Sources */,
29EB3E0B1ED05871001CAE8B /* TSReader.swift in Sources */,
297E69142324E38800D418AB /* AudioCodec.Destination.swift in Sources */,
297E69142324E38800D418AB /* AudioCodec.Format.swift in Sources */,
29EB3DF51ED05779001CAE8B /* CMFormatDescription+Extension.swift in Sources */,
BCA97C0C263D80F40027213C /* MP4SampleEntry.swift in Sources */,
29EB3E381ED05A41001CAE8B /* MD5.swift in Sources */,
Expand Down Expand Up @@ -2798,7 +2798,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
ONLY_ACTIVE_ARCH = YES;
"OTHER_SWIFT_FLAGS[arch=*]" = "-Xfrontend -debug-time-function-bodies";
PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit;
Expand Down Expand Up @@ -2832,7 +2832,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit;
PRODUCT_NAME = HaishinKit;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -2907,7 +2907,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
"OTHER_SWIFT_FLAGS[arch=*]" = "-Xfrontend -debug-time-function-bodies";
PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit;
PRODUCT_NAME = HaishinKit;
Expand Down Expand Up @@ -2939,7 +2939,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit;
PRODUCT_NAME = HaishinKit;
SDKROOT = macosx;
Expand Down Expand Up @@ -3073,7 +3073,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit;
PRODUCT_NAME = HaishinKit;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -3109,7 +3109,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.2.4;
PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit;
PRODUCT_NAME = HaishinKit;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
8 changes: 4 additions & 4 deletions Platforms/iOS/NetStream+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AVFoundation
import Foundation

extension NetStream {
open var orientation: AVCaptureVideoOrientation {
public var orientation: AVCaptureVideoOrientation {
get {
mixer.videoIO.orientation
}
Expand All @@ -13,17 +13,17 @@ extension NetStream {
}
}

open func attachScreen(_ screen: CaptureSessionConvertible?, useScreenSize: Bool = true) {
public func attachScreen(_ screen: CaptureSessionConvertible?, useScreenSize: Bool = true) {
lockQueue.async {
self.mixer.videoIO.attachScreen(screen, useScreenSize: useScreenSize)
}
}

open var zoomFactor: CGFloat {
public var zoomFactor: CGFloat {
self.mixer.videoIO.zoomFactor
}

open func setZoomFactor(_ zoomFactor: CGFloat, ramping: Bool = false, withRate: Float = 2.0) {
public func setZoomFactor(_ zoomFactor: CGFloat, ramping: Bool = false, withRate: Float = 2.0) {
self.mixer.videoIO.setZoomFactor(zoomFactor, ramping: ramping, withRate: withRate)
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ macOS 10.14+
* NSCameraUsageDescription

## 🔧 Installation
*Please set up your project Swift 5.5. *
*Please set up your project Swift 5.5.*

### CocoaPods
```rb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AudioToolbox

extension AudioCodec {
public enum Destination {
public enum Format {
case aac
case pcm

Expand Down
16 changes: 13 additions & 3 deletions Sources/Codec/AudioCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ public protocol AudioCodecDelegate: AnyObject {

// MARK: -
/**
- seealse:
- https://developer.apple.com/library/ios/technotes/tn2236/_index.html
* The AudioCodec translate audio data to another format.
* - seealse: https://developer.apple.com/library/ios/technotes/tn2236/_index.html
*/
public class AudioCodec {
enum Error: Swift.Error {
case setPropertyError(id: AudioConverterPropertyID, status: OSStatus)
}

/**
* The audio encoding or decoding options.
*/
public enum Option: String, KeyPathRepresentable {
/// Specifies the muted.
case muted
/// Specifies the bitRate of audio output.
case bitrate
/// Specifies the sampleRate of audio output.
case sampleRate
/// The bitRate of audio output.
case actualBitrate

public var keyPath: AnyKeyPath {
Expand All @@ -43,9 +50,12 @@ public class AudioCodec {
public static let defaultSampleRate: Double = 0
public static let defaultMaximumBuffers: Int = 1

public var destination: Destination = .aac
/// Specifies the output format.
public var destination: Format = .aac
/// Specifies the delegate.
public weak var delegate: AudioCodecDelegate?
public private(set) var isRunning: Atomic<Bool> = .init(false)
/// Specifies the settings for audio codec.
public var settings: Setting<AudioCodec, Option> = [:] {
didSet {
settings.observer = self
Expand Down
11 changes: 11 additions & 0 deletions Sources/Codec/VideoCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,27 @@ public protocol VideoCodecDelegate: AnyObject {

// MARK: -
public final class VideoCodec {
/**
* The video encoding or decoding options.
*/
public enum Option: String, KeyPathRepresentable, CaseIterable {
/// Specifies the muted
case muted
/// Specifies the width of video.
case width
/// Specifies the height of video.
case height
/// Specifies the bitrate.
case bitrate
/// Specifies the H264 profile level.
case profileLevel
#if os(macOS)
/// Specifies the HardwareEncoder is enabled(TRUE), or not(FALSE).
case enabledHardwareEncoder
#endif
/// Specifies the keyframeInterval.
case maxKeyFrameIntervalDuration
/// Specifies the scalingMode.
case scalingMode

public var keyPath: AnyKeyPath {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Extension/CMSampleBuffer+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extension CMSampleBuffer {
decode: nil,
renderingIntent: .defaultIntent)

public func reflectHorizontal() {
func reflectHorizontal() {
if let imageBuffer: CVImageBuffer = self.imageBuffer {
var sourceBuffer = vImage_Buffer()

Expand Down
4 changes: 4 additions & 0 deletions Sources/Media/ScalingMode.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* The scaling mode.
* - seealso: https://developer.apple.com/documentation/videotoolbox/kvtpixeltransferpropertykey_scalingmode
*/
public enum ScalingMode: String {
case normal = "Normal"
case letterbox = "Letterbox"
Expand Down
14 changes: 7 additions & 7 deletions Sources/RTMP/AMF0Serializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.2 Number Type
* - seealso: 2.2 Number Type
*/
func serialize(_ value: Double) -> Self {
writeUInt8(Type.number.rawValue).writeDouble(value)
Expand All @@ -211,7 +211,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.3 Boolean Type
* - seealso: 2.3 Boolean Type
*/
func serialize(_ value: Bool) -> Self {
writeBytes(Data([Type.bool.rawValue, value ? 0x01 : 0x00]))
Expand All @@ -225,7 +225,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.4 String Type
* - seealso: 2.4 String Type
*/
func serialize(_ value: String) -> Self {
let isLong: Bool = UInt32(UInt16.max) < UInt32(value.count)
Expand Down Expand Up @@ -282,7 +282,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.10 ECMA Array Type
* - seealso: 2.10 ECMA Array Type
*/
func serialize(_ value: ASArray) -> Self {
self
Expand Down Expand Up @@ -312,7 +312,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.12 Strict Array Type
* - seealso: 2.12 Strict Array Type
*/
func serialize(_ value: [Any?]) -> Self {
writeUInt8(Type.strictArray.rawValue)
Expand Down Expand Up @@ -340,7 +340,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.13 Date Type
* - seealso: 2.13 Date Type
*/
func serialize(_ value: Date) -> Self {
writeUInt8(Type.date.rawValue).writeDouble(value.timeIntervalSince1970 * 1000).writeBytes(Data([0x00, 0x00]))
Expand All @@ -356,7 +356,7 @@ extension AMF0Serializer: AMFSerializer {
}

/**
* @see 2.17 XML Document Type
* - seealso: 2.17 XML Document Type
*/
func serialize(_ value: ASXMLDocument) -> Self {
writeUInt8(Type.xmlDocument.rawValue).serializeUTF8(value.description, true)
Expand Down
30 changes: 20 additions & 10 deletions Sources/RTMP/ASClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ public typealias ASObject = [String: Any?]
/**
The ASUndefined class represents an undefined for ActionScript.
*/
public final class ASUndefined: NSObject {
override public var description: String {
public struct ASUndefined: CustomStringConvertible {
public var description: String {
"undefined"
}

override fileprivate init() {
super.init()
}
}

public struct ASTypedObject {
Expand Down Expand Up @@ -135,8 +131,8 @@ extension ASArray: Equatable {
- 2.17 XML Document Type (amf0-file-format-specification.pdf)
- 3.9 XMLDocument type (amf-file-format-spec.pdf)
*/
public final class ASXMLDocument: NSObject {
override public var description: String {
public struct ASXMLDocument: CustomStringConvertible {
public var description: String {
data
}

Expand All @@ -147,14 +143,21 @@ public final class ASXMLDocument: NSObject {
}
}

extension ASXMLDocument: Equatable {
// MARK: Equatable
public static func == (lhs: ASXMLDocument, rhs: ASXMLDocument) -> Bool {
(lhs.description == rhs.description)
}
}

// MARK: -
/**
ActionScript 3.0 introduces a new XML type.

- seealso: 3.13 XML type (amf-file-format-spec.pdf)
*/
public final class ASXML: NSObject {
override public var description: String {
public struct ASXML: CustomStringConvertible {
public var description: String {
data
}

Expand All @@ -164,3 +167,10 @@ public final class ASXML: NSObject {
self.data = data
}
}

extension ASXML: Equatable {
// MARK: Equatable
public static func == (lhs: ASXML, rhs: ASXML) -> Bool {
(lhs.description == rhs.description)
}
}
Loading

0 comments on commit e233e0a

Please sign in to comment.