开发者

Video packet capture over multiple IP cameras

开发者 https://www.devze.com 2023-01-03 22:26 出处:网络
We are working on a C language application which is simple RTSP/RTP client to record video from Axis a number of Cameras. We launch a pthread for each of the camera which establishes the RTP session a

We are working on a C language application which is simple RTSP/RTP client to record video from Axis a number of Cameras. We launch a pthread for each of the camera which establishes the RTP session and begin to record the 开发者_StackOverflow社区packets captured using the recvfrom() call. A single camera single pthread records fine for well over a day without issues.

But testing with more cameras available,about 25(so 25 pthreads), the recording to file goes fine for like 15 to 20 mins and then the recording just stops. The application still keeps running. Its been over a month and a half we have been trying with varied implementations but nothing seems to help. Please provide suggestions.

We are using CentOS 5 platform


Define "record" Does that mean write data to a file? How do you control access to the file?

You can't have several threads all trying to write at the exact same time. So the comment by Alon seems to be pertinent. Your write access control machanism has problems.


void *IPThread(void *ptr)
{
//Establish RTSP session
//Bind to RTP ports(video)
//Increase Socket buffer size to 625KB

record_fd=open(record_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
while(1)
{
    if(poll(RTP/RTCP ports)) //a timeout value of 1
    {
        if(RTCP event)
        RTCPhandler();
        if(RTP event)
        {
            recvfrom(); //the normal socket api recvfrom
            WritePacketToFile(record_fd)
            {
            //Create new record_fd after 100MB
            }
        }
    }
}
}

even if it is alright to stick to the single threaded implementation why is the multithreaded approach behaving such a way(not recording after ~15 mins)..?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号