1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef EVS_SUPPORT_LIBRARY_BASEUSECASE_H_
17 #define EVS_SUPPORT_LIBRARY_BASEUSECASE_H_
18 
19 #include <string>
20 #include <vector>
21 
22 namespace android {
23 namespace automotive {
24 namespace evs {
25 namespace support {
26 
27 using ::std::string;
28 using ::std::vector;
29 
30 /**
31  * Base class for all the use cases in the EVS support library.
32  */
33 class BaseUseCase {
34 public:
35     /**
36      * Requests delivery of camera frames from the desired EVS camera(s). The
37      * use case begins receiving periodic calls from EVS camera with new image
38      * frames until stopVideoStream is called.
39      *
40      * If the same EVS camera has already been started by other use cases,
41      * the frame delivery to this use case starts without affecting the status
42      * of the EVS camera.
43      *
44      * @return Returns true if the video stream is started successfully.
45      * Otherwise returns false.
46      *
47      * @see stopVideoStream()
48      */
49     virtual bool startVideoStream() = 0;
50 
51     /**
52      * Stops the delivery of EVS camera frames, and tries to close the EVS
53      * camera. Because delivery is asynchronous, frames may continue to
54      * arrive for some time after this call returns.
55      *
56      * If other use cases are using the camera at the same time, the EVS
57      * camera will not be closed, until all the other use cases using the
58      * camera are stopped.
59      *
60      * @see startVideoStream()
61      */
62     virtual void stopVideoStream() = 0;
63 
64     /**
65      * Default constructor for BaseUseCase.
66      *
67      * @param The ids for the desired EVS cameras.
68      */
BaseUseCase(vector<string> cameraIds)69     BaseUseCase(vector<string> cameraIds) : mCameraIds(cameraIds) {};
70 
~BaseUseCase()71     virtual ~BaseUseCase() {}
72 
73 protected:
74     vector<string> mCameraIds;
75 };
76 
77 }  // namespace support
78 }  // namespace evs
79 }  // namespace automotive
80 }  // namespace android
81 
82 #endif  // EVS_SUPPORT_LIBRARY_BASEUSECASE_H_
83