[Live-devel] Every 2 frame is truncated
Brilliantov Kirill Vladimirovich
brilliantov at byterg.ru
Tue Nov 26 00:52:36 PST 2013
Hello!
I use live555 2013.10.25 on my FreeScale iMX53 board.
My encoded programm put data to shared memory, access to data control
semaphore.
For get data from shared memory I write class based on FramedSource and
doGetNextFrame function.
Program is a very simple:
in_addr ipv4 = {0};
ipv4.s_addr = our_inet_addr(destination);
Groupsock gp(*env, ipv4, Port(port), ttl);
gp.multicastSendOnly();
OutPacketBuffer::maxSize = 1280 * 720 * 3 / 2;
RTPSink* h264 = H264VideoRTPSink::createNew(*env, &gp, 96);
Frame *frame = new Frame(semaphore, sh_mem, *env); // my class
H264VideoStreamFramer* video_src =
H264VideoStreamFramer::createNew(*env, frame);
h264->startPlaying(*video_src, NULL, NULL);
env->taskScheduler().doEventLoop(&is_stop);
shared memory: _data
semaphore: _sem
void Frame::doGetNextFrame()
{
if (NULL == _data || NULL == _sem) {
handleClosure(this);
return;
}
fFrameSize = 0;
fNumTruncatedBytes = 0;
if (_last_frame != _data->frame && !sem_wait(_sem)) {
fFrameSize = _data->size;
if (fFrameSize > fMaxSize) {
fNumTruncatedBytes = fFrameSize - fMaxSize;
daemon_info("frame %u, truncated %u bytes, max %u, size %u",
_data->frame,fNumTruncatedBytes, fMaxSize, fFrameSize);
fFrameSize = fMaxSize;
}
gettimeofday(&fPresentationTime, NULL);
daemon_debug("%s: start copy frame %u %lu.%lu",
__PRETTY_FUNCTION__,_data->frame,fPresentationTime.tv_sec,
fPresentationTime.tv_usec);
memcpy(fTo, _data->data, fFrameSize);
gettimeofday(&fPresentationTime, NULL);
daemon_debug("%s: stop copy frame %u (%u bytes) %lu.%lu",
__PRETTY_FUNCTION__, _data->frame, fFrameSize,fPresentationTime.tv_sec,
fPresentationTime.tv_usec);
_last_frame = _data->frame;
sem_post(_sem);
gettimeofday(&fPresentationTime, NULL);
}
nextTask() = envir().taskScheduler().scheduleDelayedTask(
40000, (TaskFunc*)FramedSource::afterGetting, this);
}
It work, but every 2 frame I see that frame truncated:
streamerd: virtual void Frame::doGetNextFrame(): start copy frame 79
12670.159867
streamerd: virtual void Frame::doGetNextFrame(): stop copy frame 79
(126794 bytes) 12670.163626
streamerd: frame 80, truncated 113146 bytes, max 23204, size 136350
streamerd: virtual void Frame::doGetNextFrame(): start copy frame 80
12670.306181
streamerd: virtual void Frame::doGetNextFrame(): stop copy frame 80
(23204 bytes) 12670.307837
streamerd: virtual void Frame::doGetNextFrame(): start copy frame 81
12670.369945
streamerd: virtual void Frame::doGetNextFrame(): stop copy frame 81
(110216 bytes) 12670.379823
streamerd: frame 82, truncated 79271 bytes, max 39782, size 119053
streamerd: virtual void Frame::doGetNextFrame(): start copy frame 82
12670.434736
streamerd: virtual void Frame::doGetNextFrame(): stop copy frame 82
(39782 bytes) 12670.436576
Why and how can I solve this problem?
Thank you and excuse me for my bad english.
--
Best regards,
Brilliantov Kirill Vladimirovich
More information about the live-devel
mailing list