You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

782 lines
27 KiB

//
// JCMediaDevice.h
// JCSDK-OC
//
// Created by maikireton on 2017/8/11.
// Copyright © 2017年 juphoon. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "JCClient.h"
#import "JCMediaDeviceVideoCanvas.h"
#import "JCMediaDeviceCallback.h"
#import "JCMediaDeviceConstants.h"
/**
* @defgroup
* @{
*
*/
/**
*
*/
@interface JCMediaDeviceCamera : NSObject
/**
* id
*/
@property (nonatomic, readonly) NSString* __nonnull cameraId;
/**
*
*/
@property (nonatomic, readonly) NSString* __nonnull cameraName;
/**
*
* - @ref JCMediaDeviceCameraTypeNone :
* - @ref JCMediaDeviceCameraTypeFront :
* - @ref JCMediaDeviceCameraTypeBack :
* - @ref JCMediaDeviceCameraTypeUnknown :
*/
@property (nonatomic, readonly) JCMediaDeviceCameraType cameraType;
@end
/**
* mac 使
*/
@interface JCMediaDeviceAudio : NSObject
/**
* id
*/
@property (nonatomic, readonly) NSString* __nonnull audioId;
/**
*
*/
@property (nonatomic, readonly) NSString* __nonnull audioName;
/**
*
*/
@property (nonatomic, readonly) bool input;
@end
/**
* mac 使
*/
@interface JCMediaDeviceWindow : NSObject
/**
* id
*/
@property (nonatomic, readonly) NSString* __nonnull windowId;
/**
*
*/
@property (nonatomic, readonly) NSString* __nonnull windowName;
@end
/**
*
*/
@interface JCMediaDeviceAudioParam : NSObject
/**
*
*
* 0 8000 0
*
* SDK将自动选择合适的音频采样率
*/
@property (nonatomic) int audioInputSamplingRate;
/**
*
*
* 0 8000 0
*
* SDK将自动选择合适的音频采样率
*/
@property (nonatomic) int audioOutputSamplingRate;
/**
*
*
* 0 0 1 >= 2 0
*/
@property (nonatomic) int audioInputChannelNumber;
/**
*
*
* 0 0 1 >= 2 0
*/
@property (nonatomic) int audioOutputChannelNumber;
/**
*
*
* true
*
* - true: SDK会自动打开音频输出设备
* - false: SDK 线 {@link JCMediaDevice.getAudioOutputData:length:sampleRateHz:channels: getAudioOutputData}
*/
@property (nonatomic) bool autoStartAudioOutputDevice;
/**
*
*
* true
*
* - true: SDK会自动打开音频输入设备
* - false: SDK 线 {@link JCMediaDevice.inputCustomAudioData:sampleRateHz:channels:playDelayMS:recDelayMS:clockDrift: inputCustomAudioData}
*/
@property (nonatomic) bool autoStartAudioInputDevice;
/**
* AEC()
*
*
*
* - @ref JCMediaDeviceAudioAECTypeOn : aec
* - @ref JCMediaDeviceAudioAECTypeOff : aec
* - @ref JCMediaDeviceAudioAECTypeAuto :
*/
@property (nonatomic) JCMediaDeviceAudioAECType aecType;
/**
* agc模式
* - @ref JCMediaDeviceAudioAECTypeOn : agc
* - @ref JCMediaDeviceAudioAECTypeOff : agc
* - @ref JCMediaDeviceAudioAECTypeAuto :
*/
@property (nonatomic) JCMediaDeviceAudioAGCType agcMode;
@end
/**
*
*/
@protocol JCAudioFrameCallback <NSObject>
/**
*
*
* @param inputId
* @param sampleRateHz
* @param channels
* @param buf
* @param playDelayMS
* @param recDelayMS
* @param clockDrift
*/
- (void)onAudioInputFrame:(NSString *_Nonnull)inputId sampleRateHz:(int)sampleRateHz channels:(int)channels buf:(unsigned char *_Nonnull)buf playDelayMS:(int)playDelayMS recDelayMS:(int)recDelayMS clockDrift:(int)clockDrift;
/**
*
*
* @param outputId
* @param sampleRateHz
* @param channels
* @param buf
*/
- (void)onAudioOutputFrame:(NSString *_Nonnull)outputId sampleRateHz:(int)sampleRateHz channels:(int)channels buf:(unsigned char *_Nonnull)buf;
@end
/**
*
*/
@protocol JCVideoFrameCallback <NSObject>
/**
*
*
* @param captureId id
* @param face
* - @ref JCMediaDeviceCameraType "JCMediaDeviceCameraTypeFront"
* - @ref JCMediaDeviceCameraType "JCMediaDeviceCameraTypeBack"
* @param imageAngle
* @param captureOrient
* @param width
* @param height
* @param buf
*/
- (void)onVideoCaptureFrame:(NSString *_Nonnull)captureId face:(JCMediaDeviceCameraType)face imageAngle:(int)imageAngle captureOrient:(int)captureOrient width:(int*_Nonnull)width height:(int*_Nonnull)height buf:(unsigned char *_Nonnull)buf;
/**
*
*
* @param renderId id
* @param sourceType
* - @ref JCMediaDeviceVideoSource "JCMediaDeviceVideoSourcePeer"
* - @ref JCMediaDeviceVideoSource "JCMediaDeviceVideoSourceCapture"
* - @ref JCMediaDeviceVideoSource "JCMediaDeviceVideoSourceFile"
* @param angle
* @param mirror
* - @ref JCMediaDeviceMirror "JCMediaDeviceMirrorNone"
* - @ref JCMediaDeviceMirror "JCMediaDeviceMirrorHorizontal"
* - @ref JCMediaDeviceMirror "JCMediaDeviceMirrorVertical"
* - @ref JCMediaDeviceMirror "JCMediaDeviceMirrorAuto"
* - @ref JCMediaDeviceMirror "JCMediaDeviceMirrorFromLeft"
* - @ref JCMediaDeviceMirror "JCMediaDeviceMirrorFromTop"
* @param width
* @param height
* @param buf
* @param timeStamp
*/
- (void)onVideoRenderFrame:(NSString *_Nonnull)renderId sourceType:(JCMediaDeviceVideoSource)sourceType angle:(int)angle mirror:(JCMediaDeviceMirror)mirror width:(int*_Nonnull)width height:(int*_Nonnull)height buf:(unsigned char *_Nonnull)buf timeStamp:(unsigned long)timeStamp;
@end
/**
*
* @note JCMediaDevice {@link enableSpeaker: enableSpeaker}
*/
@interface JCMediaDevice : NSObject
/**
*
* - true
* - false
*/
@property (nonatomic, readonly) bool cameraOpen;
/**
*
* - true
* - false
*/
@property (nonatomic, readonly) bool videoFileOpen;
/**
* 使
*/
@property (nonatomic, strong, readonly) JCMediaDeviceCamera* __nullable camera;
/**
*
*/
@property (nonatomic, readonly) NSArray<JCMediaDeviceCamera*> * __nonnull cameras;
/**
*
*/
@property (nonatomic, strong) JCMediaDeviceCamera* __nullable defaultCamera;
/**
*
*
* 使 {@link startAudio}
*/
@property (nonatomic, strong) JCMediaDeviceAudioParam * _Nonnull audioParam;
/**
*
*/
@property (nonatomic, strong, readonly) NSString* __nonnull videoFileId;
/**
*
*/
@property (nonatomic, readonly) bool audioInterrupt;
/**
*
*
* - @ref JCMediaDeviceVideoAngelAuto :
* - @ref JCMediaDeviceVideoAngel0 : 0°
* - @ref JCMediaDeviceVideoAngel90 : 90°
* - @ref JCMediaDeviceVideoAngel180 : 180°
* - @ref JCMediaDeviceVideoAngel270 : 270°
*/
@property (nonatomic) JCMediaDeviceVideoAngel videoAngle;
/**
* 使
* <br>
* 1. - 使 <br>
* 2. - 使 <br>
* 3. - 使 <br>
* 4.线 <br>
* 5. - (线) <br>
*
* - true: 使
* - false: 使
*/
@property (nonatomic) bool useInternalAudioDeviceLogic;
/**
*
*
*
*
* - true
* - false
*/
@property (nonatomic, readonly) bool audioStart;
#if TARGET_OS_OSX
/**
* mac 使
*/
@property (nonatomic, readonly) NSArray<JCMediaDeviceAudio*>* __nonnull audioInputs;
/**
* mac 使
*/
@property (nonatomic, strong) JCMediaDeviceAudio* __nullable audioInput;
/**
* mac 使
*/
@property (nonatomic, readonly) NSArray<JCMediaDeviceAudio*>* __nonnull audioOutputs;
/**
* mac 使
*/
@property (nonatomic, strong) JCMediaDeviceAudio* __nullable audioOutput;
/**
* mac 使
*/
@property (nonatomic, readonly) NSArray<JCMediaDeviceWindow*>* __nonnull desktops;
/**
* mac 使
*/
@property (nonatomic, readonly) NSArray<JCMediaDeviceWindow*>* __nonnull windows;
/**
* mac 使
*/
@property (nonatomic, strong) JCMediaDeviceWindow* __nullable screenshareWindow;
#endif
/**
* JCMediaDevice
*
* JCMediaDevice 线
*
* @note
* - JCMediaDevice {@link destroy destroy} JCMediaDevice
* - JCClient @ref JCClient.state "state" @ref JCClientStateNotInit
*
* @param client JCClient
* @param callback JCMediaDeviceCallback
* @return JCMediaDevice
* @exception "JCClient、JCMediaDeviceCallback 任意一个参数传空就会调用失败"
*/
+(JCMediaDevice* __nullable)create:(JCClient* __nonnull)client callback:(id<JCMediaDeviceCallback> __nonnull)callback;
/**
* JCMediaDevice
*
* JCMediaDevice 使 JCMediaDevice <br>
* **** JCSDK JCMediaDevice <br>
* JCMediaDevice @ref destroy
*/
+(void)destroy;
/**
*
*
* JCMediaDeviceVideoCanvasUI显示
*
* 使 {@link JCCallItem.startSelfVideo: startSelfVideo} 使 {@link JCMediaChannelParticipant.startVideo:pictureSize: startVideo}
*
* @note @ref defaultCamera nil
*
* @param type
* - @ref JCMediaDeviceRenderFullScreen :
* - @ref JCMediaDeviceRenderFullContent :
* - @ref JCMediaDeviceRenderFullAuto :
* @return
* - JCMediaDeviceVideoCanvas
* - nil
*/
-(JCMediaDeviceVideoCanvas* __nullable)startCameraVideo:(JCMediaDeviceRender)type;
/**
*
*
* JCMediaDeviceVideoCanvasUI显示
*
* 使 {@link JCCallItem#startSelfVideo: startSelfVideo} 使 {@link JCMediaChannelParticipant#startVideo:pictureSize: startVideo}
*
* @note @ref defaultCamera nil
*
* @param type
* - @ref JCMediaDeviceRenderFullScreen :
* - @ref JCMediaDeviceRenderFullContent :
* - @ref JCMediaDeviceRenderFullAuto :
* @param view
* @return
* - JCMediaDeviceVideoCanvas
* - nil
*/
-(JCMediaDeviceVideoCanvas* __nullable)startCameraVideo:(JCMediaDeviceRender)type view:(JCView* __nonnull)view;
/**
*
*
* JCMediaDeviceVideoCanvasUI显示
*
* 使 {@link JCCallItem#startOtherVideo: startOtherVideo} 使 {@link JCMediaChannelParticipant#startVideo:pictureSize: startVideo}
*
* @param videoSource JCMediaChannelParticipant @ref JCMediaChannelParticipant.renderId "renderId" JCCallItem @ref JCCallItem.renderId "renderId"
* @param type
* - @ref JCMediaDeviceRenderFullScreen :
* - @ref JCMediaDeviceRenderFullContent :
* - @ref JCMediaDeviceRenderFullAuto :
* @return
* - JCMediaDeviceVideoCanvas
* - nil
*/
-(JCMediaDeviceVideoCanvas* __nullable)startVideo:(NSString* __nonnull)videoSource renderType:(JCMediaDeviceRender)type;
/**
*
*
* JCMediaDeviceVideoCanvasUI显示
*
* 使 {@link JCCallItem#startOtherVideo: startOtherVideo} 使 {@link JCMediaChannelParticipant.startVideo:pictureSize: startVideo}
*
* @param videoSource JCMediaChannelParticipant @ref JCMediaChannelParticipant.renderId "renderId" JCCallItem @ref JCCallItem.renderId "renderId"
* @param type
* - @ref JCMediaDeviceRenderFullScreen :
* - @ref JCMediaDeviceRenderFullContent :
* - @ref JCMediaDeviceRenderFullAuto :
* @param view
* @return JCMediaDeviceVideoCanvas
*/
-(JCMediaDeviceVideoCanvas* __nullable)startVideo:(NSString* __nonnull)videoSource renderType:(JCMediaDeviceRender)type view:(JCView* __nonnull)view;
/**
*
*
* 使 {@link JCCallItem#stopSelfVideo stopSelfVideo} {@link JCCallItem#stopOtherVideo stopOtherVideo} 使 {@link JCMediaChannelParticipant#stopVideo stopVideo}
*
* @param canvas JCMediaDeviceVideoCanvas {@link startVideo:renderType: startVideo} {@link startCameraVideo: startCameraVideo}
*/
-(void)stopVideo:(JCMediaDeviceVideoCanvas* __nonnull)canvas;
/**
*
*
* SDK内部会自动调用此方法来启动音频
*
* @return
* - true
* - false
*/
-(bool)startAudio;
/**
*
*
* SDK内部会自动调用此方法来停止音频
*
* @return
* - true
* - false
*/
-(bool)stopAudio;
/**
*
*
* @note @ref defaultCamera false
*
* @return
* - true
* -
* - {@link JCMediaDeviceCallback#onCameraUpdate onCameraUpdate}
* - false
*/
-(bool)startCamera;
/**
*
*
* @return
* - true
* -
* - {@link JCMediaDeviceCallback#onCameraUpdate onCameraUpdate}
* - false
*/
-(bool)stopCamera;
/**
*
*
*
*
* - false
* - true
* - {@link switchCamera: switchCamera:(JCMediaDeviceCamera *)camera}
*
* @return
* - true
* - false
*/
-(bool)switchCamera;
/**
*
*
* 0 false
*
* @param camera
* @return
* - true
* - 1
* - 1 {@link JCMediaDeviceCallback#onCameraUpdate onCameraUpdate}
* - false
*/
-(bool)switchCamera:(JCMediaDeviceCamera* __nonnull)camera;
/**
*
*
* {@link JCCallItem#startSelfVideo: startSelfVideo} {@link JCMediaChannelParticipant#startVideo:pictureSize: startVideo}
*
* @param width 640
* @param height 360
* @param frameRate 24
*/
- (void)setCameraProperty:(int)width height:(int)height framerate:(int)framerate;
/**
*
*
* {@link JCMediaChannel#enableScreenShare: enableScreenShare}
*
* @param width 1280
* @param height 720
* @param frameRate 10
*/
- (void)setScreenCaptureProperty:(int)width height:(int)height framerate:(int)framerate;
/**
*
*
* @note
* -
* -
*
* @return
* - true
* -
* - {@link JCMediaDeviceCallback#onCameraUpdate onCameraUpdate}
* - false
*/
-(bool)startVideoFile;
/**
*
*
*
*
* @note format H264
* - 0x67 0x68 0x65 0x670x68pps0x65
* - P帧以 0x41
* - 5
*
* @param data
* @param format @ref JCMediaDeviceVideoPixelFormat "视频像素格式"
* @param width
* @param height
*/
-(void)setVideoFileFrame:(NSData* __nonnull)srcFrame format:(JCMediaDeviceVideoPixelFormat)format width:(int)width height:(int)height;
/**
*
*
*
*
* @note format H264
* - 0x67 0x68 0x65 0x670x68pps0x65
* - P帧以 0x41
* - 5
*
* @param srcFrame
* @param angle , 90
* @param mirror 0 1
*/
-(void)setVideoFileFrame:(CVPixelBufferRef __nonnull)srcFrame angle:(int)angle mirror:(int)mirror;
/**
*
*
* @return
* - true
* -
* - {@link JCMediaDeviceCallback#onCameraUpdate onCameraUpdate}
* - false
*/
-(bool)stopVideoFile;
/**
* ,EV
*
* @return
*/
-(int)getMinExposureCompensation;
/**
* ,EV
*
* @return
*/
-(int)getMaxExposureCompensation;
/**
*
*
* @return
*/
-(float)getExposureCompensationStep;
/**
*
*
* @return 使
*/
-(int)setExposureCompensation:(float)exposureValue;
/**
*
*
* @return 使
*/
-(int)setCameraZoom:(float)zoom;
/**
*
*
* @return
*/
-(bool)isCameraFlashSupported;
/**
* 使
*
* @return 使
*/
-(bool)enableFlash:(bool)enable;
#pragma mark - 音频数据管理
/**
*
*
* SDK {@link JCAudioFrameCallback.onAudioInputFrame:sampleRateHz:channels:buf:playDelayMS:recDelayMS:clockDrift: onAudioInputFrame}
* {@link JCAudioFrameCallback.onAudioOutputFrame:sampleRateHz:channels:buf: onAudioOutputFrame} 使
*
* @param callback JCAudioFrameCallback nil {@link JCMediaChannelCallback.onLeave:channelId: onLeave} {@link JCMediaChannelCallback.onStop:reason: onStop} {@link JCCallCallback.onCallItemRemove:reason:description: onCallItemRemove}
*/
- (void)registerAudioFrameCallback:(id<JCAudioFrameCallback> __nullable)callback;
/**
*
*
* SDK {@link JCVideoFrameCallback.onVideoCaptureFrame:face:imageAngle:captureOrient:width:height:buf: onVideoCaptureFrame}
* {@link JCVideoFrameCallback.onVideoRenderFrame:sourceType:angle:mirror:width:height:buf:timeStamp: onVideoRenderFrame} 使
*
* @param callback JCVideoFrameCallback nil {@link JCMediaChannelCallback.onLeave:channelId: onLeave} {@link JCMediaChannelCallback.onStop:reason: onStop} {@link JCCallCallback.onCallItemRemove:reason:description: onCallItemRemove}
*
* @return
* - true:
* - false:
*/
- (void)registerVideoFrameCallback:(id<JCVideoFrameCallback> __nullable)callback;
/**
*
* @ref JCMediaDeviceAudioParam.autoStartAudioInputDevice "autoStartAudioInputDevice" false
* 线
*
* @param data NSData
* @param sampleRateHz 800016000320004410048000
* @param channels 12
* @param playDelayMS 0
* @param recDelayMS 0
* @param clockDrift 0
*
* @return
* - true:
* - false:
*/
- (bool)inputCustomAudioData:(NSData *_Nonnull)data sampleRateHz:(int)sampleRateHz channels:(int)channels playDelayMS:(int)playDelayMS recDelayMS:(int)recDelayMS clockDrift:(int)clockDrift;
/**
*
*
* @ref JCMediaDeviceAudioParam.autoStartAudioOutputDevice "autoStartAudioOutputDevice" false
* 线
*
* @param buf unsigned char* (*/100)
* @param sampleRateHz 800016000320004410048000
* @param channels 12
* @param length buf
*
* @return
* - true:
* - false:
*/
- (bool)getAudioOutputData:(unsigned char*_Nonnull)buf length:(int)length sampleRateHz:(int)sampleRateHz channels:(int)channels;
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
/**
* iOS 使
* - true
* - false
*/
@property (nonatomic) bool defaultSpeakerOn;
/**
* /iOS 使
*
*
*
* @param enable
* - true:
* - false:
*/
-(void)enableSpeaker:(bool)enable;
/**
* iOS 使
* @return
*/
-(NSString* __nullable)getAudioOutputType;
/**
* iOS 使
* - true:
* - false:
*/
-(bool)isSpeakerOn;
#endif
@end
/**
* @}
*/