V2TXLivePusher
to enable custom video processing, so that you will receive the callback of video data.dstFrame.textureId
to a new texture ID in the callback API.- (void) onProcessVideoFrame:(V2TXLiveVideoFrame _Nonnull)srcFrame dstFrame:(V2TXLiveVideoFrame _Nonnull)dstFrame{GLuint dstTextureId = renderItemWithTexture(srcFrame.textureId, srcFrame.width, srcFrame.height);dstFrame.textureId = dstTextureId;}
- (void) onProcessVideoFrame:(V2TXLiveVideoFrame _Nonnull)srcFrame dstFrame:(V2TXLiveVideoFrame _Nonnull)dstFrame{thirdparty_process(srcFrame.textureId, srcFrame.width, srcFrame.height, dstFrame.textureId);}
onProcessVideoFrame
is called at the same frequency as the frame rate, and sophisticated processing may cause GPU overheating.V2TXLivePusher
to enable custom video capturing.
The SDK will stop capturing video data and will only execute publishing-related tasks such as encoding, QoS control, and delivery.V2TXLivePusher
to feed video data into the SDK./*** @brief In the custom video capturing mode, send captured video data to the SDK<br/>* In the custom video capturing mode, the SDK stops capturing video data and only encodes and sends data* You can package the SampleBuffer captured into `V2TXLiveVideoFrame` and use this API to send data regularly** @note You must call [enableCustomVideoCapture](@ref V2TXLivePusher#enableCustomVideoCapture:) to enable custom video capturing before [startPush](@ref V2TXLivePusher#startPush:)** @param videoFrame Video frames {@link V2TXLiveVideoFrame} sent to the SDK** @return Return code for {@link V2TXLiveCode}* - `V2TXLIVE_OK`: successful* - `V2TXLIVE_ERROR_INVALID_PARAMETER`: Operation failed because the video data is invalid.* - `V2TXLIVE_ERROR_REFUSED`: You must call `enableCustomVideoCapture` to enable custom video capturing first.*/- (V2TXLiveCode)sendCustomVideoFrame:(V2TXLiveVideoFrame *)videoFrame;
V2TXLivePusher
to enable custom video processing, so that you will receive the callback of video data.dstFrame.textureId
to a new texture ID in the callback API.private class MyPusherObserver extends V2TXLivePusherObserver {@Overridepublic void onGLContextCreated() {mFURenderer.onSurfaceCreated();mFURenderer.setUseTexAsync(true);}@Overridepublic int onProcessVideoFrame(V2TXLiveVideoFrame srcFrame, V2TXLiveVideoFrame dstFrame) {dstFrame.texture.textureId = mFURenderer.onDrawFrameSingleInput(srcFrame.texture.textureId, srcFrame.width, srcFrame.height);return 0;}@Overridepublic void onGLContextDestroyed() {mFURenderer.onSurfaceDestroyed();}}
@Overridepublic int onProcessVideoFrame(V2TXLiveVideoFrame srcFrame, V2TXLiveVideoFrame dstFrame) {thirdparty_process(srcFrame.texture.textureId, srcFrame.width, srcFrame.height, dstFrame.texture.textureId);return 0;}
onProcessVideoFrame
is called at the same frequency as the frame rate, and sophisticated processing may cause GPU overheating.V2TXLivePusher
to enable custom video capturing.
The SDK will stop capturing video data and will only execute publishing-related tasks such as encoding, QoS control, and delivery.V2TXLivePusher
to feed video data into the SDK./*** @brief In the custom video capturing mode, send captured video data to the SDK<br/>* In the custom video capturing mode, the SDK stops capturing video data and only encodes and sends data** @note You need to call {@link V2TXLivePusher#enableCustomVideoCapture(boolean)} to enable custom video capturing before {@link V2TXLivePusher#startPush(String)}** @param videoFrame Video frames {@link V2TXLiveVideoFrame} sent to the SDK** @return Return code for {@link V2TXLiveCode}* - `V2TXLIVE_OK`: successful* - `V2TXLIVE_ERROR_INVALID_PARAMETER`: Operation failed because the video data is invalid.* - `V2TXLIVE_ERROR_REFUSED`: You must call `enableCustomVideoCapture` to enable custom video capturing first.*/public abstract int sendCustomVideoFrame(V2TXLiveVideoFrame videoFrame);
@interface V2TXLivePlayer : NSObject/*** @brief Set callbacks for the player<br/>* After setting callbacks, you can listen for events of V2TXLivePlayer,* including the player status, playback volume, first audio/video frame, statistics, and warning and error messages.** @param observer Target object for the player’s callbacks. For more information, see {@link V2TXLivePlayerObserver}*/- (void)setObserver:(id<V2TXLivePlayerObserver>)observer;
/*** @brief Video frame information* V2TXLiveVideoFrame is the raw data that describes a video frame before encoding or after decoding* @note It is used during custom video capturing to package the video frames to be sent, and during custom video rendering to get the packaged video frames*/@interface V2TXLiveVideoFrame : NSObject///**Field meaning:** video pixel format///**Recommended value:** V2TXLivePixelFormatNV12@property(nonatomic, assign) V2TXLivePixelFormat pixelFormat;///**Field meaning:** video data container format///**Recommended value:** V2TXLiveBufferTypePixelBuffer@property(nonatomic, assign) V2TXLiveBufferType bufferType;///**Field meaning:** video data when bufferType is V2TXLiveBufferTypeNSData@property(nonatomic, strong, nullable) NSData *data;///**Field meaning:** video data when bufferType is V2TXLiveBufferTypePixelBuffer@property(nonatomic, assign, nullable) CVPixelBufferRef pixelBuffer;///**Field meaning:** video width@property(nonatomic, assign) NSUInteger width;///**Field meaning:** video height@property(nonatomic, assign) NSUInteger height;///**Field meaning:** clockwise rotation of video@property(nonatomic, assign) V2TXLiveRotation rotation;/// **Field description:** video texture ID@property (nonatomic, assign) GLuint textureId;@end@protocol V2TXLivePlayerObserver <NSObject>@optional/*** @brief Custom video rendering callback** @note You will receive this callback after calling [enableCustomRendering](@ref V2TXLivePlayer#enableCustomRendering:pixelFormat:bufferType:) to enable custom video rendering** @param videoFrame Video frame data {@link V2TXLiveVideoFrame}*/- (void)onRenderVideoFrame:(id<V2TXLivePlayer>)playerframe:(V2TXLiveVideoFrame *)videoFrame@end
public abstract void setObserver(V2TXLivePlayerObserver observer)
public final static class V2TXLiveVideoFrame{/// Video pixel formatpublic V2TXLivePixelFormat pixelFormat = V2TXLivePixelFormat.V2TXLivePixelFormatUnknown;/// Video data container formatpublic V2TXLiveBufferType bufferType = V2TXLiveBufferType.V2TXLiveBufferTypeUnknown;/// Video texture packpublic V2TXLiveTexture texture;/// Video datapublic byte[] data;/// Video datapublic ByteBuffer buffer;/// Video widthpublic int width;/// Video heightpublic int height;/// Clockwise rotation of videopublic int rotation;}public abstract class V2TXLivePlayerObserver {/*** Callback for custom video rendering** @param player The player object sending this callback* @param videoFrame Video frame data {@link V2TXLiveVideoFrame}*/void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveVideoFrame videoFrame);}
Was this page helpful?