智慧保安APP验收版本
shuishen
2021-12-02 56ee0734fc0cbca40f992823a636ec8feebd1f80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
//
//  anyrtc Engine SDK
//
//  Created by Sting Feng in 2017-11.
//  Copyright (c) 2017 anyrtc.io. All rights reserved.
 
#ifndef __AR_MEDIA_BASE_H__  // NOLINT(build/header_guard)
#define __AR_MEDIA_BASE_H__
 
#include <stdint.h>
#include <stddef.h>
 
namespace ar {
namespace media {
namespace base {
 
typedef void* view_t;
 
typedef const char* user_id_t;
 
 
/** The video pixel format.
 */
enum VIDEO_PIXEL_FORMAT {
  /** 0: The video pixel format is unknown.
   */
  VIDEO_PIXEL_UNKNOWN = 0,
  /** 1: The video pixel format is I420.
   */
  VIDEO_PIXEL_I420 = 1,
  /** 2: The video pixel format is BGRA.
   */
  VIDEO_PIXEL_BGRA = 2,
  /** 3: Planar YUV 4:2:2 format.
   */
  VIDEO_PIXEL_I422 = 3,
  /** 2: The video pixel format is RGBA.
   */
  VIDEO_PIXEL_RGBA = 4,
  /** 8: The video pixel format is NV12.
   */
  VIDEO_PIXEL_NV12 = 8,
};
 
/** 
 * The video display mode. 
 */
enum RENDER_MODE_TYPE {
  /**
   * 1: Uniformly scale the video until it fills the visible boundaries
   * (cropped). One dimension of the video may have clipped contents.
   */
  RENDER_MODE_HIDDEN = 1,
  /**
   * 2: Uniformly scale the video until one of its dimension fits the boundary
   * (zoomed to fit). Areas that are not filled due to the disparity in the
   * aspect ratio will be filled with black.
   */
  RENDER_MODE_FIT = 2,
  /**
   * @deprecated
   * 3: This mode is deprecated.
   */
  RENDER_MODE_ADAPTIVE = 3,
};
 
/** Definition of VideoFrame.
 
The video data format is in YUV420. The buffer provides a pointer to a pointer. However, the
interface cannot modify the pointer of the buffer, but can only modify the content of the buffer.
 
*/
struct VideoFrame {
  VIDEO_PIXEL_FORMAT type;
  /** Video pixel width.
   */
  int width;  // width of video frame
  /** Video pixel height.
   */
  int height;  // height of video frame
  /** Line span of Y buffer in YUV data.
   */
  int yStride;  // stride of Y data buffer
  /** Line span of U buffer in YUV data.
   */
  int uStride;  // stride of U data buffer
  /** Line span of V buffer in YUV data.
   */
  int vStride;  // stride of V data buffer
  /** Pointer to the Y buffer pointer in the YUV data.
   */
  uint8_t* yBuffer;  // Y data buffer
  /** Pointer to the U buffer pointer in the YUV data.
   */
  uint8_t* uBuffer;  // U data buffer
  /** Pointer to the V buffer pointer in the YUV data
   */
  uint8_t* vBuffer;  // V data buffer
  /** Set the rotation of this frame before rendering the video, and it supports 0, 90, 180, 270
   * degrees clockwise.
   */
  int rotation;  // rotation of this frame (0, 90, 180, 270)
  /** Timestamp to render the video stream. It instructs the users to use this timestamp to
  synchronize the video stream render while rendering the video streams.
 
  Note: This timestamp is for rendering the video stream, not for capturing the video stream.
  */
  int64_t renderTimeMs;
  int avsync_type;
};
 
/**
 * The struct of AudioPcmFrame.
 */
struct AudioPcmFrame {
  /**
   * The buffer size of the PCM audio frame.
   */
  enum : size_t {
    // Stereo, 32 kHz, 60 ms (2 * 32 * 60)
    kMaxDataSizeSamples = 3840,
    kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t),
  };
 
  AudioPcmFrame() {}
 
  uint32_t capture_timestamp = 0;
  size_t samples_per_channel_ = 0;
  int sample_rate_hz_ = 0;
  size_t num_channels_ = 0;
  size_t bytes_per_sample = 0;
  int16_t data_[kMaxDataSizeSamples] = {0};
 
  AudioPcmFrame(const AudioPcmFrame& frame) = delete;
  void operator=(const AudioPcmFrame& frame) = delete;
};
 
class IVideoFrameObserver {
 public:
  virtual void onFrame(const VideoFrame* frame) = 0;
  virtual ~IVideoFrameObserver() {}
};
 
class IAudioFrameObserver {
 public:
  virtual void onFrame(const AudioPcmFrame* frame) = 0;
  virtual ~IAudioFrameObserver() {}
};
 
}  // namespace base
}  // namespace media
}  // namespace ar
 
