Merge branch 'master' of https://git.did.science/WolverinDEV/TeaSpeak-Client
This commit is contained in:
commit
f51820a969
@ -196,8 +196,6 @@ void VoiceSender::encode_raw_frame(const std::unique_ptr<AudioFrame> &frame) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_trace(category::voice_connection, tr("Encode buffer size: {}"), this->_buffer_size);
|
|
||||||
|
|
||||||
char _packet_buffer[512];
|
char _packet_buffer[512];
|
||||||
auto encoded_bytes = codec_data->converter->encode(error, this->_buffer, _packet_buffer, 512);
|
auto encoded_bytes = codec_data->converter->encode(error, this->_buffer, _packet_buffer, 512);
|
||||||
if(encoded_bytes <= 0) {
|
if(encoded_bytes <= 0) {
|
||||||
|
@ -153,8 +153,9 @@ NAN_METHOD(VoiceConnectionWrap::_audio_source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(VoiceConnectionWrap::_set_audio_source) {
|
NAN_METHOD(VoiceConnectionWrap::_set_audio_source) {
|
||||||
return ObjectWrap::Unwrap<VoiceConnectionWrap>(info.Holder())->set_audio_source(info);
|
ObjectWrap::Unwrap<VoiceConnectionWrap>(info.Holder())->set_audio_source(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
NAN_METHOD(VoiceConnectionWrap::set_audio_source) {
|
NAN_METHOD(VoiceConnectionWrap::set_audio_source) {
|
||||||
if(info.Length() != 1) {
|
if(info.Length() != 1) {
|
||||||
Nan::ThrowError("invalid argument count");
|
Nan::ThrowError("invalid argument count");
|
||||||
@ -205,6 +206,35 @@ NAN_METHOD(VoiceConnectionWrap::set_audio_source) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NAN_METHOD(VoiceConnectionWrap::_get_encoder_codec) {
|
||||||
|
auto _this = ObjectWrap::Unwrap<VoiceConnectionWrap>(info.Holder());
|
||||||
|
auto handle = _this->handle.lock();
|
||||||
|
if(!handle) {
|
||||||
|
Nan::ThrowError("handle has been deallocated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.GetReturnValue().Set(handle->get_encoder_codec());
|
||||||
|
}
|
||||||
|
|
||||||
|
NAN_METHOD(VoiceConnectionWrap::_set_encoder_codec) {
|
||||||
|
auto _this = ObjectWrap::Unwrap<VoiceConnectionWrap>(info.Holder());
|
||||||
|
auto handle = _this->handle.lock();
|
||||||
|
if(!handle) {
|
||||||
|
Nan::ThrowError("handle has been deallocated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(info.Length() != 1 || !info[0]->IsNumber()) {
|
||||||
|
Nan::ThrowError("Invalid arguments");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->set_encoder_codec(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VoiceConnectionWrap::release_recorder() {
|
void VoiceConnectionWrap::release_recorder() {
|
||||||
if(!this->_voice_recoder_handle.IsEmpty()) {
|
if(!this->_voice_recoder_handle.IsEmpty()) {
|
||||||
assert(v8::Isolate::GetCurrent());
|
assert(v8::Isolate::GetCurrent());
|
||||||
@ -314,3 +344,16 @@ void VoiceConnection::process_packet(const std::shared_ptr<ts::protocol::ServerP
|
|||||||
//TODO implement whisper
|
//TODO implement whisper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoiceConnection::set_encoder_codec(const uint8_t &codec) {
|
||||||
|
if(codec > codec::MAX) return;
|
||||||
|
|
||||||
|
auto vs = this->_voice_sender;
|
||||||
|
if(vs)
|
||||||
|
vs->set_codec((codec::value) codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t VoiceConnection::get_encoder_codec() {
|
||||||
|
auto vs = this->_voice_sender;
|
||||||
|
return vs ? vs->get_codec() : 0;
|
||||||
|
}
|
@ -48,6 +48,9 @@ namespace tc {
|
|||||||
static NAN_METHOD(_set_audio_source);
|
static NAN_METHOD(_set_audio_source);
|
||||||
NAN_METHOD(set_audio_source);
|
NAN_METHOD(set_audio_source);
|
||||||
|
|
||||||
|
static NAN_METHOD(_get_encoder_codec);
|
||||||
|
static NAN_METHOD(_set_encoder_codec);
|
||||||
|
|
||||||
void release_recorder();
|
void release_recorder();
|
||||||
|
|
||||||
std::function<void(const void* /* buffer */, size_t /* samples */)> _read_callback;
|
std::function<void(const void* /* buffer */, size_t /* samples */)> _read_callback;
|
||||||
@ -87,6 +90,9 @@ namespace tc {
|
|||||||
void delete_client(const std::shared_ptr<VoiceClient>&);
|
void delete_client(const std::shared_ptr<VoiceClient>&);
|
||||||
|
|
||||||
void process_packet(const std::shared_ptr<ts::protocol::ServerPacket>&);
|
void process_packet(const std::shared_ptr<ts::protocol::ServerPacket>&);
|
||||||
|
|
||||||
|
void set_encoder_codec(const uint8_t& /* codec */);
|
||||||
|
uint8_t get_encoder_codec();
|
||||||
private:
|
private:
|
||||||
ServerConnection* _handle;
|
ServerConnection* _handle;
|
||||||
std::weak_ptr<VoiceConnection> _ref;
|
std::weak_ptr<VoiceConnection> _ref;
|
||||||
|
Loading…
Reference in New Issue
Block a user