Giter VIP home page Giter VIP logo

mamba's Introduction

Build Status Code Coverage from codecov Carthage compatible Cocoapod status GitHub release License Platform

Mamba

Mamba is a Swift iOS, tvOS and macOS framework to parse, validate and write HTTP Live Streaming (HLS) data.

This framework is used in Comcast applications to parse, validate, edit and write HLS playlists to deliver video to millions of customers. It was written by the Comcast VIPER Player Platform team.

Mamba Project Goals:

  • Simple-to-use parsing, editing and writing of HLS playlists.

  • Maximum performance. We required our parsing library to parse very large HLS playlists (12 hour Video-On-Demand) on low end phones in a few milliseconds. A internal core C library is used for very fast parsing of large playlists.

Requires

  • XCode 10.2+
  • Swift 4+ (written in Swift 5)
  • iOS 9+ or tvOS 9+ or macOS 10.13+

Usage

Parsing a HLS Playlist

Create an PlaylistParser.

let parser = PlaylistParser()

Parse your HLS playlist using the parser. Here's the asynchronous version:

let myPlaylistData: Data = ... // source of HLS data
let myPlaylistURL: URL = ... // the URL of this playlist resource

parser.parse(playlistData: myPlaylistData,
             url: myPlaylistURL,
             callback: { result in
                switch result {
                case .parsedVariant(let variant):
                    // do something with the parsed VariantPlaylist 
                    myVariantPlaylistHandler(variantPlaylist: variant)
                    break
                case .parsedMaster(let master):
                    // do something with the parsed MasterPlaylist 
                    myMasterPlaylistHandler(masterPlaylist: master)
                    break
                case .parseError(let error):
                    // handle the ParserError
                    myErrorHandler(error: error)
                    break
                }
})

And here's the synchronous version:

// note: could take several milliseconds for large transcripts!
let result = parser.parse(playlistData: myPlaylistData,
                          url: myPlaylistURL)
switch result {
case .parsedVariant(let variant):
    // do something with the parsed VariantPlaylist object
    myVariantPlaylistHandler(variantPlaylist: variant)
    break
case .parsedMaster(let master):
    // do something with the parsed MasterPlaylist object
    myMasterPlaylistHandler(masterPlaylist: master)
    break
case .parseError(let error):
    // handle the ParserError
    myErrorHandler(error: error)
    break
}

You now have an HLS playlist object.

MasterPlaylist and VariantPlaylist

These structs are in-memory representations of a HLS playlist.

They include:

  • The URL of the playlist.
  • An array of PlaylistTags that represent each line in the HLS playlist. This array is editable, so you can make edits to the playlist.
  • Utility functions to tell if a variant playlist is a Live, VOD or Event style playlist.
  • Helpful functionality around the structure of a playlist. This structure is kept up to date behind the scenes as the playlist is edited.
  • VariantPlaylist: includes calculated references to the "header", "footer" and all the video segments and the metadata around them.
  • MasterPlaylist: includes calculated references to the variant streams and their URL's.

MasterPlaylist and VariantPlaylist objects are highly editable.

Validating a Playlist

Validate your playlist using the PlaylistValidator.

let variantPlaylist: VariantPlaylistInterface = myVariantPlaylistFactoryFunction()
let masterPlaylist: MasterPlaylistInterface = myMasterPlaylistFactoryFunction()

let variantissues = PlaylistValidator.validate(variantPlaylist: variantPlaylist)
let masterissues = PlaylistValidator.validate(masterPlaylist: masterPlaylist)

It returns an array of PlaylistValidationIssues found with the playlist. They each have a description and a severity associated with them.

We currently implement only a subset of the HLS validation rules as described in the HLS specification. Improving our HLS validation coverage would be a most welcome pull request!

Writing a HLS Playlist

Create a PlaylistWriter.

let writer = PlaylistWriter()

Write your HLS playlist to a stream.

let stream: OutputStream = ... // stream to receive the HLS Playlist

do {
   try writer.write(playlist: variantPlaylist, toStream: stream)
   try writer.write(playlist: masterPlaylist, toStream: stream)
}
catch {
    // there was an error severe enough for us to stop writing the data
}

There is also a utility function in the playlist to write out the playlist to a Data object.

do {
    let variantData = try variantPlaylist.write()
    let masterData = try masterPlaylist.write()
    
    // do something with the resulting data
    myDataHandler(data: variantData)
    myDataHandler(data: masterData)
}
catch {
    // there was an error severe enough for us to stop writing the data
}

