Latest 0.0.4
Homepage https://github.com/fromcelticpark/PHAssetResourceInputStream
License MIT
Platforms ios 8.0, requires ARC
Dependencies POSInputStreamLibrary
Frameworks Foundation, Photos
Authors

Build Status
codecov
Version
Platform
Swift

Description

PHAssetResourceInputStream is a library that adds input stream support for assets from Photos Framework. It is build on the top of POSInputStreamLibrary and it uses bounded blocking queue under the hood to inverse the producer-like API of PHAssetResourceManager and makes it consumer-friendly.

Example

Creating a stream:

let inputStream = InputStream.inputStream(withAssetResource: assetResource)

Setting an offset:

inputStream.setProperty(100, forKey: .fileCurrentOffsetKey)

Furthemore, the library provides a set of data structures that allows you to work with data of PHAssetResource in a synchronous manner.

Bellow is the example of getting the size from a PHAssetResource:

let dataProducer = PHAssetResourceDataProducer(assetResource: assetResource)
let dataGenerator = DataGeneratorFromDataProducer(dataProducer: dataProducer)

do {
    var size = 0
    while let data = try dataGenerator.nextChunk() {
        size += data.length
    }
    print(size)
} catch let error {
    print("Error occured: (error)")
}

TODO

  • [-] Add an example project

Installation

PHAssetResourceInputStream is available through CocoaPods. To install, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'PHAssetResourceInputStream'
end

License

PHAssetResourceInputStream is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "PHAssetResourceInputStream",
    "version": "0.0.4",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "summary": "PHAssetResourceInputStream is an input stream implementation library for assets from Photos Framework",
    "homepage": "https://github.com/fromcelticpark/PHAssetResourceInputStream",
    "authors": {
        "Aleksandr Dvornikov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fromcelticpark/PHAssetResourceInputStream.git",
        "tag": "0.0.4"
    },
    "source_files": "PHAssetResourceInputStream/*.swift",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "frameworks": [
        "Foundation",
        "Photos"
    ],
    "dependencies": {
        "POSInputStreamLibrary": [
            "~> 2.3"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This