Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataChannel subchannels #1152

Merged
merged 11 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion node/src/tests/test-DataConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ test('transport.consumeData() succeeds', async () =>
{
dataProducerId : dataProducer.id,
maxPacketLifeTime : 4000,
appData : { baz: 'LOL' }
appData : { baz: 'LOL' },
// Valid values are 0...65535 so others and duplicated ones will be
// discarded.
subchannels : [ 0, 1, 1, 1, 2, 65535, 65536, 65537, 100 ]
});

expect(onObserverNewDataConsumer).toHaveBeenCalledTimes(1);
Expand All @@ -70,6 +73,7 @@ test('transport.consumeData() succeeds', async () =>
expect(dataConsumer1.label).toBe('foo');
expect(dataConsumer1.protocol).toBe('bar');
expect(dataConsumer1.paused).toBe(false);
expect(dataConsumer1.subchannels.sort((a, b) => a - b)).toEqual([ 0, 1, 2, 100, 65535 ]);
expect(dataConsumer1.appData).toEqual({ baz: 'LOL' });

const dump = await router.dump();
Expand Down
18 changes: 14 additions & 4 deletions worker/src/RTC/DataConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,34 @@ namespace RTC
{
MS_TRACE();

flatbuffers::Offset<FBS::SctpParameters::SctpStreamParameters> sctpStreamParametersOffset;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed Offset suffix to be consistent. For instance, in Producer::FillBuffer() we don't add Offset suffix anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmillan I think we should decide whether Offset suffix must be added or not. I see equivalent places where it's added and others in which it's not. IMHO it's redundant and unsightly and we should remove it from everywhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree.

flatbuffers::Offset<FBS::SctpParameters::SctpStreamParameters> sctpStreamParameters;

// Add sctpStreamParameters.
if (this->type == DataConsumer::Type::SCTP)
{
sctpStreamParametersOffset = this->sctpStreamParameters.FillBuffer(builder);
sctpStreamParameters = this->sctpStreamParameters.FillBuffer(builder);
}

std::vector<uint16_t> subchannelsArray;

subchannelsArray.reserve(this->subchannels.size());

for (auto subchannel : this->subchannels)
{
subchannelsArray.emplace_back(subchannel);
}

return FBS::DataConsumer::CreateDumpResponseDirect(
builder,
this->id.c_str(),
this->dataProducerId.c_str(),
this->typeString.c_str(),
sctpStreamParametersOffset,
sctpStreamParameters,
this->label.c_str(),
this->protocol.c_str(),
this->paused,
this->dataProducerPaused);
this->dataProducerPaused,
&subchannelsArray);
}

flatbuffers::Offset<FBS::DataConsumer::GetStatsResponse> DataConsumer::FillBufferStats(
Expand Down