func (c *TestClient) OnBinary(id int, value []byte) bool { if id != webm.IdSimpleBlock { fmt.Printf("%s<%s type=\"binary\" size=\"%d\"/>\n", c.indent(), webm.IdToName(id), len(value)) } else { blockInfo := webm.ParseSimpleBlock(value) presentationTimecode := int64(c.clusterTimecode) + int64(blockInfo.Timecode) if blockInfo != nil { fmt.Printf("%s<%s type=\"binary\" size=\"%d\" trackNum=\"%d\" timecode=\"%d\" presentationTimecode=\"%d\" flags=\"%x\"/>\n", c.indent(), webm.IdToName(id), len(value), blockInfo.Id, blockInfo.Timecode, presentationTimecode, blockInfo.Flags) } else { fmt.Printf("%s<%s type=\"binary\" size=\"%d\" invalid=\"true\"/>\n", c.indent(), webm.IdToName(id), len(value)) } } return true }
func (c *BlockGroupClient) OnBinary(id int, value []byte) bool { if id == webm.IdBlock { blockInfo := webm.ParseSimpleBlock(value) c.id = blockInfo.Id c.rawTimecode = int64(blockInfo.Timecode) c.flags = blockInfo.Flags & 0x0f c.blockData = value[blockInfo.HeaderSize:] c.parsedBlock = true return true } else if id == webm.IdBlockAdditions { c.writer.Write(id, value) return true } log.Printf("OnBinary() : Unexpected element %s size %d\n", webm.IdToName(id), len(value)) return false }
func (c *TestClient) OnBinary(id int, value []byte) bool { if id == webm.IdSimpleBlock { blockInfo := webm.ParseSimpleBlock(value) presentationTimecode := int64(c.clusterTimecode) + int64(blockInfo.Timecode) if blockInfo != nil { frameData := value[blockInfo.HeaderSize:] fmt.Printf("frame size %d timestamp %d\n", len(frameData), presentationTimecode) buf := new(bytes.Buffer) binary.Write(buf, binary.LittleEndian, uint32(len(frameData))) binary.Write(buf, binary.LittleEndian, uint64(presentationTimecode)) binary.Write(buf, binary.BigEndian, frameData) c.out.Write(buf.Bytes()) c.frameCount += 1 } else { fmt.Printf("Invalid simple block") return false } } return true }