Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 7d48bc3

Browse files
committed
Address some format and naming issues.
1 parent 0d5198a commit 7d48bc3

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

source/agent/addons/quic/QuicFactory.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include <mutex>
87
#include "QuicFactory.h"
98
#include "owt/quic/quic_transport_factory.h"
9+
#include <mutex>
1010

1111
DEFINE_LOGGER(QuicFactory, "QuicFactory");
1212

@@ -17,18 +17,13 @@ std::shared_ptr<QuicFactory> QuicFactory::s_quicFactory = nullptr;
1717
QuicFactory::QuicFactory()
1818
: m_quicTransportFactory(std::shared_ptr<owt::quic::QuicTransportFactory>(owt::quic::QuicTransportFactory::Create()))
1919
{
20-
ELOG_DEBUG("QuicFactory ctor.");
2120
}
2221

2322
std::shared_ptr<owt::quic::QuicTransportFactory> QuicFactory::getQuicTransportFactory()
2423
{
25-
ELOG_DEBUG("Before call once.");
2624
std::call_once(getQuicFactoryOnce, []() {
27-
ELOG_DEBUG("Before new.");
28-
QuicFactory* factory=new QuicFactory();
29-
ELOG_DEBUG("After new.");
25+
QuicFactory* factory = new QuicFactory();
3026
s_quicFactory = std::shared_ptr<QuicFactory>(factory);
3127
});
32-
ELOG_DEBUG("After call once.");
3328
return s_quicFactory->m_quicTransportFactory;
3429
}

source/agent/addons/quic/QuicTransportStream.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DEFINE_LOGGER(QuicTransportStream, "QuicTransportStream");
1717

1818
Nan::Persistent<v8::Function> QuicTransportStream::s_constructor;
1919

20-
const int uuidSizeInByte = 16;
20+
const int uuidSizeInBytes = 16;
2121

2222
QuicTransportStream::QuicTransportStream()
2323
: QuicTransportStream(nullptr)
@@ -70,7 +70,6 @@ NAN_MODULE_INIT(QuicTransportStream::init)
7070

7171
Nan::SetPrototypeMethod(tpl, "write", write);
7272
Nan::SetPrototypeMethod(tpl, "addDestination", addDestination);
73-
//Nan::SetPrototypeMethod(tpl, "write", write);
7473

7574
s_constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked());
7675
Nan::Set(target, Nan::New("QuicTransportStream").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
@@ -89,13 +88,14 @@ NAN_METHOD(QuicTransportStream::newInstance)
8988
info.GetReturnValue().Set(info.This());
9089
}
9190

