Skip to content

Commit

Permalink
simple_auth_server: Configure detection and videoprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
jailuthra committed Jun 23, 2021
1 parent 1c10706 commit f08ec26
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion cmd/simple_auth_server/simple_auth_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,38 @@ type authWebhookReq struct {
Url string `json:"url"`
}

type detectClass struct {
ID int `json:"id"`
Name string `json: "name"`
}

type sceneClassificationProfile struct {
SampleRate uint `json:"sampleRate"`
Classes []detectClass `json:"classes"`
}

type detection struct {
Freq uint `json:"freq"`
SceneClassificationProfile sceneClassificationProfile `json:"sceneClassificationProfile"`
}

type profile struct {
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Bitrate int `json:"bitrate"`
FPS uint `json:"fps"`
FPSDen uint `json:"fpsDen"`
Profile string `json:"profile"`
GOP string `json:"gop"`
}

type authWebhookResponse struct {
ManifestID string `json:"manifestID"`
Profiles []profile `json:"profiles"`
Detection detection `json:"detection"`
}

func main() {
http.HandleFunc("/auth", func(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
Expand All @@ -40,7 +72,29 @@ func main() {
fmt.Printf("Detected \"fizz\" as manifestID. Crazy! Renaming to \"buzz\".\n")
}
fmt.Printf("Stream started with manifestID: %v\n", mid)
w.Write([]byte(fmt.Sprintf("{\"ManifestID\":\"%v\"}", mid)))

resp := authWebhookResponse{
ManifestID: string(mid),
Profiles: []profile{{
Name: "240p",
Width: 426,
Height: 240,
Bitrate: 250000,
FPS: 0,
}},
Detection: detection{
Freq: 4,
SceneClassificationProfile: sceneClassificationProfile{
SampleRate: 1,
Classes: []detectClass{
{ID: 0, Name: "adult"},
{ID: 1, Name: "soccer"},
},
},
},
}
byteSlice, _ := json.Marshal(resp)
w.Write(byteSlice)
})

fmt.Println("Listening on localhost:8000/auth\nTry something crazy - stream with \"fizz\" as the manifestID.")
Expand Down

0 comments on commit f08ec26

Please sign in to comment.