Using Custom Tags

Natively, Mamba only understands HLS tags as defined in the Pantos IETF specification. If you'd like to add support for a custom set of tags, you'll need to create them as a object implementing PlaylistTagDescriptor. Please look at PantosTag or one of the examples in the unit tests for sample code.

If you have any custom PlaylistTagDescriptor collections you'd like to parse alongside the standard Pantos tags, pass them in through this PlaylistParser initializer:

enum MyCustomTagSet: String {
    // define your custom tags here
    case EXT_MY_CUSTOM_TAG = "EXT-MY-CUSTOM-TAG"
}

extension MyCustomTagSet: PlaylistTagDescriptor {
    ... // conform to HLSTagDescriptor here
}

let customParser = PlaylistParser(tagTypes: [MyCustomTagSet.self])

If there is specfic data inside your custom tag that you'd like to access, e.g.

#EXT-MY-CUSTOM-TAG:CUSTOMDATA1="Data1",CUSTOMDATA2="Data1"

you can define that data in an enum that conforms to PlaylistTagValueIdentifier:

enum MyCustomValueIdentifiers: String {
    // define your custom value identifiers here
    case CUSTOMDATA1 = "CUSTOMDATA1"
    case CUSTOMDATA2 = "CUSTOMDATA2"
}

extension MyCustomValueIdentifiers: PlaylistTagValueIdentifier {
    ... // conform to PlaylistTagValueIdentifier here
}

You can now look through PlaylistTag objects for your custom tag values just as if it were a valuetype defined in the HLS specification.

Important Note About Memory Safety

In order to achieve our performance goals, the internal C parser for HLS had to minimize the amount of heap memory allocated.

This meant that, for each PlaylistTag object that is included in a MasterPlaylist/VariantPlaylist, instead of using a swift String to represent data, we use a MambaStringRef, which is a object that is a reference into the memory of the original data used to parse the playlist. This greatly speeds parsing, but comes at a cost: these PlaylistTag objects are unsafe to use beyond the lifetime of their parent MasterPlaylist/VariantPlaylist.

In general, this is no problem. Normal usage of a MasterPlaylist/VariantPlaylist would be (1) Parse the playlist, (2) Edit by manipulating PlaylistTags (3) Write the playlist.

If you do, for some reason, need to access PlaylistTag data beyond the lifetime of the parent MasterPlaylist/VariantPlaylist object, you'll need to make a copy of all MambaStringRef data of interest into a regular swift String. There's a string conversion function in MambaStringRef to accomplish this.

--

Note: We have legacy branches for mamba 1.x at our main 1.x branch and our develop 1.x branch. We are maintaining that branch, but may stop updating in the near future. Users are welcome to submit pull requests against the 1.x branches or potentially fork if they do not want to move to 2.0

--

mamba's People

Contributors

boctor avatar dcoufal avatar jaybpierce avatar jesse-calkin avatar jgainfort avatar johnriv avatar jonnybach avatar morrowa avatar subbotkin avatar therealrobg avatar youngkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mamba's Issues

Add more owners to podspec

Description

we need more than one owner who can push the podspec in case the owner is out of contact.

Tasks

  • add a couple more owners (at least the internal team)

References

Open Questions

improve (HLS)ValidationIssue

Description

comment I ran across in our current implementation:
// mamba validation issues have a poor interface. Best I can do is search in the description field when trying to find a specific issue in a list.

Tasks

  • change public init(description: IssueDescription, severity: IssueSeverity) to store the IssueDescription instead of just the description string
  • change public init(description: String, severity: IssueSeverity) to store the description as a .undefined(String) within IssueDescription enum
  • change description attribute to an accessor of the string of the stored IssueDescription

Open Questions

  • Does this seem like the right approach IYO @dcoufal ?

Include a playground as a demo

Description

It would be helpful for new users to have a working playground as a demo for what can be done.

Tasks

  • Create a playground that exercises most of mamba's common functions (parsing, reading, editing and writing HLS).
  • Update the README with info on the playground.

One character urls do not parse successfully.

Expected Behavior

If you parse the playlist

#EXT3MU
#EXTINF:5000
a

You should see the a line as a Location URL tag.

Observed Behavior

Parsing such a playlist gives no location. The line is completely skipped.

It's worth noting that this playlist:

#EXT3MU
#EXTINF:5000
aa

does produce the correct, expected Location URL tag with the value aa

