# Video Management

# Video data collection management

# Set the type of camera to turn on

Before video capture settings, you can get the camera list, current camera, and default camera through the properties in the JCMediaDevice class, as follows:

/// Camera list
NSArray<JCMediaDeviceCamera*> *  __nonnull cameras;

/// The camera being used
JCMediaDeviceCamera* __nullable camera;

/// Default camera
JCMediaDeviceCamera* __nullable defaultCamera;

Among them, the camera object (JCMediaDeviceCamera) has the following properties:

/// Camera id
NSString* __nonnull cameraId;

/// Camera name
NSString* __nonnull cameraName;

/// Camera type
JCMediaDeviceCameraType cameraType;

The camera type (JCMediaDeviceCameraType) has the following types:

JCMediaDeviceCameraTypeNone = 0,
JCMediaDeviceCameraTypeFront = 1,
JCMediaDeviceCameraTypeBack = 2,
JCMediaDeviceCameraTypeUnknown = 3

After the camera list is obtained, you can call the following method to switch the specified camera:

/// Switch the specified camera
/// @param camera camera
-(bool)switchCamera:(JCMediaDeviceCamera* __nonnull)camera;

# Set camera capture resolution

You can achieve different video resolutions by customizing camera acquisition parameters, such as acquisition height, width, and frame rate.

The camera collection property setting interface is as follows:

/**
 *  @breif Set camera collection properties
 *  @param width default640
 *  @param height default360
 *  @param framerate default30
 */
- (void)setCameraProperty:(int)width height:(int)height framerate:(int)framerate;

Sample code:

//Get a list of cameras
NSArray<JCMediaDeviceCamera*> * cameras = mediaDevice.cameras;
//Set the camera you want to switch
[mediaDevice switchCamera:cameras[1]];
//Set camera capture properties
[mediaDevice setCameraProperty:640 height:360 framerate:30];

# Video rendering management

# Create local and remote video images

  • Local video rendering

Local video rendering obtains local video objects for UI interface display by calling the startCameraVideo interface, which opens the camera

/**
 *  @brief get preview video object, and you can get view for UI display through this object
 *  @param type rendering mode, @ref JCMediaDeviceRender
 *  @return JCMediaDeviceVideoCanvas object
 */
-(JCMediaDeviceVideoCanvas* __nullable)startCameraVideo:(int)type;

Among them, the rendering mode (JCMediaDeviceRender) has the following three:

Name

Description

JCMediaDeviceRenderFullScreen = 0

The video image fills the entire rendering area proportionally (crop out part of the area beyond the rendering area)

JCMediaDeviceRenderFullContent

The content of the video image is completely presented in the rendering area (black borders may appear, similar to the screen of a movie)

JCMediaDeviceRenderFullAuto

automatic

  • Remote video rendering

You can call the startVideo method to get the peer video object and render:

/**
 *  @brief get preview video object, and you can get view for UI display through this object
 *  @param videoSource rendering identifier string, such as renderId in JCMediaChannelParticipant JCCallItem, when videoSource is videoFileId, startVideoFile will be called internally
 *  @param type         rendering mode, @ref JCMediaDeviceRender
 *  @return JCMediaDeviceVideoCanvas object
 */
-(JCMediaDeviceVideoCanvas* __nullable)startVideo:(NSString* __nonnull)videoSource renderType:(int)type;

Sample code:

// Create local and remote video images object
JCMediaDeviceVideoCanvas *local = [mediaDevice startCameraVideo:JCMediaDeviceRenderFullContent];
local.videoView.frame = CGRectMake(0, 0, 100, 100);
[self.view addSubview:local.videoView];

// Create a remote video image object; the renderId comes from the call object; one-to-one is a JCCallItem object, and many parties are JCMediaChannelParticipant objects
JCMediaDeviceVideoCanvas *remote = [mediaDevice startVideo:renderId renderType:JCMediaDeviceRenderFullContent];
remote.videoView.frame = CGRectMake(100, 0, 100, 100);
[self.view addSubview:remote.videoView];

# Destroy local and remote video images

At the end of a video call or during a video call, if you want to destroy the video image, you can call the following interface:

/**
 *  @brief stop video
 *  @param canvas JCMediaDeviceVideoCanvas object, obtained by startVideo
 */
-(void)stopVideo:(JCMediaDeviceVideoCanvas* __nonnull)canvas;

Sample code:

JCMediaDeviceVideoCanvas *localCanvas = [mediaDevice startCameraVideo:JCMediaDeviceRenderFullContent];
JCMediaDeviceVideoCanvas *remoteCanvas = [mediaDevice startVideo:renderId renderType:JCMediaDeviceRenderFullContent];
if (localCanvas) {
    // Remove local video
    [mediaDevice stopVideo:localCanvas];
    [localCanvas.videoView removeFromSuperview];
    localCanvas = nil;
}
if (remoteCanvas) {
    // Remove remote video
    [mediaDevice stopVideo:remoteCanvas];
    [remoteCanvas.videoView removeFromSuperview];
    remoteCanvas = nil;
}

Rendering control mainly uses the interface in the JCMediaDeviceVideoCanvas class. Details are as follows:

If you want to update the video rendering logo, you can call the following interface:

/**
 *  @breif Update video rendering logo
 *  @param videoSource video source
 *  @return return true/ false
 */
-(bool)replace:(NSString*)videoSource;

# Pause rendering

If you want to pause the rendering of the screen, you can call the following interface:

/**
 *  @brief Pause rendering
 *  @return return true/ false
 */
-(void)pause;

# Resume rendering

If you want to continue rendering the paused picture, you can call the following interface:

/**
 *  @brief Resume rendering
 *  @return return true/ false
 */
-(void)resume;

# Video equipment management

Video device management mainly uses the methods in the JCMediaDevice class, as follows:

# Turn camera on and off

/**
 *  @breif  turn on the camera, usually called when you only need to turn on the camera
 *  @return return true/ false
 */
-(bool)startCamera;

/**
 *  @breif turn off the camera, usually used with startCamera
 *  @return return true/ false
 */
-(bool)stopCamera;

# Switch the camera

/**
 *  @breif switch between front and back cameras, and SDK will switch camera types according to the current camera type
 *  @return return true/ false
 */
-(bool)switchCamera;

Sample code:

// Turn on the camera
[mediaDevice startCamera];

// Turn off the camera
[mediaDevice stopCamera];

// Switch the camera
[mediaDevice switchCamera];
最后更新时间: 1/17/2023, 5:17:17 PM