func (c *DemuxerClient) OnListStart(offset int64, id int) bool {
	//log.Printf("OnListStart(%d, %s)\n", offset, webm.IdToName(id))

	if !c.readEBMLHeader {
		log.Printf("Unexpected element %s before EBMLHeader\n", webm.IdToName(id))
		return false
	}

	if id == webm.IdSegment {
		c.segmentOffset = offset

		c.writer.WriteListStart(webm.IdSegment)
		c.outputSegmentOffset = c.writer.Offset()
		c.writer.WriteVoid(SEEK_HEAD_RESERVE_SIZE)
		return true
	}

	if id == webm.IdCluster {
		c.clusterTimecode = -1
		if c.outputClusterOffset == -1 {
			c.outputClusterOffset = c.writer.Offset()
		}
		return true
	}

	log.Printf("OnListStart() : Unexpected element %s\n", webm.IdToName(id))
	return false
}
func (c *DemuxerClient) OnString(id int, value string) bool {
	if !c.readEBMLHeader {
		log.Printf("Unexpected element %s before EBMLHeader\n", webm.IdToName(id))
		return false
	}

	log.Printf("OnString() : Unexpected element %s\n", webm.IdToName(id))
	return false
}
Exemple #3
0
func (c *TestClient) OnUint(id int, value uint64) bool {
	if id != webm.IdSeekID {
		fmt.Printf("%s<%s type=\"uint\" value=\"%d\"/>\n", c.indent(), webm.IdToName(id), value)
	} else {
		fmt.Printf("%s<%s type=\"uint\" id_name=\"%s\" value=\"%d\"/>\n", c.indent(), webm.IdToName(id), webm.IdToName(int(value)), value)
	}
	if id == webm.IdTimecode {
		c.clusterTimecode = value
	}
	return true
}
func (c *DemuxerClient) OnUint(id int, value uint64) bool {
	if !c.readEBMLHeader {
		log.Printf("Unexpected element %s before EBMLHeader\n", webm.IdToName(id))
		return false
	}

	if id == webm.IdTimecode {
		c.clusterTimecode = int64(value)
		//log.Printf("Input Cluster timecode %d\n", c.clusterTimecode)
		return true
	}

	log.Printf("OnUint() : Unexpected element %s\n", webm.IdToName(id))
	return false
}
Exemple #5
0
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) OnInt(id int, value int64) bool {
	if id == webm.IdDiscardPadding || id == webm.IdReferenceBlock {
		c.writer.Write(id, value)
		return true
	}
	log.Printf("OnInt() : Unexpected element %s %d\n", webm.IdToName(id), value)
	return false
}
func (c *BlockGroupClient) OnUint(id int, value uint64) bool {
	if id == webm.IdBlockDuration {
		c.writer.Write(id, value)
		return true
	}
	log.Printf("OnUint() : Unexpected element %s %u\n", webm.IdToName(id), value)
	return false
}
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 *DemuxerClient) OnListEnd(offset int64, id int) bool {
	//log.Printf("OnListEnd(%d, %s)\n", offset, webm.IdToName(id))

	if id == webm.IdSegment {
		if c.outputClusterTimecode != -1 {
			c.writeRemainingBlocks()
			c.writer.WriteListEnd(webm.IdCluster)
		}

		if c.writer.CanSeek() {
			c.writeCues()
		}

		// Rewrite seek head.
		oldOffset := c.writer.Offset()
		if c.writer.SetOffset(c.outputSegmentOffset) {
			c.writeSeekHead()

			if c.writer.Offset() < c.outputInfoOffset {
				c.writer.WriteVoid(int(c.outputInfoOffset - c.writer.Offset()))
			}

			c.writer.SetOffset(oldOffset)
		}

		c.writer.WriteListEnd(webm.IdSegment)
		return true
	}

	if id == webm.IdCluster {
		return true
	}

	log.Printf("OnListEnd() : Unexpected element %s\n", webm.IdToName(id))
	return false
}
func (c *DemuxerClient) OnInt(id int, value int64) bool {
	log.Printf("OnInt() : Unexpected element %s\n", webm.IdToName(id))
	return false
}
Exemple #11
0
func (c *TestClient) OnInt(id int, value int64) bool {
	fmt.Printf("%<%s type=\"int\" value=\"%d\"/>\n", c.indent(), webm.IdToName(id), value)
	return true
}
Exemple #12
0
func (c *TestClient) OnListEnd(offset int64, id int) bool {
	c.depth--
	fmt.Printf("%s</%s>\n", c.indent(), webm.IdToName(id))
	return true
}
Exemple #13
0
func (c *TestClient) OnListStart(offset int64, id int) bool {
	fmt.Printf("%s<%s type=\"list\" offset=\"%d\">\n", c.indent(), webm.IdToName(id), offset)
	c.depth++
	return true
}
Exemple #14
0
func (c *TestClient) OnFloat(id int, value float64) bool {
	fmt.Printf("%s<%s type=\"float\" value=\"%f\"/>\n", c.indent(), webm.IdToName(id), value)
	return true
}
func (c *DemuxerClient) OnBinary(id int, value []byte) bool {
	if id == ebml.IdHeader {
		if c.readEBMLHeader {
			log.Printf("Already read an EBMLHeader\n")
			return false
		}
		if !c.ParseEBMLHeader(value) {
			return false
		}
		c.readEBMLHeader = true
		webm.WriteHeader(c.writer)
		//c.writer.Write(id, value)
		return true
	}

	if !c.readEBMLHeader {
		log.Printf("Unexpected element %s before EBMLHeader\n", webm.IdToName(id))
		return false
	}

	if id == ebml.IdVoid {
		return true
	}

	if id == webm.IdSeekHead {
		return true
	}

	if id == webm.IdInfo {
		if !c.ParseInfo(value) {
			return false
		}
		c.outputInfoOffset = c.writer.Offset()
		c.writer.Write(id, value)
		return true

	}

	if id == webm.IdTracks {
		if !c.ParseTracks(value) {
			return false
		}
		c.outputTracksOffset = c.writer.Offset()

		// Filter out deprecated values.
		filteredValue := webm.Filter(value, []int{webm.IdFrameRate})

		c.writer.Write(id, filteredValue)
		return true
	}

	if id == webm.IdSimpleBlock {
		return c.ParseSimpleBlock(value)
	}

	switch id {
	case webm.IdCues,
		webm.IdPrevSize,
		webm.IdPosition:
		return true
	}

	log.Printf("OnBinary() : Unexpected element %s\n", webm.IdToName(id))
	return false
}
func (c *BlockGroupClient) OnString(id int, value string) bool {
	log.Printf("OnString() : Unexpected element %s %s\n", webm.IdToName(id), value)
	return false
}
func (c *BlockGroupClient) OnFloat(id int, value float64) bool {
	log.Printf("OnFloat() : Unexpected element %s %f\n", webm.IdToName(id), value)
	return false
}
Exemple #18
0
func (c *TestClient) OnString(id int, value string) bool {
	fmt.Printf("%s<%s type=\"string\" value=\"%s\"/>\n", c.indent(), webm.IdToName(id), value)
	return true
}
func (c *BlockGroupClient) OnListEnd(offset int64, id int) bool {
	//log.Printf("OnListEnd(%d, %s)\n", offset, webm.IdToName(id))
	log.Printf("OnListEnd() : Unexpected element %s\n", webm.IdToName(id))
	return false
}