Reproduction Steps

  1. Use the HLSParser to parse a playlist containing a Location URL that has one character.
  2. Examine the output HLSPlaylist. You will not see that Location URL in the output.

Observed on device(s):

  • All devices

Observed on OS Version(s):

  • All Versions

Implement faster EVENT style playlist parsing

Description

EVENT style playlists just add fragments onto the end of an existing variant.

This ticket is to implement a special parsing pathway that will take a previous EVENT style variant and update it with a new version. Only a small amount of parsing will have to be done to update the HLSPlaylist object.

Tasks

  • Provide an "update" style method for HLSParser that will take an previously parsed HLSPlaylist as an argument and will parse this playlist specially to save effort.
  • This new method should handle edge and error conditions well (i.e. both must be event style variants, should share a URL, difference between each should be small). If these conditions are not met, the new parse method should fall back to normal parsing.

`HLSParser` should not delete itself.

Let's say we are asynchronously parsing a HLS playlist.

The client creates a HLSParser.

The client starts a parse with a callback.

The client does not retain a reference to the HLSParser while parsing happens.

Expected Behavior

The client should be called back.

Observed Behavior

The client is not called back.

Why? There is a weak ref between the HLSParseWorker and the HLSParser. As soon as the work starts, no one has a strong ref to HLSParser and it's deleted (along with the callback closure ref!).

I think the fix should be to have a temp strong link between the HLSParseWorker and the HLSParser which should be broken when the parse is done (to avoid a circular ref). There might be other fixes as well.

Observed on device(s):

  • Simulators

Observed on OS Version(s):

  • iOS 11.3

API to get the time associated with custom tags.

Hi Mamba Team,

I am exploring the framework and it looks great for parsing custom tags in the HLS Playlists. Is there any existing API to get the time associated with each occurrence of a custom tag relevant to the first ts segment in the playlist?

For example, while parsing the below playlist, the first appearance of MYCUSTOMTAG is at 0 seconds because there are no ts chunks before that and the second appearance is at 10.01 seconds in the playlist after 123.ts and 456.ts, each with 5.005 seconds duration. Is there a way to get this information programmatically?

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-MYCUSTOMTAG:ID="1", X-CUSTOM-ATTRIBUTE="VAL1"
#EXTINF:5.005,
123.ts
#EXTINF:5.005,
456.ts
#EXT-X-MYCUSTOMTAG:ID="2",X-CUSTOM-ATTRIBUTE="VAL2"
#EXTINF:5.005,
789.ts
#EXT-X-ENDLIST

Parsing malformed HLS causes crash

(Note: Found in 1.x but should also check 2.x when fixing)

Parsing this playlist:

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-TARGETDURATION:3
#EXT-X-KEY:METHOD=AES-128,URI="http://myserver.com",IV=0x000102030aaaaccccccccbbbbb0d0e0f
#EXT-X-MAP:URI=\"http://myserver.com/init.mp4\"
#EXT-X-ENDLIST

Expected Behavior

Parse should succeed

Observed Behavior

Crash in HLSPlaylistStructure.rebuild()

Observed on device(s):

  • All devices

Observed on OS Version(s):

  • iOS 13.2

Carthage Build Error

Bug Template:


Expected Behavior

Carthage build / update works.

Observed Behavior

Carthage build fails

Observed on device(s):

  • MacBook Pro 2018

Observed on OS Version(s):

  • macOS 10.14

Open Questions

We've been seeing an intermittent issue with building the Mamba dependency through Carthage. The command that Carthage runs is:

/usr/bin/xcrun xcodebuild -workspace /PATH/TO/CARTFILE/DIRECTORY/Carthage/Checkouts/mamba/mamba.xcworkspace -scheme mamba -configuration Release -derivedDataPath ~/Library/Caches/org.carthage.CarthageKit/DerivedData/10.3_10G8/mamba/1.2.0 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/qf/05lm714d1h9fz1r47bsw8xmc0000gp/T/mamba SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO

The error is that occasionally it can't find the <mamba/mamba-Swift.h> header in mambaSharedFramework/HLS\ Rapid\ Parser/RapidParserError.m.
The build failure appears to happen more consistently on the newer MacBook Pros (MacBook Pro (15-inch, 2018) 2.9 GHz Intel Core i9, for example). Personally I have not seen this occur on older models (MacBook Pro (15-inch, 2017) 2.8 GHz intel Core i7).
The suspicion is some sort of race condition combined with the new build system and its parallel builds that is exacerbated by the speed of the machine.
As an experiment, we have changed the build system to the legacy one (File > Workspace Settings... > Build System: from Xcode) within the Mamba workspace on, the newer machines, and run the command, and it passes successfully every time.
When changing back to the "New Build System (Default)" it fails consistently with the missing Swift header error.

  1. Has anyone experienced this before
  2. Could this have been solved in 1.3?
  3. What about 2.0? If so how difficult would it be to upgrade to the new API?

