Skip to content

Commit

Permalink
会议模块获取屏幕
Browse files Browse the repository at this point in the history
  • Loading branch information
Joy1024 committed Feb 1, 2025
1 parent 445254d commit 1b97e32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/lib/video/cameradevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ void CameraDevice::readFrame()
av_packet_unref(&packet);
}

bool CameraDevice::open(VideoDevice dev, AVDictionary** options, std::string &error) {
bool CameraDevice::open(const VideoDevice& dev, AVDictionary** options, std::string &error) {
QMutexLocker locker(&openDeviceLock);

qDebug() << __func__ << std::format("device:{} url:{}", dev.name.toStdString(), dev.url.toStdString()).c_str();

auto format = getDefaultInputFormat(dev.type);
int ret = avformat_open_input(&context, dev.url.toStdString().c_str(), format, options);
if (ret < 0) {
char msg[AV_ERROR_MAX_STRING_SIZE];
av_strerror(ret, msg, AV_ERROR_MAX_STRING_SIZE);
qWarning() << "Error opening device:" << msg;
qWarning() << "Error opening device:" << dev.url << msg;
error = msg;
return false;
}
Expand Down Expand Up @@ -442,7 +444,7 @@ QVector<VideoDevice> CameraDevice::getDeviceList() {
if(iformat->name == QString("x11grab")){
auto count = ok::base::X11Display::Count();
for (size_t c = 0; c < count; ++c) {
QString dev = "x11grab#:" + QString::number(c);
QString dev = ":" + QString::number(c);
QString name = QString("Desktop %1").arg(c);
devices.push_back(VideoDevice{.type = type, .name = name, .url=dev});
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/video/cameradevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CameraDevice {
private:
void readFrame();

bool open(VideoDevice dev, AVDictionary** options, std::string &error);
bool open(const VideoDevice& dev, AVDictionary** options, std::string &error);


// QVector<QPair<QString, QString>> getRawDeviceListGeneric();
Expand Down

0 comments on commit 1b97e32

Please sign in to comment.