mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 15:15:28 +00:00
Merge branch 'track-api' into webrtc_media
This commit is contained in:
@ -28,6 +28,7 @@
|
||||
#include "message.hpp"
|
||||
#include "reliability.hpp"
|
||||
#include "rtc.hpp"
|
||||
#include "track.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
@ -85,12 +86,12 @@ public:
|
||||
std::optional<Description> mediaDescription = nullopt);
|
||||
void addRemoteCandidate(Candidate candidate);
|
||||
|
||||
std::shared_ptr<DataChannel> createDataChannel(const string &label, const string &protocol = "",
|
||||
const Reliability &reliability = {});
|
||||
std::shared_ptr<DataChannel> createDataChannel(string label, string protocol = "",
|
||||
Reliability reliability = {});
|
||||
|
||||
void onDataChannel(std::function<void(std::shared_ptr<DataChannel> dataChannel)> callback);
|
||||
void onLocalDescription(std::function<void(const Description &description)> callback);
|
||||
void onLocalCandidate(std::function<void(const Candidate &candidate)> callback);
|
||||
void onLocalDescription(std::function<void(Description description)> callback);
|
||||
void onLocalCandidate(std::function<void(Candidate candidate)> callback);
|
||||
void onStateChange(std::function<void(State state)> callback);
|
||||
void onGatheringStateChange(std::function<void(GatheringState state)> callback);
|
||||
|
||||
@ -100,13 +101,11 @@ public:
|
||||
size_t bytesReceived();
|
||||
std::optional<std::chrono::milliseconds> rtt();
|
||||
|
||||
// Media
|
||||
// Media support requires compilation with SRTP
|
||||
bool hasMedia() const;
|
||||
void sendMedia(const binary &packet);
|
||||
void sendMedia(const byte *packet, size_t size);
|
||||
void sendMedia(rtc::message_ptr ptr);
|
||||
|
||||
void onMedia(const std::function<void(rtc::message_ptr)>& callback);
|
||||
std::shared_ptr<Track> createTrack(Description::Media description);
|
||||
void onTrack(std::function<void(std::shared_ptr<Track> track)> callback);
|
||||
|
||||
// libnice only
|
||||
bool getSelectedCandidatePair(CandidateInfo *local, CandidateInfo *remote);
|
||||
@ -123,18 +122,20 @@ private:
|
||||
void forwardMedia(message_ptr message);
|
||||
void forwardBufferedAmount(uint16_t stream, size_t amount);
|
||||
|
||||
std::shared_ptr<DataChannel> emplaceDataChannel(Description::Role role, const string &label,
|
||||
const string &protocol,
|
||||
const Reliability &reliability);
|
||||
std::shared_ptr<DataChannel> emplaceDataChannel(Description::Role role, string label,
|
||||
string protocol, Reliability reliability);
|
||||
std::shared_ptr<DataChannel> findDataChannel(uint16_t stream);
|
||||
void iterateDataChannels(std::function<void(std::shared_ptr<DataChannel> channel)> func);
|
||||
void openDataChannels();
|
||||
void closeDataChannels();
|
||||
void remoteCloseDataChannels();
|
||||
|
||||
void openTracks();
|
||||
|
||||
void processLocalDescription(Description description);
|
||||
void processLocalCandidate(Candidate candidate);
|
||||
void triggerDataChannel(std::weak_ptr<DataChannel> weakDataChannel);
|
||||
void triggerTrack(std::weak_ptr<Track> weakTrack);
|
||||
bool changeState(State state);
|
||||
bool changeGatheringState(GatheringState state);
|
||||
|
||||
@ -154,18 +155,19 @@ private:
|
||||
std::shared_ptr<DtlsTransport> mDtlsTransport;
|
||||
std::shared_ptr<SctpTransport> mSctpTransport;
|
||||
|
||||
std::unordered_map<unsigned int, std::weak_ptr<DataChannel>> mDataChannels;
|
||||
std::shared_mutex mDataChannelsMutex;
|
||||
std::unordered_map<unsigned int, std::weak_ptr<DataChannel>> mDataChannels; // by stream ID
|
||||
std::unordered_map<string, std::weak_ptr<Track>> mTracks; // by mid
|
||||
std::shared_mutex mDataChannelsMutex, mTracksMutex;
|
||||
|
||||
std::atomic<State> mState;
|
||||
std::atomic<GatheringState> mGatheringState;
|
||||
|
||||
synchronized_callback<std::shared_ptr<DataChannel>> mDataChannelCallback;
|
||||
synchronized_callback<const Description &> mLocalDescriptionCallback;
|
||||
synchronized_callback<const Candidate &> mLocalCandidateCallback;
|
||||
synchronized_callback<Description> mLocalDescriptionCallback;
|
||||
synchronized_callback<Candidate> mLocalCandidateCallback;
|
||||
synchronized_callback<State> mStateChangeCallback;
|
||||
synchronized_callback<GatheringState> mGatheringStateChangeCallback;
|
||||
synchronized_callback<rtc::message_ptr> mMediaCallback;
|
||||
synchronized_callback<std::shared_ptr<Track>> mTrackCallback;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
Reference in New Issue
Block a user