KSYDummyAudioSource.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // KSYDummyAudioSource.h
  3. // KSYStreamer
  4. //
  5. //
  6. // Created by pengbin on 10/15/15.
  7. // Copyright © 2015 ksyun. All rights reserved.
  8. //
  9. #import <Foundation/Foundation.h>
  10. #import <AVFoundation/AVFoundation.h>
  11. /** 静音音频数据源
  12. 和音频采集模块类型能够实时产生音频数据, 但是音量都为0
  13. 主要用于真实音频采集需要被暂停时,用于持续产生音频数据避免中断
  14. */
  15. @interface KSYDummyAudioSource : NSObject
  16. /** 构造函数
  17. @param asbd 输入的音频格式
  18. @return 新实例
  19. */
  20. - (id) initWithAudioFmt:(AudioStreamBasicDescription) asbd;
  21. /** 启动产生数据
  22. @return 是否启动成功
  23. @discussion 自动生成系统时间戳
  24. */
  25. - (BOOL)start;
  26. /** 启动产生数据
  27. @param initPts 设置启动时间戳
  28. @return 是否启动采集成功
  29. @discussion 内部都会先将时间戳的timescale转为ns
  30. */
  31. - (BOOL)startAt: (CMTime) initPts;
  32. /** 停止产生数据 */
  33. - (void)stop;
  34. /**
  35. @abstract 静音音频数据输出回调函数
  36. @discussion sampleBuffer 生成的音频数据
  37. */
  38. @property(nonatomic, copy) void(^audioProcessingCallback)(CMSampleBufferRef sampleBuffer);
  39. /** format description for audio data
  40. * 默认PCM格式为: (Float32), 单声道, 44100Hz
  41. */
  42. @property(nonatomic, assign) AudioStreamBasicDescription asbd;
  43. /**
  44. * 每次尝试产生的数据长度 (sample数, 默认为1024)
  45. * 实际每次产生的音频的数据长度不确定, 应该是在nbSample附近波动
  46. */
  47. @property(nonatomic, assign) int nbSample;
  48. /** 当前是否正在工作 */
  49. @property(nonatomic, readonly) BOOL bRunning;
  50. @end