namespace ar {
namespace media {
 
/**
 * @brief Player state
 *
 */
enum MEDIA_PLAYER_STATE {
  /** Default state
   */
  PLAYER_STATE_IDLE = 0,
  /** Opening media file
   */
  PLAYER_STATE_OPENING = 1,
  /** Media file opened successfully
   *
   */
  PLAYER_STATE_OPEN_COMPLETED = 2,
  /** Player playing
   */
  PLAYER_STATE_PLAYING = 3,
  /** Player paused
   */
  PLAYER_STATE_PAUSED = 4,
  /** Player playback complete
   */
  PLAYER_STATE_PLAYBACK_COMPLETED = 5,
  /** Player stopped
   */
  PLAYER_STATE_STOPPED = 6,
  /** Player failed
   */
  PLAYER_STATE_FAILED = 100,
};
 
/**
 * @brief Player error code
 *
 */
enum MEDIA_PLAYER_ERROR {
  /** No error
   */
  PLAYER_ERROR_NONE = 0,
  /** The parameter is incorrect
   */
  PLAYER_ERROR_INVALID_ARGUMENTS = -1,
  /** Internel error
   */
  PLAYER_ERROR_INTERNAL = -2,
  /** No resource error
   */
  PLAYER_ERROR_NO_RESOURCE = -3,
  /** Media source is invalid
   */
  PLAYER_ERROR_INVALID_MEDIA_SOURCE = -4,
  /** Unknown stream type
   */
  PLAYER_ERROR_UNKNOWN_STREAM_TYPE = -5,
  /** Object is not initialized
   */
  PLAYER_ERROR_OBJ_NOT_INITIALIZED = -6,
  /** Decoder codec not supported
   */
  PLAYER_ERROR_CODEC_NOT_SUPPORTED = -7,
  /** Video renderer is invalid
   */
  PLAYER_ERROR_VIDEO_RENDER_FAILED = -8,
  /** Internal state error
   */
  PLAYER_ERROR_INVALID_STATE = -9,
  /** Url not found
   */
  PLAYER_ERROR_URL_NOT_FOUND = -10,
  /** Invalid connection state
   */
  PLAYER_ERROR_INVALID_CONNECTION_STATE = -11,
  /** Insufficient buffer data
   */
  PLAY_ERROR_SRC_BUFFER_UNDERFLOW = -12,
};
 
/**
 * @brief Media stream type
 *
 */
enum MEDIA_STREAM_TYPE {
  /** Unknown stream type
   */
  STREAM_TYPE_UNKNOWN = 0,
  /** Video stream
   */
  STREAM_TYPE_VIDEO = 1,
  /** Audio stream
   */
  STREAM_TYPE_AUDIO = 2,
  /** Subtitle stream
   */
  STREAM_TYPE_SUBTITLE = 3,
};
 
/**
 * @brief Playback speed type
 *
 */
enum MEDIA_PLAYER_PLAY_SPEED {
  /** origin playback speed
   */
  ORIGIN_PLAYBACK_SPEED = 100,
  /** playback speed slow down to 0.75
   */
  PLAYBACK_SPEED_75_PERCENT = 75,
  /** playback speed slow down to 0.5
   */
  PLAYBACK_SPEED_50_PERCENT = 50,
  /** playback speed speed up to 1.25
   */
  PLAYBACK_SPEED_125_PERCENT = 125,
  /** playback speed speed up to 1.5
   */
  PLAYBACK_SPEED_150_PERCENT = 150,
    /** playback speed speed up to 2.0
   */
  PLAYBACK_SPEED_200_PERCENT = 200,
};
 
/**
 * @brief Player event
 *
 */
enum MEDIA_PLAYER_EVENT {
  /** seek complete
   */
  PLAYER_EVENT_SEEK_BEGIN = 0,
  /** seek complete
   */
  PLAYER_EVENT_SEEK_COMPLETE = 1,
  /** seek failed
   */
  PLAYER_EVENT_SEEK_ERROR = 2,
  /** player video published
   */
  PLAYER_EVENT_VIDEO_PUBLISHED = 3,
  /** player audio published
   */
  PLAYER_EVENT_AUDIO_PUBLISHED = 4,
  /** player audio track changed
   */
  PLAYER_EVENT_AUDIO_TRACK_CHANGED = 5,
};
 
/**
 * @brief Media stream object
 *
 */
static const uint8_t kMaxCodecNameLength = 50;
struct MediaStreamInfo { /* the index of the stream in the media file */
  int streamIndex;
 
  /* stream type */
  MEDIA_STREAM_TYPE streamType;
 
  /* stream encoding name */
  char codecName[kMaxCodecNameLength];
 
  /* streaming language */
  char language[kMaxCodecNameLength];
 
  /* If it is a video stream, video frames rate */
  int videoFrameRate;
 
  /* If it is a video stream, video bit rate */
  int videoBitRate;
 
  /* If it is a video stream, video width */
  int videoWidth;
 
  /* If it is a video stream, video height */
  int videoHeight;
 
  /* If it is a video stream, video rotation */
  int videoRotation;
 
  /* If it is an audio stream, audio bit rate */
  int audioSampleRate;
 
  /* If it is an audio stream, the number of audio channels */
  int audioChannels;
 
  /* stream duration in second */
  int64_t duration;};
 
/**
 * @brief Player Metadata type
 *
 */
enum MEDIA_PLAYER_METADATA_TYPE {
  /** data type unknown
   */
  PLAYER_METADATA_TYPE_UNKNOWN = 0,
  /** sei data
   */
  PLAYER_METADATA_TYPE_SEI = 1,
};
 
}  // namespace media
 
namespace rtc {
/**
 * The audio route.
 */
enum AudioRoute
{
  /**
   * -1: The default audio route.
   */
  ROUTE_DEFAULT = -1,
  /**
   * The headset.
   */
  ROUTE_HEADSET,
  /**
   * The earpiece.
   */
  ROUTE_EARPIECE,
  /**
   * The headset with no microphone.
   */
  ROUTE_HEADSETNOMIC,
  /**
   * The speakerphone.
   */
  ROUTE_SPEAKERPHONE,
  /**
   * The loudspeaker.
   */
  ROUTE_LOUDSPEAKER,
  /**
   * The Bluetooth headset.
   */
  ROUTE_HEADSETBLUETOOTH
};
} // namespace rtc
 
 
}  // namespace ar
 
#endif // __AR_MEDIA_BASE_H__