Community
cancel
Showing results for 
Search instead for 
Did you mean: 
pushkar_p
Beginner
80 Views

RE: CSocketReader implementation for MPEG TS

Hello,

I have implemented CSocketReader class derived from DataReader that reads a UDP based MPEG TS stream. I have adhered to UMC coding style as much as possible. I would like to contribute this to the IPP library or to other people who are interested.

If anyone is interested please let me know and where to upload the files?

0 Kudos
3 Replies
Vladimir_Dudnik
Employee
80 Views

Hello,

Thanks you for help to the community. I think you can attach your implementation to this thread, so people can take your implementation from here.

Regards,
Vladimir

pushkar_p
Beginner
80 Views

Hello,

I am posting the code in the attached zip file, there are 4 files:

SocketReader.h, SocketReade.cpp: Derived from UMC::DataReader. Internally it creates a socket, spawns a new thread which writes the incoming TS packetsto a circular buffer. The demuxer thread picks up the data through the normal ReadData, CacheData, and MovePosition operations.

CircularBuffer.h, .cpp: I downloadedthis circular buffer code from codeproject.com (original author and copyright notice included).I made the following changes to the original code:

Fixed race condition and memory leakbugs,

Replaced allWindows specific API with standardC++. (E.g. variable typedefs, synchronization objects, etc.)

Instead of using mutexes to synchronize read/write operations from multiple threads I use the one byte open strategy to prevent data corruption. (http://en.wikipedia.org/wiki/Circular_buffer). Thisis sufficientfor the one reader thread and one writer thread model.

Note: The socket code is Windows specific and I have not tested the multicast option.

pushkar_p
Beginner
80 Views

Hello,

I just found a serious bug in my code, I was calling WSACleanup() multiple times, which was causing later stream playbacks to fail. WSACleanup() should be called only once for each call to WSAStartup(...). So I am updating the attachment.

Reply