mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge branch 'master' of https://github.com/mannol1/ProjectTox-Core into mannol1-master
This commit is contained in:
commit
ef744ebbc2
|
@ -191,10 +191,12 @@ START_TEST(test_AV)
|
|||
|
||||
printf("All set after %llu seconds! Starting call...\n", time(NULL) - cur_time);
|
||||
|
||||
ToxAvCodecSettings muhcaps = av_DefaultSettings;
|
||||
muhcaps.video_height = muhcaps.video_width = 128;
|
||||
|
||||
Status status_control = {
|
||||
{none, toxav_new(Alice, 128, 128), NULL},
|
||||
{none, toxav_new(Bob, 128, 128), NULL},
|
||||
{none, toxav_new(Alice, &muhcaps), NULL},
|
||||
{none, toxav_new(Bob, &muhcaps), NULL},
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#include "event.h"
|
||||
#include "../toxcore/tox.h"
|
||||
|
||||
#define AUDIO_FRAME_SIZE (av_DefaultSettings.audio_sample_rate * av_DefaultSettings.audio_frame_duration / 1000)
|
||||
|
||||
#ifdef TOX_FFMPEG
|
||||
/* Video encoding/decoding */
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
@ -1055,7 +1057,7 @@ av_session_t *av_init_session()
|
|||
|
||||
_retu->audio_capture_device =
|
||||
(struct ALCdevice *)alcCaptureOpenDevice(
|
||||
device_names[selection], AUDIO_SAMPLE_RATE, AL_FORMAT_MONO16, AUDIO_FRAME_SIZE * 4);
|
||||
device_names[selection], av_DefaultSettings.audio_sample_rate, AL_FORMAT_MONO16, AUDIO_FRAME_SIZE * 4);
|
||||
|
||||
|
||||
if (alcGetError((ALCdevice *)_retu->audio_capture_device) != AL_NO_ERROR) {
|
||||
|
@ -1117,8 +1119,10 @@ failed_init_ffmpeg: ;
|
|||
tox_get_address(_retu->_messenger, _byte_address );
|
||||
fraddr_to_str( _byte_address, _retu->_my_public_id );
|
||||
|
||||
|
||||
_retu->av = toxav_new(_retu->_messenger, width, height);
|
||||
ToxAvCodecSettings cs = av_DefaultSettings;
|
||||
cs.video_height = height;
|
||||
cs.video_width = width;
|
||||
_retu->av = toxav_new(_retu->_messenger, &cs);
|
||||
|
||||
/* ------------------ */
|
||||
|
||||
|
|
|
@ -35,12 +35,6 @@
|
|||
|
||||
#include "toxav.h"
|
||||
|
||||
/* Default video bitrate in bytes/s */
|
||||
#define VIDEO_BITRATE (10*1000*100)
|
||||
|
||||
/* Default audio bitrate in bits/s */
|
||||
#define AUDIO_BITRATE 64000
|
||||
|
||||
/* Assume 60 fps*/
|
||||
#define MAX_ENCODE_TIME_US ((1000 / 60) * 1000)
|
||||
|
||||
|
@ -80,7 +74,7 @@ typedef struct _ToxAv {
|
|||
* @return ToxAv*
|
||||
* @retval NULL On error.
|
||||
*/
|
||||
ToxAv *toxav_new( Tox* messenger, uint16_t video_width, uint16_t video_height)
|
||||
ToxAv *toxav_new( Tox* messenger, ToxAvCodecSettings* codec_settings)
|
||||
{
|
||||
ToxAv *av = calloc ( sizeof(ToxAv), 1);
|
||||
|
||||
|
@ -95,10 +89,15 @@ ToxAv *toxav_new( Tox* messenger, uint16_t video_width, uint16_t video_height)
|
|||
av->rtp_sessions[0] = av->rtp_sessions [1] = NULL;
|
||||
|
||||
/* NOTE: This should be user defined or? */
|
||||
av->j_buf = create_queue(20);
|
||||
av->j_buf = create_queue(codec_settings->jbuf_capacity);
|
||||
|
||||
av->cs = codec_init_session(AUDIO_BITRATE, AUDIO_FRAME_DURATION, AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, video_width,
|
||||
video_height, VIDEO_BITRATE);
|
||||
av->cs = codec_init_session(codec_settings->audio_bitrate,
|
||||
codec_settings->audio_frame_duration,
|
||||
codec_settings->audio_sample_rate,
|
||||
codec_settings->audio_channels,
|
||||
codec_settings->video_width,
|
||||
codec_settings->video_height,
|
||||
codec_settings->video_bitrate);
|
||||
|
||||
return av;
|
||||
}
|
||||
|
|
|
@ -39,18 +39,6 @@ typedef struct Tox Tox;
|
|||
|
||||
#define RTP_PAYLOAD_SIZE 65535
|
||||
|
||||
/* Number of audio channels. */
|
||||
#define AUDIO_CHANNELS 1
|
||||
|
||||
/* Audio frame duration in miliseconds */
|
||||
#define AUDIO_FRAME_DURATION 20
|
||||
|
||||
/* Audio sample rate recommended to be 48kHz for Opus */
|
||||
#define AUDIO_SAMPLE_RATE 48000
|
||||
|
||||
/* The amount of samples in one audio frame */
|
||||
#define AUDIO_FRAME_SIZE (AUDIO_SAMPLE_RATE*AUDIO_FRAME_DURATION/1000)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Callbacks ids that handle the call states.
|
||||
|
@ -114,6 +102,35 @@ typedef enum {
|
|||
VideoDecoding = 1 << 3
|
||||
} ToxAvCapabilities;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Encoding settings.
|
||||
*/
|
||||
typedef struct _ToxAvCodecSettings {
|
||||
uint32_t video_bitrate; /* In bits/s */
|
||||
uint16_t video_width; /* In px */
|
||||
uint16_t video_height; /* In px */
|
||||
|
||||
uint32_t audio_bitrate; /* In bits/s */
|
||||
uint16_t audio_frame_duration; /* In ms */
|
||||
uint32_t audio_sample_rate; /* In Hz */
|
||||
uint32_t audio_channels;
|
||||
|
||||
uint32_t jbuf_capacity; /* Size of jitter buffer */
|
||||
} ToxAvCodecSettings;
|
||||
|
||||
static const ToxAvCodecSettings av_DefaultSettings = {
|
||||
1000000,
|
||||
800,
|
||||
600,
|
||||
|
||||
64000,
|
||||
20,
|
||||
48000,
|
||||
1,
|
||||
20
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Start new A/V session. There can only be one session at the time. If you register more
|
||||
* it will result in undefined behaviour.
|
||||
|
@ -125,7 +142,7 @@ typedef enum {
|
|||
* @return ToxAv*
|
||||
* @retval NULL On error.
|
||||
*/
|
||||
ToxAv *toxav_new(Tox *messenger, uint16_t video_width, uint16_t video_height);
|
||||
ToxAv *toxav_new(Tox *messenger, ToxAvCodecSettings* codec_settings);
|
||||
|
||||
/**
|
||||
* @brief Remove A/V session.
|
||||
|
|
Loading…
Reference in New Issue
Block a user