2020-03-12 09:10:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
2018-08-26 07:36:42 +08:00
|
|
|
* Copyright © 2016-2018 The TokTok team.
|
2017-01-14 23:46:31 +08:00
|
|
|
* Copyright © 2013-2015 Tox project.
|
2015-04-21 08:31:12 +08:00
|
|
|
*/
|
2018-09-10 03:54:05 +08:00
|
|
|
#ifndef C_TOXCORE_TOXAV_VIDEO_H
|
|
|
|
#define C_TOXCORE_TOXAV_VIDEO_H
|
2015-04-21 08:31:12 +08:00
|
|
|
|
|
|
|
#include <vpx/vpx_decoder.h>
|
|
|
|
#include <vpx/vpx_encoder.h>
|
|
|
|
#include <vpx/vpx_image.h>
|
2016-09-01 07:33:20 +08:00
|
|
|
|
|
|
|
#include <vpx/vp8cx.h>
|
|
|
|
#include <vpx/vp8dx.h>
|
2018-01-20 05:59:42 +08:00
|
|
|
|
2015-04-21 08:31:12 +08:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2022-01-18 01:12:05 +08:00
|
|
|
#include "toxav.h"
|
|
|
|
|
|
|
|
#include "../toxcore/logger.h"
|
|
|
|
#include "../toxcore/util.h"
|
|
|
|
#include "ring_buffer.h"
|
|
|
|
#include "rtp.h"
|
|
|
|
|
2022-01-05 00:36:28 +08:00
|
|
|
typedef struct VCSession {
|
2015-04-21 08:31:12 +08:00
|
|
|
/* encoding */
|
2015-04-26 06:31:03 +08:00
|
|
|
vpx_codec_ctx_t encoder[1];
|
2015-04-21 08:31:12 +08:00
|
|
|
uint32_t frame_counter;
|
|
|
|
|
|
|
|
/* decoding */
|
2015-04-26 06:31:03 +08:00
|
|
|
vpx_codec_ctx_t decoder[1];
|
2016-09-22 22:20:33 +08:00
|
|
|
struct RingBuffer *vbuf_raw; /* Un-decoded data */
|
2015-04-21 08:31:12 +08:00
|
|
|
|
|
|
|
uint64_t linfts; /* Last received frame time stamp */
|
|
|
|
uint32_t lcfd; /* Last calculated frame duration for incoming video payload */
|
|
|
|
|
2018-06-24 01:16:28 +08:00
|
|
|
const Logger *log;
|
2015-04-21 08:31:12 +08:00
|
|
|
ToxAV *av;
|
2015-04-29 07:01:25 +08:00
|
|
|
uint32_t friend_number;
|
2015-10-11 05:54:23 +08:00
|
|
|
|
2018-08-12 18:55:20 +08:00
|
|
|
/* Video frame receive callback */
|
|
|
|
toxav_video_receive_frame_cb *vcb;
|
|
|
|
void *vcb_user_data;
|
2015-10-11 05:54:23 +08:00
|
|
|
|
2015-04-21 08:31:12 +08:00
|
|
|
pthread_mutex_t queue_mutex[1];
|
|
|
|
} VCSession;
|
|
|
|
|
2018-08-27 04:34:26 +08:00
|
|
|
VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
|
2018-08-18 01:22:18 +08:00
|
|
|
toxav_video_receive_frame_cb *cb, void *cb_data);
|
2015-10-11 05:54:23 +08:00
|
|
|
void vc_kill(VCSession *vc);
|
2016-09-20 04:49:04 +08:00
|
|
|
void vc_iterate(VCSession *vc);
|
2018-08-27 04:34:26 +08:00
|
|
|
int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg);
|
2018-01-20 05:59:42 +08:00
|
|
|
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist);
|
2015-04-21 08:31:12 +08:00
|
|
|
|
2018-09-10 03:54:05 +08:00
|
|
|
#endif // C_TOXCORE_TOXAV_VIDEO_H
|