Dissecting play packets

This article is a very basic way to open and dissect various play packets. It could be the start of a debug module ripping out timestamps.

From the source file attached:

// grab a AMF Packet
AMFPacket packet = packets.get(i);
String type = "Data";

// check the type of packet
// if audio grab sample rate
if(packet.isAudio()) {
	type = "Audio";
	try {
		sampleRate = (long) (((double)1000 / (double)packet.getTimecode()) * 1024);
	} 
	catch (ArithmeticException e) {
		getLogger().error("ArithmeticException",e);
	}
}

// Grab frames per second
if(packet.isVideo()) { 
	type = "Video";
	try {
		fps = (double)((int)((1000 / (double) packet.getTimecode()) * 100) / 100) ;
	} catch (ArithmeticException e) {
		// error
	}
} 

// some determination of whether the video packet is a keyframe
boolean isKeyFrame = packet.isVideo() && FLVUtils.isVideoKeyFrame(packet);

getLogger().info("seq: "+packet.getSeq()+", sz: "+packet.getSize()+" abs: "+packet.getAbsTimecode()+", tc: "+packet.getTimecode()+" typ: "+type);
if(packet.isAudio())
	getLogger().info("sr: "+sampleRate);

if(packet.isVideo()) {
	getLogger().info("fps: "+fps);
	if(isKeyFrame)
		getLogger().info("Key Frame");
}

Debugger.java


Comments are closed.