• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_CAMERA_CAPTURE_SESSION_H
17 #define OHOS_CAMERA_CAPTURE_SESSION_H
18 
19 #include <iostream>
20 #include <vector>
21 #include "input/capture_input.h"
22 #include "output/capture_output.h"
23 #include "icapture_session.h"
24 #include "icapture_session_callback.h"
25 
26 namespace OHOS {
27 namespace CameraStandard {
28 class SessionCallback {
29 public:
30     SessionCallback() = default;
31     virtual ~SessionCallback() = default;
32     virtual void OnError(int32_t errorCode) = 0;
33 };
34 
35 class CaptureSession : public RefBase {
36 public:
37     CaptureSession(sptr<ICaptureSession> &captureSession);
~CaptureSession()38     ~CaptureSession() {};
39     int32_t BeginConfig();
40     int32_t CommitConfig();
41     int32_t AddInput(sptr<CaptureInput> &input);
42     int32_t AddOutput(sptr<CaptureOutput> &output);
43     int32_t RemoveInput(sptr<CaptureInput> &input);
44     int32_t RemoveOutput(sptr<CaptureOutput> &output);
45     int32_t Start();
46     int32_t Stop();
47     void SetCallback(std::shared_ptr<SessionCallback> callback);
48     std::shared_ptr<SessionCallback> GetApplicationCallback();
49     void Release();
50 
51 private:
52     sptr<ICaptureSession> captureSession_;
53     std::shared_ptr<SessionCallback> appCallback_;
54     sptr<ICaptureSessionCallback> captureSessionCallback_;
55 };
56 } // namespace CameraStandard
57 } // namespace OHOS
58 #endif // OHOS_CAMERA_CAPTURE_SESSION_H
59