You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lal/app/demo/pullhttpflv/pullhttpflv.go

56 lines
1.2 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// Copyright 2019, Chef. All rights reserved.
// https://github.com/q191201771/lal
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef (191201771@qq.com)
package main
import (
"encoding/hex"
"flag"
"github.com/q191201771/lal/pkg/base"
"github.com/q191201771/lal/pkg/httpflv"
"github.com/q191201771/naza/pkg/nazalog"
)
// 拉取HTTP-FLV的流
//
// TODO
// - 存储成flv文件
// - 拉取HTTP-FLV流进行分析参见另外一个demoanalyseflvts。 这个demo可能可以删除掉了。
func main() {
_ = nazalog.Init(func(option *nazalog.Option) {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
url := parseFlag()
session := httpflv.NewPullSession()
err := session.Pull(url, func(tag httpflv.Tag) {
switch tag.Header.Type {
case httpflv.TagTypeMetadata:
nazalog.Info(hex.Dump(tag.Payload()))
case httpflv.TagTypeAudio:
case httpflv.TagTypeVideo:
}
})
nazalog.Assert(nil, err)
err = <-session.WaitChan()
nazalog.Assert(nil, err)
}
func parseFlag() string {
url := flag.String("i", "", "specify http-flv url")
flag.Parse()
if *url == "" {
flag.Usage()
base.OSExitAndWaitPressIfWindows(1)
}
return *url
}