I'm trying to implement stream decoder for mpeg2ts container. I was able to identify stream as mpeg2ts but i guess i have problem with buffer implementation. I get stuck somewhere inside CodecPipeline::SelectSplitter so AVSync class doesnt initialize properly ..
Can anyone suggest me how to handle buffering ? I'm using something like this:
char Package; //one container package 188 bytes char *buffer[10000UL]; //to hold 10+ frames: ~ (900*188) for one frame
this seems like a good idea cause DataReader::MovePosition function moves pointer by 188 and that is basically *(buffer++).
But this doesnt work as i was hopping it would. So i was trying to increase size of buffer pointer but receive access violation for larger memory. I've read somewhere that std::vecor have same memory issue for larger sizes. So now i dont have a clue what else to try .. Hope someone can give me some hint what else to try .. Thanx
1-Using a circular buffer
as a buffering schema will be quite appropriate , because before UMC
reads any data from buffer new data's can be sent to buffer.Or an
expanding/shrinking buffer will be better. Circular Buffer : static size , better performance but data loss possibility Shrinking/expanding buffer : changing size with worse performance but no data loss
i know ,cache data should not change buffer read cursor.It only put
read data chunck to given pointer parameter.This may cause the stucking
3-MovePosition should not be called on streaming operations(like data streams
with unknown length) , to cause it not be called, a method like
"getsize" or something should return 0 or -1.If i can find exact one,
i'll return you with a proper solution.But you can start searching
4-No, i also didn't use m_pDataPointer variable.
your data reader's methods are implemented as exactly as mentioned in
the UMC documents.Any missing or wrongly implemented method can cause
problems.Also give attention to data types and return values.For
example if ReadData returns UMC_END_OF_STREAM or FAILED , this may
stops demuxer's operation.
I've implemented circular buffer with size of 1024*188*20, which gives me about 2-3 sec of udp stream in buffer. AVSync Init function went fine, it recognize video stream correctly, but it seems that audio is not initialized. Also when player goes to AVSync play loop it doesnt decode video as it should be. There is bunch of colors on screen, processor time is almost 0 and refresh rate of those colors are around 1sec or less. So i guess something else isnt as it should be.
In umc documentation it was stated that for online streams getposition and getsize should return -1. But when i set -1 as return value, splitter initialization fails looping indefinitly somewhere. I'm also returning UMC_ERR_FAILED from setpostion function.
Same player, with setting prefered datareader to file reader and readcontext to context local, works just fine. So i guess it doesnt lack some parameter initialization. Also, because it recognize correct video stream i think socketreader class is implemented correctly. What else could cause such a behaviour ?