音视频通讯SDK API参考手册  iOS 1.4.0
av_device.h
1 #ifndef AV_DEVICE_H_
2 #define AV_DEVICE_H_
3 
4 #include "av_common.h"
5 #include "av_device_base.h"
6 #include <vector>
7 
8 namespace tencent {
9 
10 namespace av {
11 class AVContext;
13 #define DEVICE_UNKNOWN "\\unknown" // Unknown device type.
14 
15 // Video input/output device type/id
16 #define DEVICE_VIDEO "\\video" // Video device type.
17 #define DEVICE_CAMERA "\\video\\camera" // Camera device type.
18 #define DEVICE_REMOTE_VIDEO "\\video\\remote_video" // The virtual remote video output device.
19 #define DEVICE_EXTERNAL_CAPTURE "\\video\\external_capture" //external capture device type.
20 
21 // Audio input/output device type/id
22 #define DEVICE_AUDIO "\\audio" // Audio device type.
23 #define DEVICE_MIC "\\audio\\mic" // Mic device type.
24 #define DEVICE_PLAYER "\\audio\\player" // Sound player device type.
25 #define DEVICE_ACCOMPANY "\\audio\\accompany" // Audio Accompany device type.
26 #define DEVICE_REMOTE_AUDIO "\\audio\\remote_audio" // The virtual remote audio output device.
27 #define DEVICE_MIX "\\audio\\mix" // Mix device
28 #define DEVICE_MIX_INPUT "\\audio\\mix\\input" // Input mix device
29 #define DEVICE_MIX_OUTPUT "\\audio\\mix\\output" // Output mix device
30 
32 //
33 // 音频设备相关的由此开始
34 
36 #define MIN_AUDIO_DEVICE_VOLUME 0
37 
39 #define MAX_AUDIO_DEVICE_VOLUME 100
40 
53 class AV_EXPORT AVAudioDevice : public AVDevice {
54  public:
65  virtual uint32 GetVolume() = 0;
66 
78  virtual void SetVolume(uint32 value) = 0;
79 
87  virtual uint32 GetDynamicVolume() = 0;
88 
89  // Register an audio frame data callback. When a new audio frame appears,
90  // the callback will be invoked, and the 'custom_data' is passed back as the last parameter.
91  typedef void(*FrameDataCallback)(AudioFrame* audio_frame, void* custom_data);
92 
93  virtual void SetFrameDataCallback(FrameDataCallback frame_callback, void* custom_data = NULL) = 0;
94 
95  virtual FrameDataCallback GetFrameDataCallback() = 0;
96 
97  virtual void* GetFrameCustomData() = 0;
98 };
99 
108 class AV_EXPORT AVSupportAudioPreview {
109  public:
118  typedef void(*PreviewCallback)(AudioFrame* audio_frame, void* custom_data);
119 
128  virtual void SetPreviewCallback(PreviewCallback frame_callback, void* custom_data = NULL) = 0;
129 
130  virtual PreviewCallback GetPreviewCallback() = 0;
131 
132  virtual void* GetPreviewCustomData() = 0;
133 };
134 
142 class AV_EXPORT AVRemoteAudioDevice
143  : public AVAudioDevice
144  , public AVSupportAudioPreview {
145  public:
146 
147 };
148 
156 class AV_EXPORT AVMicDevice
157  : public AVAudioDevice
158  , public AVSupportAudioPreview {
159  public:
160 
161 };
162 
170 class AV_EXPORT AVPlayerDevice
171  : public AVAudioDevice
172  , public AVSupportAudioPreview {
173  public:
174 
175 };
176 
185 class AV_EXPORT AVAccompanyDevice
186  : public AVAudioDevice
187  , public AVSupportAudioPreview {
188  public:
194  enum SourceType {
195  AV_ACCOMPANY_SOURCE_TYPE_NONE = 0,
196  AV_ACCOMPANY_SOURCE_TYPE_SYSTEM = 1,
197  ACCOMPANY_SOURCE_TYPE_PROCESS = 2,
198  };
199 
200  public:
215  virtual void SetSource(std::string player_path, std::string media_file_path, SourceType source_type) = 0;
216 
222  virtual SourceType GetSourceType() = 0;
223 
229  virtual std::string GetPlayerPath() = 0;
230 
236  virtual std::string GetMediaFilePath() = 0;
237 };
238 
254 class AV_EXPORT AVMixDevice
255  : public AVAudioDevice
256  , public AVSupportAudioPreview {
257  public:
265  virtual bool AddDevice(std::string device_id) = 0;
266 
274  virtual bool RemoveDevice(std::string device_id) = 0;
275 
281  virtual int32 GetDeviceCount() = 0;
282 
288  virtual std::vector<std::string> GetDeviceIdList() = 0;
289 
290 };
291 
292 // mix input device.
293 // mix input device has a type of 'DEVICE_MIX_INPUT'.
294 class AV_EXPORT AVMixInputDevice : public AVMixDevice {
295 
296 };
297 
298 // mix output device.
299 // mix output device has a type of 'DEVICE_MIX_OUTPUT'.
300 class AV_EXPORT AVMixOutputDevice : public AVMixDevice {
301 
302 };
303 
305 //
306 // 视频设备相关的由此开始
307 
316 class AV_EXPORT AVVideoDevice : public AVDevice {
317  public:
318  typedef void(*FrameDataCallback)(VideoFrame* video_frame, void* custom_data);
319 
320  virtual void SetFrameDataCallback(FrameDataCallback frame_callback, void* custom_data = NULL) = 0;
321 
322  virtual FrameDataCallback GetFrameDataCallback() = 0;
323 
324  virtual void* GetFrameCustomData() = 0;
325 };
326 
337 class AV_EXPORT AVSupportVideoPreview {
338  public:
339  struct PreviewParam {
340  std::string device_id;
341  uint32 width;
342  uint32 height;
345  };
346 
355  typedef void(*PreviewCallback)(VideoFrame* video_frame, void* custom_data);
356 
365  virtual void SetPreviewCallback(PreviewCallback frame_callback, void* custom_data = NULL) = 0;
366 
378  virtual int SetPreviewParam(std::string id, uint32 width, uint32 height, ColorFormat color_format) = 0;
379 
380  virtual PreviewCallback GetPreviewCallback() = 0;
381 
382  virtual void* GetPreviewCustomData() = 0;
383 };
384 
391 class AV_EXPORT AVSupportVideoPreTreatment {
392  public:
393  typedef void(*PreTreatmentFun)(VideoFrame* video_frame, void* custom_data);
394 
403  virtual void SetPreTreatmentFun(PreTreatmentFun pre_fun, void* custom_data = NULL) = 0;
404 };
405 
413 class AV_EXPORT AVRemoteVideoDevice
414  : public AVVideoDevice
415  , public AVSupportVideoPreview {
416  public:
418  struct Delegate {
419  virtual ~Delegate() {}
420 
429  virtual void OnRenderFrame(const std::string& identifier, void* custom_data) = 0;
430  };
431 
432  virtual void SetDelegate(Delegate* delegate, void* custom_data = NULL) = 0;
433 };
434 
442 class AV_EXPORT AVCameraDevice
443  : public AVVideoDevice
444  , public AVSupportVideoPreview
445  , public AVSupportVideoPreTreatment {
446  public:
447 
448 #ifdef OS_IOS
449 
460  virtual void* GetPreviewLayer() = 0;
461 
469  virtual void* GetCameraSession() = 0;
470 #endif
471 };
472 
480 class AV_EXPORT AVExternalCapture
481  : public AVCameraDevice {
482  public:
483 
484 #if defined(TARGET_OS_IPHONE)
485  virtual void* GetPreviewLayer() = 0;
486 
487 #endif
488  virtual int OnCaptureFrame(VideoFrame &frame) = 0;
489 };
490 
491 } // namespace av
492 } // namespace tencent
493 
494 #endif // #ifndef AV_DEVICE_H_
Definition: av_audio_ctrl.h:6
远端视频设备的封装类。
Definition: av_device.h:413
视频预览能力的封装类。
Definition: av_device.h:337
VideoSrcType
视频源类型。
Definition: av_common.h:122
Definition: av_device.h:294
virtual ~Delegate()
Definition: av_device.h:419
视频设备封装类的基类。
Definition: av_device.h:316
远程视频设备委托的抽象基类,App需要实现其成员函数来监听远程视频设备的事件。
Definition: av_device.h:418
Definition: av_device.h:300
视频预处理能力的封装类。
Definition: av_device.h:391
ColorFormat
色彩格式。
Definition: av_common.h:106
音频帧。
Definition: av_common.h:89
远端音频设备的封装类。
Definition: av_device.h:142
视频帧。
Definition: av_common.h:157
uint32 height
Definition: av_device.h:342
SourceType
伴奏源类型。
Definition: av_device.h:194
ColorFormat color_format
Definition: av_device.h:343
uint32 width
Definition: av_device.h:341
伴奏设备。
Definition: av_device.h:185
音频设备封装类的基类。
Definition: av_device.h:53
VideoSrcType src_type
Definition: av_device.h:344
音视频设备封装类的基类。
Definition: av_device_base.h:18
外部视频捕获设备。
Definition: av_device.h:480
std::string device_id
Definition: av_device.h:340
摄像头的封装类。
Definition: av_device.h:442
软件混音器。
Definition: av_device.h:254
音频预览能力的封装类。
Definition: av_device.h:108
麦克风的封装类。
Definition: av_device.h:156
音频播放设备的封装类。
Definition: av_device.h:170