ZegoPlayRecorder
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
LiveRoom.h
Go to the documentation of this file.
1 //
2 // LiveRoom.h
3 // zegoliveroom
4 //
5 // Copyright © 2017年 Zego. All rights reserved.
6 //
7 
8 #ifndef LiveRoom_h
9 #define LiveRoom_h
10 
11 #ifndef ZEGO_API
12 #ifdef WIN32
13 #ifdef ZEGO_EXPORTS
14 #define ZEGO_API __declspec(dllexport)
15 #else
16 #define ZEGO_API __declspec(dllimport)
17 #endif
18 #else
19 #define ZEGO_API __attribute__((visibility("default")))
20 #endif
21 #endif // !ZEGO_API
22 
23 
24 #define ZEGO_MAX_COMMON_LEN (512)
25 #define ZEGO_MAX_USERID_LEN (64)
26 #define ZEGO_MAX_USERNAME_LEN (256)
27 
28 namespace ZEGO
29 {
30  namespace LIVEROOM
31  {
34  {
36  {
37  szUserId[0] = '\0';
38  szUserName[0] = '\0';
39  szStreamId[0] = '\0';
40  szExtraInfo[0] = '\0';
42  }
43 
48  unsigned long uStreamCreateTime;
49  };
50 
53  {
54  StreamAdded = 2001,
55  StreamDeleted = 2002,
56  };
57 
60  {
64  };
65 
68  {
71  };
72 
74  {
78  };
79 
81  {
84  };
85 
87  {
91  };
92 
94  {
96  unsigned int recordDuration;
97  unsigned int fileSize;
98  };
99 
101  {
102  bool videoAndAudioSeperate = false;
106  int externalVideoBitrate = 600000;
107  };
108 
113  {
114  const char *info = nullptr;
115  int xPosition = -1;
116  int yPosition = -1;
117  int nWidth = 0;
118  int nHeight = 0;
119  int fontColor = 0xFFFFFF00;
120  int backgroundColor = 0x3F3F3FFF;
121  };
122 
125  {
127  struct
128  {
129  int top;
130  int left;
131  int bottom;
132  int right;
133  } layout;
134  int layer;
135 
140  int frameFillColor = 0x00000000;
142  {
143  szStreamID[0] = '\0';
144  }
155  };
156 
159  {
164  };
165 
168  {
170  int width = 0;
171  int height = 0;
172  };
173 
175  {
178  };
179 
182  {
183  const char *imagePath = nullptr;
184  int xPosition = -1;
185  int yPosition = -1;
186  int nWidth = 0;
187  int nHeight = 0;
189  };
190 
191  struct AudioFrame
192  {
194  {
195  frameType = 0;
196  samples = 0;
197  bytesPerSample = 0;
198  channels = 0;
199  sampleRate = 0;
200  timeStamp = 0.0;
201  configLen = 0;
202  bufLen = 0;
203  buffer = 0;
204  }
205 
206  int frameType; //refer to enum FrameType
207  int samples; //PCM:capture pcm samples at this input. AAC:aac encode one frame need samples
208  int bytesPerSample; //bytes per sample = 2 * channels, current bit depth only support 16bit(2 bytes).
209  int channels; //channels, 1 or 2.
210  int sampleRate; //PCM: capture sample rate; AAC: encode sample rate. supported [16k/32k/44.1k/48k]
211  double timeStamp; //time stamp, PCM: 0; AAC: 0 or encode timeStamp, if buffer data only contain special config fill 0.
212  int configLen; //aac special config Len, PCM: 0; AAC: range [0-64]. 0 indicate this frame not contain spcial config.
213  int bufLen; /*buffer Length, PCM bufLen = 2 * samples * channels(only need correct fill samples and channels,
214  not use filed bufLen). AAC encode data len = bufLen - configLen.*/
215  unsigned char* buffer; //data buffer, the caller is responsible for bufer allocate and release
216  };
217 
220  {
244  : bGenerateMp3(false)
246  , nFragmentSeconds(2)
247  , nOutputFps(0)
248  , nOutputBitrate(0)
249  , nOutputWidth(0)
250  , nOutputHeight(0)
251  , nOutputAudioBitrate(80*1000)
252  , pInputStream(0)
253  , nInputStreamCount(0)
254  , nOutputBackgroundColor(0x00000000)
256  , pTimestampConfig(nullptr)
257  , videoAudioSeperateFile(false)
259  , pImageWaterMark(nullptr)
260  {
261  szPathAndName[0] = '\0';
262  }
263  };
264 
267  {
285  };
286 
289  {
292  };
293 
295  {
302  };
303 
305  {
306  public:
307  virtual int OnIncomingVideoData(const unsigned char *pData[4],
308  int dataLen[4],
309  int width,
310  int height,
311  int strides[4],
312  VideoPixelFormat format,
313  unsigned long long referenceTime,
314  unsigned int referenceTimeScale) = 0;
315  };
316 
318  class ICallback
319  {
320  public:
326  virtual void OnInitSDK(int errorCode) {}
327 
334  virtual void OnLoginRoom(int errorCode, const char *pszRoomID) = 0;
335 
342  virtual void OnLogoutRoom(int errorCode, const char *pszRoomID) {}
343 
352  virtual void OnDisconnect(int errorCode, const char *pszRoomID) = 0;
353 
363  virtual void OnStreamUpdate(ZegoStreamUpdateType type, ZegoStreamInfo *pStreamInfo, unsigned int streamCount, const char *pszRoomID) = 0;
364 
377  virtual void OnPlayQualityUpdate(const char* pszStreamID, int quality, double videoFPS, double videoKBPS) {};
378 
385  virtual void OnStreamRecordBegin(const char* pszStreamID, const char *pszPathAndName) = 0;
386 
394  virtual void OnStreamRecordEnd(const char* pszStreamID, const char *pszPathAndName, RecordEndReason reason) = 0;
395 
404  virtual void OnStreamRecordVideoSizeChanged(const char* pszStreamID, int width, int height) {};
405 
412  virtual void OnStreamRecordEvent(const char* pszStreamID, RecordEvent event) {};
413 
422  virtual void OnStreamRecordData(const char* pszStreamID, const char *data, int len) {};
423 
432  virtual void OnSeek(const char* pszStreamID, long long offset, int whence) {};
433 
446  virtual void OnVideoDataCallback(const unsigned char **pData, int* dataLen, const char* pszStreamID, int width, int height, int strides[4], VideoPixelFormat pixel_format) {}
447 
454  virtual void OnAudioDataCallback(const char* pszStreamID, const AudioFrame &frame) {};
455 
463  virtual void OnMixStreamRecordUpdate(const char** ppszStreamID, int nStreamCount) = 0;
464 
476  virtual void OnRecordFilePath(const char *pszStreamID, const char *filePath, MuxerStreamType muxerType, unsigned int startTimeStamp, unsigned int stopTimeStamp) {};
477 
484  virtual void OnExternalVideoDataSource(const char *pszStreamID, IExternalVideoDataSource *source) {};
485 
486  virtual ~ICallback() {}
487  };
488 
490  {
491  public:
499  virtual void OnRecvMediaSideInfo(const char * pszStreamID, const unsigned char *buf, int dataLen) = 0;
500 
501  virtual ~IMediaSideCallback() {}
502  };
503 
509  ZEGO_API const char* GetSDKVersion();
510 
520  ZEGO_API bool SetLogDirAndSize(const char* pszLogDir, unsigned long long lLogFileSize = 5 * 1024 * 1024);
521 
525  ZEGO_API void UploadLog();
526 
532  ZEGO_API void SetUseTestEnv(bool bTestEnv);
533 
543  ZEGO_API void SetConfig(const char *config);
544 
554  ZEGO_API bool InitSDK(unsigned int uiAppID, unsigned char* pBufAppSignature, int nSignatureSize);
555 
561  ZEGO_API bool UnInitSDK();
562 
569  ZEGO_API bool SetCallback(ICallback* pCB);
570 
578  ZEGO_API bool LoginRoom(const char* pszRoomID);
579 
580 
591  ZEGO_API bool SetUser(const char* pszUserID, const char* pszUserName);
592 
600  ZEGO_API void SetCustomToken(const char *thirdPartyToken);
601 
608  ZEGO_API bool LogoutRoom();
609 
616 
624 
631  ZEGO_API void SetMuxerCacheSize(int size);
632 
639  ZEGO_API void EnableSingleAndMixRecordMode(bool enable);
640 
647  ZEGO_API void EnableExternalRender(bool bEnable);
648 
655  ZEGO_API bool SetFontFile(const char *pszPathAndName);
656 
665  ZEGO_API void EnableExternalAudioData(bool bEnable, int sampleRate, int channels);
666 
680  ZEGO_API bool StartRecordSingleStream(const char* pszStreamID, const char *pszPathAndName, MuxerStreamType nMuxerStreamType = MuxerStreamTypeBoth, int nFragmentSeconds = 2, ZegoRecordSingleStreamConfig *config = nullptr);
681 
688  ZEGO_API bool StopRecordSingleStream(const char* pszStreamID);
689 
698  ZEGO_API bool StartRecordMixStream(ZegoMixStreamRecordConfig* pConfig);
699 
708  ZEGO_API bool UpdateInputStreamConfig(ZegoStreamConfig* pInputStream, int nInputStreamCount);
709 
717  ZEGO_API bool UpdateImageWaterMarkConfig(ZegoImageWaterMarkConfig* pConfig);
718 
725 
735  ZEGO_API bool GetRecordStatus(const char* streamID, ZegoRecordStatus& status);
736 
745  ZEGO_API unsigned int GetRecordLastMediaSideTime(const char* streamID);
746 
753  ZEGO_API bool SetMediaSideCallback(IMediaSideCallback *pCB);
754 
755  }
756 }
757 
758 #endif /* LiveRoom.h */
ZegoVideoStreamLayerType streamLayerType
Definition: LiveRoom.h:104
virtual void OnRecordFilePath(const char *pszStreamID, const char *filePath, MuxerStreamType muxerType, unsigned int startTimeStamp, unsigned int stopTimeStamp)
Definition: LiveRoom.h:476
bool videoAudioSeperateFile
Definition: LiveRoom.h:238
Definition: LiveRoom.h:89
int nOutputFps
Definition: LiveRoom.h:226
Definition: LiveRoom.h:54
Definition: LiveRoom.h:93
int channels
Definition: LiveRoom.h:209
#define ZEGO_MAX_USERNAME_LEN
Definition: LiveRoom.h:26
const char * info
Definition: LiveRoom.h:114
ZEGO_API void EnableSingleAndMixRecordMode(bool enable)
bool videoAndAudioSeperate
Definition: LiveRoom.h:102
RecordEndReason
Definition: LiveRoom.h:266
int externalVideoBitrate
Definition: LiveRoom.h:106
int nFragmentSeconds
Definition: LiveRoom.h:225
unsigned long uStreamCreateTime
Definition: LiveRoom.h:48
ZEGO_API bool LoginRoom(const char *pszRoomID)
virtual void OnStreamRecordBegin(const char *pszStreamID, const char *pszPathAndName)=0
int right
Definition: LiveRoom.h:132
ZegoFillMode fillMode
Definition: LiveRoom.h:138
ZEGO_API bool LogoutRoom()
virtual void OnStreamUpdate(ZegoStreamUpdateType type, ZegoStreamInfo *pStreamInfo, unsigned int streamCount, const char *pszRoomID)=0
int nOutputHeight
Definition: LiveRoom.h:229
int samples
Definition: LiveRoom.h:207
Definition: LiveRoom.h:167
int nOutputBackgroundColor
Definition: LiveRoom.h:235
ZegoImageWaterMarkConfig * pImageWaterMark
Definition: LiveRoom.h:241
const char * pOutputBackgroundImage
Definition: LiveRoom.h:236
ZEGO_API bool UpdateInputStreamConfig(ZegoStreamConfig *pInputStream, int nInputStreamCount)
unsigned char * buffer
Definition: LiveRoom.h:215
int left
Definition: LiveRoom.h:130
int nHeight
Definition: LiveRoom.h:187
char szExtraInfo[ZEGO_MAX_COMMON_LEN]
Definition: LiveRoom.h:47
int nInputStreamCount
Definition: LiveRoom.h:233
ZegoMixStreamRecordConfig()
Definition: LiveRoom.h:243
char szUserId[ZEGO_MAX_USERID_LEN]
Definition: LiveRoom.h:44
ZEGO_API bool GetRecordStatus(const char *streamID, ZegoRecordStatus &status)
ZegoImageWaterMarkFillMode fillMode
Definition: LiveRoom.h:188
int nWidth
Definition: LiveRoom.h:186
unsigned int recordDuration
Definition: LiveRoom.h:96
RecordEvent
Definition: LiveRoom.h:288
ZegoImageWaterMarkFillMode
Definition: LiveRoom.h:174
virtual void OnStreamRecordEnd(const char *pszStreamID, const char *pszPathAndName, RecordEndReason reason)=0
virtual void OnDisconnect(int errorCode, const char *pszRoomID)=0
ZEGO_API void SetMuxerCacheSize(int size)
ZEGO_API bool StopRecordSingleStream(const char *pszStreamID)
ZegoStreamConfig()
Definition: LiveRoom.h:141
ZEGO_API void UploadLog()
int nOutputWidth
Definition: LiveRoom.h:228
virtual void OnInitSDK(int errorCode)
Definition: LiveRoom.h:326
Definition: LiveRoom.h:290
int bufLen
Definition: LiveRoom.h:213
virtual void OnStreamRecordData(const char *pszStreamID, const char *data, int len)
Definition: LiveRoom.h:422
MuxerStreamType nMuxerStreamType
Definition: LiveRoom.h:224
Definition: LiveRoom.h:61
Definition: LiveRoom.h:298
int nHeight
Definition: LiveRoom.h:118
#define ZEGO_MAX_COMMON_LEN
Definition: LiveRoom.h:24
virtual void OnStreamRecordEvent(const char *pszStreamID, RecordEvent event)
Definition: LiveRoom.h:412
Definition: LiveRoom.h:318
char szStreamID[ZEGO_MAX_COMMON_LEN]
Definition: LiveRoom.h:126
ZegoFillMode
Definition: LiveRoom.h:80
ZEGO_API bool SetLogDirAndSize(const char *pszLogDir, unsigned long long lLogFileSize=5 *1024 *1024)
ZegoFrameFillMode frameFillMode
Definition: LiveRoom.h:139
virtual void OnRecvMediaSideInfo(const char *pszStreamID, const unsigned char *buf, int dataLen)=0
int frameFillColor
Definition: LiveRoom.h:140
ZegoTimestampConfig * pTimestampConfig
Definition: LiveRoom.h:237
double timeStamp
Definition: LiveRoom.h:211
int height
Definition: LiveRoom.h:171
bool isExternalVideoDataSource
Definition: LiveRoom.h:137
Definition: LiveRoom.h:299
Definition: LiveRoom.h:112
Definition: LiveRoom.h:163
int nOutputAudioBitrate
Definition: LiveRoom.h:230
Definition: LiveRoom.h:191
ZEGO_API bool StopRecordMixStream()
ZegoStreamUpdateType
Definition: LiveRoom.h:52
Definition: LiveRoom.h:301
ZEGO_API bool SetCallback(ICallback *pCB)
ZegoStreamConfig * pInputStream
Definition: LiveRoom.h:232
ZegoStreamInfo()
Definition: LiveRoom.h:35
char filePath[ZEGO_MAX_COMMON_LEN]
Definition: LiveRoom.h:95
virtual ~ICallback()
Definition: LiveRoom.h:486
ZEGO_API void SetUseTestEnv(bool bTestEnv)
virtual void OnLogoutRoom(int errorCode, const char *pszRoomID)
Definition: LiveRoom.h:342
#define ZEGO_MAX_USERID_LEN
Definition: LiveRoom.h:25
Definition: LiveRoom.h:489
const char * imagePath
Definition: LiveRoom.h:183
virtual ~IMediaSideCallback()
Definition: LiveRoom.h:501
Definition: LiveRoom.h:177
virtual void OnSeek(const char *pszStreamID, long long offset, int whence)
Definition: LiveRoom.h:432
ZEGO_API unsigned int GetRecordLastMediaSideTime(const char *streamID)
ZEGO_API void SetMuxerOutType(MuxerOutType type)
Definition: LiveRoom.h:90
int yPosition
Definition: LiveRoom.h:185
ZEGO_API int GetMaxRecordCount()
char szPathAndName[ZEGO_MAX_COMMON_LEN]
Definition: LiveRoom.h:221
virtual void OnMixStreamRecordUpdate(const char **ppszStreamID, int nStreamCount)=0
ZEGO_API bool SetFontFile(const char *pszPathAndName)
struct ZEGO::LIVEROOM::ZegoStreamConfig::@0 layout
virtual void OnPlayQualityUpdate(const char *pszStreamID, int quality, double videoFPS, double videoKBPS)
Definition: LiveRoom.h:377
int bottom
Definition: LiveRoom.h:131
ZEGO_API bool StartRecordSingleStream(const char *pszStreamID, const char *pszPathAndName, MuxerStreamType nMuxerStreamType=MuxerStreamTypeBoth, int nFragmentSeconds=2, ZegoRecordSingleStreamConfig *config=nullptr)
ZegoTimestampPosition position
Definition: LiveRoom.h:169
int xPosition
Definition: LiveRoom.h:184
virtual void OnStreamRecordVideoSizeChanged(const char *pszStreamID, int width, int height)
Definition: LiveRoom.h:404
int xPosition
Definition: LiveRoom.h:115
Definition: LiveRoom.h:63
ZEGO_API bool InitSDK(unsigned int uiAppID, unsigned char *pBufAppSignature, int nSignatureSize)
virtual void OnLoginRoom(int errorCode, const char *pszRoomID)=0
ZegoVideoStreamLayerType
Definition: LiveRoom.h:73
Definition: LiveRoom.h:55
Definition: LiveRoom.h:160
int nOutputBitrate
Definition: LiveRoom.h:227
char szStreamId[ZEGO_MAX_COMMON_LEN]
Definition: LiveRoom.h:46
bool isExternalVideoDataSource
Definition: LiveRoom.h:105
ZEGO_API const char * GetSDKVersion()
Definition: LiveRoom.h:62
VideoPixelFormat
Definition: LiveRoom.h:294
virtual int OnIncomingVideoData(const unsigned char *pData[4], int dataLen[4], int width, int height, int strides[4], VideoPixelFormat format, unsigned long long referenceTime, unsigned int referenceTimeScale)=0
int yPosition
Definition: LiveRoom.h:116
int configLen
Definition: LiveRoom.h:212
virtual void OnVideoDataCallback(const unsigned char **pData, int *dataLen, const char *pszStreamID, int width, int height, int strides[4], VideoPixelFormat pixel_format)
Definition: LiveRoom.h:446
int width
Definition: LiveRoom.h:170
Definition: LiveRoom.h:300
Definition: LiveRoom.h:275
int fontColor
Definition: LiveRoom.h:119
AudioFrame()
Definition: LiveRoom.h:193
bool bGenerateMp3
Definition: LiveRoom.h:223
ZEGO_API bool UnInitSDK()
ZEGO_API bool StartRecordMixStream(ZegoMixStreamRecordConfig *pConfig)
ZegoWaterMarkConfig waterMark
Definition: LiveRoom.h:136
Definition: LiveRoom.h:88
int backgroundColor
Definition: LiveRoom.h:120
int bytesPerSample
Definition: LiveRoom.h:208
ZEGO_API void EnableExternalAudioData(bool bEnable, int sampleRate, int channels)
Definition: LiveRoom.h:161
Definition: LiveRoom.h:124
MuxerOutType
Definition: LiveRoom.h:67
int frameType
Definition: LiveRoom.h:206
virtual void OnExternalVideoDataSource(const char *pszStreamID, IExternalVideoDataSource *source)
Definition: LiveRoom.h:484
int nWidth
Definition: LiveRoom.h:117
Definition: LiveRoom.h:277
Definition: LiveRoom.h:291
char szUserName[ZEGO_MAX_USERNAME_LEN]
Definition: LiveRoom.h:45
ZEGO_API bool SetUser(const char *pszUserID, const char *pszUserName)
Definition: LiveRoom.h:276
ZEGO_API bool UpdateImageWaterMarkConfig(ZegoImageWaterMarkConfig *pConfig)
ZegoTimestampPosition
Definition: LiveRoom.h:158
int top
Definition: LiveRoom.h:129
ZEGO_API void EnableExternalRender(bool bEnable)
int layer
Definition: LiveRoom.h:134
unsigned int fileSize
Definition: LiveRoom.h:97
ZEGO_API bool SetMediaSideCallback(IMediaSideCallback *pCB)
Definition: LiveRoom.h:33
ZegoVideoStreamLayerType streamLayerType
Definition: LiveRoom.h:239
#define ZEGO_API
Definition: LiveRoom.h:16
virtual void OnAudioDataCallback(const char *pszStreamID, const AudioFrame &frame)
Definition: LiveRoom.h:454
Definition: LiveRoom.h:297
ZEGO_API void SetCustomToken(const char *thirdPartyToken)
ZegoFrameFillMode
Definition: LiveRoom.h:86
int sampleRate
Definition: LiveRoom.h:210
Definition: LiveRoom.h:296
MuxerStreamType
Definition: LiveRoom.h:59
Definition: LiveRoom.h:176
ZEGO_API void SetConfig(const char *config)
Definition: LiveRoom.h:82