untangledco / streaming Goto Github PK
View Code? Open in Web Editor NEWMedia streaming and broadcast systems in Go
Home Page: https://twitch.tv/untangledco
License: ISC License
Media streaming and broadcast systems in Go
Home Page: https://twitch.tv/untangledco
License: ISC License
Our struct SessionData
is just skipped in Encode()
.
At a high level what we need is to have a SessionData like:
v := SessionData{
ID: "1234",
Value: "5678",
URI: "hello/hi.json",
Language: "indonesian",
}
to be represented as a string like this:
#EXT-X-SESSION-DATA:DATA-ID="1234",VALUE="5678",URI="hello/hi.json",LANGUAGE="indonesian"
For every test case, Segmentation.EventIDCompliance (or anywhere else a so-called event ID field is) the value is always true. But this isn't really specified in plain language in the specs. It looks like it should be calculated from the associated event ID at encode/decode time.
Arguably we don't really need to have the field, exported or not, in the struct.
Relevant structures are:
There's an array with a bunch of magic values that we don't know how they are generated or where they come from.
If they can't be generated trivially, then maybe a link to somewhere the table can be copy & pasted from would be helpful.
Not that 114 lines is really big, it's just that it's much longer than it needs to be.
The logic to write Renditions in m3u8 format could be extracted to its own function and tested independently,
especially considering that in m3u8, a Rendition comes out to be one tag.
For example, two Renditions would look like:
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Main",DEFAULT=YES,URI="low/main/audio-video.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Centerfield",DEFAULT=NO,URI="low/centerfield/audio-video.m3u8"
For example, something like...
func writeRenditions(w io.Writer, renditions []Rendition) (n int, err error) {
//
}
func TestWriteRenditions(t *testing.T) {}
Test cases should be pretty easy too.
For the first rendition in the above example:
type t struct {
name string
rend Rendition
out string
}
v := t{
name: "Main"
rend: Rendition{
Type: MediaVideo,
URI: "low/main/audio-video.m3u8",
Group: "low",
Name: "Main",
Default: true,
}
out: `#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Main",DEFAULT=YES,URI="low/main/audio-video.m3u8"`,
}
We should avoid using fmt.Fprint and instead just append each tag attribute to a []string
to obviate a bunch of error handling.
The same idea as #7.
Say we have a Variant:
v := Variant{
Bandwidth: 1280000,
Video: "low",
URI: "low/main/audio-video.m3u8"
}
we want a function that can take that structure and return a string that would be inserted into a playlist, like:
#EXT-X-STREAM-INF:BANDWIDTH=1280000,VIDEO="low"
low/main/audio-video.m3u8
I think we have most of that implemented but we aren't testing it in isolation.
Some function like
TestWriteVariant(t *testing.T) {}
will make it much easier to add test cases: both ones that are valid EXT-X-STREAM-INF tags, and invalid ones too.
For more examples, see m3u8/testdata/master.m3u8
The values are documented in SCTE 35 section SCTE 35 section 10.3.3.1.
Right now we have magic values floating around. See in particular:
crc_32.go:95: 0x30476DC0,
splice_descriptor.go:152: case 0x34, 0x30, 0x32, 0x36, 0x38, 0x3a, 0x44, 0x46:
splice_descriptor.go:206: case 0x34, 0x30, 0x32, 0x36, 0x38, 0x3a, 0x44, 0x46:
splice_info.go:17: SAPNone = 0x30
These should be constants named, for example, ProviderAdStart or so.
In parseCCInfo()
, we can parse values for the ID field that are invalid.
The only valid values for CCInfo.ID
are the 4 integers 1, 2, 3, 4.
For example, we parse this playlist without error:
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-MEDIA:TYPE=AUDIO,INSTREAM-ID="CC69"
The only valid values for the INSTREAM-ID attribute are "CC1", "CC2", "CC3", "CC4" and
"SERVICE1" through "SERVICE63".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.