niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | // This sub-API supports the following functionalities: |
| 12 | // - Effect filters |
| 13 | // - Deflickering |
| 14 | // - Denoising |
| 15 | // - Color enhancement |
| 16 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 17 | #ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ |
| 18 | #define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
pbos@webrtc.org | f5d4cb1 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 20 | #include "webrtc/common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 22 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
sprang@webrtc.org | 4070935 | 2013-11-26 11:41:59 +0000 | [diff] [blame] | 24 | class EncodedImageCallback; |
pbos@webrtc.org | fe1ef93 | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 25 | class I420FrameCallback; |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 26 | class VideoEngine; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
| 28 | // This class declares an abstract interface for a user defined effect filter. |
| 29 | // The effect filter is registered using RegisterCaptureEffectFilter(), |
| 30 | // RegisterSendEffectFilter() or RegisterRenderEffectFilter() and deregistered |
| 31 | // with the corresponding deregister function. |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 32 | class WEBRTC_DLLEXPORT ViEEffectFilter { |
| 33 | public: |
| 34 | // This method is called with an I420 video frame allowing the user to |
| 35 | // modify the video frame. |
wu@webrtc.org | 6c75c98 | 2014-04-15 17:46:33 +0000 | [diff] [blame^] | 36 | virtual int Transform(int size, |
| 37 | unsigned char* frame_buffer, |
| 38 | int64_t ntp_time_ms, |
| 39 | unsigned int timestamp, |
| 40 | unsigned int width, |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 41 | unsigned int height) = 0; |
| 42 | protected: |
| 43 | ViEEffectFilter() {} |
| 44 | virtual ~ViEEffectFilter() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 47 | class WEBRTC_DLLEXPORT ViEImageProcess { |
| 48 | public: |
| 49 | // Factory for the ViEImageProcess sub‐API and increases an internal |
| 50 | // reference counter if successful. Returns NULL if the API is not supported |
| 51 | // or if construction fails. |
| 52 | static ViEImageProcess* GetInterface(VideoEngine* video_engine); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 54 | // Releases the ViEImageProcess sub-API and decreases an internal reference |
| 55 | // counter. Returns the new reference count. This value should be zero |
| 56 | // for all sub-API:s before the VideoEngine object can be safely deleted. |
| 57 | virtual int Release() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 59 | // This function registers a EffectFilter to use for a specified capture |
| 60 | // device. |
| 61 | virtual int RegisterCaptureEffectFilter(const int capture_id, |
| 62 | ViEEffectFilter& capture_filter) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 64 | // This function deregisters a EffectFilter for a specified capture device. |
| 65 | virtual int DeregisterCaptureEffectFilter(const int capture_id) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 67 | // This function registers an EffectFilter to use for a specified channel. |
| 68 | virtual int RegisterSendEffectFilter(const int video_channel, |
| 69 | ViEEffectFilter& send_filter) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 71 | // This function deregisters a send effect filter for a specified channel. |
| 72 | virtual int DeregisterSendEffectFilter(const int video_channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 74 | // This function registers a EffectFilter to use for the rendered video |
| 75 | // stream on an incoming channel. |
| 76 | virtual int RegisterRenderEffectFilter(const int video_channel, |
| 77 | ViEEffectFilter& render_filter) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 79 | // This function deregisters a render effect filter for a specified channel. |
| 80 | virtual int DeregisterRenderEffectFilter(const int video_channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 82 | // All cameras run the risk of getting in almost perfect sync with |
| 83 | // florescent lamps, which will result in a very annoying flickering of the |
| 84 | // image. Most cameras have some type of filter to protect against this but |
| 85 | // not all of them succeed. Enabling this function will remove the flicker. |
| 86 | virtual int EnableDeflickering(const int capture_id, const bool enable) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 88 | // Some cameras produce very noisy captured images, especially in low‐light |
| 89 | // conditions. This functionality will reduce the camera noise. |
| 90 | virtual int EnableDenoising(const int capture_id, const bool enable) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 92 | // This function enhances the colors on the decoded video stream, enabled by |
| 93 | // default. |
| 94 | virtual int EnableColorEnhancement(const int video_channel, |
| 95 | const bool enable) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
pbos@webrtc.org | fe1ef93 | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 97 | // New-style callbacks, used by VideoSendStream/VideoReceiveStream. |
| 98 | virtual void RegisterPreEncodeCallback( |
| 99 | int video_channel, |
| 100 | I420FrameCallback* pre_encode_callback) = 0; |
| 101 | virtual void DeRegisterPreEncodeCallback(int video_channel) = 0; |
| 102 | |
sprang@webrtc.org | 4070935 | 2013-11-26 11:41:59 +0000 | [diff] [blame] | 103 | virtual void RegisterPostEncodeImageCallback( |
| 104 | int video_channel, |
sprang@webrtc.org | b3ea3af | 2013-11-27 10:28:27 +0000 | [diff] [blame] | 105 | EncodedImageCallback* post_encode_callback) {} |
sprang@webrtc.org | 4070935 | 2013-11-26 11:41:59 +0000 | [diff] [blame] | 106 | virtual void DeRegisterPostEncodeCallback(int video_channel) {} |
| 107 | |
| 108 | virtual void RegisterPreDecodeImageCallback( |
| 109 | int video_channel, |
sprang@webrtc.org | b3ea3af | 2013-11-27 10:28:27 +0000 | [diff] [blame] | 110 | EncodedImageCallback* pre_decode_callback) {} |
sprang@webrtc.org | 4070935 | 2013-11-26 11:41:59 +0000 | [diff] [blame] | 111 | virtual void DeRegisterPreDecodeCallback(int video_channel) {} |
| 112 | |
pbos@webrtc.org | fe1ef93 | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 113 | virtual void RegisterPreRenderCallback( |
| 114 | int video_channel, |
| 115 | I420FrameCallback* pre_render_callback) = 0; |
| 116 | virtual void DeRegisterPreRenderCallback(int video_channel) = 0; |
| 117 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 118 | protected: |
| 119 | ViEImageProcess() {} |
| 120 | virtual ~ViEImageProcess() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 121 | }; |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 122 | |
| 123 | } // namespace webrtc |
| 124 | |
| 125 | #endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ |