summaryrefslogtreecommitdiff
path: root/toxav/video.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxav/video.h')
-rw-r--r--toxav/video.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/toxav/video.h b/toxav/video.h
new file mode 100644
index 00000000..96d3205d
--- /dev/null
+++ b/toxav/video.h
@@ -0,0 +1,113 @@
1/** video.h
2 *
3 * Copyright (C) 2013-2015 Tox project All Rights Reserved.
4 *
5 * This file is part of Tox.
6 *
7 * Tox is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Tox is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef VIDEO_H
23#define VIDEO_H
24
25#include <vpx/vpx_decoder.h>
26#include <vpx/vpx_encoder.h>
27#include <vpx/vp8dx.h>
28#include <vpx/vp8cx.h>
29#include <vpx/vpx_image.h>
30#define VIDEO_CODEC_DECODER_INTERFACE (vpx_codec_vp8_dx())
31#define VIDEO_CODEC_ENCODER_INTERFACE (vpx_codec_vp8_cx())
32
33#include <pthread.h>
34
35#include "toxav.h"
36
37#include "../toxcore/util.h"
38
39struct RTPMessage_s;
40
41/*
42 * Base Video Codec session type.
43 */
44typedef struct VCSession_s {
45
46 /* encoding */
47 vpx_codec_ctx_t encoder[1];
48 vpx_codec_ctx_t test_encoder[1];
49 uint32_t frame_counter;
50 uint32_t test_frame_counter;
51
52 /* decoding */
53 vpx_codec_ctx_t decoder[1];
54 void *vbuf_raw; /* Un-decoded data */
55
56 /* Data handling */
57 uint8_t *frame_buf; /* buffer for split video payloads */
58 uint32_t frame_size; /* largest address written to in frame_buf for current input frame */
59 uint8_t frameid_in, frameid_out; /* id of input and output video frame */
60 uint64_t linfts; /* Last received frame time stamp */
61 uint32_t lcfd; /* Last calculated frame duration for incoming video payload */
62
63 /* Limits */
64 uint32_t peer_video_frame_piece_size;
65
66 /* Splitting */
67 uint8_t *split_video_frame;
68 const uint8_t *processing_video_frame;
69 uint16_t processing_video_frame_size;
70
71 ToxAV *av;
72 uint32_t friend_number;
73
74 PAIR(toxav_video_receive_frame_cb *, void *) vcb; /* Video frame receive callback */
75
76 pthread_mutex_t queue_mutex[1];
77} VCSession;
78
79/*
80 * Create new Video Codec session.
81 */
82VCSession* vc_new(ToxAV* av, uint32_t friend_number, toxav_video_receive_frame_cb *cb, void *cb_data, uint32_t mvfpsz);
83/*
84 * Kill the Video Codec session.
85 */
86void vc_kill(VCSession* vc);
87/*
88 * Do periodic work. Work is consisted out of decoding only.
89 */
90void vc_do(VCSession* vc);
91/*
92 * Set new video splitting cycle. This is requirement in order to send video packets.
93 */
94void vc_init_video_splitter_cycle(VCSession* vc);
95/*
96 * Update the video splitter cycle with new data.
97 */
98int vc_update_video_splitter_cycle(VCSession* vc, const uint8_t* payload, uint16_t length);
99/*
100 * Iterate over splitted cycle.
101 */
102const uint8_t *vc_iterate_split_video_frame(VCSession* vc, uint16_t *size);
103/*
104 * Queue new rtp message.
105 */
106int vc_queue_message(void *vcp, struct RTPMessage_s *msg);
107/*
108 * Set new values to the encoders.
109 */
110int vc_reconfigure_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height);
111int vc_reconfigure_test_encoder(VCSession* vc, int32_t bit_rate, uint16_t width, uint16_t height);
112
113#endif /* VIDEO_H */ \ No newline at end of file