Changeset 5001 for pjproject/trunk
- Timestamp:
- Mar 19, 2015 5:26:17 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/v4l2_dev.c
r4736 r5001 209 209 } 210 210 211 static vid4lin_fmt_map* get_v4l2_format_info(pjmedia_format_id id) 212 { 213 unsigned i; 214 215 for (i = 0; i < PJ_ARRAY_SIZE(v4l2_fmt_maps); i++) { 216 if (v4l2_fmt_maps[i].pjmedia_fmt_id == id) 217 return &v4l2_fmt_maps[i]; 218 } 219 220 return NULL; 221 } 222 223 /* Get the supported size */ 224 static void v4l2_get_supported_size(int fd, 225 pj_uint32_t fmt_id, 226 pjmedia_vid_dev_info *info) 227 { 228 int i=0; 229 pjmedia_rect_size v4l_sizes[] = 230 { 231 /* Some webcam doesn't work well using size below 320x240 */ 232 /*{ 128, 96 }, { 176, 144 },*/ { 320, 240 }, { 352, 240 }, 233 { 352, 288 }, { 352, 480 }, { 352, 576 }, { 640, 480 }, 234 { 704, 480 }, { 720, 480 }, { 704, 576 }, { 720, 576 }, 235 { 800, 600 }, { 1024, 768 }, { 1280, 720 }, { 1280, 960 }, 236 { 1280, 1024 }, { 1408, 960 }, { 1408, 1152 }, { 1600, 1200 }, 237 { 1920, 1080 }/*, { 1920, 1088 }, { 2048, 1024 }, { 2048, 1080 }, 238 { 2048, 1088 }, { 2048, 1536 }, { 2560, 1920 }, { 3616, 1536 }, 239 { 3672, 1536 }, { 3680, 1536 }, { 3840, 2160 }, { 4096, 2048 }, 240 { 4096, 2160 }, { 4096, 2304 }*/ 241 }; 242 243 const vid4lin_fmt_map *fmt_map = get_v4l2_format_info(fmt_id); 244 if (fmt_map == NULL) 245 return; 246 247 for (;i<PJ_ARRAY_SIZE(v4l_sizes) && 248 info->fmt_cnt<PJMEDIA_VID_DEV_INFO_FMT_CNT; 249 i++) 250 { 251 struct v4l2_format v4l2_fmt; 252 pj_status_t status; 253 254 pj_bzero(&v4l2_fmt, sizeof(v4l2_fmt)); 255 v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 256 v4l2_fmt.fmt.pix.width = v4l_sizes[i].w; 257 v4l2_fmt.fmt.pix.height = v4l_sizes[i].h; 258 v4l2_fmt.fmt.pix.pixelformat = fmt_map->v4l2_fmt_id; 259 v4l2_fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; 260 status = xioctl(fd, VIDIOC_TRY_FMT, &v4l2_fmt); 261 if (status != PJ_SUCCESS || 262 v4l2_fmt.fmt.pix.pixelformat != fmt_map->v4l2_fmt_id || 263 v4l2_fmt.fmt.pix.width != v4l_sizes[i].w || 264 v4l2_fmt.fmt.pix.height != v4l_sizes[i].h) 265 { 266 continue; 267 } 268 269 pjmedia_format_init_video(&info->fmt[info->fmt_cnt++], 270 fmt_id, 271 v4l_sizes[i].w, 272 v4l_sizes[i].h, 273 DEFAULT_FPS, 1); 274 } 275 } 276 211 277 /* Scan V4L2 devices */ 212 278 static pj_status_t v4l2_scan_devs(vid4lin_factory *f) … … 282 348 } 283 349 284 v4l2_close(fd);285 286 350 if (fmt_cnt==0) { 287 351 PJ_LOG(5,(THIS_FILE, " Found no common format")); 352 v4l2_close(fd); 288 353 continue; 289 354 } … … 300 365 pdi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT; 301 366 302 pdi->info.fmt_cnt = fmt_cnt;303 367 for (j=0; j<fmt_cnt; ++j) { 304 pjmedia_format_init_video(&pdi->info.fmt[j], 305 fmt_cap[j], 306 DEFAULT_WIDTH, 307 DEFAULT_HEIGHT, 308 DEFAULT_FPS, 1); 368 v4l2_get_supported_size(fd, fmt_cap[j], &pdi->info); 309 369 } 370 371 v4l2_close(fd); 372 310 373 if (j < fmt_cnt) 311 374 continue; … … 407 470 408 471 return PJ_SUCCESS; 409 }410 411 static vid4lin_fmt_map* get_v4l2_format_info(pjmedia_format_id id)412 {413 unsigned i;414 415 for (i = 0; i < PJ_ARRAY_SIZE(v4l2_fmt_maps); i++) {416 if (v4l2_fmt_maps[i].pjmedia_fmt_id == id)417 return &v4l2_fmt_maps[i];418 }419 420 return NULL;421 472 } 422 473
Note: See TracChangeset
for help on using the changeset viewer.