Guest User

Untitled

a guest
Oct 15th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. [vince@dozer harbour-advanced-camera]$ git diff @~
  2. diff --git a/harbour-advanced-camera.pro b/harbour-advanced-camera.pro
  3. index 536a25a..337222a 100644
  4. --- a/harbour-advanced-camera.pro
  5. +++ b/harbour-advanced-camera.pro
  6. @@ -25,7 +25,8 @@ SOURCES += src/harbour-advanced-camera.cpp \
  7. src/focusmodel.cpp \
  8. src/flashmodel.cpp \
  9. src/fsoperations.cpp \
  10. - src/resourcehandler.cpp
  11. + src/resourcehandler.cpp \
  12. + src/framegrabber.cpp
  13.  
  14. DISTFILES += rpm/harbour-advanced-camera.changes.in \
  15. rpm/harbour-advanced-camera.changes.run.in \
  16. @@ -70,6 +71,7 @@ HEADERS += \
  17. src/focusmodel.h \
  18. src/flashmodel.h \
  19. src/fsoperations.h \
  20. - src/resourcehandler.h
  21. + src/resourcehandler.h \
  22. + src/framegrabber.h
  23.  
  24. LIBS += -ldl
  25. diff --git a/qml/pages/GalleryUI.qml b/qml/pages/GalleryUI.qml
  26. index 67ce167..7f5e33f 100644
  27. --- a/qml/pages/GalleryUI.qml
  28. +++ b/qml/pages/GalleryUI.qml
  29. @@ -8,7 +8,7 @@ import "../components/"
  30. Page {
  31. id: galleryPage
  32.  
  33. - property var fileList: ({})
  34. + property ListModel fileList
  35. property alias showButtons: btnClose.visible
  36.  
  37. // The effective value will be restricted by ApplicationWindow.allowedOrientations
  38. @@ -147,7 +147,7 @@ Page {
  39.  
  40. onClicked: {
  41. pageStack.push(Qt.resolvedUrl("VideoPlayer.qml"),
  42. - { videoFile: filePath },
  43. + { videoFile: filePath, fileList: fileList },
  44. PageStackAction.Immediate);
  45. }
  46. }
  47. diff --git a/qml/pages/VideoPlayer.qml b/qml/pages/VideoPlayer.qml
  48. index 1548682..015e4a9 100644
  49. --- a/qml/pages/VideoPlayer.qml
  50. +++ b/qml/pages/VideoPlayer.qml
  51. @@ -1,11 +1,14 @@
  52. import QtQuick 2.0
  53. import Sailfish.Silica 1.0
  54. import QtMultimedia 5.6
  55. +import uk.co.piggz.harbour_advanced_camera 1.0
  56. import "../components/"
  57.  
  58. Page {
  59. id: videoPage
  60.  
  61. + property ListModel fileList
  62. +
  63. // The effective value will be restricted by ApplicationWindow.allowedOrientations
  64. allowedOrientations: Orientation.All
  65.  
  66. @@ -39,6 +42,7 @@ Page {
  67. anchors.fill: parent
  68. source: player
  69. fillMode: VideoOutput.PreserveAspectFit
  70. + filters: [ frameGrabber ]
  71.  
  72. MouseArea {
  73. anchors.fill: parent
  74. @@ -48,6 +52,30 @@ Page {
  75. }
  76. }
  77.  
  78. + FrameGrabber {
  79. + id: frameGrabber
  80. +
  81. + active: false
  82. +
  83. + onFinished: {
  84. + console.log("FrameGrabber: finished!");
  85. + active = false;
  86. + animFlash.start();
  87. + var path = fsOperations.writableLocation("image") + "/AdvancedCam/PIC_" + Qt.formatDateTime(new Date(), "yyyyMMdd_hhmmss") + ".jpg"
  88. + result.saveToFile(path);
  89. + console.log("Snapshot taken:", path);
  90. + fileList.append({ filePath: path, isVideo: false });
  91. + }
  92. + }
  93. +
  94. + Rectangle {
  95. + id: rectFlash
  96. + anchors.fill: parent
  97. + opacity: 0
  98. +
  99. + NumberAnimation on opacity {id:animFlash; from: 1.0; to: 0.0; duration: 200 }
  100. + }
  101. +
  102. Item {
  103. id: itemsControls
  104. anchors.fill: parent
  105. @@ -96,6 +124,24 @@ Page {
  106. }
  107. }
  108.  
  109. + RoundButton {
  110. + id: btnSnapshot
  111. +
  112. + enabled: controlsOpacity > 0
  113. + icon.source: "image://theme/icon-m-camera"
  114. + size: Theme.itemSizeMedium
  115. +
  116. + anchors {
  117. + verticalCenter: parent.verticalCenter
  118. + right: parent.right
  119. + rightMargin: Theme.paddingMedium
  120. + }
  121. +
  122. + onClicked: {
  123. + frameGrabber.active = true;
  124. + }
  125. + }
  126. +
  127. Row {
  128. id: rowBottomVideo
  129.  
  130. @@ -131,4 +177,8 @@ Page {
  131. }
  132. }
  133. }
  134. +
  135. + FSOperations {
  136. + id: fsOperations
  137. + }
  138. }
  139. diff --git a/src/framegrabber.cpp b/src/framegrabber.cpp
  140. new file mode 100644
  141. index 0000000..1132d0b
  142. --- /dev/null
  143. +++ b/src/framegrabber.cpp
  144. @@ -0,0 +1,24 @@
  145. +#include "framegrabber.h"
  146. +#include <QDebug>
  147. +#include <QImage>
  148. +
  149. +QVideoFilterRunnable* FrameGrabber::createFilterRunnable()
  150. +{
  151. + qDebug() << "FrameGrabber::createFilterRunnable() !!!";
  152. + return new FrameGrabberRunnable(this);
  153. +}
  154. +
  155. +QVideoFrame FrameGrabberRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat &surface, RunFlags flags)
  156. +{
  157. + qDebug() << "FrameGrabberRunnable::run() !!!";
  158. + Q_UNUSED(surface);
  159. + Q_UNUSED(flags);
  160. + QImage img;
  161. + QImage::Format format = QVideoFrame::imageFormatFromPixelFormat(input->pixelFormat());
  162. + if (format != QImage::Format_Invalid)
  163. + img = QImage(input->bits(), input->width(), input->height(), format);
  164. + else
  165. + img = QImage::fromData(input->bits(), input->mappedBytes());
  166. + emit m_filter->finished(img);
  167. + return *input;
  168. +}
  169. diff --git a/src/framegrabber.h b/src/framegrabber.h
  170. new file mode 100644
  171. index 0000000..db62338
  172. --- /dev/null
  173. +++ b/src/framegrabber.h
  174. @@ -0,0 +1,26 @@
  175. +#ifndef FRAMEGRABBER_H
  176. +#define FRAMEGRABBER_H
  177. +
  178. +#include <QAbstractVideoFilter>
  179. +
  180. +class FrameGrabber : public QAbstractVideoFilter
  181. +{
  182. + Q_OBJECT
  183. +public:
  184. + QVideoFilterRunnable *createFilterRunnable();
  185. +
  186. +signals:
  187. + void finished(QImage result);
  188. +};
  189. +
  190. +class FrameGrabberRunnable : public QVideoFilterRunnable
  191. +{
  192. +public:
  193. + FrameGrabberRunnable(FrameGrabber *filter = nullptr) : m_filter(filter) { };
  194. + QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags);
  195. +
  196. +private:
  197. + FrameGrabber *m_filter;
  198. +};
  199. +
  200. +#endif // FRAMEGRABBER_H
  201. diff --git a/src/harbour-advanced-camera.cpp b/src/harbour-advanced-camera.cpp
  202. index d2b675a..0e52b33 100644
  203. --- a/src/harbour-advanced-camera.cpp
  204. +++ b/src/harbour-advanced-camera.cpp
  205. @@ -17,6 +17,7 @@
  206. #include "flashmodel.h"
  207. #include "fsoperations.h"
  208. #include "resourcehandler.h"
  209. +#include "framegrabber.h"
  210.  
  211. int main(int argc, char *argv[])
  212. {
  213. @@ -40,6 +41,7 @@ int main(int argc, char *argv[])
  214. qmlRegisterType<FocusModel>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FocusModel");
  215. qmlRegisterType<FlashModel>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FlashModel");
  216. qmlRegisterType<FSOperations>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FSOperations");
  217. + qmlRegisterType<FrameGrabber>("uk.co.piggz.harbour_advanced_camera", 1, 0, "FrameGrabber");
  218.  
  219. ResolutionModel resolutionModel;
  220. QSortFilterProxyModel sortedResolutionModel;
  221. diff --git a/translations/harbour-advanced-camera-fr.ts b/translations/harbour-advanced-camera-fr.ts
  222. index a8ca50e..ce9332b 100644
  223. --- a/translations/harbour-advanced-camera-fr.ts
  224. +++ b/translations/harbour-advanced-camera-fr.ts
  225. @@ -296,7 +296,7 @@
  226. <context>
  227. <name>GalleryUI</name>
  228. <message>
  229. - <location filename="../qml/pages/GalleryUI.qml" line="79"/>
  230. + <location filename="../qml/pages/GalleryUI.qml" line="80"/>
  231. <source>Deleting %1</source>
  232. <translation type="unfinished"></translation>
  233. </message>
  234. [vince@dozer harbour-advanced-camera]$
Advertisement
Add Comment
Please, Sign In to add comment