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 // - Color enhancement 15 16 #ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ 17 #define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ 18 19 #include "webrtc/common_types.h" 20 21 namespace webrtc { 22 23 class EncodedImageCallback; 24 class I420FrameCallback; 25 class VideoEngine; 26 27 // This class declares an abstract interface for a user defined effect filter. 28 // The effect filter is registered using RegisterCaptureEffectFilter(), 29 // RegisterSendEffectFilter() or RegisterRenderEffectFilter() and deregistered 30 // with the corresponding deregister function. 31 class WEBRTC_DLLEXPORT ViEEffectFilter { 32 public: 33 // This method is called with an I420 video frame allowing the user to 34 // modify the video frame. 35 virtual int Transform(int size, 36 unsigned char* frame_buffer, 37 int64_t ntp_time_ms, 38 unsigned int timestamp, 39 unsigned int width, 40 unsigned int height) = 0; 41 protected: ViEEffectFilter()42 ViEEffectFilter() {} ~ViEEffectFilter()43 virtual ~ViEEffectFilter() {} 44 }; 45 46 class WEBRTC_DLLEXPORT ViEImageProcess { 47 public: 48 // Factory for the ViEImageProcess subāAPI and increases an internal 49 // reference counter if successful. Returns NULL if the API is not supported 50 // or if construction fails. 51 static ViEImageProcess* GetInterface(VideoEngine* video_engine); 52 53 // Releases the ViEImageProcess sub-API and decreases an internal reference 54 // counter. Returns the new reference count. This value should be zero 55 // for all sub-API:s before the VideoEngine object can be safely deleted. 56 virtual int Release() = 0; 57 58 // This function registers a EffectFilter to use for a specified capture 59 // device. 60 virtual int RegisterCaptureEffectFilter(const int capture_id, 61 ViEEffectFilter& capture_filter) = 0; 62 63 // This function deregisters a EffectFilter for a specified capture device. 64 virtual int DeregisterCaptureEffectFilter(const int capture_id) = 0; 65 66 // This function registers an EffectFilter to use for a specified channel. 67 virtual int RegisterSendEffectFilter(const int video_channel, 68 ViEEffectFilter& send_filter) = 0; 69 70 // This function deregisters a send effect filter for a specified channel. 71 virtual int DeregisterSendEffectFilter(const int video_channel) = 0; 72 73 // This function registers a EffectFilter to use for the rendered video 74 // stream on an incoming channel. 75 virtual int RegisterRenderEffectFilter(const int video_channel, 76 ViEEffectFilter& render_filter) = 0; 77 78 // This function deregisters a render effect filter for a specified channel. 79 virtual int DeregisterRenderEffectFilter(const int video_channel) = 0; 80 81 // All cameras run the risk of getting in almost perfect sync with 82 // florescent lamps, which will result in a very annoying flickering of the 83 // image. Most cameras have some type of filter to protect against this but 84 // not all of them succeed. Enabling this function will remove the flicker. 85 virtual int EnableDeflickering(const int capture_id, const bool enable) = 0; 86 87 // TODO(pbos): Remove this function when removed from fakewebrtcvideoengine.h. EnableDenoising(const int capture_id,const bool enable)88 virtual int EnableDenoising(const int capture_id, const bool enable) { 89 return -1; 90 } 91 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; 96 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 RegisterPostEncodeImageCallback(int video_channel,EncodedImageCallback * post_encode_callback)103 virtual void RegisterPostEncodeImageCallback( 104 int video_channel, 105 EncodedImageCallback* post_encode_callback) {} DeRegisterPostEncodeCallback(int video_channel)106 virtual void DeRegisterPostEncodeCallback(int video_channel) {} 107 RegisterPreDecodeImageCallback(int video_channel,EncodedImageCallback * pre_decode_callback)108 virtual void RegisterPreDecodeImageCallback( 109 int video_channel, 110 EncodedImageCallback* pre_decode_callback) {} DeRegisterPreDecodeCallback(int video_channel)111 virtual void DeRegisterPreDecodeCallback(int video_channel) {} 112 113 virtual void RegisterPreRenderCallback( 114 int video_channel, 115 I420FrameCallback* pre_render_callback) = 0; 116 virtual void DeRegisterPreRenderCallback(int video_channel) = 0; 117 118 protected: ViEImageProcess()119 ViEImageProcess() {} ~ViEImageProcess()120 virtual ~ViEImageProcess() {} 121 }; 122 123 } // namespace webrtc 124 125 #endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ 126