1 /* SPDX-License-Identifier: GPL-3.0-or-later
2  * Copyright © 2016-2018 The TokTok team.
3  * Copyright © 2013-2015 Tox project.
4  */
5 #ifndef C_TOXCORE_TOXAV_VIDEO_H
6 #define C_TOXCORE_TOXAV_VIDEO_H
7 
8 #include "toxav.h"
9 
10 #include "../toxcore/logger.h"
11 #include "../toxcore/util.h"
12 #include "ring_buffer.h"
13 #include "rtp.h"
14 
15 #include <vpx/vpx_decoder.h>
16 #include <vpx/vpx_encoder.h>
17 #include <vpx/vpx_image.h>
18 
19 #include <vpx/vp8cx.h>
20 #include <vpx/vp8dx.h>
21 
22 
23 #include <pthread.h>
24 
25 typedef struct VCSession_s {
26     /* encoding */
27     vpx_codec_ctx_t encoder[1];
28     uint32_t frame_counter;
29 
30     /* decoding */
31     vpx_codec_ctx_t decoder[1];
32     struct RingBuffer *vbuf_raw; /* Un-decoded data */
33 
34     uint64_t linfts; /* Last received frame time stamp */
35     uint32_t lcfd; /* Last calculated frame duration for incoming video payload */
36 
37     const Logger *log;
38     ToxAV *av;
39     uint32_t friend_number;
40 
41     /* Video frame receive callback */
42     toxav_video_receive_frame_cb *vcb;
43     void *vcb_user_data;
44 
45     pthread_mutex_t queue_mutex[1];
46 } VCSession;
47 
48 VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
49                   toxav_video_receive_frame_cb *cb, void *cb_data);
50 void vc_kill(VCSession *vc);
51 void vc_iterate(VCSession *vc);
52 int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg);
53 int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist);
54 
55 #endif // C_TOXCORE_TOXAV_VIDEO_H
56