blob: fece3e67b507d5b87aaecd66f7f57dace04007b2 [file] [log] [blame]
Wind Yuan75564b12015-01-15 06:51:15 -05001/*
2 * image_processor.h - 3a image processor
3 *
4 * Copyright (c) 2014-2015 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_IMAGE_PROCESSOR_H
22#define XCAM_IMAGE_PROCESSOR_H
23
Wind Yuan75564b12015-01-15 06:51:15 -050024#include "xcam_utils.h"
25#include "video_buffer.h"
26#include "x3a_result.h"
27#include "smartptr.h"
28#include "safe_list.h"
29
30namespace XCam {
31
32class ImageProcessor;
33
34/* callback interface */
35class ImageProcessCallback {
36public:
37 ImageProcessCallback () {}
38 virtual ~ImageProcessCallback () {}
39 virtual void process_buffer_done (ImageProcessor *processor, SmartPtr<VideoBuffer> &buf);
40 virtual void process_buffer_failed (ImageProcessor *processor, SmartPtr<VideoBuffer> &buf);
41 virtual void process_image_result_done (ImageProcessor *processor, SmartPtr<X3aResult> &result);
42
43private:
44 XCAM_DEAD_COPY (ImageProcessCallback);
45};
46
47class ImageProcessorThread;
48
49/* base class, ImageProcessor */
50class ImageProcessor
51{
52 friend class ImageProcessorThread;
53
54 typedef SafeList<VideoBuffer> VideoBufQueue;
55
56public:
57 explicit ImageProcessor (const char* name);
58 virtual ~ImageProcessor ();
59
60 const char *get_name () const {
61 return _name;
62 }
63
64 bool set_callback (ImageProcessCallback *callback);
65 XCamReturn start();
66 XCamReturn stop ();
67
68 XCamReturn push_buffer (SmartPtr<VideoBuffer> &buf);
69 XCamReturn push_3a_results (X3aResultList &results);
70 XCamReturn push_3a_result (SmartPtr<X3aResult> &result);
71
72protected:
73 virtual bool can_process_result (SmartPtr<X3aResult> &result) = 0;
74 virtual XCamReturn apply_3a_results (X3aResultList &results) = 0;
75 virtual XCamReturn apply_3a_result (SmartPtr<X3aResult> &result) = 0;
76 // buffer runs in another thread
77 virtual XCamReturn process_buffer(SmartPtr<VideoBuffer> &input, SmartPtr<VideoBuffer> &output) = 0;
78
79private:
80 void filter_valid_results (X3aResultList &input, X3aResultList &valid_results);
81 XCamReturn buffer_process_loop ();
82
83private:
84 XCAM_DEAD_COPY (ImageProcessor);
85
86protected:
87 char *_name;
88 ImageProcessCallback *_callback;
89 SmartPtr<ImageProcessorThread> _processor_thread;
90 VideoBufQueue _video_buf_queue;
91};
92
93};
94
95#endif //XCAM_IMAGE_PROCESSOR_H