代码拉取完成,页面将自动刷新
package record
import (
"go.uber.org/zap"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/codec"
"m7s.live/engine/v4/track"
)
type RawRecorder struct {
Recorder
IsAudio bool
}
func NewRawRecorder() (r *RawRecorder) {
r = &RawRecorder{}
r.Record = RecordPluginConfig.Raw
return r
}
func NewRawAudioRecorder() (r *RawRecorder) {
r = &RawRecorder{IsAudio: true}
r.Record = RecordPluginConfig.RawAudio
return r
}
func (r *RawRecorder) Start(streamPath string) error {
r.ID = streamPath + "/raw"
if r.IsAudio {
r.ID += "_audio"
}
return r.start(r, streamPath, SUBTYPE_RAW)
}
func (r *RawRecorder) Close() (err error) {
if r.File != nil {
err = r.File.Close()
}
return
}
func (r *RawRecorder) OnEvent(event any) {
switch v := event.(type) {
case FileWr:
r.SetIO(v)
case *RawRecorder:
r.Recorder.OnEvent(event)
case *track.Video:
if r.IsAudio {
break
}
if r.Ext == "." {
if v.CodecID == codec.CodecID_H264 {
r.Ext = ".h264"
} else {
r.Ext = ".h265"
}
}
r.AddTrack(v)
case *track.Audio:
if !r.IsAudio {
break
}
if r.Ext == "." {
switch v.CodecID {
case codec.CodecID_AAC:
r.Ext = ".aac"
case codec.CodecID_PCMA:
r.Ext = ".pcma"
case codec.CodecID_PCMU:
r.Ext = ".pcmu"
}
}
r.AddTrack(v)
case AudioFrame:
r.Recorder.OnEvent(event)
if _, err := v.WriteRawTo(r); err != nil {
r.Stop(zap.Error(err))
}
case VideoFrame:
r.Recorder.OnEvent(event)
if _, err := v.WriteAnnexBTo(r); err != nil {
r.Stop(zap.Error(err))
}
default:
r.IO.OnEvent(v)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。