1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Video (both ways)

May or not work, depending on the camera, time of day, phases of the moon, and distance to the closest uTox installation
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-06-30 16:17:20 +02:00
parent b394372ad0
commit aabc8367bb
4 changed files with 17 additions and 5 deletions

View File

@ -1172,7 +1172,7 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled
calls[callId].sendVideoTimer.setSingleShot(true);
connect(&calls[callId].sendVideoTimer, &QTimer::timeout, [=](){
Widget::getInstance()->getCore()->sendCallVideo(callId);});
//calls[callId].sendVideoTimer.start();
calls[callId].sendVideoTimer.start();
Widget::getInstance()->getCamera()->suscribe();
}
@ -1300,14 +1300,15 @@ void Core::sendCallVideo(int callId)
if (!calls[callId].active || !calls[callId].videoEnabled)
return;
uint8_t videobuf[TOXAV_VIDEO_WIDTH * TOXAV_VIDEO_HEIGHT * 4];
const int bufsize = TOXAV_MAX_VIDEO_WIDTH * TOXAV_MAX_VIDEO_HEIGHT * 4;
uint8_t videobuf[bufsize];
vpx_image frame = camera->getLastVPXImage();
if (frame.w && frame.h)
{
int result;
if((result = toxav_prepare_video_frame(toxav, callId, videobuf, sizeof(videobuf), &frame)) < 0)
if((result = toxav_prepare_video_frame(toxav, callId, videobuf, bufsize, &frame)) < 0)
{
qDebug() << "Core: toxav_prepare_video_frame error\n";
qDebug() << QString("Core: toxav_prepare_video_frame: error %1").arg(result);
calls[callId].sendVideoTimer.start();
return;
}

2
core.h
View File

@ -43,6 +43,8 @@
#define TOXAV_RINGING_TIME 15
// TODO: Put that in the settings
#define TOXAV_MAX_VIDEO_WIDTH 1600
#define TOXAV_MAX_VIDEO_HEIGHT 1200
#define TOXAV_VIDEO_WIDTH 640
#define TOXAV_VIDEO_HEIGHT 480

View File

@ -24,6 +24,7 @@ int main(int argc, char *argv[])
/** TODO
* ">using a dedicated tool to maintain a TODO list" edition
*
* Most cameras use YUYV, implement YUYV -> YUV240
* Groupchat users count not updated when people leave
* Sending large files (~380MB) "restarts" after ~10MB. Goes back to 0%, consumes twice as much ram (reloads the file?)
* => Don't load the whole file at once, load small chunks (25MB?) when needed, then free them and load the next

View File

@ -1,6 +1,8 @@
#include "camera.h"
#include <QVideoSurfaceFormat>
#include <QMessageBox>
#include <QVideoEncoderSettings>
#include <QVideoEncoderSettingsControl>
Camera::Camera()
: refcount{0}, camera{new QCamera}
@ -8,6 +10,12 @@ Camera::Camera()
camera->setCaptureMode(QCamera::CaptureVideo);
camera->setViewfinder(this);
QMediaService *m = camera->service();
QVideoEncoderSettingsControl *enc = m->requestControl<QVideoEncoderSettingsControl*>();
QVideoEncoderSettings sets = enc->videoSettings();
sets.setResolution(640, 480);
enc->setVideoSettings(sets);
connect(camera, SIGNAL(error(QCamera::Error)), this, SLOT(onCameraError(QCamera::Error)));
supportedFormats << QVideoFrame::Format_YUV420P << QVideoFrame::Format_YV12 << QVideoFrame::Format_RGB32;
@ -191,7 +199,7 @@ vpx_image Camera::getLastVPXImage()
img.planes[VPX_PLANE_U] = vData;
img.planes[VPX_PLANE_V] = uData;
}
else if (frameFormat == QVideoFrame::Format_RGB32)
else if (frameFormat == QVideoFrame::Format_RGB32 || frameFormat == QVideoFrame::Format_ARGB32)
{
img.w = img.h = 0; // Invalid frame. TODO: Implement conversion
qWarning() << "Camera: Can't convert from RGB32! Go complain at github.com/tux3/toxgui";