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

// 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)
4 years ago
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
}