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:
Yoann Lopes
2015-09-29 16:13:53 +02:00
parent 5b3cd2f8b1
commit 038e22078b
4 changed files with 82 additions and 38 deletions

View File

@@ -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