-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48bb006
Showing
12 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Test package | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Build | ||
run: swift build | ||
- name: Run tests | ||
run: | | ||
set -e | ||
echo "::group::Run BitwiseTests" | ||
.build/debug/BitwiseTests | ||
echo "::endgroup::" | ||
echo "::group::Run FramingTests" | ||
.build/debug/FramingTests | ||
echo "::endgroup::" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.build/ | ||
.swiftpm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "ogg"] | ||
path = Sources/COgg/ogg | ||
url = https://github.com/xiph/ogg.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Readdle Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// swift-tools-version: 5.4 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "swift-ogg", | ||
products: [ | ||
.library( | ||
name: "Ogg", | ||
targets: ["COgg"] | ||
), | ||
], | ||
targets: [ | ||
.target( | ||
name: "COgg", | ||
sources: [ | ||
"./ogg/src/bitwise.c", | ||
"./ogg/src/framing.c", | ||
] | ||
), | ||
.executableTarget( | ||
name: "BitwiseTests", | ||
path: "Tests/BitwiseTests", | ||
cSettings: [ | ||
.headerSearchPath("../../Sources/COgg/ogg/include"), | ||
.headerSearchPath("../../Sources/COgg/ogg/src"), | ||
.define("_V_SELFTEST"), | ||
.unsafeFlags(["-Wno-shorten-64-to-32"]), | ||
] | ||
), | ||
.executableTarget( | ||
name: "FramingTests", | ||
path: "Tests/FramingTests", | ||
cSettings: [ | ||
.headerSearchPath("../../Sources/COgg/ogg/include"), | ||
.headerSearchPath("../../Sources/COgg/ogg/src"), | ||
.define("_V_SELFTEST"), | ||
.unsafeFlags(["-Wno-shorten-64-to-32"]), | ||
] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# swift-ogg | ||
A basic Swift Package wrapper for `libogg` from [xiph/ogg](https://github.com/xiph/ogg). | ||
|
||
# Usage | ||
Add a dependency to your Swift Package definition. | ||
The example below is in `swift-tools-version: 5.4` syntax: | ||
```swift | ||
let package = Package( | ||
name: "MyPackage", | ||
products: [.library(name: "MyLib", targets: ["MyLib"])], | ||
dependencies: [ | ||
.package(url: "https://github.com/readdle/swift-ogg.git", .upToNextMinor(from: "1.3.5")), | ||
], | ||
targets: [ | ||
.target( | ||
name: "MyLib", | ||
dependencies: [ | ||
.product(name: "Ogg", package: "swift-ogg"), | ||
], | ||
… | ||
``` | ||
Import C module in your code and use [ogg API](https://www.xiph.org/ogg/doc/libogg/reference.html): | ||
```swift | ||
import COgg | ||
|
||
var streamState = ogg_stream_state() | ||
var headerPacket = ogg_packet() | ||
var oggPage = ogg_page() | ||
|
||
ogg_stream_init(&streamState, Int32(Date().timeIntervalSince1970)) | ||
|
||
// Prepare required header packets | ||
|
||
ogg_stream_packetin(&streamState, &headerPacket) | ||
… | ||
|
||
while ogg_stream_flush(&streamState, &oggPage) != 0 { | ||
// Process page data, e.g. write to file | ||
} | ||
``` | ||
|
||
# Versioning | ||
As it is only a wrapper, versioning strictly follows the original. | ||
Version `1.3.5` would correspond to official [v1.3.5](https://github.com/xiph/ogg/releases/tag/v1.3.5) release | ||
and so on. | ||
|
||
# Licenses | ||
This project is under MIT license. `libogg` sources are | ||
from [xiph/ogg repository](https://github.com/xiph/ogg) and are licensed under | ||
the [BSD-3-Clause license](https://github.com/xiph/ogg?tab=BSD-3-Clause-1-ov-file#BSD-3-Clause-1-ov-file). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module COgg [system] { | ||
umbrella header "ogg/ogg.h" | ||
export * | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../ogg/include/ogg/ogg.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../ogg/include/ogg/os_types.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../Sources/COgg/ogg/src/bitwise.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../Sources/COgg/ogg/src/framing.c |