diff --git a/DashFiles/DASHPlaylist-1.mpd b/DashFiles/DASHPlaylist-1.mpd new file mode 100644 index 0000000..ce4f0d6 --- /dev/null +++ b/DashFiles/DASHPlaylist-1.mpd @@ -0,0 +1,30 @@ + + + + + DASH_2_4_M + + + + + + DASH_1_2_M + + + + + + DASH_4_8_M + + + + + + DASH_600_K + + + + + + + \ No newline at end of file diff --git a/DashFiles/DASHPlaylist-2.mpd b/DashFiles/DASHPlaylist-2.mpd new file mode 100644 index 0000000..ce4f0d6 --- /dev/null +++ b/DashFiles/DASHPlaylist-2.mpd @@ -0,0 +1,30 @@ + + + + + DASH_2_4_M + + + + + + DASH_1_2_M + + + + + + DASH_4_8_M + + + + + + DASH_600_K + + + + + + + \ No newline at end of file diff --git a/DashFiles/DASHPlaylist-3.mpd b/DashFiles/DASHPlaylist-3.mpd new file mode 100644 index 0000000..ce4f0d6 --- /dev/null +++ b/DashFiles/DASHPlaylist-3.mpd @@ -0,0 +1,30 @@ + + + + + DASH_2_4_M + + + + + + DASH_1_2_M + + + + + + DASH_4_8_M + + + + + + DASH_600_K + + + + + + + \ No newline at end of file diff --git a/DashFiles/DASHPlaylist-4.mpd b/DashFiles/DASHPlaylist-4.mpd new file mode 100644 index 0000000..916a2e6 --- /dev/null +++ b/DashFiles/DASHPlaylist-4.mpd @@ -0,0 +1,39 @@ + + + + + DASH_2_4_M + + + + + + DASH_1_2_M + + + + + + DASH_4_8_M + + + + + + DASH_600_K + + + + + + + + + audio + + + + + + + \ No newline at end of file diff --git a/DashFiles/DASHPlaylist-5.mpd b/DashFiles/DASHPlaylist-5.mpd new file mode 100644 index 0000000..916a2e6 --- /dev/null +++ b/DashFiles/DASHPlaylist-5.mpd @@ -0,0 +1,39 @@ + + + + + DASH_2_4_M + + + + + + DASH_1_2_M + + + + + + DASH_4_8_M + + + + + + DASH_600_K + + + + + + + + + audio + + + + + + + \ No newline at end of file diff --git a/DashFiles/DASHPlaylist-6.mpd b/DashFiles/DASHPlaylist-6.mpd new file mode 100644 index 0000000..fe0f456 --- /dev/null +++ b/DashFiles/DASHPlaylist-6.mpd @@ -0,0 +1,33 @@ + + + + + + DASH_audio.mp4 + + + + + + + + DASH_240.mp4 + + + + + + DASH_360.mp4 + + + + + + DASH_480.mp4 + + + + + + + \ No newline at end of file diff --git a/DashFiles/DASHPlaylist.mpd b/DashFiles/DASHPlaylist.mpd new file mode 100644 index 0000000..ce4f0d6 --- /dev/null +++ b/DashFiles/DASHPlaylist.mpd @@ -0,0 +1,30 @@ + + + + + DASH_2_4_M + + + + + + DASH_1_2_M + + + + + + DASH_4_8_M + + + + + + DASH_600_K + + + + + + + \ No newline at end of file diff --git a/dash.go b/dash.go new file mode 100644 index 0000000..fc120d2 --- /dev/null +++ b/dash.go @@ -0,0 +1,37 @@ +package main + +import ( + "encoding/xml" + "fmt" + "io" + "os" +) + +type BaseUrl struct { + Data string `xml:",chardata"` +} + +// decode returns all variations of BaseUrl in a DASHPlaylist.mpd file. +func decode(fileName string) []string { + f, _ := os.Open(fileName) + dec := xml.NewDecoder(f) + var stack []string + for { + tok, err := dec.Token() + if err == io.EOF { + break + } else if err != nil { + fmt.Fprintf(os.Stderr, "xmlselect: %v\n", err) + os.Exit(1) + } + switch tok := tok.(type) { + case xml.StartElement: + if tok.Name.Local == "BaseURL" { + var Url BaseUrl + _ = dec.DecodeElement(&Url, &tok) + stack = append(stack, Url.Data) + } + } + } + return stack +} diff --git a/dash_test.go b/dash_test.go new file mode 100644 index 0000000..4222d56 --- /dev/null +++ b/dash_test.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "io/ioutil" + "strings" + "testing" +) + +func Test_decode(t *testing.T) { + dashDir := "./DashFiles/" + fs, _ := ioutil.ReadDir(dashDir) + for _, f := range fs { + if strings.HasSuffix(f.Name(), ".mpd") { + list := decode(dashDir + f.Name()) + fmt.Println(list) + } + } +}