RCYUVEncoder.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // ESCVideoToolboxEncodeH264DataTool.h
  3. // ESCCameraH264Demo
  4. //
  5. // Created by xiang on 2019/4/28.
  6. // Copyright © 2019 xiang. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. typedef NS_CLOSED_ENUM(NSInteger, VideoCodecType) {
  11. VideoCodecType_H264 = 0L,
  12. VideoCodecType_H265
  13. };
  14. @class RCYUVEncoder;
  15. @protocol ESCVideoToolboxYUVEncoderToolDelegate<NSObject>
  16. /**
  17. 压缩后的h264数据流
  18. */
  19. - (void)encoder:(RCYUVEncoder *)encoder encodeData:(void *)encodeData dataLenth:(NSInteger)lenth;
  20. /**
  21. 压缩结束
  22. */
  23. - (void)encoderEnd:(RCYUVEncoder *)encoder;
  24. @end
  25. @interface RCYUVEncoder : NSObject
  26. @property(nonatomic,weak)id delegate;
  27. //sps和pps数据是否包含在关键帧前面,默认为YES
  28. @property(nonatomic,assign)BOOL spsAndPpsIsIncludedInIframe;
  29. - (instancetype)initWithCodecType:(VideoCodecType)codecType;
  30. /**
  31. yuv流转h264流
  32. */
  33. - (void)setupVideoWidth:(NSInteger)width
  34. height:(NSInteger)height
  35. frameRate:(NSInteger)frameRate
  36. delegate:(id<ESCVideoToolboxYUVEncoderToolDelegate>)delegate;
  37. /**
  38. 填充需要压缩的yuv流数据
  39. */
  40. - (void)encoderYUVData:(NSData *)yuvData;
  41. /**
  42. yuv流数据接收完毕
  43. */
  44. -(void)endYUVDataStream;
  45. @end
  46. NS_ASSUME_NONNULL_END