AMediaStream.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // AMediaStream.h
  3. // all
  4. //
  5. // Created by admin on 2024/3/14.
  6. //
  7. #ifndef AMediaStream_h
  8. #define AMediaStream_h
  9. #import <Foundation/Foundation.h>
  10. #import <WebRTC/RTCPeerConnection.h>
  11. #import <WebRTC/RTCDataChannel.h>
  12. #import <WebRTC/RTCStatisticsReport.h>
  13. #import <WebRTC/RTCVideoRenderer.h>
  14. RTC_OBJC_EXPORT
  15. @protocol RTC_OBJC_TYPE(MediaStreamClientEventsDelegate) <NSObject>
  16. - (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state;
  17. -(void)onChannelDataFromPeerName:(NSString*)peerName buffer:(RTC_OBJC_TYPE(RTCDataBuffer) *)buffer;
  18. -(void)onChangeConnectionStateFromPeerName:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state;
  19. -(void)onFrameResolutionChangedFromPeerName:(NSString*)peerName videoWidth:(int)videoWidth videoHeight:(int)videoHeight rotation:(int)rotation;
  20. -(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats;
  21. //code 0 成功 1失败
  22. -(void)onAuthResultFromPeerName:(NSString*)peerName code:(int)code descriptions:(NSString*)descriptions;
  23. @end
  24. RTC_OBJC_EXPORT
  25. @interface RTC_OBJC_TYPE(AMediaStream) : UIView
  26. +(void)globalInitialization;
  27. +(void)globalDeinitialization;
  28. -(instancetype)initWithFrame:(CGRect)frame;
  29. //NSDictionary *iceMessage=@{
  30. // @"CHINANET":@"电信",
  31. // @"CMNET":@"移动",
  32. // @"UNICOM":@"联通"
  33. //};
  34. -(int)start:(NSURL *)url
  35. ice:(NSDictionary*)ice
  36. sn:(NSString*)sn
  37. direct:(NSInteger)direct
  38. fmt:(NSInteger)fmt
  39. videoWidth:(NSInteger)videoWidth
  40. videoHeight:(NSInteger)videoHeight
  41. fps:(NSInteger)fps
  42. bitrate:(NSInteger)bitrate
  43. cardWidth:(NSInteger)cardWidth
  44. cardHeight:(NSInteger)cardHeight
  45. cardDensity:(NSInteger)cardDensity
  46. token:(NSString*)token;
  47. - (int)startUploadChannel:(NSURL *)url
  48. ice:(NSDictionary*)ice
  49. sn:(NSString*)sn
  50. token:(NSString*)token;
  51. - (void)disconnect;
  52. - (BOOL)sendData:(NSString*)strData;
  53. - (BOOL)sendBinary:(NSData*)data;
  54. - (void)sendKey:(int)value;
  55. - (void)pauseStream;
  56. - (void)resumeStream;
  57. - (void)setMaxBitrate:(NSNumber*)rate;
  58. - (void)setShouldGetStats:(BOOL)shouldGetStats;
  59. - (void)setVideoContentMode:(UIViewContentMode)mode;
  60. - (void)setCardSize:(NSInteger)cardWidth
  61. cardHeight:(NSInteger)cardHeight
  62. cardDensity:(NSInteger)cardDensity;
  63. - (void)setVideoSize:(NSInteger)videoWidth
  64. videoHeight:(NSInteger)videoHeight;
  65. @property (nonatomic, weak) id <MediaStreamClientEventsDelegate> eventDelegate;
  66. @property(nonatomic,readonly) NSString *name;
  67. @property(nonatomic, assign) BOOL shouldGetStats;
  68. @end
  69. #endif /* AMediaStream_h */
  70. //
  71. // AMediaStream.h
  72. // all
  73. //
  74. // Created by admin on 2024/3/14.
  75. //
  76. #ifndef AMediaStream_h
  77. #define AMediaStream_h
  78. #import <Foundation/Foundation.h>
  79. #import <WebRTC/RTCPeerConnection.h>
  80. #import <WebRTC/RTCDataChannel.h>
  81. #import <WebRTC/RTCStatisticsReport.h>
  82. #import <WebRTC/RTCVideoRenderer.h>
  83. RTC_OBJC_EXPORT
  84. @protocol RTC_OBJC_TYPE(MediaStreamClientEventsDelegate) <NSObject>
  85. - (void)dataChannelDidChangeFromPeerName:(NSString*)peerName State:(RTCDataChannelState)state;
  86. -(void)onChannelDataFromPeerName:(NSString*)peerName buffer:(RTC_OBJC_TYPE(RTCDataBuffer) *)buffer;
  87. -(void)onChangeConnectionStateFromPeerName:(NSString*)peerName didChangeIceConnectionState:(RTCIceConnectionState)state;
  88. -(void)onFrameResolutionChangedFromPeerName:(NSString*)peerName videoWidth:(int)videoWidth videoHeight:(int)videoHeight rotation:(int)rotation;
  89. -(void)didGetStats:(NSString*)peerName stats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats;
  90. //code 0 成功 1失败
  91. -(void)onAuthResultFromPeerName:(NSString*)peerName code:(int)code descriptions:(NSString*)descriptions;
  92. @end
  93. RTC_OBJC_EXPORT
  94. @interface RTC_OBJC_TYPE(AMediaStream) : UIView
  95. +(void)globalInitialization;
  96. +(void)globalDeinitialization;
  97. -(instancetype)initWithFrame:(CGRect)frame;
  98. //NSDictionary *iceMessage=@{
  99. // @"CHINANET":@"电信",
  100. // @"CMNET":@"移动",
  101. // @"UNICOM":@"联通"
  102. //};
  103. -(int)start:(NSURL *)url
  104. ice:(NSDictionary*)ice
  105. sn:(NSString*)sn
  106. direct:(NSInteger)direct
  107. fmt:(NSInteger)fmt
  108. videoWidth:(NSInteger)videoWidth
  109. videoHeight:(NSInteger)videoHeight
  110. fps:(NSInteger)fps
  111. bitrate:(NSInteger)bitrate
  112. cardWidth:(NSInteger)cardWidth
  113. cardHeight:(NSInteger)cardHeight
  114. cardDensity:(NSInteger)cardDensity
  115. token:(NSString*)token;
  116. - (int)startUploadChannel:(NSURL *)url
  117. ice:(NSDictionary*)ice
  118. sn:(NSString*)sn
  119. token:(NSString*)token;
  120. - (void)disconnect;
  121. - (BOOL)sendData:(NSString*)strData;
  122. - (BOOL)sendBinary:(NSData*)data;
  123. - (void)sendKey:(int)value;
  124. - (void)pauseStream;
  125. - (void)resumeStream;
  126. - (void)setMaxBitrate:(NSNumber*)rate;
  127. - (void)setShouldGetStats:(BOOL)shouldGetStats;
  128. - (void)setVideoContentMode:(UIViewContentMode)mode;
  129. - (void)setCardSize:(NSInteger)cardWidth
  130. cardHeight:(NSInteger)cardHeight
  131. cardDensity:(NSInteger)cardDensity;
  132. - (void)setVideoSize:(NSInteger)videoWidth
  133. videoHeight:(NSInteger)videoHeight;
  134. @property (nonatomic, weak) id <MediaStreamClientEventsDelegate> eventDelegate;
  135. @property(nonatomic,readonly) NSString *name;
  136. @property(nonatomic, assign) BOOL shouldGetStats;
  137. @end
  138. #endif /* AMediaStream_h */