RCLiveSteamManager.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // RCLiveSteamManager.h
  3. // RCLiveDemo
  4. //
  5. // Created by My Apple on 2021/11/11.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #include <CoreVideo/CVPixelBuffer.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. typedef enum EventState {
  11. EventStateUnKnown = -1L,
  12. EventStateLandscape = 0L,
  13. EventStateVerticalScreen,
  14. EventStateTurnOnAudioThrough,
  15. EventStateTurnOffAudioThrough,
  16. EventStateTurnOnVideoThrough,
  17. EventStateTurnOffVideoThrough,
  18. EventStateScreenChange,
  19. EventStateTurnOnVideoFront,
  20. EventStateUploadFileOnLine,
  21. EventStateUploadFileOffLine,
  22. EventStateTurnOnVideoDontNeedToServer,
  23. EventStateTurnOnVideoFrontDontNeedToServer
  24. } EventState;
  25. typedef enum ConnectState {
  26. ConnectStateDestroy = 0L,
  27. ConnectStateConnecting,
  28. ConnectStateConnected,
  29. ConnectStateRendering,
  30. ConnectStateClosing,
  31. ConnectStateClosed,
  32. ConnectStateAbnormalDisconnect,
  33. ConnectStateVfailed,
  34. ConnectStatePicPushing,
  35. ConnectStatePicPushed,
  36. ConnectStatePicPushErr,
  37. ConnectStateMultiLogin,
  38. ConnectStateVerifyErr,
  39. ConnectStateNetRequestIFrame
  40. } ConnectState;
  41. typedef enum VirtualDataType {
  42. VirtualDataTypeVideo = 1L,
  43. VirtualDataTypeAudio,
  44. VirtualDataTypePicture = 9L
  45. } VirtualDataType;
  46. typedef enum VirtualRecordState {
  47. VirtualRecordStateTurnOnAudioThrough = 2L,
  48. VirtualRecordStateTurnOffAudioThrough,
  49. VirtualRecordStateTurnOnVideoThrough,
  50. VirtualRecordStateTurnOffVideoThrough,
  51. VirtualRecordStateAudioThroughPause,
  52. VirtualRecordStateVideoThroughPause
  53. } VirtualRecordState;
  54. typedef enum ConnectChannelType {
  55. ConnectChannelTypeUpload = 0L,
  56. ConnectChannelTypeUdp = 1L,
  57. ConnectChannelTypeTcp,
  58. ConnectChannelTypeKcp,
  59. ConnectChannelTypeUdpH265,
  60. ConnectChannelTypeTcpH265,
  61. ConnectChannelTypeWebsocket,
  62. ConnectChannelTypeWebsocketH265
  63. } ConnectChannelType;
  64. typedef enum VideoDecodeType {
  65. VideoDecodeTypeSdk,
  66. VideoDecodeTypeNative
  67. } VideoDecodeType;
  68. typedef enum AudioDecodeType {
  69. AudioDecodeTypeSdk,
  70. AudioDecodeTypeNative
  71. } AudioDecodeType;
  72. typedef enum VirtualThroughModel {
  73. VirtualThroughModelOnline = 1L,
  74. VirtualThroughModelOffline
  75. } VirtualThroughModel;
  76. typedef NS_CLOSED_ENUM(NSInteger, RCCloudPhoneConnectType) {
  77. RCCloudPhoneConnectType_udp = 0L,
  78. RCCloudPhoneConnectType_websocket
  79. };
  80. typedef NS_CLOSED_ENUM(NSInteger, RCCloudPhoneVideoQuality) {
  81. RCCloudPhoneVideoQuality_Default = 0L, //h264
  82. RCCloudPhoneVideoQuality_High //h265
  83. };
  84. typedef struct {
  85. int loss_rate_ratio; //丢包率 = loss_rate_ratio / 256 * 100
  86. int min_rtt; //传输延时
  87. int send_fps; //帧率
  88. int send_bytes; //码率
  89. int current_estimator_rate; //当前带宽
  90. int send_delay_ms; //发送耗时
  91. int encode_delay_ms; //编号耗时
  92. int support_resolution_level;
  93. } NetEstimator;
  94. typedef NSInteger RCStateInt;
  95. @class RCLiveSteamManager;
  96. @protocol RCLiveSteamManagerDelegate <NSObject>
  97. - (void)liveStreamManagerOutPut:(RCLiveSteamManager *)manager didOutPutVideoPixelBuffer:(CVPixelBufferRef)pixelBuffer;
  98. - (void)liveStreamManagerOutPut:(RCLiveSteamManager *)manager didOutPutAudioData:(NSData *)pcmData;
  99. - (void)liveStreamManager:(RCLiveSteamManager *)manager connectState:(ConnectState)state;
  100. - (void)liveStreamManager:(RCLiveSteamManager *)manager didReceiveEvent:(EventState)event;
  101. - (void)liveStreamManager:(RCLiveSteamManager *)manager didReceiveMessage:(NSString *)message;
  102. - (void)liveStreamManager:(RCLiveSteamManager *)manager didReceiNetEstimator:(NetEstimator)estimator;
  103. - (void)liveStreamManager:(RCLiveSteamManager *)manager didReceiveJitterDelay:(int)jitterDelayMs;
  104. @end
  105. @interface RCLiveStreamConfigure : NSObject
  106. @property (nonatomic, strong) NSString *ipAdress;
  107. @property (nonatomic, assign) NSInteger port;
  108. @property (nonatomic, assign) RCCloudPhoneConnectType connectType;
  109. @property (nonatomic, assign) RCCloudPhoneVideoQuality videoQuality;
  110. @end
  111. @interface RCLiveSteamManager : NSObject
  112. @property (nonatomic, weak) id <RCLiveSteamManagerDelegate> delegate;
  113. - (RCStateInt)rc_openWithConfigure:(RCLiveStreamConfigure *)configure verify:(nullable NSString *)verify;
  114. - (RCStateInt)rc_openWithIp:(nonnull NSString *)ip
  115. port:(NSInteger)port
  116. connectType:(RCCloudPhoneConnectType)connectType
  117. videoQuality:(RCCloudPhoneVideoQuality)videoQuality
  118. verify:(nullable NSString *)verify
  119. streamAESKey:(nullable NSString *)aesKey;
  120. - (void)rc_requestIDFrame;
  121. - (void)rc_disconnect;
  122. - (void)rc_release;
  123. - (void)rc_sendTransportData:(const char *)buffer length:(int)length dataType:(VirtualDataType)type;
  124. - (void)rc_sendTransportRecordState:(VirtualRecordState)state;
  125. - (void)rc_setMediaTransportModel:(VirtualThroughModel)model;
  126. - (void)rc_sendJsonData:(const char *)data;
  127. - (void)rc_setDecodeVideoDelay:(int)delay;
  128. @end
  129. NS_ASSUME_NONNULL_END