Skip to content

Commit

Permalink
[libuvc] fix resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
gozfree committed Dec 15, 2019
1 parent 78f3da8 commit 88fa365
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ PLATFORM="[linux|pi|android|ios]"

#basic libraries
BASIC_LIBS="libmacro libtime liblog libgevent libworkq libdict libhash libsort \
librbtree libringbuffer libthread libconfig libvector libbase64 \
librbtree libringbuffer libthread libvector libbase64 libmedia-io \
libdebug libfile libuvc libmp4parser libqueue libplugin libhal libsubmask"
FRAMEWORK_LIBS="libipc"
NETWORK_LIBS="libskt librpc librtsp"
NETWORK_LIBS="libskt librpc "

usage()
{
Expand Down Expand Up @@ -152,7 +152,8 @@ build_module()
*)
MAKE="make ARCH=${ARCH} OUTPUT=${OUTPUT} MODE=${MODE}"
if [[ ${ARCH} == "linux" || ${ARCH} == "pi" || ${ARCH} == "android" ]]; then
${MAKE} > /dev/null
${MAKE}
#> /dev/null
else
echo "${ARCH} not support now" #make -f Makefile.${ARCH} > /dev/null
fi
Expand Down
10 changes: 7 additions & 3 deletions gear-lib/libuvc/v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,28 @@ static void *uvc_v4l2_open(struct uvc_ctx *uvc, const char *dev, int width, int
}
vc->name = strdup(dev);
vc->fd = fd;
vc->width = width;
vc->height = height;

vc->channel = -1;
vc->standard = -1;
vc->resolution = -1;
vc->framerate = -1;
vc->dv_timing = -1;

if (-1 == v4l2_init(vc)) {
printf("v4l2_init failed\n");
goto failed;
}

vc->resolution = v4l2_pack_tuple(width, height);

if (-1 == v4l2_set_format(vc->fd, &vc->resolution, &vc->pixfmt, &vc->linesize)) {
printf("v4l2_set_format failed\n");
goto failed;
}

v4l2_unpack_tuple(&vc->width, &vc->height, vc->resolution);
if (vc->width != width || vc->height != height) {
printf("v4l2 format is forced to %dx%d\n", vc->width, vc->height);
}

/* set framerate */
if (v4l2_set_framerate(vc->fd, &vc->framerate) < 0) {
Expand Down

0 comments on commit 88fa365

Please sign in to comment.