MeiCam SDK For iOS  3.16.3
NvsCustomVideoFx.h
Go to the documentation of this file.
1 //================================================================================
2 //
3 // (c) Copyright Meishe Co. Ltd, 2017. All rights reserved.
4 //
5 // This code and information is provided "as is" without warranty of any kind,
6 // either expressed or implied, including but not limited to the implied
7 // warranties of merchantability and/or fitness for a particular purpose.
8 //
9 //--------------------------------------------------------------------------------
10 // Birth Date: Jul 20. 2017
11 // Author: Meishe video team
12 //================================================================================
13 #pragma once
14 
15 #import <Foundation/Foundation.h>
16 #import "NvsCommonDef.h"
17 
19  int texId;
20  int width;
21  int height;
24 
26 };
27 
28 typedef enum {
36 } NvsParamType;
37 
38 struct NvsFxParamVal {
40  int intVal;
41  float fltVal;
42  bool boolVal;
44  NSString *strVal;
46 };
47 
56  int64_t effectTime;
57  int64_t effectStartTime;
58  int64_t effectEndTime;
59  int64_t mediaStreamTime;
60  NSMutableDictionary *paramsMap;
61  NSMutableArray *attachedVideoFrames;
62 };
63 
64 #define NVS_CUSTOM_VIDEO_FX_REQUIREMENT_OUTPUT_TEXTURE_COLOR_TRANSFER @"output-texture-color-transfer"
65 #define NVS_CUSTOM_VIDEO_FX_REQUIREMENT_OUTPUT_TEXTURE_COLOR_PRIMARIES @"output-texture-color-primaries"
66 #define NVS_CUSTOM_VIDEO_FX_REQUIREMENT_BUDDY_FRAME_FORMAT @"buddy-frame-pixel-format"
67 #define NVS_CUSTOM_VIDEO_FX_REQUIREMENT_OUTPUT_SIZE_FOLLOW_SINK @"output-size-follow-sink"
68 
70 
79 @protocol NvsCustomVideoFxRenderer <NSObject>
80 
93 - (void)didInit;
94 
107 - (void)didCleanup;
108 
123 - (void)didPreloadResources;
124 
153 - (void)didRender:(struct NvsCustomVideoFxRenderContext *)renderContext
154  renderHelper:(NvsCustomVideoFxRenderHelper *)renderHelper;
155 
156 @optional
157 
170 - (void)didClearCacheResources;
171 
186 - (bool)needInputBuddyFrame;
187 
202 - (NSDictionary*)didGetRequirement;
203 @end
204 
212 
227 - (int)allocateRGBATexture:(NvsSize)texSize;
228 
245 - (int)allocateRGBATexture:(NvsSize)texSize format:(NvsGpuVideoFrameFormat)fmt;
246 
255 - (void)reclaimTexture:(int)texId;
256 
267 - (BOOL)uploadHostBufferToOpenGLTexture:(NvsVideoFrameInfo*)hostBuffer textureId:(int)tId;
268 
279 - (BOOL)uploadHostBufferToOpenGLTexture:(NvsVideoFrameInfoExt*)hostBuffer gpuVideoFrame:(struct NvsCustomVideoFxVideoFrame*)tex;
280 
281 @end
282 
NvsCustomVideoFxRenderContext::inputVideoFrame
struct NvsCustomVideoFxVideoFrame inputVideoFrame
Inputs video frame.
Definition: NvsCustomVideoFx.h:49
NvsVideoFrameColorPrimaries
NvsVideoFrameColorPrimaries
Definition: NvsCommonDef.h:265
NvsCustomVideoFxVideoFrame::texId
int texId
The texture ID of the video frame.
Definition: NvsCustomVideoFx.h:19
NvsVideoFrameColorTransfer
NvsVideoFrameColorTransfer
Definition: NvsCommonDef.h:245
NvsCustomVideoFxVideoFrame::proxyScale
NvsRational proxyScale
Definition: NvsCustomVideoFx.h:23
-[NvsCustomVideoFxRenderer-p didGetRequirement]
NSDictionary * didGetRequirement()
Meishe SDK calls this method on custom video effects to allow input buddy frame.
NvsParamType_Float
@ NvsParamType_Float
Definition: NvsCustomVideoFx.h:31
NvsCustomVideoFxVideoFrame::isUpsideDownTexture
BOOL isUpsideDownTexture
YES means that the texture in this video frame is upside down. The user needs to deal with the textur...
Definition: NvsCustomVideoFx.h:22
NvsVideoFrameInfo
Video frame information.
Definition: NvsCommonDef.h:472
NvsCustomVideoFxRenderContext::effectEndTime
int64_t effectEndTime
Effect ending time (in microseconds).
Definition: NvsCustomVideoFx.h:58
-[NvsCustomVideoFxRenderer-p didCleanup]
void didCleanup()
Meishe SDK calls this method on custom video special effects to let users clean up resources.
-[NvsCustomVideoFxRenderer-p didClearCacheResources]
void didClearCacheResources()
Meishe SDK calls this method on custom video effects to allow some resource preprocessing.
NvsRational
Rational value.
Definition: NvsCommonDef.h:350
NvsCustomVideoFxRenderContext
Definition: NvsCustomVideoFx.h:48
NvsParamType
NvsParamType
Definition: NvsCustomVideoFx.h:28
NvsCustomVideoFxRenderContext::hasBuddyVideoFrame
bool hasBuddyVideoFrame
Indicates that whether the buddy video frame exists or not.Buddy video frames will only exist which s...
Definition: NvsCustomVideoFx.h:50
NvsCustomVideoFxVideoFrame::width
int width
The width of the video frame.
Definition: NvsCustomVideoFx.h:20
NvsCustomVideoFxRenderContext::mediaStreamTime
int64_t mediaStreamTime
Effect ending time (in microseconds).
Definition: NvsCustomVideoFx.h:59
NvsCustomVideoFxRenderContext::effectStartTime
int64_t effectStartTime
Effect starting time (in microseconds).
Definition: NvsCustomVideoFx.h:57
NvsFxParamVal::type
NvsParamType type
Definition: NvsCustomVideoFx.h:39
NvsCustomVideoFxRenderContext::inputBuddyVideoFrame
NvsVideoFrameInfo inputBuddyVideoFrame
Data and information of the input video frame in Host Memory.
Definition: NvsCustomVideoFx.h:51
NvsFxParamVal::colorVal
NvsColor colorVal
Definition: NvsCustomVideoFx.h:45
NvsCustomVideoFxRenderer-p
Custom video effects renderer interface.
Definition: NvsCustomVideoFx.h:79
-[NvsCustomVideoFxRenderer-p needInputBuddyFrame]
bool needInputBuddyFrame()
Meishe SDK calls this method on custom video effects to allow input buddy frame.
NvsCustomVideoFxRenderContext::inputBuddyVideoFrameColorMatrix
NvsVideoFrameYUVColorMatrix inputBuddyVideoFrameColorMatrix
Definition: NvsCustomVideoFx.h:52
NvsCustomVideoFxRenderContext::outputVideoFrame
struct NvsCustomVideoFxVideoFrame outputVideoFrame
Output video frame.
Definition: NvsCustomVideoFx.h:55
NvsColor
Self-defined color.
Definition: NvsCommonDef.h:429
NvsFxParamVal::fltVal
float fltVal
Definition: NvsCustomVideoFx.h:41
NvsFxParamVal
Definition: NvsCustomVideoFx.h:38
NvsFxParamVal::menuItemIdx
int menuItemIdx
Definition: NvsCustomVideoFx.h:43
NvsCustomVideoFxVideoFrame::height
int height
The height of the video frame.
Definition: NvsCustomVideoFx.h:21
NvsParamType_Int
@ NvsParamType_Int
Definition: NvsCustomVideoFx.h:30
NvsCustomVideoFxRenderHelper
Auxiliary method interface for custom video effects.
Definition: NvsCustomVideoFx.h:212
NvsParamType_String
@ NvsParamType_String
Definition: NvsCustomVideoFx.h:35
NvsParamType_Unknown
@ NvsParamType_Unknown
Definition: NvsCustomVideoFx.h:29
NvsFxParamVal::strVal
NSString * strVal
Definition: NvsCustomVideoFx.h:44
NvsVideoFrameYUVColorMatrix
NvsVideoFrameYUVColorMatrix
Definition: NvsCommonDef.h:227
NVS_EXPORT
#define NVS_EXPORT
Definition: NvsCommonDef.h:20
-[NvsCustomVideoFxRenderer-p didPreloadResources]
void didPreloadResources()
Meishe SDK calls this method on custom video effects to allow some resource preprocessing.
NvsCustomVideoFxVideoFrame::texFormat
NvsGpuVideoFrameFormat texFormat
Definition: NvsCustomVideoFx.h:25
NvsFxParamVal::boolVal
bool boolVal
Definition: NvsCustomVideoFx.h:42
NvsParamType_Menu
@ NvsParamType_Menu
Definition: NvsCustomVideoFx.h:33
-[NvsCustomVideoFxRenderer-p didInit]
void didInit()
Meishe SDK calls this method on custom video effects to let the user initialize resources.
NvsCustomVideoFxRenderContext::paramsMap
NSMutableDictionary * paramsMap
Effect params map.
Definition: NvsCustomVideoFx.h:60
NvsCommonDef.h
NvsParamType_Color
@ NvsParamType_Color
Definition: NvsCustomVideoFx.h:34
NvsGpuVideoFrameFormat
NvsGpuVideoFrameFormat
Video frame pixel format.
Definition: NvsCommonDef.h:212
NvsCustomVideoFxRenderContext::inputBuddyVideoFrameColorPrimaries
NvsVideoFrameColorPrimaries inputBuddyVideoFrameColorPrimaries
Definition: NvsCustomVideoFx.h:54
NvsCustomVideoFxVideoFrame
Definition: NvsCustomVideoFx.h:18
NvsFxParamVal::intVal
int intVal
Definition: NvsCustomVideoFx.h:40
NvsParamType_Bool
@ NvsParamType_Bool
Definition: NvsCustomVideoFx.h:32
NvsCustomVideoFxRenderContext::effectTime
int64_t effectTime
Special effect duration (in microseconds).
Definition: NvsCustomVideoFx.h:56
NvsCustomVideoFxRenderContext::inputBuddyVideoFrameColorTransfer
NvsVideoFrameColorTransfer inputBuddyVideoFrameColorTransfer
Definition: NvsCustomVideoFx.h:53
NvsSize
Size.
Definition: NvsCommonDef.h:361
NvsCustomVideoFxRenderContext::attachedVideoFrames
NSMutableArray * attachedVideoFrames
Attached video frames.
Definition: NvsCustomVideoFx.h:61
NvsVideoFrameInfoExt
Video frame extra information.
Definition: NvsCommonDef.h:492