1. Fix parsing redirect url when logging into msn.

2. Fix null icon in PopupDialog and NPE
3. H264 skip data till new marker in case of dropped packets.
cusax-fix
Damian Minkov 17 years ago
parent f91a99e02a
commit 4f6a499001

@ -174,7 +174,9 @@ else if (messageType == PopupDialog.WARNING_MESSAGE)
type = JOptionPane.PLAIN_MESSAGE;
}
ImageIcon imageIcon = new ImageIcon(icon);
ImageIcon imageIcon = null;
if(icon != null)
imageIcon = new ImageIcon(icon);
return showInputDialog(null, message, title, type,
imageIcon, selectionValues, initialSelectionValue);
@ -264,7 +266,9 @@ else if (messageType == PopupDialog.WARNING_MESSAGE)
type = JOptionPane.PLAIN_MESSAGE;
}
ImageIcon imageIcon = new ImageIcon(icon);
ImageIcon imageIcon = null;
if(icon != null)
imageIcon = new ImageIcon(icon);
showMessageDialog(null, message, title, type, imageIcon);
}
@ -431,7 +435,9 @@ else if (messageType == PopupDialog.WARNING_MESSAGE)
msgType = JOptionPane.PLAIN_MESSAGE;
}
ImageIcon imageIcon = new ImageIcon(icon);
ImageIcon imageIcon = null;
if(icon != null)
imageIcon = new ImageIcon(icon);
return showConfirmDialog(null, message, title,
optType, msgType, imageIcon);

@ -7,22 +7,22 @@
/**
* Parses H264 rtp headers and extracts the data in the format
* the decoder expects it. RFC3984.
*
*
* @author Damian Minkov
*/
public class H264Parser
{
private final Logger logger = Logger.getLogger(H264Parser.class);
// allocate enough space for the incoming data
private static final int MAX_FRAME_SIZE = 128 * 1024;
// every NAL starts with this start sequence
private static final byte[] startSequence = { 0, 0, 1};
// the timestamp of the last received rtp packet
private long lastTimestamp = -1;
// the result data is collected in this buffer
private byte[] encodedFrame = new byte[MAX_FRAME_SIZE];
// the size of the result data
@ -37,9 +37,9 @@ public boolean pushRTPInput(Buffer inputBuffer)
{
long currentStamp = inputBuffer.getTimeStamp();
// the rtp marker field points that this is the last packet of
// the rtp marker field points that this is the last packet of
// the received frame
boolean hasMarker =
boolean hasMarker =
(inputBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0;
// if the timestamp changes we are starting receiving a new frame
@ -93,11 +93,11 @@ else if (type == 28)
* Extract data from FU packet. This are packets across several rtp packets,
* the first has a start bit set, we store all data and don't care about end
* bit.
*
*
* @param nal
* @param inputBuffer
*/
private void deencapsulateFU (byte nal, Buffer inputBuffer)
private void deencapsulateFU (byte nal, Buffer inputBuffer)
{
byte[] buf = (byte[])inputBuffer.getData();
int len = inputBuffer.getLength();
@ -114,7 +114,7 @@ private void deencapsulateFU (byte nal, Buffer inputBuffer)
byte reconstructed_nal;
//reconstruct this packet's true nal; only the data follows..
//the original nal forbidden bit and NRI are stored in this packet's nal;
reconstructed_nal = (byte)(fu_indicator & (byte)0xe0);
reconstructed_nal = (byte)(fu_indicator & (byte)0xe0);
reconstructed_nal |= nal_type;
// skip the fu_header...

@ -73,6 +73,11 @@ public class NativeDecoder
// current width of video, so we can detect changes in video size
private double currentVideoWidth;
// keep track of last received sequence in order to avoid inconsistent data
private long lastReceivedSeq = -1;
// in case of inconsistent data drop all data till a marker is received
private boolean waitingForMarker = false;
/**
* Constructs new h264 decoder
*/
@ -204,7 +209,7 @@ public void close()
if (opened)
{
opened = false;
synchronized (AVCODEC)
synchronized (this)
{
super.close();
@ -216,8 +221,6 @@ public void close()
}
}
long lastReceivedSeq = -1;
public int process(Buffer inputBuffer, Buffer outputBuffer)
{
if (!checkInputBuffer(inputBuffer))
@ -238,15 +241,28 @@ public int process(Buffer inputBuffer, Buffer outputBuffer)
return BUFFER_PROCESSED_OK;
}
if(waitingForMarker)
{
lastReceivedSeq = inputBuffer.getSequenceNumber();
if((inputBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) != 0)
{
waitingForMarker = false;
outputBuffer.setDiscard(true);
return BUFFER_PROCESSED_OK;
}
else
return OUTPUT_BUFFER_NOT_FILLED;
}
if(lastReceivedSeq != -1 && inputBuffer.getSequenceNumber() - lastReceivedSeq > 1)
{
long oldRecv = lastReceivedSeq;
lastReceivedSeq = inputBuffer.getSequenceNumber();
logger.trace("DROP rtp data!");
waitingForMarker = true;
logger.trace("DROP rtp data! " + oldRecv + "/" + lastReceivedSeq);
parser.reset();
inputBuffer.setDiscard(true);
outputBuffer.setDiscard(true);
reset();
return BUFFER_PROCESSED_OK;
return OUTPUT_BUFFER_NOT_FILLED;
}
else if(!parser.pushRTPInput(inputBuffer))
{
@ -261,22 +277,22 @@ else if(!parser.pushRTPInput(inputBuffer))
Pointer encBuf = AVUTIL.av_malloc(parser.getEncodedFrameLen());
arraycopy(parser.getEncodedFrame(), 0, encBuf, 0, parser.getEncodedFrameLen());
synchronized (AVCODEC)
synchronized (this)
{
// decodes the data
AVCODEC.avcodec_decode_video(
avcontext, avpicture, got_picture, encBuf, parser.getEncodedFrameLen());
if(currentVideoWidth != avcontext.width)
if(avcontext.width != 0 && currentVideoWidth != avcontext.width)
{
currentVideoWidth = avcontext.width;
VideoFormat format = getVideoFormat(currentVideoWidth);
if(format != null)
{
outputBuffer.setFormat(format);
outputFormat = format;
}
}
outputBuffer.setFormat(outputFormat);
if(got_picture.getValue() == 0)
{

Loading…
Cancel
Save