From: <dsa...@us...> - 2003-11-25 22:55:16
|
Update of /cvsroot/openh323/pwlib/plugins/vidinput_v4l In directory sc8-pr-cvs1:/tmp/cvs-serv15700/plugins/vidinput_v4l Modified Files: vidinput_v4l.cxx Log Message: Added fallback using major and minor numbers for detection of devices when /proc/video doesn't exist (some 2.4 kernels and all 2.6 kernels). Index: vidinput_v4l.cxx =================================================================== RCS file: /cvsroot/openh323/pwlib/plugins/vidinput_v4l/vidinput_v4l.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vidinput_v4l.cxx 18 Nov 2003 10:42:09 -0000 1.2 --- vidinput_v4l.cxx 25 Nov 2003 22:55:13 -0000 1.3 *************** *** 26,29 **** --- 26,32 ---- * * $Log$ + * Revision 1.3 2003/11/25 22:55:13 dsandras + * Added fallback using major and minor numbers for detection of devices when /proc/video doesn't exist (some 2.4 kernels and all 2.6 kernels). + * * Revision 1.2 2003/11/18 10:42:09 csoutheren * Changed to work with new plugins *************** *** 290,293 **** --- 293,299 ---- static PDictionary<PString, PString> *dico = NULL; + #define MAJOR(a) (int)((unsigned short) (a) >> 8) + #define MINOR(a) (int)((unsigned short) (a) & 0xFF) + // Now, the userfriendly translation functions: static PString to_userfriendly(PString devname) *************** *** 357,360 **** --- 363,400 ---- } + + static void CollectVideoDevices (PDirectory devdir, POrdinalToString & vid) + { + if (!devdir.Open()) + return; + + do { + PString filename = devdir.GetEntryName(); + PString devname = devdir + filename; + if (devdir.IsSubDir()) + CollectVideoDevices(devname, vid); + else { + + PFileInfo info; + if (devdir.GetInfo(info) && info.type == PFileInfo::CharDevice) { + struct stat s; + if (lstat(devname, &s) == 0) { + + static const int deviceNumbers[] = { 81 }; + for (PINDEX i = 0; i < PARRAYSIZE(deviceNumbers); i++) { + if (MAJOR(s.st_rdev) == deviceNumbers[i]) { + + PINDEX num = MINOR(s.st_rdev); + if (num <= 63 && num >= 0) + vid.SetAt(num, devname); + } + } + } + } + } + } while (devdir.Next()); + } + + /////////////////////////////////////////////////////////////////////////////// // PVideoInputV4lDevice *************** *** 580,590 **** } ! if (devlist.IsEmpty ()) { ! ! devlist.AppendString(to_userfriendly("/dev/video0")); ! devlist.AppendString(to_userfriendly("/dev/video1")); } ! return devlist; } --- 620,639 ---- } + else { ! POrdinalToString vid; ! CollectVideoDevices("/dev/", vid); ! ! for (PINDEX i = 0; i < vid.GetSize(); i++) { ! PINDEX cardnum = vid.GetKeyAt(i); ! ! int fd = ::open(vid[cardnum], O_RDONLY | O_NONBLOCK); ! if (fd >= 0 || errno == EBUSY) { ! ::close(fd); ! devlist.AppendString(to_userfriendly(vid[cardnum])); ! } ! } } ! return devlist; } |