92-
NAN_METHOD(QuicTransportStream::write){
93-
if(info.Length()<2){
91+
NAN_METHOD(QuicTransportStream::write)
92+
{
93+
if (info.Length() < 2) {
9494
Nan::ThrowTypeError("Data is not provided.");
9595
return;
9696
}
9797
QuicTransportStream* obj = Nan::ObjectWrap::Unwrap<QuicTransportStream>(info.Holder());
98-
uint8_t* buffer=(uint8_t*)node::Buffer::Data(info[0]->ToObject());
98+
uint8_t* buffer = (uint8_t*)node::Buffer::Data(info[0]->ToObject());
9999
unsigned int length = info[1]->Uint32Value();
100100
obj->m_stream->Write(buffer, length);
101101
info.GetReturnValue().Set(info.This());
@@ -133,14 +133,14 @@ void QuicTransportStream::MaybeReadContentSessionId()
133133
{
134134
if (!m_receivedContentSessionId) {
135135
// Match to a content session.
136-
if (m_stream->ReadableBytes() > 0 && m_stream->ReadableBytes() < uuidSizeInByte) {
136+
if (m_stream->ReadableBytes() > 0 && m_stream->ReadableBytes() < uuidSizeInBytes) {
137137
ELOG_ERROR("No enough data to get content session ID.");
138138
m_stream->Close();
139139
return;
140140
}
141-
uint8_t* data = new uint8_t[uuidSizeInByte];
142-
m_stream->Read(data, uuidSizeInByte);
143-
m_contentSessionId = std::vector<uint8_t>(data, data + uuidSizeInByte);
141+
uint8_t* data = new uint8_t[uuidSizeInBytes];
142+
m_stream->Read(data, uuidSizeInBytes);
143+
m_contentSessionId = std::vector<uint8_t>(data, data + uuidSizeInBytes);
144144
m_receivedContentSessionId = true;
145145
m_asyncOnContentSessionId.data = this;
146146
uv_async_send(&m_asyncOnContentSessionId);
@@ -150,7 +150,8 @@ void QuicTransportStream::MaybeReadContentSessionId()
150150
}
151151
}
152152

153-
NAUV_WORK_CB(QuicTransportStream::onData){
153+
NAUV_WORK_CB(QuicTransportStream::onData)
154+
{
154155
Nan::HandleScope scope;
155156
QuicTransportStream* obj = reinterpret_cast<QuicTransportStream*>(async->data);
156157
if (obj == nullptr) {
@@ -185,15 +186,15 @@ NAUV_WORK_CB(QuicTransportStream::onContentSessionId)
185186
if (onEventLocal->IsFunction()) {
186187
v8::Local<v8::Function> eventCallback = onEventLocal.As<Function>();
187188
Nan::AsyncResource* resource = new Nan::AsyncResource(Nan::New<v8::String>("oncontentsessionid").ToLocalChecked());
188-
Local<Value> args[]={Nan::CopyBuffer((char*)obj->m_contentSessionId.data(),uuidSizeInByte).ToLocalChecked()};
189+
Local<Value> args[] = { Nan::CopyBuffer((char*)obj->m_contentSessionId.data(), uuidSizeInBytes).ToLocalChecked() };
189190
resource->runInAsyncScope(Nan::GetCurrentContext()->Global(), eventCallback, 1, args);
190191
}
191192
}
192193
}
193194

194195
void QuicTransportStream::SignalOnData()
195196
{
196-
if(!m_isPiped){
197+
if (!m_isPiped) {
197198
m_asyncOnData.data = this;
198199
uv_async_send(&m_asyncOnData);
199200
return;

source/agent/conference/roomController.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,13 +1524,13 @@ module.exports.create = function (spec, on_init_ok, on_init_failed) {
15241524
on_error(error_reason);
15251525
};
15261526

1527-
const createMapForSources=function(audioStreamId, videoStreamId, dataStreamId){
1528-
const sourceMap=new Map();
1529-
sourceMap['audio']=audioStreamId;
1530-
sourceMap['video']=videoStreamId;
1531-
sourceMap['data']=dataStreamId
1527+
const createMapForSources = function(audioStreamId, videoStreamId, dataStreamId) {
1528+
const sourceMap = new Map();
1529+
sourceMap['audio'] = audioStreamId;
1530+
sourceMap['video'] = videoStreamId;
1531+
sourceMap['data'] = dataStreamId;
15321532
return sourceMap;
1533-
}
1533+
};
15341534

15351535
var finally_ok = function (audioStream, videoStream, dataStream) {
15361536
return function () {
@@ -1540,9 +1540,9 @@ module.exports.create = function (spec, on_init_ok, on_init_failed) {
15401540
(!dataStream || streams[dataStream])) {
15411541

15421542
terminals[terminal_id].subscribed[subscriptionId] = {};
1543-
for(cosnt [kind, streamId] of createMapForSources(audioStream,videoStream,dataStream)){
1544-
if(from){
1545-
streams[streamId][kind].subscriber=streams[streamId][kind].subscribers||[];
1543+
for (const [kind, streamId] of createMapForSources(audioStream, videoStream, dataStream)) {
1544+
if (from) {
1545+
streams[streamId][kind].subscriber = streams[streamId][kind].subscribers || [];
15461546
streams[streamId][kind].subscribers.push(terminal_id);
15471547
terminals[terminal_id].subscribed[subscriptionId].audio = streamId;
15481548
}

source/agent/quic/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
const Connections = require('./connections');
1919
const InternalConnectionFactory = require('./InternalConnectionFactory');
2020
const logger = require('../logger').logger;
21-
const QuicTransportServer=require('./webtransport/quicTransportServer');
22-
const QuicTransportStreamPipeline=require('./webtransport/quicTransportStreamPipeline');
21+
const QuicTransportServer = require('./webtransport/quicTransportServer');
22+
const QuicTransportStreamPipeline =
23+
require('./webtransport/quicTransportStreamPipeline');
2324
const log = logger.getLogger('QuicNode');
2425
const addon = require('./build/Release/quic');
2526

@@ -34,7 +35,7 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
3435
var internalConnFactory = new InternalConnectionFactory;
3536
const incomingStreamPipelines =
3637
new Map(); // Key is publication ID, value is stream pipeline.
37-
const outgoingStreamPipeline =
38+
const outgoingStreamPipelines =
3839
new Map(); // Key is subscription ID, value is stream pipeline.
3940

4041
var notifyStatus = (controller, sessionId, direction, status) => {
@@ -68,7 +69,7 @@ module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
6869
if (direction === 'in') {
6970
pipelineMap = incomingStreamPipelines;
7071
} else {
71-
pipelineMap = outgoingStreamPipeline;
72+
pipelineMap = outgoingStreamPipelines;
7273
}
7374
if (pipelineMap.has(streamId)) {
7475
return callback(

0 commit comments

Comments
 (0)