C++SDK  1.0.0
mstreamexporter.h
浏览该文件的文档.
1 #ifndef AVD_Module_Exporter_H__
2 #define AVD_Module_Exporter_H__
3 
4 #include "common.h"
5 #include "videorender.h"
6 #include "room.h"
7 #include <functional>
8 
10 
12 public:
13  virtual Result addMetaData(const String& mtag, const String& value) = 0;
14 
15  virtual Result setScaleType(IVideoRenderView::ScalingType scale) = 0;
16 
17  virtual Result setAutoLayout(bool useAuto) = 0;
18 
19  virtual Result addSubVideo(const DeviceId& vId, int zorder, float x, float y, float w, float h) = 0;
20 
21  virtual Result modSubVideo(const DeviceId& vId, int zorder, float x, float y, float w, float h) = 0;
22 
23  virtual bool rmvSubVideo(const DeviceId& vId) = 0;
24 
25  virtual void clearSubVideos() = 0;
26 protected:
27  virtual ~IVideoMixer() {}
28 };
29 
35 struct ExporterInfo {
52 public:
53  ExporterInfo() : size(0), status(rs_created){}
54  bool isValid() const { return !id.empty(); }
55 };
57 const String toString(const ExporterInfo& obj);
58 typedef std::vector<ExporterInfo> ExporterInfosType;
59 
60 
61 class RT_API_EXPORT IMStreamExporter : public IModule {
62 public:
64  public:
65  virtual void videoStreamOut(const String& eId, uint64 timestamp_ns, tee3::avd::VideoCodec c, unsigned int w, unsigned int h, bool isKeyFrame, const uint8 *data, unsigned int len) = 0;
66 
67  virtual void audioStreamOut(const String& eId, uint64 timestamp_ns, tee3::avd::AudioCodec c, int sampleRate, int channels, const uint8 *data, unsigned int len) = 0;
68  protected:
69  virtual ~StreamOut() {}
70  };
71 
72  static IMStreamExporter* getExporter(IRoom* room);
73  //
74  typedef std::function<void(const String& eId, Result error, const String& msg)> Cb_OnError;
75  virtual void setCb4OnError(Cb_OnError cb) = 0;
76  //
77  struct ViewInfo {
78  uint32 mixWidth; //混流输出视频分辨率宽
79  uint32 mixHeight; //混流输出视频分辨率高
80  uint32 backgroundColor; //如:"#C0C0C0" RGB
81  uint32 outBitrate; //混流输出码率
82  uint32 outFps; //混流输出帧率
83  ViewInfo() :mixWidth(0), mixHeight(0), backgroundColor(0), outBitrate(0), outFps(0){}
84  ViewInfo(uint32 aw, uint32 ah, uint32 outbt) :mixWidth(aw), mixHeight(ah), backgroundColor(0), outBitrate(outbt), outFps(15){}
85  };
86  virtual Result createLocalRecorder(String& eId, const String& filePath, const ViewInfo& view) = 0;
87 
88  virtual Result createLocalRealtimeRecorder(String& eId, const String& filePath, const ViewInfo& view) = 0;
89 
90  virtual Result createLocalRealtimeRecorder(String& eId, StreamOut* out, const ViewInfo& view) = 0;
91 
92  virtual Result createLocalLivecast(String& eId, const String& pushUrl, const ViewInfo& view) = 0;
93  //
94  typedef std::function<void(Result result, const ExporterInfo& info)> Cb_CreateResult;
95  virtual Result createServerRecorder(String& eId, const String& filePath, const ViewInfo& view, Cb_CreateResult cb) = 0;
96 
97  virtual Result createServerRealtimeRecorder(String& eId, const String& filePath, const ViewInfo& view, Cb_CreateResult cb) = 0;
98 
99  virtual Result createServerLivecast(String& eId, const String& pushUrl, const String& name, const ViewInfo& view, Cb_CreateResult cb) = 0;
100  //
101  virtual Result updateExporterInfo(const String& eId, const String& appdata) = 0;
102 
103  //
104  virtual Result selectAudio4Exporter(const String& eId, const UserId& audioUserId) = 0;
105  virtual Result selectSingleVideo4Exporter(const String& eId, const DeviceId& singleVideo) = 0;
106  struct VideoInfo {
107  DeviceId id; //摄像头Id,唯一标示一路共享的摄像头视频。
108  float x, y; //此视频在左上角左边位置(上边位置),即x坐标,取值0.0~1.0,内部取值为:width * X(height * Y)
109  float width, height; //此视频宽度(高度)比例,取值0.0~1.0,内部取值为:width * W(height * H)
110  uint16 zorder; //多个视频覆盖时,前后位置,zorder越小,视频越在下层,会被覆盖;取值0-10
111  uint16 alpha; //(暂不使用)透明度
112  IVideoRenderView::ScalingType render; //(暂不使用)视频渲染到混流视频上的渲染模式
113 
115  : x(0.0f), y(0.0f), width(0.0f), height(0.0f), zorder(0), alpha(0), render(IVideoRenderView::Scale_Aspect_Fit) {}
116  VideoInfo(const DeviceId& aId, float ax, float ay, float aw, float ah, uint16 az)
117  : id(aId), x(ax), y(ay), width(aw), height(ah), zorder(az), alpha(0), render(IVideoRenderView::Scale_Aspect_Fit) {}
118  bool update(float ax, float ay, float aw, float ah, uint16 az) {
119  if (infosEqual(VideoInfo(id, ax, ay, aw, ah, az))) {
120  return false;
121  }
122  x = ax; y = ay; width = aw; height = ah;
123  zorder = az;
124  return true;
125  }
126  bool infosEqual(const VideoInfo& r) const {
127  if (r.x == x && r.y == y && r.width == width && r.height == height && r.zorder == zorder) {
128  return true;
129  }
130  else {
131  return false;
132  }
133  }
134  bool isValid() const {
135  return !id.empty();
136  }
137  };
138  typedef std::vector<VideoInfo> VideosType;
139  virtual Result selectMixedVideos4Exporter(const String& eId, const VideosType& mixedVideos) = 0;
140  virtual IVideoMixer* getVideoMixer(const String& eId) = 0;
141 
142  //
143  virtual Result pauseResume(const String& eId, bool isResume) = 0;
144 
145  virtual Result stopExporter(const String& eId) = 0;
146 
147  virtual Result stopExporterAll() = 0;
148 
149  //
150  virtual Result getExporterInfo(const String& eId) = 0;
151 
152  virtual Result findExporterInfos(uint32& callId, uint32 begindex, uint32 ncount, const String& filter) = 0;
153 
154  virtual Result deleteExporter(const String& eId) = 0;
155 
156  virtual void* getCurExportItem(String eId) = 0;
157 protected:
158  virtual ~IMStreamExporter() {}
159 };
160 
164 
166 
167 #endif//AVD_Module_Exporter_H__
uint32 mixHeight
Definition: mstreamexporter.h:79
unsigned short uint16
Definition: defines.h:395
float height
Definition: mstreamexporter.h:109
NAMESPACE_TEE3_BEGIN typedef std::string String
Definition: common.h:10
float width
Definition: mstreamexporter.h:109
virtual ~StreamOut()
Definition: mstreamexporter.h:69
RecordStatus
Definition: combase.h:497
RoomId roomId
Definition: mstreamexporter.h:37
String UserId
Definition: common.h:13
#define NAMESPACE_TEE3_AVD_END
Definition: combase.h:121
uint16 alpha
Definition: mstreamexporter.h:111
virtual ~IVideoMixer()
Definition: mstreamexporter.h:27
int Result
Definition: combase.h:13
Definition: mstreamexporter.h:63
RecordId id
Definition: mstreamexporter.h:36
bool isValid() const
Definition: mstreamexporter.h:54
float y
Definition: mstreamexporter.h:108
String DeviceId
Definition: common.h:12
bool update(float ax, float ay, float aw, float ah, uint16 az)
Definition: mstreamexporter.h:118
#define RT_API_EXPORT
Definition: defines.h:188
std::function< void(Result result, const ExporterInfo &info)> Cb_CreateResult
Definition: mstreamexporter.h:94
VideoInfo(const DeviceId &aId, float ax, float ay, float aw, float ah, uint16 az)
Definition: mstreamexporter.h:116
uint32 backgroundColor
Definition: mstreamexporter.h:80
unsigned int uint32
Definition: defines.h:393
VideoCodec
Definition: combase.h:174
UserId creatorId
Definition: mstreamexporter.h:38
#define NAMESPACE_TEE3_AVD_BEGIN
Definition: combase.h:120
ExporterInfo * LPExporterInfo
Definition: mstreamexporter.h:56
const String toString(const ExporterInfo &obj)
Definition: mstreamexporter.h:77
unsigned long long uint64
Definition: defines.h:382
Definition: combase.h:498
std::vector< VideoInfo > VideosType
Definition: mstreamexporter.h:138
uint32 outFps
Definition: mstreamexporter.h:82
virtual ~IMStreamExporter()
Definition: mstreamexporter.h:158
Definition: mstreamexporter.h:11
ViewInfo()
Definition: mstreamexporter.h:83
String playurls
Definition: mstreamexporter.h:49
String createTime
Definition: mstreamexporter.h:41
String RoomId
Definition: common.h:11
float x
Definition: mstreamexporter.h:108
DeviceId RecordId
Definition: common.h:15
ViewInfo(uint32 aw, uint32 ah, uint32 outbt)
Definition: mstreamexporter.h:84
bool isValid() const
Definition: mstreamexporter.h:134
Definition: mstreamexporter.h:61
String desturl
Definition: mstreamexporter.h:46
ExporterInfo()
Definition: mstreamexporter.h:53
unsigned char uint8
Definition: defines.h:397
uint32 outBitrate
Definition: mstreamexporter.h:81
uint64 size
Definition: mstreamexporter.h:43
std::vector< ExporterInfo > ExporterInfosType
Definition: mstreamexporter.h:58
String name
Definition: mstreamexporter.h:39
std::function< void(const String &eId, Result error, const String &msg)> Cb_OnError
Definition: mstreamexporter.h:74
bool infosEqual(const VideoInfo &r) const
Definition: mstreamexporter.h:126
AudioCodec
Definition: combase.h:684
IVideoRenderView::ScalingType render
Definition: mstreamexporter.h:112
DeviceId id
Definition: mstreamexporter.h:107
Definition: mstreamexporter.h:106
uint32 mixWidth
Definition: mstreamexporter.h:78
Definition: mstreamexporter.h:35
VideoInfo()
Definition: mstreamexporter.h:114
String appdata
Definition: mstreamexporter.h:40
RecordStatus status
Definition: mstreamexporter.h:42
uint16 zorder
Definition: mstreamexporter.h:110