资源简介
用QT做前端界面,调用 gstreamer的一些接口,写的DVR,用于视频存贮
代码片段和文件信息
/*
DVR a Digital video Recorder for Linux.
Copyright (C) 2001-2007 Pierre Hebert
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not write to the
Free Software Foundation Inc. 59 Temple Place - Suite 330
Boston MA 02111-1307 USA.
*/
#include
#include
#include
#include
#include
#include
#include
#include “device_selection.h“
DeviceSelection::DeviceSelection(QWidget *parent const char *name) : UIDeviceSelection(parent name) {}
DeviceSelection::~DeviceSelection() {}
int DeviceSelection::exec() {
QDir d(“/sys/class/video4linux“);
if(d.exists()) {
d.setFilter(QDir::Dirs);
QStringList list=d.entryList(“video*“);
// look for all dir entries in /sys/class/video4linux
for(QStringList::Iterator it=list.begin(); it!=list.end(); ++it) {
QString filename=d.path()+“/“+(*it)+“/dev“;
FILE *f=fopen(filename “r“);
if(f) {
int major minor;
QString device_name device_filename;
if(fscanf(f “%d:%d“ &major &minor)==2) {
fclose(f);
// look for a device file with the specified major/minor numbers
device_filename=findVideoDevices(“/dev“ makedev(major minor));
// a device file has been found find its name
if(device_filename!=““) {
filename=d.path()+“/“+(*it)+“/name“;
f=fopen(filename “r“);
if(f) {
char tmp[200];
int len=fread(tmp 1 sizeof(tmp) f);
tmp[len-1]=‘\0‘; // -1 -> remove trailing \n
device_name=tmp;
} else {
device_name=QString(tr(“Unnamed device \““))+device_filename+“\““;
}
} else {
fprintf(stderr tr(“A video device is reported in /sys (%s) but not matching file was found in /dev\n“) filename.latin1());
}
qcb_device->insertItem(device_name);
devices_list.push_back(DeviceDesc(device_name device_filename));
} else {
fclose(f);
}
}
}
}
if(qcb_device->count()==0) {
qcb_device->insertItem(tr(““));
qcb_device->setEnabled(false);
qpb_list->setEnabled(false);
}
return UIDeviceSelection::exec();
}
/* Find the first char device file name matching rdev */
QString DeviceSelection::fin
评论
共有 条评论