summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml
blob: d6e4b85b5d69ba885396b3e51c3801d17cbec7c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtMultimedia

Item {
    id: root
    height: width

    signal fatalError
    signal sizeChanged

    onHeightChanged: root.sizeChanged()

    CaptureSession {
        camera: Camera {
            id: camera

            onErrorOccurred: function(error, errorString) {
                if (Camera.NoError !== error) {
                    console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
                    root.fatalError()
                }
            }
        }
        imageCapture: ImageCapture {
            id: imageCapture
        }

        recorder: MediaRecorder {
            id: recorder
//             resolution: "640x480"
//             frameRate: 30
        }
        videoOutput: videoOutput
    }

    VideoOutput {
        id: videoOutput
        anchors.fill: parent
    }


    function start() { camera.start() }
    function stop() { camera.stop() }
}