Skip to content

Commit

Permalink
Horizontal flip front camera view finder
Browse files Browse the repository at this point in the history
We would rather show the viewfinder as a mirror by
default.

The recording would be normal, though.

Fixes: Igalia#5.
  • Loading branch information
tanty committed Jun 26, 2013
1 parent cdedab0 commit 3106267
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* Miguel Gómez <[email protected]>
* Xabier Rodriguez Calvar <[email protected]>
* Víctor Jáquez <[email protected]>
* Andrés Gómez <[email protected]>
* Based on the original idea of Jens Wilke <[email protected]>
25 changes: 23 additions & 2 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* This file is part of aura
*
* Copyright (C) 2012 Igalia S.L.
* Copyright (C) 2012, 2013 Igalia S.L.
*
* Contact: Miguel Gómez <[email protected]>
* Xabier Rodriguez Calvar <[email protected]>
* Víctor Jáquez <[email protected]>
* Andrés Gómez <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -86,6 +87,7 @@ Pipeline::Pipeline(QObject *parent)
camerabin(0),
videoSrc(0),
viewfinder(0),
viewfinderFlip(0),
effectBin(0),
effectValve(0),
effect(0),
Expand Down Expand Up @@ -138,6 +140,9 @@ Pipeline::Pipeline(QObject *parent)
g_object_set(camerabin, "audio-encoder", audioEncBin, NULL);

// viewfinder
viewfinderFlip = gst_element_factory_make("videoflip", NULL);
g_object_set (G_OBJECT (camerabin), "viewfinder-filter", viewfinderFlip, NULL);

viewfinder = gst_element_factory_make("omapxvsink", NULL);
g_object_set(viewfinder, "autopaint-colorkey", FALSE, NULL);
g_object_set (G_OBJECT (camerabin), "viewfinder-sink", viewfinder, NULL);
Expand Down Expand Up @@ -338,7 +343,23 @@ void Pipeline::setVideoEffect(const QString &value)
void Pipeline::setDevice(ControllerSettings::Device value)
{
stop();
g_object_set(videoSrc, "camera-device", value, NULL);
switch (value) {
case ControllerSettings::Primary:
g_object_set(videoSrc, "camera-device", 0, NULL);
// GST_VIDEO_FLIP_METHOD_IDENTITY
g_object_set(viewfinderFlip, "method", 0, NULL);
break;
case ControllerSettings::Secondary:
// When we use the secondary (front) camera, we expect to work
// as a mirror by default *only* in the viewfinder. The
// recording would be normal.
g_object_set(videoSrc, "camera-device", 1, NULL);
// GST_VIDEO_FLIP_METHOD_HORIZ
g_object_set(viewfinderFlip, "method", 4, NULL);
break;
default:
Q_ASSERT(0 != instancePointer);
}
start();
}

Expand Down
4 changes: 3 additions & 1 deletion src/pipeline.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* This file is part of aura
*
* Copyright (C) 2012 Igalia S.L.
* Copyright (C) 2012, 2013 Igalia S.L.
*
* Contact: Miguel Gómez <[email protected]>
* Xabier Rodriguez Calvar <[email protected]>
* Víctor Jáquez <[email protected]>
* Andrés Gómez <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -88,6 +89,7 @@ class Pipeline : public QObject
GstElement *camerabin;
GstElement *videoSrc;
GstElement *viewfinder;
GstElement *viewfinderFlip;

GstElement *effectBin;
GstElement *effectValve;
Expand Down

0 comments on commit 3106267

Please sign in to comment.