AVFoundation: fix camera capture previews.
Generate the preview from a viewfinder frame and not from the final JPG image. In addition, the preview is now rotated to always be in the same orientation as the device at the time of capture. Task-number: QTBUG-46971 Change-Id: I48851225738e50fbd89c2f94904bac366303a9ad Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
@@ -36,19 +36,24 @@
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#include <QtCore/qqueue.h>
|
||||
#include <QtCore/qsemaphore.h>
|
||||
#include <QtMultimedia/qcameraimagecapturecontrol.h>
|
||||
#include <private/qvideooutputorientationhandler_p.h>
|
||||
#include "avfcamerasession.h"
|
||||
#include "avfstoragelocation.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class AVFCameraSession;
|
||||
class AVFCameraService;
|
||||
class AVFCameraControl;
|
||||
|
||||
class AVFImageCaptureControl : public QCameraImageCaptureControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct CaptureRequest {
|
||||
int captureId;
|
||||
QSemaphore *previewReady;
|
||||
};
|
||||
|
||||
AVFImageCaptureControl(AVFCameraService *service, QObject *parent = 0);
|
||||
~AVFImageCaptureControl();
|
||||
|
||||
@@ -64,8 +69,11 @@ public:
|
||||
private Q_SLOTS:
|
||||
void updateCaptureConnection();
|
||||
void updateReadyStatus();
|
||||
void onNewViewfinderFrame(const QVideoFrame &frame);
|
||||
|
||||
private:
|
||||
void makeCapturePreview(CaptureRequest request, const QVideoFrame &frame, AVFCameraInfo cameraInfo, int screenOrientation);
|
||||
|
||||
AVFCameraSession *m_session;
|
||||
AVFCameraControl *m_cameraControl;
|
||||
bool m_ready;
|
||||
@@ -73,8 +81,14 @@ private:
|
||||
AVCaptureStillImageOutput *m_stillImageOutput;
|
||||
AVCaptureConnection *m_videoConnection;
|
||||
AVFStorageLocation m_storageLocation;
|
||||
QVideoOutputOrientationHandler m_orientationHandler;
|
||||
|
||||
QMutex m_requestsMutex;
|
||||
QQueue<CaptureRequest> m_captureRequests;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(AVFImageCaptureControl::CaptureRequest, Q_PRIMITIVE_TYPE);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user