<div dir="ltr">Dear all,<br> <br><div> <br> I have been implementing the video [ only] player in android using SDL and ffmpeg.<br><br> <br> I followed the below approach [from dranger tutorial ]<br><br> 1) There is a linked list with each node of type AVPacketList<br>
<br> AVPacketList *firstNode=NULL, *lastNode=NULL;<br><br> 2) There are two threads:<br> ReadPacket - Reads packet from av_read_frame, and stores in the linked list. <br> FrameDisplay - Reads packet from Linked list , decodes the same if complete packet is received. Pushes specific event to SDL to render the frame.<br>
<br><br> 3) Main Function:<br> kick starts two threads ReadPacket, FrameDisplay.<br> <br><b>Issue:</b><br><br><br> How can i pass to and from queue ? what is the correct way of doing ?<br><br> In ReadPacket thread:<br>
<br> AVPacket pkt1, *rpacket=&pkt1;<br><br> if ( av_read_frame(pFormatCtx, rpacket) >= 0) {<br> if (packet.stream_index == videoStream) {<br><br> // Creating new node to push..<br>
<br> AVPacketList *newNode = av_malloc(sizeof(AVPacketList));<br> newNode->pkt = *rpacket;<br> newNode->next = NULL;<br>
// pushing newNode.<br><br> }<br><br><br> In FrameDisplay Thread:<br><br> 1) Reading node from queue <br> 2) take the packet like:<br><br> AVPacket *pkt;<br>
*pkt = newNode->pkt;<br> <br> 3) Decode Now:<br> <br> avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, pkt);<br> if (frameFinished) {<br>
</div><div> // I AM UNABLE TO REACH HERE...<br></div><div> }<br><br><br><b>It is the right way to copy the AVPacket structure to and from ?<br></b><br>ie: While copying newNode->pkt = *rpacket;<br>
While retrieving AVPacket *pkt = newNode->pkt ?<br><br><br><b>Surprisingly, instead of keeping the AVPacket in the queue, if i directly decode, i could able to decode successfully.<br></b><br>Kindly point out what went wrong ?<br>
<br></div></div>