diff options
Diffstat (limited to 'toxmsi/toxmedia.h')
-rw-r--r-- | toxmsi/toxmedia.h | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/toxmsi/toxmedia.h b/toxmsi/toxmedia.h deleted file mode 100644 index 8734b173..00000000 --- a/toxmsi/toxmedia.h +++ /dev/null | |||
@@ -1,168 +0,0 @@ | |||
1 | /* AV_codec.h | ||
2 | * | ||
3 | * Audio and video codec intitialisation, encoding/decoding and playback | ||
4 | * | ||
5 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
6 | * | ||
7 | * This file is part of Tox. | ||
8 | * | ||
9 | * Tox is free software: you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation, either version 3 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * Tox is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | /*----------------------------------------------------------------------------------*/ | ||
25 | #ifndef _AVCODEC_H_ | ||
26 | #define _AVCODEC_H_ | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <math.h> | ||
30 | #include <libavcodec/avcodec.h> | ||
31 | #include <libavformat/avformat.h> | ||
32 | #include <libswscale/swscale.h> | ||
33 | #include <libavdevice/avdevice.h> | ||
34 | #include <libavutil/opt.h> | ||
35 | #include <pthread.h> | ||
36 | #include <AL/al.h> | ||
37 | #include <AL/alc.h> | ||
38 | #include "toxrtp.h" | ||
39 | #include "tox.h" | ||
40 | |||
41 | #include <SDL/SDL.h> | ||
42 | #include <opus/opus.h> | ||
43 | |||
44 | /* ffmpeg VP8 codec ID */ | ||
45 | #define VIDEO_CODEC AV_CODEC_ID_VP8 | ||
46 | |||
47 | /* ffmpeg Opus codec ID */ | ||
48 | #define AUDIO_CODEC AV_CODEC_ID_OPUS | ||
49 | |||
50 | /* default video bitrate in bytes/s */ | ||
51 | #define VIDEO_BITRATE 10*1000 | ||
52 | |||
53 | /* default audio bitrate in bytes/s */ | ||
54 | #define AUDIO_BITRATE 64000 | ||
55 | |||
56 | /* audio frame duration in miliseconds */ | ||
57 | #define AUDIO_FRAME_DURATION 20 | ||
58 | |||
59 | /* audio sample rate recommended to be 48kHz for Opus */ | ||
60 | #define AUDIO_SAMPLE_RATE 48000 | ||
61 | |||
62 | /* the amount of samples in one audio frame */ | ||
63 | #define AUDIO_FRAME_SIZE AUDIO_SAMPLE_RATE*AUDIO_FRAME_DURATION/1000 | ||
64 | |||
65 | /* the quit event for SDL */ | ||
66 | #define FF_QUIT_EVENT (SDL_USEREVENT + 2) | ||
67 | |||
68 | #ifdef __linux__ | ||
69 | #define VIDEO_DRIVER "video4linux2" | ||
70 | #define DEFAULT_WEBCAM "/dev/video0" | ||
71 | #endif | ||
72 | |||
73 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | ||
74 | #define VIDEO_DRIVER "vfwcap" | ||
75 | #define DEFAULT_WEBCAM "0" | ||
76 | #endif | ||
77 | |||
78 | extern SDL_Surface *screen; | ||
79 | |||
80 | typedef struct { | ||
81 | SDL_Overlay *bmp; | ||
82 | int width, height; | ||
83 | } VideoPicture; | ||
84 | |||
85 | |||
86 | typedef struct { | ||
87 | uint8_t send_audio; | ||
88 | uint8_t receive_audio; | ||
89 | uint8_t send_video; | ||
90 | uint8_t receive_video; | ||
91 | |||
92 | uint8_t support_send_audio; | ||
93 | uint8_t support_send_video; | ||
94 | uint8_t support_receive_audio; | ||
95 | uint8_t support_receive_video; | ||
96 | |||
97 | /* video encoding */ | ||
98 | AVInputFormat *video_input_format; | ||
99 | AVFormatContext *video_format_ctx; | ||
100 | uint8_t video_stream; | ||
101 | AVCodecContext *webcam_decoder_ctx; | ||
102 | AVCodec *webcam_decoder; | ||
103 | AVCodecContext *video_encoder_ctx; | ||
104 | AVCodec *video_encoder; | ||
105 | |||
106 | /* video decoding */ | ||
107 | AVCodecContext *video_decoder_ctx; | ||
108 | AVCodec *video_decoder; | ||
109 | |||
110 | /* audio encoding */ | ||
111 | ALCdevice *audio_capture_device; | ||
112 | OpusEncoder *audio_encoder; | ||
113 | int audio_bitrate; | ||
114 | |||
115 | /* audio decoding */ | ||
116 | OpusDecoder *audio_decoder; | ||
117 | |||
118 | uint8_t req_video_refresh; | ||
119 | |||
120 | /* context for converting image format to something SDL can use*/ | ||
121 | struct SwsContext *sws_SDL_r_ctx; | ||
122 | |||
123 | /* context for converting webcam image format to something the video encoder can use */ | ||
124 | struct SwsContext *sws_ctx; | ||
125 | |||
126 | /* rendered video picture, ready for display */ | ||
127 | VideoPicture video_picture; | ||
128 | |||
129 | rtp_session_t *_rtp_video; | ||
130 | rtp_session_t *_rtp_audio; | ||
131 | int socket; | ||
132 | Networking_Core *_networking; | ||
133 | |||
134 | pthread_t encode_audio_thread; | ||
135 | pthread_t encode_video_thread; | ||
136 | |||
137 | pthread_t decode_audio_thread; | ||
138 | pthread_t decode_video_thread; | ||
139 | |||
140 | pthread_mutex_t rtp_msg_mutex_lock; | ||
141 | pthread_mutex_t avcodec_mutex_lock; | ||
142 | |||
143 | uint8_t quit; | ||
144 | SDL_Event SDL_event; | ||
145 | |||
146 | msi_session_t *_msi; | ||
147 | uint32_t _frame_rate; | ||
148 | uint16_t _send_port, _recv_port; | ||
149 | int _tox_sock; | ||
150 | //pthread_id _medialoop_id; | ||
151 | |||
152 | } codec_state; | ||
153 | |||
154 | int display_received_frame(codec_state *cs, AVFrame *r_video_frame); | ||
155 | int init_receive_audio(codec_state *cs); | ||
156 | int init_decoder(codec_state *cs); | ||
157 | int init_send_video(codec_state *cs); | ||
158 | int init_send_audio(codec_state *cs); | ||
159 | int init_encoder(codec_state *cs); | ||
160 | int video_encoder_refresh(codec_state *cs, int bps); | ||
161 | void *encode_video_thread(void *arg); | ||
162 | void *encode_audio_thread(void *arg); | ||
163 | int video_decoder_refresh(codec_state *cs, int width, int height); | ||
164 | int handle_rtp_video_packet(codec_state *cs, rtp_msg_t *r_msg); | ||
165 | void *decode_video_thread(void *arg); | ||
166 | void *decode_audio_thread(void *arg); | ||
167 | |||
168 | #endif | ||