AMediaStream.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 */