-
-
Notifications
You must be signed in to change notification settings - Fork 194
Implementation of data channels on top of webrtc data channels #77
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
4b5f5e9
implementation
c21fb2a
removed comment
0be1c49
bug fixes
d918fe4
Update include/DataProducer.hpp
tdrz 69bceb7
Update include/Transport.hpp
tdrz 3f99aa7
Update include/Transport.hpp
tdrz 5ca2912
Update include/Transport.hpp
tdrz a5f19a1
Update include/Transport.hpp
tdrz ce973bb
Update src/DataConsumer.cpp
tdrz 34ca1b0
Update src/DataConsumer.cpp
tdrz 065d88f
Update src/DataConsumer.cpp
tdrz 6e2e1f6
Update src/DataConsumer.cpp
tdrz 28c1a88
Update src/DataConsumer.cpp
tdrz b11b3ac
Update src/DataConsumer.cpp
tdrz 78ef6be
Update src/DataConsumer.cpp
tdrz 22397bc
Update src/Transport.cpp
tdrz f3eca4a
Update src/Transport.cpp
tdrz 377828e
Update src/sdp/RemoteSdp.cpp
tdrz f17e0e8
Update test/include/FakeTransportListener.hpp
tdrz c857327
Update src/DataConsumer.cpp
tdrz dabb3c9
Update src/Transport.cpp
tdrz f686d17
Update src/DataConsumer.cpp
tdrz 0e637ef
Update src/DataConsumer.cpp
tdrz bfcc39c
Update src/DataConsumer.cpp
tdrz 403ce0c
Update src/DataConsumer.cpp
tdrz 81cfccf
Update src/DataConsumer.cpp
tdrz a9d3812
Update src/DataConsumer.cpp
tdrz e17b53e
Update src/DataProducer.cpp
tdrz ef2c1e2
Update src/DataProducer.cpp
tdrz 5923d2d
Update src/DataProducer.cpp
tdrz 01de49f
Update src/DataProducer.cpp
tdrz 37caf76
Update src/DataProducer.cpp
tdrz 73e4978
Update src/DataProducer.cpp
tdrz 4339a4d
Update src/DataProducer.cpp
tdrz 2d274e9
Update src/DataProducer.cpp
tdrz 77412cd
Update src/DataProducer.cpp
tdrz 23e1818
Update src/DataProducer.cpp
tdrz ec9b144
Update src/DataProducer.cpp
tdrz 9776829
Update src/DataProducer.cpp
tdrz b347fdc
Update src/DataProducer.cpp
tdrz 10d88a6
Update src/Handler.cpp
tdrz ac312f5
Update src/PeerConnection.cpp
tdrz a7ddce4
Update src/PeerConnection.cpp
tdrz 9d66f6e
Update src/Transport.cpp
tdrz 2f5285a
Update src/Transport.cpp
tdrz 05e5ae5
applied code changes suggestions
11ac109
indentation fix
c3af35c
Update src/DataConsumer.cpp
tdrz 0f475e2
Update src/DataConsumer.cpp
tdrz 2225491
Update src/DataProducer.cpp
tdrz 0a6b3e4
partial changes
83367b4
more changes
515d2ce
test adapted to new methods
d8164f0
Merge branch 'ChangesAfterCodeReview2' into v3-DataChannelsImpl
c78098f
gulp format
jmillan dba8822
Merge pull request #1 from versatica/v3
tdrz 0a6ed09
rename createsend/recvdatachannel
c766d60
Merge pull request #2 from copiltembel/v3-DataChannelsImpl-Refactorings
tdrz 581d5dd
Revert previous commit; make it build
2b45ac9
leftovers
c9e0860
validate sctp stream parameters before creating the data channel
f164bf4
removed data channel priority as it is not supported by newer version…
fb0ccbe
refactorings
fda2363
Merge pull request #3 from copiltembel/v3-DataChannelsImpl-Retake
tdrz 348af1b
Merge remote-tracking branch 'origin/v3' into v3-DataChannelsImpl
jmillan 4ce835a
Data[Consumer|Producer]: Add missing MSC_CLASS definition
jmillan f49795b
test: fix DataChannel tests
jmillan 4cf262c
update .clang-tidy
jmillan 6e65c8b
cosmetic
jmillan 29f4540
remove commented line
jmillan 62e2c5f
format
jmillan 6a73d77
Make Data[Producer|Consumer] constructors private
jmillan 2458eac
remove commented lines
jmillan fb2fa5e
cosmetic
jmillan a27d950
Handler: unify recv and send DataChannel struct and cleanup
jmillan cfa84d0
DataConsumer: add log for unknown data channel state
jmillan 7dc53cd
remove comment
jmillan 9ae8e5d
DataChannel naming
jmillan f1487dd
more DataChannel naming
jmillan 36a80c0
more on DataChannel naming
jmillan 30583c2
format
jmillan 44f8509
DataConsumer: remove unnecessary include statements
jmillan 24d8f47
DataProducer: remove unnecessary include statements
jmillan 16805b5
cosmetic
jmillan 9854276
cosmetic
jmillan b881e66
data channel code cleanup
jmillan e4d4f43
Handler: consistency with media and data send|recv
jmillan 1b0d06c
cosmetic
jmillan 92cb89e
Data[Consumer|Producer] reorder methods
jmillan 7d17aa7
make 'protocol' optional in RecvTransport::ConsumeData
jmillan 3fe943d
Merge branch 'v3' into HEAD
jmillan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#ifndef MSC_DATACONSUMER_HPP | ||
#define MSC_DATACONSUMER_HPP | ||
|
||
#include <json.hpp> | ||
#include <api/media_stream_interface.h> // webrtc::MediaStreamTrackInterface | ||
#include <api/rtp_receiver_interface.h> // webrtc::RtpReceiverInterface | ||
#include <api/data_channel_interface.h> | ||
#include <string> | ||
|
||
namespace mediasoupclient | ||
{ | ||
class DataConsumer : public webrtc::DataChannelObserver { | ||
public: | ||
class PrivateListener | ||
{ | ||
public: | ||
virtual void OnClose(DataConsumer* dataConsumer) = 0; | ||
}; | ||
|
||
class Listener { | ||
public: | ||
// The data channel state have changed. | ||
virtual void OnStateChange(DataConsumer* dataConsumer) { }; | ||
tdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// A data buffer was successfully received. | ||
virtual void OnMessage(DataConsumer* dataConsumer, const webrtc::DataBuffer& buffer) = 0; | ||
// The data channel's buffered_amount has changed. | ||
// virtual void OnBufferedAmountChange(uint64_t sent_data_size) {} | ||
// | ||
virtual void OnTransportClosed(DataConsumer* dataConsumer) { }; | ||
tdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
public: | ||
DataConsumer( | ||
Listener* listener, | ||
PrivateListener* privateListener, | ||
const std::string& id, | ||
const std::string& dataProducerId, | ||
rtc::scoped_refptr<webrtc::DataChannelInterface> webrtcDataChannel, | ||
const nlohmann::json& sctpStreamParameters, | ||
const nlohmann::json& appData); | ||
|
||
const std::string& GetId(); | ||
std::string GetLocalId() const; | ||
const std::string& GetDataProducerId(); | ||
const bool IsClosed(); | ||
const nlohmann::json& GetSctpStreamParameters(); | ||
webrtc::DataChannelInterface::DataState GetReadyState(); | ||
std::string GetLabel(); | ||
std::string GetProtocol(); | ||
const nlohmann::json& GetAppData(); | ||
void Close(); | ||
void TransportClosed(); | ||
tdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private: | ||
Listener* listener; | ||
PrivateListener* privateListener; | ||
std::string id; | ||
std::string dataProducerId; | ||
rtc::scoped_refptr<webrtc::DataChannelInterface> webrtcDataChannel; | ||
bool closed; | ||
nlohmann::json sctpParameters; | ||
nlohmann::json appData; | ||
|
||
|
||
public: | ||
// From webrtc::DataChannelObsever | ||
// The data channel state have changed. | ||
void OnStateChange() override; | ||
// A data buffer was successfully received. | ||
void OnMessage(const webrtc::DataBuffer& buffer) override; | ||
// The data channel's buffered_amount has changed. | ||
void OnBufferedAmountChange(uint64_t sent_data_size) override; | ||
}; | ||
} // namespace mediasoupclient | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#ifndef MSC_DATAPRODUCER_HPP | ||
#define MSC_DATAPRODUCER_HPP | ||
|
||
#include <json.hpp> | ||
#include <string> | ||
#include <api/data_channel_interface.h> | ||
#include <api/stats/rtcstats_objects.h> | ||
#include <third_party/abseil-cpp/absl/types/optional.h> | ||
#include "Handler.hpp" | ||
|
||
namespace mediasoupclient | ||
{ | ||
// class Transport; | ||
class SendTransport; | ||
|
||
class DataProducer : public webrtc::DataChannelObserver { | ||
public: | ||
class PrivateListener | ||
{ | ||
public: | ||
virtual void OnClose(DataProducer* dataProducer) = 0; | ||
}; | ||
|
||
/* Public Listener API */ | ||
class Listener | ||
{ | ||
public: | ||
virtual void OnTransportClose(DataProducer* dataProducer) {}; | ||
virtual void OnBufferedAmountChange(DataProducer* dataProducer, uint64_t sent_data_size) {}; | ||
// virtual void OnOpen(DataProducer* dataProducer) = 0; | ||
tdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// virtual void OnError(DataProducer* dataProducer) = 0; | ||
// virtual void OnClose(DataProducer* dataProducer) = 0; | ||
}; | ||
|
||
|
||
private: | ||
PrivateListener* privateListener; | ||
Listener* listener; | ||
std::string id; | ||
// std::string _localId; | ||
rtc::scoped_refptr<webrtc::DataChannelInterface> webrtcDataChannel; | ||
bool closed; | ||
nlohmann::json sctpStreamParameters; | ||
nlohmann::json appData; | ||
tdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
void TransportClosed(); | ||
|
||
friend SendTransport; | ||
|
||
public: | ||
DataProducer( | ||
DataProducer::PrivateListener* privateListener, | ||
DataProducer::Listener* listener, | ||
const std::string& id, | ||
// const std::string& localId, | ||
rtc::scoped_refptr<webrtc::DataChannelInterface> webrtcDataChannel, | ||
const nlohmann::json& sctpStreamParameters, | ||
const nlohmann::json& appData); | ||
const std::string& GetId() const; | ||
std::string GetLocalId() const; | ||
// const std::string& GetLocalId() const; | ||
bool IsClosed() const; | ||
const nlohmann::json& GetSctpStreamParameters() const; | ||
webrtc::DataChannelInterface::DataState GetReadyState(); // I would call this GetDataState() | ||
std::string GetLabel(); | ||
std::string GetProtocol(); | ||
uint64_t GetBufferedAmount() const; | ||
uint64_t BufferedAmountLowThreshold; | ||
const nlohmann::json& GetAppData() const; | ||
void Close(); | ||
void Send(const webrtc::DataBuffer& buffer); | ||
|
||
// from DataChannelObserver | ||
public: | ||
void OnStateChange() override; | ||
// A data buffer was successfully received. | ||
void OnMessage(const webrtc::DataBuffer& buffer) override; | ||
// The data channel's buffered_amount has changed. | ||
void OnBufferedAmountChange(uint64_t sent_data_size) override; | ||
}; | ||
} // namespace mediasoupclient | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.