CustomDebugStringConvertible output for HLSPlaylist and related classes is not easy to read

Description

When debugging issues, it's common to look at the playlist, especially if you are editing it in some way.

Current output is basically a dump of the HLSTag array, which is hard to read and put in the context of a actual HL playlist.

This ticket is to have the output of debugDescription for HLSPlaylist and related classes print out the actual playlist as it would be delivered by HLSWriter.

Tasks

  • Update HLSPlaylistStructure so that the tags are not included in output. Instead, we should output the actual manifest. Ideally, we'd reuse some of all of HLSWriter to do this.

Using .transform and replacing a tag of tagDescription PantosTag.Location results in a invalid playlist with literal #Location

I am trying to rewrite a playlist, specifically change the Location

                let parser = PlaylistParser()
                let result = parser.parse(playlistData: data, url: url)
                switch result {
                case .parsedMaster(var master):
                    do {
                        try master.transform {
                            (tag: PlaylistTag) -> PlaylistTag in
                            var mutableTag = tag
                            case PantosTag.Location:
                                mutableTag = PlaylistTag(
                                    tagDescriptor: PantosTag.Location,
                                    stringTagData: /* some URL String */,
                                    parsedValues: nil
                                )
[... other stuff]

But when I do this i get something like this as output

#Location:http://MY-URL

When I compare the incoming tag and my mutableTag, I can see some differences that don't seem to be exposed by the API.

For example, tagName is nil in the incoming tag, but it's not possible to set it to nil using the exposed API AFAICT.

The reason I am creating a new tag is because tagData is immutable.

Expected Behavior

To be able to set a PantosTag.Location while doing .transform.
A PlaylistTag with PantosTag.Location should be written as the string in tagData, without any decoration.

Observed Behavior

It's not possible to set a correct PantosTag.Location during .transform.
The PlaylistTag is decorated with #Location:... when writing it.

Reproduction Steps

  1. Parse any playlist with LocationTags
  2. Try to replace any LocationTag with a new LocationTag
  3. write the playlist
  4. Observe literal #Location rows, which are not valid HLS.

Observed on device(s):

  • iPad Air 2

Observed on OS Version(s):

  • iOS 12.4

Thanks for all the good work! I hope I am just doing something silly and this can/should be done in a completely different way.

Support XCode 9+

Hi! The README states that the library supports XCode 9+ but is using an operator requiring XCode 9.3+.

Seems this was introduced with this commit and changing flatMap to compactMap

2ecd85c

Is the intention still to support XCode 9+ or to move to only supporting 9.3+? Would a PR converting compactMap back to flatMap be acceptable?

playlist.tagIndexes(forMediaSequence:) is not working properly.

Parse this variant:

#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:3
#EXT-X-VERSION:3
#EXTINF:2.96130,
fileSequence0.ts
#EXTINF:2.96130,
fileSequence1.ts
#EXTINF:2.96129,
fileSequence2.ts
#EXTINF:2.96129,
fileSequence3.ts
#EXTINF:2.96130,
fileSequence4.ts
#EXTINF:2.96130,
fileSequence5.ts
#EXTINF:2.96129,
fileSequence6.ts
#EXTINF:2.96129,
fileSequence7.ts
#EXTINF:2.96130,
fileSequence8.ts
#EXTINF:2.96130,
fileSequence9.ts
#EXTINF:2.96129,
fileSequence10.ts

Call playlist.tagIndexes(forMediaSequence: 0)

Expected Behavior

I would expect to get a range back (namely 4...5, I think, but there should be a range as that media sequence exists)

Observed Behavior

You get nil back.

Note that if you call playlist.segmentGroup(forMediaSequence: 0) you do get the correct structure back and that structure has the correct range, so this problem is likely trivial to fix.

Reproduction Steps

(steps are above)

Observed on device(s):

  • iPhone X Simulator

Observed on OS Version(s):

  • iOS 11.4

Notes:

Please add a unit test for this as part of the fix.

Revert deployment changes made in #61

We updated the 1.x version of the mamba library to iOS 11.0 (from iOS 9.3) in this PR: #61

This is an external implementation of Comcast's internal support matrix, and should not have been made public. This ticket is to revert that change for the 1.x branch.

Remove the HLSTagCriteria and HLSTagCriterion Query Language objects

Description

This ticket is to remove the HLSTagCriteria and HLSTagCriterion objects.

I don't think people are using those objects. At Comcast, we use filter/map/reduce to do queries instead, and that seems much more natural and easy to understand.

Tasks

  • Remove HLSTagCriteria and HLSTagCriterion
  • Replace the internal usage of those objects in mamba with Swift filter/map/reduce

Tag new release 1.5.6

The PR with small changes have been merged into develop_1.x
#119
Can you please tag new release 1.5.6

`HLSParser` crashes with empty `Data` object.

Expected Behavior

You should be able to "parse" an empty Data object with HLSParser

Observed Behavior

HLSParser will crash if you try to do so.


This ticket is to fix the crash so you get an empty HLSPlaylist when parsed.

LHLS Support - Low-Latency HLS

Feature Request

It doesn't seem that Mamba currently supports Low-Latency HLS, is this in the plan, or did I miss something? It claims that this writes HLS playlists, does this mean I can hook up my AV Inputs to this library to write the streams and publish them to an HLS server? I cannot seem to find sufficient information on this.
More than happy to contribute to this project as I am looking for a good solution, I'm just having trouble determining exactly what this library is capable of based on the documentation and lack of examples.

Tasks

  • Output LHLS using native camera/microphone/Bluetooth
  • Playback LHLS using the mamba player

References

Open Questions

  1. Did I miss something, or does this plugin provide any type of LHLS support? (Low-Latency HLS).
  2. Great work, perhaps it's because this is mostly for streaming video that is not reliant on live-streaming, but I hope I can utilize this for my new LHLS library.

Should be an interface to figure out the muxed/demuxed makeup of an asset

Description

It's useful to be able to look at a master playlist and figure out if it has:

demuxed video
demuxed audio
muxed audio and video

or some combination of such.

In my head, this would be a function on a MasterPlaylist and would return an OptionSet, but there are likely other ways of skinning the cat.

Tasks

  • Write a function on HLSPlaylist or MasterPlaylist to return mixed/demuxed status.

Notes

Comcast has private code that basically does this, so might be best to wait for someone in the company to do the work.

HLSWriter.write fatal error using CocoaPods

Expected Behavior

Install mamba with CocoaPods. HLSWriter.write should work.

Observed Behavior

HLSWriter.write gives an error Fatal error: Unable to find framework bundle: file /path/to/project/Pods/mamba/mambaSharedFramework/Mamba.swift, line 29

Workaround

In Pods/mamba/Support Files/Info.plist, change the "Bundle identifier" to "com.comcast.mamba".

Swift Compiler Code Optimization

I noticed that when accessing Playlist Tags in iterations on a debug build would work fine, but on a production build it would crash the app.

The way I was able to solve this was by setting

Swift compiler code generation optimize level: None

Which I fear has an impact on performance. Is this known at all?

Swift Package Manager support?

Do you guys have any plans on adding SPM support? We're looking to move away from Carthage, now that SPM supports iOS/tvOS

hevc should be supported as a video type

Description

Right now we only support avc as a codec, but hevc is supported in AVFoundation as of iOS 11.

Tasks

  • Alter HLSCodec and HLSCodecArray to accept avc and hevc as codecs, and return true for containsVideo if hevc is present.

Add a simple function to return segment based info from info about a tag to look for.

Description

It's a common task to ask "what time does this tag appear in a variant playlist" or "where does this tag appear in a variant"? This info is available via mamba but it's a little bit of a pain to get and non-obvious.

This ticket is to add a one-liner syntactic sugar function to get this info.

There should be functions that return (1) an array of times (probably CMTime if feasible) (2) an array of media sequence numbers (3) an array of tag indexes (i.e. indexes into the playlist tag array) and (4) an array of tag group indexes (i.e. indexes into the media groups array). This function should take some kind of predicate (probably a closure that takes a HLSTag and returns true or false for a match)

This task depends on #5 and should only be added to VariantPlaylists. The array of times potentially does not make sense for LIVE playlists, so we'll have to figure out what to do there.

Tasks

  • Add the functions described above.

References

  • Original bug: #29

v 1.2.0 cocoapods

Is it possible to get 1.2.0 onto cocoapods? I unfortunately have not been able to move off pods just yet.

Support Version 8 of the HLS specification

Description

Ideally, mamba would support all HLS tags through version 8.

This issue is more of a epic, and each tag would be a specific sub issue. If you decide to peel off a unsupported tag, make a new issue and link back to this one.

Tasks

For each tag

  • Add the tag to PantosTag
  • Add any data keys needed for the tag in PantosValue
  • Add a new HLSTagValidator if needed.

References

FailableStringLiteralConvertible should be a little more specific in it's initializer.

Description

A number of common types (Int, Float, etc) have the FailableStringLiteralConvertible interface.

public protocol FailableStringLiteralConvertible {
    init?(string: String)
}

This is public since users might want to create custom HLS parsers for their custom tags.

But, it's not clear that these belong to mamba.

Rename the initializer to be more specific to mamba, or at least make it clearer that this is custom and you shouldn't be using it if you don't recognize it.

My first thought is:

public protocol FailableStringLiteralConvertible {
    init?(withFailableString: String)
}

Tasks

  • Update the FailableStringLiteralConvertible interface and all the mamba-supplied overrides.
  • When the release is done for this change, we should follow semantic versioning and update to the next major version, as this change might break clients.

The `playlistType` for a variant playlist should be cached and not calculated every time.

Description

Right now, if you call playlistType for a playlist, the type is calculated every time from scratch. It's a small calculation, but it's not uncommon in Comcast code to call this a lot.

It should be cached. The cached value should clear if the playlist is edited.

Depends on #5

Tasks

  • Have a private cached version of playlistType. Calls to public playlistType should check if there's a cache and return it.
  • The cache should probably live in PlaylistStructure since, if the playlist is edited, the cache value should clear.
  • Shouldn't be a unknown type anymore since we know we are a variant and therefore have rules about determination of playlistType that are always applicable.

Updating podspec to include fix for static libraries

Expected Behavior

Integrating mamba into XCode project through Cocoapods should raise no issue.

Observed Behavior

Build error with the message mamba/mamba-Swift.h file not found`. Observed in Xcode 11.6.

Open Questions

Seems like commit 56a03fd fixes this issue, but the podspec is not pointing to the latest commit on the develop branch. Is it possible for the podspec to be updated?

Remove `HLS` prefix from all classes

Description

We use the prefix HLS on many mamba objects. This is not required and is just extra typing/old fashioned. Let's remove it.

Notes: I think HLSParser, HLSWriter, etc should become PlaylistParser, PlaylistWriter etc. HLSPlaylist will become Playlist. Use best judgment when updating symbol names.

Tasks

  • Remove HLS prefix on all mamba symbols.

Playlists should be "Master" and "Variant" flavored

Description

Right now, all HLS playlists are HLSPlaylist type. You can tell if a playlist is master or variant by inspecting the type.

However, there are weak typing issues in HLSPlaylist. The mediaSegmentGroups and all the HLSPlaylistTimelineTranslator don't really make sense unless the playlist is a Variant. Also, this situation leads to a lot of:

guard playlist.type == .master else {
    // exit with an error, exception and possibly an assert
}

which could be avoided with strong typing.

Tasks

It's not 100% clear what the correct solution is. Perhaps the HLSParser could have two success callbacks, one for master and one for variant playlists.

Most functionality should be shared between HLSMasterPlaylist and HLSVariantPlaylist. It's only mediaSegmentGroups and HLSPlaylistTimelineTranslator that are specific to HLSVariantPlaylist. I would imagine that HLSMasterPlaylist could have some specific functionality to deal with #EXT-X-STREAM-INF tags paired with variant urls (similar to mediaSegmentGroups).

We should have an agreement about architecture before going forward.

This will be a large architectural change.

Enable module stability. Now can't use with Swift 5.3.2.

Description

Currently, I can't include it with Swift 5.3.2.
Screenshot 2021-02-22 at 6 10 26 PM

Since Swift 5.1, Apple provide module stability feature in Xcode. This enables a framework to be able to be included in targets with newer Swift versions. But BUILD_LIBRARY_FOR_DISTRIBUTION build setting has to be enabled.
Screenshot 2021-02-22 at 5 59 38 PM

Screenshot 2021-02-22 at 5 53 34 PM

My current workaround is to add a Podfile post_install script to do so:

post_install do | installer |
  installer.pods_project.targets.each do |target|
    if target.name == 'mamba-iOS' || target.name == 'mamba-tvOS'
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end
    end
  end
end

Tasks

  • Set BUILD_LIBRARY_FOR_DISTRIBUTION build setting to Yes

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.