|
@@ -28,6 +28,14 @@ extern "C" {
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#define BUFFER_DEBUG_FMT_STR \
|
|
|
+ "buffer#%u @ %p type=%u bytesused=%u length=%u flags=%x " \
|
|
|
+ "field=%u timestamp= %lld.%06lld sequence=%u"
|
|
|
+#define BUFFER_DEBUG_FMT_ARGS(buf) \
|
|
|
+ (buf)->index, (buf), (buf)->type, (buf)->bytesused, (buf)->length, \
|
|
|
+ (buf)->flags, (buf)->field, \
|
|
|
+ (long long)(buf)->timestamp.tv_sec, \
|
|
|
+ (long long)(buf)->timestamp.tv_usec, (buf)->sequence
|
|
|
|
|
|
static const int kBufferAlignment = 64;
|
|
|
|
|
@@ -564,6 +572,10 @@ static void* VideoCaptureProcess(void *arg)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (pVideoCapture) {
|
|
|
+ pVideoCapture->CapLog(VIDEOCAP_LOG_DEBUG, "deviceid(%d), DQBUF(CAPTURE, index=%u) -> " BUFFER_DEBUG_FMT_STR, pVideoCapture->GetCaptureVideoId(), buf.index, BUFFER_DEBUG_FMT_ARGS(&buf));
|
|
|
+ }
|
|
|
+
|
|
|
VideoCaptureCapability frameInfo;
|
|
|
frameInfo.width = pVideoCapture->GetCapture_Width();
|
|
|
frameInfo.height = pVideoCapture->GetCapture_Height();
|
|
@@ -578,6 +590,11 @@ static void* VideoCaptureProcess(void *arg)
|
|
|
pVideoCapture->CapLog(VIDEOCAP_LOG_INFO, "Failed to enqueue capture buffer");
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ if (pVideoCapture) {
|
|
|
+ pVideoCapture->CapLog(VIDEOCAP_LOG_DEBUG, "deviceid(%d), QBUF(CAPTURE, index=%u) -> " BUFFER_DEBUG_FMT_STR "\n", pVideoCapture->GetCaptureVideoId(), buf.index, BUFFER_DEBUG_FMT_ARGS(&buf));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -776,6 +793,9 @@ int VideoCaptureImpl::StartVideoCapture()
|
|
|
close(m_deviceFd);
|
|
|
return -1;
|
|
|
}
|
|
|
+ else {
|
|
|
+ CapLog(VIDEOCAP_LOG_DEBUG, "succeed to turn on stream.");
|
|
|
+ }
|
|
|
|
|
|
m_bCaptureStarted = true;
|
|
|
|
|
@@ -802,6 +822,9 @@ bool VideoCaptureImpl::AllocateVideoBuffers()
|
|
|
CapLog(VIDEOCAP_LOG_ERROR, "Could not get buffers from device for %s.", strerror(errno));
|
|
|
return false;
|
|
|
}
|
|
|
+ else {
|
|
|
+ CapLog(VIDEOCAP_LOG_DEBUG, "req buffers count is %d.", rbuffer.count);
|
|
|
+ }
|
|
|
|
|
|
if (rbuffer.count > kNoOfV4L2Bufffers) {
|
|
|
rbuffer.count = kNoOfV4L2Bufffers;
|
|
@@ -824,12 +847,16 @@ bool VideoCaptureImpl::AllocateVideoBuffers()
|
|
|
if (ioctl(m_deviceFd, VIDIOC_QUERYBUF, &buffer) < 0){
|
|
|
return false;
|
|
|
}
|
|
|
+ else {
|
|
|
+ CapLog(VIDEOCAP_LOG_DEBUG, "QUERYBUF(CAPTURE, index=%u) -> " BUFFER_DEBUG_FMT_STR, buffer.index, BUFFER_DEBUG_FMT_ARGS(&buffer));
|
|
|
+ }
|
|
|
|
|
|
m_pool[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, m_deviceFd, buffer.m.offset);
|
|
|
|
|
|
if (MAP_FAILED == m_pool[i].start){
|
|
|
- for (unsigned int j = 0; j < i; j++)
|
|
|
+ for (unsigned int j = 0; j < i; j++) {
|
|
|
munmap(m_pool[j].start, m_pool[j].length);
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -838,6 +865,9 @@ bool VideoCaptureImpl::AllocateVideoBuffers()
|
|
|
if (ioctl(m_deviceFd, VIDIOC_QBUF, &buffer) < 0){
|
|
|
return false;
|
|
|
}
|
|
|
+ else {
|
|
|
+ CapLog(VIDEOCAP_LOG_DEBUG, "%s:%d deviceid(%d), QBUF(CAPTURE, index=%u) -> " BUFFER_DEBUG_FMT_STR, __FUNCTION__, __LINE__, m_deviceId, buffer.index, BUFFER_DEBUG_FMT_ARGS(&buffer));
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -857,6 +887,9 @@ bool VideoCaptureImpl::DeAllocateVideoBuffers()
|
|
|
if (ioctl(m_deviceFd, VIDIOC_STREAMOFF, &type) < 0){
|
|
|
CapLog(VIDEOCAP_LOG_ERROR, "VIDIOC_STREAMOFF error. error no: %d", errno);
|
|
|
}
|
|
|
+ else {
|
|
|
+ CapLog(VIDEOCAP_LOG_DEBUG, "succeed to turn off stream.");
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -918,6 +951,12 @@ int VideoCaptureImpl::GetCaptureVideoFd()
|
|
|
}
|
|
|
|
|
|
|
|
|
+int VideoCaptureImpl::GetCaptureVideoId()
|
|
|
+{
|
|
|
+ return m_deviceId;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
VideoType VideoCaptureImpl::GetCaptureVideoType()
|
|
|
{
|
|
|
return m_captureVideoType;
|