Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility fix to get mjpg_streamer work with kernel 3.18 #3

Merged
merged 1 commit into from
Feb 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mjpg-streamer-experimental/plugins/input_uvc/input_uvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,14 @@ void *cam_thread(void *arg)
if ((pcontext->videoIn->formatIn == V4L2_PIX_FMT_YUYV) || (pcontext->videoIn->formatIn == V4L2_PIX_FMT_RGB565)) {
DBG("compressing frame from input: %d\n", (int)pcontext->id);
pglobal->in[pcontext->id].size = compress_image_to_jpeg(pcontext->videoIn, pglobal->in[pcontext->id].buf, pcontext->videoIn->framesizeIn, gquality);
/* copy this frame's timestamp to user space */
pglobal->in[pcontext->id].timestamp = pcontext->videoIn->buf.timestamp;
} else {
#endif
DBG("copying frame from input: %d\n", (int)pcontext->id);
pglobal->in[pcontext->id].size = memcpy_picture(pglobal->in[pcontext->id].buf, pcontext->videoIn->tmpbuffer, pcontext->videoIn->buf.bytesused);
pglobal->in[pcontext->id].size = memcpy_picture(pglobal->in[pcontext->id].buf, pcontext->videoIn->tmpbuffer, pcontext->videoIn->tmpbytesused);
/* copy this frame's timestamp to user space */
pglobal->in[pcontext->id].timestamp = pcontext->videoIn->tmptimestamp;
#ifndef NO_LIBJPEG
}
#endif
Expand All @@ -528,8 +532,6 @@ void *cam_thread(void *arg)
prev_size = global->size;
#endif

/* copy this frame's timestamp to user space */
pglobal->in[pcontext->id].timestamp = pcontext->videoIn->buf.timestamp;

/* signal fresh_frame */
pthread_cond_broadcast(&pglobal->in[pcontext->id].db_update);
Expand Down
5 changes: 5 additions & 0 deletions mjpg-streamer-experimental/plugins/input_uvc/v4l2uvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ int uvcGrab(struct vdIn *vd)
{
#define HEADERFRAME1 0xaf
int ret;
int32_t bytesused;

if(vd->streamingState == STREAMING_OFF) {
if(video_enable(vd))
Expand All @@ -511,6 +512,7 @@ int uvcGrab(struct vdIn *vd)
perror("Unable to dequeue buffer");
goto err;
}
bytesused = vd->buf.bytesused;

switch(vd->formatIn) {
case V4L2_PIX_FMT_MJPEG:
Expand All @@ -529,6 +531,8 @@ int uvcGrab(struct vdIn *vd)
*/

memcpy(vd->tmpbuffer, vd->mem[vd->buf.index], vd->buf.bytesused);
vd->tmpbytesused = vd->buf.bytesused;
vd->tmptimestamp = vd->buf.timestamp;

if(debug)
fprintf(stderr, "bytes in used %d \n", vd->buf.bytesused);
Expand All @@ -547,6 +551,7 @@ int uvcGrab(struct vdIn *vd)
}

ret = xioctl(vd->fd, VIDIOC_QBUF, &vd->buf);
vd->buf.bytesused = bytesused;
if(ret < 0) {
perror("Unable to requeue buffer");
goto err;
Expand Down
3 changes: 3 additions & 0 deletions mjpg-streamer-experimental/plugins/input_uvc/v4l2uvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
Expand Down Expand Up @@ -108,6 +109,8 @@ struct vdIn {
int framecount;
int recordstart;
int recordtime;
uint32_t tmpbytesused;
struct timeval tmptimestamp;
v4l2_std_id vstd;
unsigned long frame_period_time; // in ms
unsigned char soft_framedrop;
Expand Down