• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * soft_handler.h - soft image handler class
3  *
4  *  Copyright (c) 2017 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Wind Yuan <feng.yuan@intel.com>
19  */
20 
21 #ifndef XCAM_SOFT_HANDLER_H
22 #define XCAM_SOFT_HANDLER_H
23 
24 #include <xcam_std.h>
25 #include <image_handler.h>
26 #include <video_buffer.h>
27 #include <worker.h>
28 
29 namespace XCam {
30 
31 class SoftHandler;
32 class ThreadPool;
33 class SyncMeta;
34 class SoftWorker;
35 
36 struct SoftArgs
37     : Worker::Arguments
38 {
39 private:
40     SmartPtr<ImageHandler::Parameters> _param;
41 public:
_paramSoftArgs42     explicit SoftArgs (const SmartPtr<ImageHandler::Parameters> &param = NULL) : _param (param) {}
get_paramSoftArgs43     inline const SmartPtr<ImageHandler::Parameters> &get_param () const {
44         return _param;
45     }
set_paramSoftArgs46     inline void set_param (const SmartPtr<ImageHandler::Parameters> &param) {
47         _param = param;
48         XCAM_ASSERT (param.ptr ());
49     }
50 };
51 
52 class SoftHandler
53     : public ImageHandler
54 {
55 public:
56     explicit SoftHandler (const char* name);
57     ~SoftHandler ();
58 
59     bool set_threads (const SmartPtr<ThreadPool> &pool);
60     bool set_out_video_info (const VideoBufferInfo &info);
61     bool enable_allocator (bool enable);
62 
63     // derive from ImageHandler
64     virtual XCamReturn execute_buffer (const SmartPtr<Parameters> &param, bool sync);
65     virtual XCamReturn finish ();
66     virtual XCamReturn terminate ();
67 
68 protected:
69     virtual XCamReturn configure_resource (const SmartPtr<Parameters> &param) = 0;
70     virtual XCamReturn start_work (const SmartPtr<Parameters> &param) = 0;
71     //virtual SmartPtr<Worker::Arguments> get_first_worker_args (const SmartPtr<SoftWorker> &worker, SmartPtr<Parameters> &params) = 0;
72     virtual void work_well_done (const SmartPtr<ImageHandler::Parameters> &param, XCamReturn err);
73     virtual void work_broken (const SmartPtr<ImageHandler::Parameters> &param, XCamReturn err);
74 
75     //directly usage
76     bool check_work_continue (const SmartPtr<ImageHandler::Parameters> &param, XCamReturn err);
77 
78 private:
79     XCamReturn confirm_configured ();
80     void param_ended (SmartPtr<ImageHandler::Parameters> param, XCamReturn err);
81     static bool is_param_error (const SmartPtr<ImageHandler::Parameters> &param);
82 
83 private:
84     XCAM_DEAD_COPY (SoftHandler);
85 
86 private:
87     SmartPtr<ThreadPool>    _threads;
88     VideoBufferInfo         _out_video_info;
89     SmartPtr<SyncMeta>      _cur_sync;
90     bool                    _need_configure;
91     bool                    _enable_allocator;
92     SafeList<Parameters>    _params;
93     mutable std::atomic<int32_t>  _wip_buf_count;
94 };
95 
96 }
97 
98 #endif //XCAM_SOFT_HANDLER_H
99