-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image capture added #4
Open
netvandal
wants to merge
1
commit into
Igalia:master
Choose a base branch
from
netvandal:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
* Xabier Rodriguez Calvar <[email protected]> | ||
* Víctor Jáquez <[email protected]> | ||
* Based on the original idea of Jens Wilke <[email protected]> | ||
|
||
* Michele Tameni <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* Contact: Miguel Gómez <[email protected]> | ||
* Xabier Rodriguez Calvar <[email protected]> | ||
* Víctor Jáquez <[email protected]> | ||
* Michele Tameni <[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 | ||
|
@@ -224,12 +225,42 @@ PageStackWindow { | |
} | ||
} | ||
|
||
Button { | ||
id: cameraShutter | ||
platformStyle: ButtonStyle { | ||
background: "qrc:/resources/shutter-bg.png" | ||
disabledBackground: "qrc:/resources/shutter-bg.png" | ||
pressedBackground: "qrc:/resources/shutter-bg-pressed.png" | ||
textColor: "white" | ||
fontPixelSize: UIConstants.FONT_DEFAULT | ||
fontFamily: UIConstants.FONT_FAMILY | ||
} | ||
anchors { | ||
top: postCapture.bottom | ||
topMargin: 5 | ||
right: shutter.left | ||
rightMargin: 10 | ||
} | ||
height: 90 | ||
width: 100 | ||
iconSource: "qrc:/resources/camera-icon.png" | ||
visible: controller.recording ? false: !page.__dialogsVisible | ||
enabled: controller.pipelineReady | ||
opacity: enabled ? 1 : page.__dimmedOpacity | ||
Behavior on opacity { NumberAnimation { duration: page.__animationDuration } } | ||
|
||
onClicked: { | ||
controller.cameraShutterClicked() | ||
} | ||
} | ||
|
||
Image { | ||
id: timer | ||
anchors { | ||
top: postCapture.bottom | ||
top: shutter.bottom | ||
topMargin: 5 | ||
left: postCapture.left | ||
left: shutter.left | ||
leftMargin: 10 | ||
} | ||
source: "qrc:/resources/timer-bg.png" | ||
Text { | ||
|
@@ -243,20 +274,7 @@ PageStackWindow { | |
color: "white" | ||
text: controller.recordedTime | ||
} | ||
visible: !page.__dialogsVisible | ||
} | ||
|
||
Text { | ||
id: deviceText | ||
anchors { | ||
left: deviceConf.left | ||
bottom: deviceConf.top | ||
} | ||
visible: !controller.recording && !page.__dialogsVisible | ||
font.pixelSize: UIConstants.FONT_DEFAULT | ||
font.family: UIConstants.FONT_FAMILY | ||
color: "white" | ||
text: "Camera" | ||
visible: controller.recording ? !page.__dialogsVisible : false | ||
} | ||
|
||
Rectangle { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* Contact: Miguel Gómez <[email protected]> | ||
* Xabier Rodriguez Calvar <[email protected]> | ||
* Víctor Jáquez <[email protected]> | ||
* Michele Tameni <[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 | ||
|
@@ -141,6 +142,16 @@ void Controller::stopRecording() | |
} | ||
} | ||
|
||
void Controller::captureImage() | ||
{ | ||
if (ResourceManager::instance()->acquireRecordingResources()) { | ||
m_pipeline->captureImage(); | ||
} else { | ||
qCritical() << "Recording resources denied"; | ||
resourcesLost(); | ||
} | ||
} | ||
|
||
void Controller::shutterClicked() | ||
{ | ||
if (!m_recording) { | ||
|
@@ -150,6 +161,11 @@ void Controller::shutterClicked() | |
} | ||
} | ||
|
||
void Controller::cameraShutterClicked() | ||
{ | ||
captureImage(); | ||
} | ||
|
||
void Controller::setResolution(Pipeline::Resolution value) | ||
{ | ||
if (m_currentResolution != value) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* Contact: Miguel Gómez <[email protected]> | ||
* Xabier Rodriguez Calvar <[email protected]> | ||
* Víctor Jáquez <[email protected]> | ||
* Michele Tameni <[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 | ||
|
@@ -94,7 +95,9 @@ public slots: | |
void pausePipeline(); | ||
void startRecording(); | ||
void stopRecording(); | ||
void captureImage(); | ||
void shutterClicked(); | ||
void cameraShutterClicked(); | ||
void setRecording(bool recording); | ||
void setVideoEffect(const QString &value); | ||
void setColorFilter(const ControllerSettings::ColorFilter value); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* Contact: Miguel Gómez <[email protected]> | ||
* Xabier Rodriguez Calvar <[email protected]> | ||
* Víctor Jáquez <[email protected]> | ||
* Michele Tameni <[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 | ||
|
@@ -166,9 +167,25 @@ Pipeline::~Pipeline() | |
gst_object_unref(GST_OBJECT(camerabin)); | ||
} | ||
|
||
void Pipeline::setCameraMode() | ||
{ | ||
currentMode = MODE_IMAGE; | ||
g_object_set(camerabin, "mode", 0, NULL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't you use MODE_IMAGE here instead of 0? |
||
|
||
// set auto scene mode | ||
gst_photography_set_scene_mode(GST_PHOTOGRAPHY(videoSrc), | ||
GST_PHOTOGRAPHY_SCENE_MODE_AUTO); | ||
// disable autofocus | ||
gst_photography_set_autofocus (GST_PHOTOGRAPHY(videoSrc), FALSE); | ||
// disable flash | ||
g_object_set(videoSrc, "video-torch", FALSE, NULL); | ||
|
||
} | ||
|
||
void Pipeline::setVideoMode() | ||
{ | ||
g_object_set(camerabin, "mode", 1, NULL); | ||
currentMode = MODE_VIDEO; | ||
g_object_set(camerabin, "mode", MODE_VIDEO, NULL); | ||
|
||
// set auto scene mode | ||
gst_photography_set_scene_mode(GST_PHOTOGRAPHY(videoSrc), | ||
|
@@ -209,6 +226,9 @@ void Pipeline::prepare() | |
|
||
void Pipeline::startRecording() | ||
{ | ||
if(currentMode == MODE_IMAGE) | ||
setVideoMode(); | ||
|
||
currentFile = nextFileName(); | ||
emit savedFileNameChanged(currentFile); | ||
|
||
|
@@ -229,6 +249,27 @@ void Pipeline::stopRecording() | |
g_signal_emit_by_name(camerabin, "capture-stop", 0); | ||
} | ||
|
||
void Pipeline::captureImage() | ||
{ | ||
if(currentMode == MODE_VIDEO) | ||
setCameraMode(); | ||
|
||
currentFile = nextFileName(); | ||
emit savedFileNameChanged(currentFile); | ||
|
||
// set next file name | ||
g_object_set(camerabin, | ||
"filename", | ||
currentFile.toUtf8().constData(), | ||
NULL); | ||
|
||
// write image metadata | ||
writeMetadata(); | ||
|
||
g_signal_emit_by_name(camerabin, "capture-start", 0); | ||
} | ||
|
||
|
||
void Pipeline::setResolution(Resolution value) | ||
{ | ||
int width, height; | ||
|
@@ -436,7 +477,7 @@ QString Pipeline::nextFileName() | |
int index = dir.count() + 1; | ||
|
||
QString filename(APP_FOLDER); | ||
filename += QDir::separator() + QString("%1_%2.%3").arg(date).arg(index).arg(FILE_SUFFIX); | ||
filename += QDir::separator() + QString("%1_%2.%3").arg(date).arg(index).arg((currentMode==MODE_VIDEO) ? VIDEO_FILE_SUFFIX : IMAGE_FILE_SUFFIX); | ||
return filename; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* Contact: Miguel Gómez <[email protected]> | ||
* Xabier Rodriguez Calvar <[email protected]> | ||
* Víctor Jáquez <[email protected]> | ||
* Michele Tameni <[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 | ||
|
@@ -58,6 +59,7 @@ class Pipeline : public QObject | |
Pipeline(QObject *parent = 0); | ||
~Pipeline(); | ||
void setupFileStorage(); | ||
void setCameraMode(); | ||
void setVideoMode(); | ||
void setResolution(const Resolution value); | ||
void setZoom(const double value); | ||
|
@@ -70,6 +72,7 @@ class Pipeline : public QObject | |
void prepare(); | ||
void startRecording(); | ||
void stopRecording(); | ||
void captureImage(); | ||
void setWindowId(int winId); | ||
void handleBusMessage(GstMessage *message); | ||
bool isIdle(); | ||
|
@@ -84,7 +87,6 @@ class Pipeline : public QObject | |
QString nextFileName(); | ||
void setupEffectBins(); | ||
void writeMetadata(); | ||
|
||
GstElement *camerabin; | ||
GstElement *videoSrc; | ||
GstElement *viewfinder; | ||
|
@@ -100,5 +102,12 @@ class Pipeline : public QObject | |
int windowId; | ||
QSystemDeviceInfo systemInfo; | ||
QString currentFile; | ||
|
||
typedef enum { | ||
MODE_IMAGE, | ||
MODE_VIDEO | ||
} videoMode; | ||
int currentMode; | ||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't really need to acquire the recording resources in order to get a pic. That's only needed for video because you need to get the audio recording resources. For pics, you already have the camera and the viewfinder since the app gets launched, so you don't need anything else.