mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 15:15:28 +00:00
Use ptrs, optionals and variants from rtc namespace
This commit is contained in:
@ -52,8 +52,8 @@ public:
|
||||
|
||||
bool isResolved() const;
|
||||
Family family() const;
|
||||
std::optional<string> address() const;
|
||||
std::optional<uint16_t> port() const;
|
||||
optional<string> address() const;
|
||||
optional<uint16_t> port() const;
|
||||
|
||||
private:
|
||||
void parse(string candidate);
|
||||
@ -66,7 +66,7 @@ private:
|
||||
string mNode, mService;
|
||||
string mTail;
|
||||
|
||||
std::optional<string> mMid;
|
||||
optional<string> mMid;
|
||||
|
||||
// Extracted on resolution
|
||||
Family mFamily;
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -57,8 +56,8 @@ public:
|
||||
void setBufferedAmountLowThreshold(size_t amount);
|
||||
|
||||
// Extended API
|
||||
std::optional<message_variant> receive(); // only if onMessage unset
|
||||
std::optional<message_variant> peek(); // only if onMessage unset
|
||||
optional<message_variant> receive(); // only if onMessage unset
|
||||
optional<message_variant> peek(); // only if onMessage unset
|
||||
size_t availableAmount() const; // total size available to receive
|
||||
void onAvailable(std::function<void()> callback);
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@ -57,10 +58,12 @@ namespace rtc {
|
||||
|
||||
using std::byte;
|
||||
using std::nullopt;
|
||||
using std::optional;
|
||||
using std::shared_ptr;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::unique_ptr;
|
||||
using std::variant;
|
||||
using std::weak_ptr;
|
||||
|
||||
using binary = std::vector<byte>;
|
||||
|
@ -66,12 +66,12 @@ struct RTC_CPP_EXPORT ProxyServer {
|
||||
|
||||
struct RTC_CPP_EXPORT Configuration {
|
||||
std::vector<IceServer> iceServers;
|
||||
std::optional<ProxyServer> proxyServer;
|
||||
optional<ProxyServer> proxyServer;
|
||||
bool enableIceTcp = false;
|
||||
bool disableAutoNegotiation = false;
|
||||
uint16_t portRangeBegin = 1024;
|
||||
uint16_t portRangeEnd = 65535;
|
||||
std::optional<size_t> mtu;
|
||||
optional<size_t> mtu;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <functional>
|
||||
#include <shared_mutex>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
#include <shared_mutex>
|
||||
|
||||
namespace rtc {
|
||||
|
@ -25,9 +25,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace rtc {
|
||||
@ -54,9 +51,9 @@ public:
|
||||
string typeString() const;
|
||||
Role role() const;
|
||||
string bundleMid() const;
|
||||
std::optional<string> iceUfrag() const;
|
||||
std::optional<string> icePwd() const;
|
||||
std::optional<string> fingerprint() const;
|
||||
optional<string> iceUfrag() const;
|
||||
optional<string> icePwd() const;
|
||||
optional<string> fingerprint() const;
|
||||
bool ended() const;
|
||||
|
||||
void hintType(Type type);
|
||||
@ -116,16 +113,16 @@ public:
|
||||
void hintSctpPort(uint16_t port) { mSctpPort = mSctpPort.value_or(port); }
|
||||
void setMaxMessageSize(size_t size) { mMaxMessageSize = size; }
|
||||
|
||||
std::optional<uint16_t> sctpPort() const { return mSctpPort; }
|
||||
std::optional<size_t> maxMessageSize() const { return mMaxMessageSize; }
|
||||
optional<uint16_t> sctpPort() const { return mSctpPort; }
|
||||
optional<size_t> maxMessageSize() const { return mMaxMessageSize; }
|
||||
|
||||
virtual void parseSdpLine(string_view line) override;
|
||||
|
||||
private:
|
||||
virtual string generateSdpLines(string_view eol) const override;
|
||||
|
||||
std::optional<uint16_t> mSctpPort;
|
||||
std::optional<size_t> mMaxMessageSize;
|
||||
optional<uint16_t> mSctpPort;
|
||||
optional<size_t> mMaxMessageSize;
|
||||
};
|
||||
|
||||
// Media (non-data)
|
||||
@ -140,10 +137,10 @@ public:
|
||||
|
||||
void removeFormat(const string &fmt);
|
||||
|
||||
void addSSRC(uint32_t ssrc, std::optional<string> name,
|
||||
std::optional<string> msid = nullopt, std::optional<string> trackID = nullopt);
|
||||
void replaceSSRC(uint32_t oldSSRC, uint32_t ssrc, std::optional<string> name,
|
||||
std::optional<string> msid = nullopt, std::optional<string> trackID = nullopt);
|
||||
void addSSRC(uint32_t ssrc, optional<string> name,
|
||||
optional<string> msid = nullopt, optional<string> trackID = nullopt);
|
||||
void replaceSSRC(uint32_t oldSSRC, uint32_t ssrc, optional<string> name,
|
||||
optional<string> msid = nullopt, optional<string> trackID = nullopt);
|
||||
bool hasSSRC(uint32_t ssrc);
|
||||
std::vector<uint32_t> getSSRCs();
|
||||
|
||||
@ -203,10 +200,10 @@ public:
|
||||
Audio(string mid = "audio", Direction dir = Direction::SendOnly);
|
||||
|
||||
void addAudioCodec(int payloadType, string codec,
|
||||
std::optional<string> profile = std::nullopt);
|
||||
optional<string> profile = std::nullopt);
|
||||
|
||||
void addOpusCodec(int payloadType,
|
||||
std::optional<string> profile = DEFAULT_OPUS_AUDIO_PROFILE);
|
||||
optional<string> profile = DEFAULT_OPUS_AUDIO_PROFILE);
|
||||
};
|
||||
|
||||
class RTC_CPP_EXPORT Video : public Media {
|
||||
@ -214,10 +211,10 @@ public:
|
||||
Video(string mid = "video", Direction dir = Direction::SendOnly);
|
||||
|
||||
void addVideoCodec(int payloadType, string codec,
|
||||
std::optional<string> profile = std::nullopt);
|
||||
optional<string> profile = std::nullopt);
|
||||
|
||||
void addH264Codec(int payloadType,
|
||||
std::optional<string> profile = DEFAULT_H264_VIDEO_PROFILE);
|
||||
optional<string> profile = DEFAULT_H264_VIDEO_PROFILE);
|
||||
void addVP8Codec(int payloadType);
|
||||
void addVP9Codec(int payloadType);
|
||||
};
|
||||
@ -232,8 +229,8 @@ public:
|
||||
int addVideo(string mid = "video", Direction dir = Direction::SendOnly);
|
||||
int addAudio(string mid = "audio", Direction dir = Direction::SendOnly);
|
||||
|
||||
std::variant<Media *, Application *> media(unsigned int index);
|
||||
std::variant<const Media *, const Application *> media(unsigned int index) const;
|
||||
variant<Media *, Application *> media(unsigned int index);
|
||||
variant<const Media *, const Application *> media(unsigned int index) const;
|
||||
unsigned int mediaCount() const;
|
||||
|
||||
Application *application();
|
||||
@ -242,8 +239,8 @@ public:
|
||||
static string typeToString(Type type);
|
||||
|
||||
private:
|
||||
std::optional<Candidate> defaultCandidate() const;
|
||||
std::shared_ptr<Entry> createEntry(string mline, string mid, Direction dir);
|
||||
optional<Candidate> defaultCandidate() const;
|
||||
shared_ptr<Entry> createEntry(string mline, string mid, Direction dir);
|
||||
void removeApplication();
|
||||
|
||||
Type mType;
|
||||
@ -252,12 +249,12 @@ private:
|
||||
Role mRole;
|
||||
string mUsername;
|
||||
string mSessionId;
|
||||
std::optional<string> mIceUfrag, mIcePwd;
|
||||
std::optional<string> mFingerprint;
|
||||
optional<string> mIceUfrag, mIcePwd;
|
||||
optional<string> mFingerprint;
|
||||
|
||||
// Entries
|
||||
std::vector<std::shared_ptr<Entry>> mEntries;
|
||||
std::shared_ptr<Application> mApplication;
|
||||
std::vector<shared_ptr<Entry>> mEntries;
|
||||
shared_ptr<Application> mApplication;
|
||||
|
||||
// Candidates
|
||||
std::vector<Candidate> mCandidates;
|
||||
|
@ -32,7 +32,7 @@ class RTC_CPP_EXPORT H264PacketizationHandler : public MediaChainableHandler {
|
||||
public:
|
||||
/// Construct handler for H264 packetization.
|
||||
/// @param packetizer RTP packetizer for h264
|
||||
H264PacketizationHandler(std::shared_ptr<H264RtpPacketizer> packetizer);
|
||||
H264PacketizationHandler(shared_ptr<H264RtpPacketizer> packetizer);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -29,7 +29,7 @@ namespace rtc {
|
||||
|
||||
/// RTP packetization of h264 payload
|
||||
class RTC_CPP_EXPORT H264RtpPacketizer : public RtpPacketizer, public MediaHandlerRootElement {
|
||||
std::shared_ptr<NalUnits> splitMessage(binary_ptr message);
|
||||
shared_ptr<NalUnits> splitMessage(binary_ptr message);
|
||||
const uint16_t maximumFragmentSize;
|
||||
|
||||
public:
|
||||
@ -44,7 +44,7 @@ public:
|
||||
Length // first 4 bytes is nal unit length
|
||||
};
|
||||
|
||||
H264RtpPacketizer(H264RtpPacketizer::Separator separator, std::shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
H264RtpPacketizer(H264RtpPacketizer::Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
|
||||
|
||||
/// Constructs h264 payload packetizer with given RTP configuration.
|
||||
@ -52,7 +52,7 @@ public:
|
||||
/// properties such as sequence number.
|
||||
/// @param rtpConfig RTP configuration
|
||||
/// @param maximumFragmentSize maximum size of one NALU fragment
|
||||
H264RtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
H264RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
|
||||
|
||||
ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
using init_token = std::shared_ptr<void>;
|
||||
using init_token = shared_ptr<void>;
|
||||
|
||||
class RTC_CPP_EXPORT Init {
|
||||
public:
|
||||
@ -38,8 +38,8 @@ public:
|
||||
private:
|
||||
Init();
|
||||
|
||||
static std::weak_ptr<void> Weak;
|
||||
static std::shared_ptr<void> *Global;
|
||||
static weak_ptr<void> Weak;
|
||||
static shared_ptr<void> *Global;
|
||||
static bool Initialized;
|
||||
static std::recursive_mutex Mutex;
|
||||
};
|
||||
|
@ -26,8 +26,8 @@
|
||||
namespace rtc {
|
||||
|
||||
class RTC_CPP_EXPORT MediaChainableHandler : public MediaHandler {
|
||||
const std::shared_ptr<MediaHandlerRootElement> root;
|
||||
std::shared_ptr<MediaHandlerElement> leaf;
|
||||
const shared_ptr<MediaHandlerRootElement> root;
|
||||
shared_ptr<MediaHandlerElement> leaf;
|
||||
std::mutex inoutMutex;
|
||||
|
||||
message_ptr handleIncomingBinary(message_ptr);
|
||||
@ -36,7 +36,7 @@ class RTC_CPP_EXPORT MediaChainableHandler : public MediaHandler {
|
||||
message_ptr handleOutgoingControl(message_ptr);
|
||||
bool sendProduct(ChainedOutgoingProduct product);
|
||||
public:
|
||||
MediaChainableHandler(std::shared_ptr<MediaHandlerRootElement> root);
|
||||
MediaChainableHandler(shared_ptr<MediaHandlerRootElement> root);
|
||||
~MediaChainableHandler();
|
||||
message_ptr incoming(message_ptr ptr) override;
|
||||
message_ptr outgoing(message_ptr ptr) override;
|
||||
@ -45,7 +45,7 @@ public:
|
||||
|
||||
/// Adds element to chain
|
||||
/// @param chainable Chainable element
|
||||
void addToChain(std::shared_ptr<MediaHandlerElement> chainable);
|
||||
void addToChain(shared_ptr<MediaHandlerElement> chainable);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
using ChainedMessagesProduct = std::shared_ptr<std::vector<binary_ptr>>;
|
||||
using ChainedMessagesProduct = shared_ptr<std::vector<binary_ptr>>;
|
||||
|
||||
RTC_CPP_EXPORT ChainedMessagesProduct make_chained_messages_product();
|
||||
RTC_CPP_EXPORT ChainedMessagesProduct make_chained_messages_product(message_ptr msg);
|
||||
@ -47,17 +47,17 @@ struct RTC_CPP_EXPORT ChainedIncomingProduct {
|
||||
|
||||
/// Incoming control messages with response
|
||||
struct RTC_CPP_EXPORT ChainedIncomingControlProduct {
|
||||
ChainedIncomingControlProduct(message_ptr incoming, std::optional<ChainedOutgoingProduct> outgoing = nullopt);
|
||||
ChainedIncomingControlProduct(message_ptr incoming, optional<ChainedOutgoingProduct> outgoing = nullopt);
|
||||
const message_ptr incoming;
|
||||
const std::optional<ChainedOutgoingProduct> outgoing;
|
||||
const optional<ChainedOutgoingProduct> outgoing;
|
||||
};
|
||||
|
||||
/// Chainable handler
|
||||
class RTC_CPP_EXPORT MediaHandlerElement: public std::enable_shared_from_this<MediaHandlerElement> {
|
||||
std::shared_ptr<MediaHandlerElement> upstream = nullptr;
|
||||
std::shared_ptr<MediaHandlerElement> downstream = nullptr;
|
||||
shared_ptr<MediaHandlerElement> upstream = nullptr;
|
||||
shared_ptr<MediaHandlerElement> downstream = nullptr;
|
||||
|
||||
void prepareAndSendResponse(std::optional<ChainedOutgoingProduct> outgoing, std::function<bool (ChainedOutgoingProduct)> send);
|
||||
void prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing, std::function<bool (ChainedOutgoingProduct)> send);
|
||||
|
||||
void removeFromChain();
|
||||
public:
|
||||
@ -66,13 +66,13 @@ public:
|
||||
/// Creates response to incoming message
|
||||
/// @param messages Current repsonse
|
||||
/// @returns New response
|
||||
std::optional<ChainedOutgoingProduct> processOutgoingResponse(ChainedOutgoingProduct messages);
|
||||
optional<ChainedOutgoingProduct> processOutgoingResponse(ChainedOutgoingProduct messages);
|
||||
|
||||
// Process incoming and ougoing messages
|
||||
message_ptr formIncomingControlMessage(message_ptr message, std::function<bool (ChainedOutgoingProduct)> send);
|
||||
ChainedMessagesProduct formIncomingBinaryMessage(ChainedMessagesProduct messages, std::function<bool (ChainedOutgoingProduct)> send);
|
||||
message_ptr formOutgoingControlMessage(message_ptr message);
|
||||
std::optional<ChainedOutgoingProduct> formOutgoingBinaryMessage(ChainedOutgoingProduct product);
|
||||
optional<ChainedOutgoingProduct> formOutgoingBinaryMessage(ChainedOutgoingProduct product);
|
||||
|
||||
/// Process current control message
|
||||
/// @param messages current message
|
||||
@ -98,7 +98,7 @@ public:
|
||||
/// Set given element as upstream to this
|
||||
/// @param upstream Upstream element
|
||||
/// @returns Upstream element
|
||||
std::shared_ptr<MediaHandlerElement> chainWith(std::shared_ptr<MediaHandlerElement> upstream);
|
||||
shared_ptr<MediaHandlerElement> chainWith(shared_ptr<MediaHandlerElement> upstream);
|
||||
|
||||
/// Remove all downstream elements from chain
|
||||
void recursiveRemoveChain();
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include "reliability.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -44,12 +41,12 @@ struct RTC_CPP_EXPORT Message : binary {
|
||||
Type type;
|
||||
unsigned int stream = 0; // Stream id (SCTP stream or SSRC)
|
||||
unsigned int dscp = 0; // Differentiated Services Code Point
|
||||
std::shared_ptr<Reliability> reliability;
|
||||
shared_ptr<Reliability> reliability;
|
||||
};
|
||||
|
||||
using message_ptr = std::shared_ptr<Message>;
|
||||
using message_ptr = shared_ptr<Message>;
|
||||
using message_callback = std::function<void(message_ptr message)>;
|
||||
using message_variant = std::variant<binary, string>;
|
||||
using message_variant = variant<binary, string>;
|
||||
|
||||
inline size_t message_size_func(const message_ptr &m) {
|
||||
return m->type == Message::Binary || m->type == Message::String ? m->size() : 0;
|
||||
@ -58,7 +55,7 @@ inline size_t message_size_func(const message_ptr &m) {
|
||||
template <typename Iterator>
|
||||
message_ptr make_message(Iterator begin, Iterator end, Message::Type type = Message::Binary,
|
||||
unsigned int stream = 0,
|
||||
std::shared_ptr<Reliability> reliability = nullptr) {
|
||||
shared_ptr<Reliability> reliability = nullptr) {
|
||||
auto message = std::make_shared<Message>(begin, end, type);
|
||||
message->stream = stream;
|
||||
message->reliability = reliability;
|
||||
@ -67,11 +64,11 @@ message_ptr make_message(Iterator begin, Iterator end, Message::Type type = Mess
|
||||
|
||||
RTC_CPP_EXPORT message_ptr make_message(size_t size, Message::Type type = Message::Binary,
|
||||
unsigned int stream = 0,
|
||||
std::shared_ptr<Reliability> reliability = nullptr);
|
||||
shared_ptr<Reliability> reliability = nullptr);
|
||||
|
||||
RTC_CPP_EXPORT message_ptr make_message(binary &&data, Message::Type type = Message::Binary,
|
||||
unsigned int stream = 0,
|
||||
std::shared_ptr<Reliability> reliability = nullptr);
|
||||
shared_ptr<Reliability> reliability = nullptr);
|
||||
|
||||
RTC_CPP_EXPORT message_ptr make_message(message_variant data);
|
||||
|
||||
|
@ -101,8 +101,8 @@ struct RTC_CPP_EXPORT NalUnitFragmentA : NalUnit {
|
||||
NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t nri, uint8_t unitType,
|
||||
binary data);
|
||||
|
||||
static std::vector<std::shared_ptr<NalUnitFragmentA>>
|
||||
fragmentsFrom(std::shared_ptr<NalUnit> nalu, uint16_t maximumFragmentSize);
|
||||
static std::vector<shared_ptr<NalUnitFragmentA>>
|
||||
fragmentsFrom(shared_ptr<NalUnit> nalu, uint16_t maximumFragmentSize);
|
||||
|
||||
uint8_t unitType() { return fragmentHeader()->unitType(); }
|
||||
|
||||
@ -141,11 +141,11 @@ protected:
|
||||
const uint8_t nal_type_fu_A = 28;
|
||||
};
|
||||
|
||||
class RTC_CPP_EXPORT NalUnits : public std::vector<std::shared_ptr<NalUnit>> {
|
||||
class RTC_CPP_EXPORT NalUnits : public std::vector<shared_ptr<NalUnit>> {
|
||||
public:
|
||||
static const uint16_t defaultMaximumFragmentSize =
|
||||
uint16_t(RTC_DEFAULT_MTU - 12 - 8 - 40); // SRTP/UDP/IPv6
|
||||
std::vector<std::shared_ptr<binary>> generateFragments(uint16_t maximumFragmentSize);
|
||||
std::vector<shared_ptr<binary>> generateFragments(uint16_t maximumFragmentSize);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -32,7 +32,7 @@ class RTC_CPP_EXPORT OpusPacketizationHandler : public MediaChainableHandler {
|
||||
public:
|
||||
/// Construct handler for opus packetization.
|
||||
/// @param packetizer RTP packetizer for opus
|
||||
OpusPacketizationHandler(std::shared_ptr<OpusRtpPacketizer> packetizer);
|
||||
OpusPacketizationHandler(shared_ptr<OpusRtpPacketizer> packetizer);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
/// @note RTP configuration is used in packetization process which may change some configuration
|
||||
/// properties such as sequence number.
|
||||
/// @param rtpConfig RTP configuration
|
||||
OpusRtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
OpusRtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
|
||||
/// Creates RTP packet for given payload based on `rtpConfig`.
|
||||
/// @note This function increase sequence number after packetization.
|
||||
|
@ -43,7 +43,7 @@ struct PeerConnection;
|
||||
struct RTC_CPP_EXPORT DataChannelInit {
|
||||
Reliability reliability = {};
|
||||
bool negotiated = false;
|
||||
std::optional<uint16_t> id = nullopt;
|
||||
optional<uint16_t> id = nullopt;
|
||||
string protocol = "";
|
||||
};
|
||||
|
||||
@ -85,10 +85,10 @@ public:
|
||||
bool hasLocalDescription() const;
|
||||
bool hasRemoteDescription() const;
|
||||
bool hasMedia() const;
|
||||
std::optional<Description> localDescription() const;
|
||||
std::optional<Description> remoteDescription() const;
|
||||
std::optional<string> localAddress() const;
|
||||
std::optional<string> remoteAddress() const;
|
||||
optional<Description> localDescription() const;
|
||||
optional<Description> remoteDescription() const;
|
||||
optional<string> localAddress() const;
|
||||
optional<string> remoteAddress() const;
|
||||
bool getSelectedCandidatePair(Candidate *local, Candidate *remote);
|
||||
|
||||
void setLocalDescription(Description::Type type = Description::Type::Unspec);
|
||||
@ -96,11 +96,10 @@ public:
|
||||
void setRemoteDescription(Description description);
|
||||
void addRemoteCandidate(Candidate candidate);
|
||||
|
||||
std::shared_ptr<DataChannel> createDataChannel(string label, DataChannelInit init = {});
|
||||
|
||||
shared_ptr<DataChannel> createDataChannel(string label, DataChannelInit init = {});
|
||||
void onDataChannel(std::function<void(std::shared_ptr<DataChannel> dataChannel)> callback);
|
||||
|
||||
std::shared_ptr<Track> addTrack(Description::Media description);
|
||||
shared_ptr<Track> addTrack(Description::Media description);
|
||||
void onTrack(std::function<void(std::shared_ptr<Track> track)> callback);
|
||||
|
||||
void onLocalDescription(std::function<void(Description description)> callback);
|
||||
@ -113,7 +112,7 @@ public:
|
||||
void clearStats();
|
||||
size_t bytesSent();
|
||||
size_t bytesReceived();
|
||||
std::optional<std::chrono::milliseconds> rtt();
|
||||
optional<std::chrono::milliseconds> rtt();
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "common.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -31,7 +30,7 @@ struct Reliability {
|
||||
|
||||
Type type = Type::Reliable;
|
||||
bool unordered = false;
|
||||
std::variant<int, std::chrono::milliseconds> rexmit = 0;
|
||||
variant<int, std::chrono::milliseconds> rexmit = 0;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -34,21 +34,21 @@ class RTC_CPP_EXPORT RtcpNackResponder: public MediaHandlerElement {
|
||||
|
||||
/// Packet storage element
|
||||
struct RTC_CPP_EXPORT Element {
|
||||
Element(binary_ptr packet, uint16_t sequenceNumber, std::shared_ptr<Element> next = nullptr);
|
||||
Element(binary_ptr packet, uint16_t sequenceNumber, shared_ptr<Element> next = nullptr);
|
||||
const binary_ptr packet;
|
||||
const uint16_t sequenceNumber;
|
||||
/// Pointer to newer element
|
||||
std::shared_ptr<Element> next = nullptr;
|
||||
shared_ptr<Element> next = nullptr;
|
||||
};
|
||||
|
||||
private:
|
||||
/// Oldest packet in storage
|
||||
std::shared_ptr<Element> oldest = nullptr;
|
||||
shared_ptr<Element> oldest = nullptr;
|
||||
/// Newest packet in storage
|
||||
std::shared_ptr<Element> newest = nullptr;
|
||||
shared_ptr<Element> newest = nullptr;
|
||||
|
||||
/// Inner storage
|
||||
std::unordered_map<uint16_t, std::shared_ptr<Element>> storage{};
|
||||
std::unordered_map<uint16_t, shared_ptr<Element>> storage{};
|
||||
|
||||
/// Maximum storage size
|
||||
const unsigned maximumSize;
|
||||
@ -62,14 +62,14 @@ class RTC_CPP_EXPORT RtcpNackResponder: public MediaHandlerElement {
|
||||
Storage(unsigned _maximumSize);
|
||||
|
||||
/// Returns packet with given sequence number
|
||||
std::optional<binary_ptr> get(uint16_t sequenceNumber);
|
||||
optional<binary_ptr> get(uint16_t sequenceNumber);
|
||||
|
||||
/// Stores packet
|
||||
/// @param packet Packet
|
||||
void store(binary_ptr packet);
|
||||
};
|
||||
|
||||
const std::shared_ptr<Storage> storage;
|
||||
const shared_ptr<Storage> storage;
|
||||
std::mutex reportMutex;
|
||||
|
||||
public:
|
||||
|
@ -46,9 +46,9 @@ public:
|
||||
const uint32_t &previousReportedTimestamp = _previousReportedTimestamp;
|
||||
|
||||
/// RTP configuration
|
||||
const std::shared_ptr<RtpPacketizationConfig> rtpConfig;
|
||||
const shared_ptr<RtpPacketizationConfig> rtpConfig;
|
||||
|
||||
RtcpSrReporter(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
RtcpSrReporter(shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
|
||||
ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
/// @param startTimestamp Corresponding timestamp for given start time (current timestamp will
|
||||
/// be used if value is nullopt)
|
||||
void setStartTime(double startTime_s, EpochStart epochStart,
|
||||
std::optional<uint32_t> startTimestamp = std::nullopt);
|
||||
optional<uint32_t> startTimestamp = std::nullopt);
|
||||
|
||||
/// Construct RTP configuration used in packetization process
|
||||
/// @param ssrc SSRC of source
|
||||
@ -66,8 +66,8 @@ public:
|
||||
/// nullopt)
|
||||
/// @param timestamp Initial timastamp of RTP packets (random number is choosed if nullopt)
|
||||
RtpPacketizationConfig(SSRC ssrc, std::string cname, uint8_t payloadType, uint32_t clockRate,
|
||||
std::optional<uint16_t> sequenceNumber = std::nullopt,
|
||||
std::optional<uint32_t> timestamp = std::nullopt);
|
||||
optional<uint16_t> sequenceNumber = std::nullopt,
|
||||
optional<uint32_t> timestamp = std::nullopt);
|
||||
|
||||
/// Convert timestamp to seconds
|
||||
/// @param timestamp Timestamp
|
||||
|
@ -32,19 +32,19 @@ class RTC_CPP_EXPORT RtpPacketizer {
|
||||
|
||||
public:
|
||||
// RTP configuration
|
||||
const std::shared_ptr<RtpPacketizationConfig> rtpConfig;
|
||||
const shared_ptr<RtpPacketizationConfig> rtpConfig;
|
||||
|
||||
/// Constructs packetizer with given RTP configuration.
|
||||
/// @note RTP configuration is used in packetization process which may change some configuration
|
||||
/// properties such as sequence number.
|
||||
/// @param rtpConfig RTP configuration
|
||||
RtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
|
||||
/// Creates RTP packet for given payload based on `rtpConfig`.
|
||||
/// @note This function increase sequence number after packetization.
|
||||
/// @param payload RTP payload
|
||||
/// @param setMark Set marker flag in RTP packet if true
|
||||
virtual std::shared_ptr<binary> packetize(std::shared_ptr<binary> payload, bool setMark);
|
||||
virtual shared_ptr<binary> packetize(shared_ptr<binary> payload, bool setMark);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <shared_mutex>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -59,8 +58,8 @@ public:
|
||||
bool requestKeyframe();
|
||||
|
||||
// RTCP handler
|
||||
void setRtcpHandler(std::shared_ptr<MediaHandler> handler);
|
||||
std::shared_ptr<MediaHandler> getRtcpHandler();
|
||||
void setRtcpHandler(shared_ptr<MediaHandler> handler);
|
||||
shared_ptr<MediaHandler> getRtcpHandler();
|
||||
|
||||
private:
|
||||
using CheshireCat<impl::Track>::impl;
|
||||
|
@ -233,11 +233,11 @@ bool Candidate::isResolved() const { return mFamily != Family::Unresolved; }
|
||||
|
||||
Candidate::Family Candidate::family() const { return mFamily; }
|
||||
|
||||
std::optional<string> Candidate::address() const {
|
||||
optional<string> Candidate::address() const {
|
||||
return isResolved() ? std::make_optional(mAddress) : nullopt;
|
||||
}
|
||||
|
||||
std::optional<uint16_t> Candidate::port() const {
|
||||
optional<uint16_t> Candidate::port() const {
|
||||
return isResolved() ? std::make_optional(mPort) : nullopt;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#endif
|
||||
|
||||
using namespace rtc;
|
||||
using std::optional;
|
||||
using std::chrono::milliseconds;
|
||||
|
||||
namespace {
|
||||
@ -55,7 +54,7 @@ std::unordered_map<int, void *> userPointerMap;
|
||||
std::mutex mutex;
|
||||
int lastId = 0;
|
||||
|
||||
std::optional<void *> getUserPointer(int id) {
|
||||
optional<void *> getUserPointer(int id) {
|
||||
std::lock_guard lock(mutex);
|
||||
auto it = userPointerMap.find(id);
|
||||
return it != userPointerMap.end() ? std::make_optional(it->second) : nullopt;
|
||||
@ -328,7 +327,7 @@ private:
|
||||
} // namespace
|
||||
|
||||
void rtcInitLogger(rtcLogLevel level, rtcLogCallbackFunc cb) {
|
||||
static std::optional<plogAppender> appender;
|
||||
static optional<plogAppender> appender;
|
||||
const auto severity = static_cast<plog::Severity>(level);
|
||||
std::lock_guard lock(mutex);
|
||||
if (appender) {
|
||||
@ -821,7 +820,7 @@ int rtcSetDataChannelCallback(int pc, rtcDataChannelCallbackFunc cb) {
|
||||
return wrap([&] {
|
||||
auto peerConnection = getPeerConnection(pc);
|
||||
if (cb)
|
||||
peerConnection->onDataChannel([pc, cb](std::shared_ptr<DataChannel> dataChannel) {
|
||||
peerConnection->onDataChannel([pc, cb](shared_ptr<DataChannel> dataChannel) {
|
||||
int dc = emplaceDataChannel(dataChannel);
|
||||
if (auto ptr = getUserPointer(pc)) {
|
||||
rtcSetUserPointer(dc, *ptr);
|
||||
@ -838,7 +837,7 @@ int rtcSetTrackCallback(int pc, rtcTrackCallbackFunc cb) {
|
||||
return wrap([&] {
|
||||
auto peerConnection = getPeerConnection(pc);
|
||||
if (cb)
|
||||
peerConnection->onTrack([pc, cb](std::shared_ptr<Track> track) {
|
||||
peerConnection->onTrack([pc, cb](shared_ptr<Track> track) {
|
||||
int tr = emplaceTrack(track);
|
||||
if (auto ptr = getUserPointer(pc)) {
|
||||
rtcSetUserPointer(tr, *ptr);
|
||||
|
@ -51,7 +51,7 @@ void Channel::onMessage(std::function<void(message_variant data)> callback) {
|
||||
|
||||
void Channel::onMessage(std::function<void(binary data)> binaryCallback,
|
||||
std::function<void(string data)> stringCallback) {
|
||||
onMessage([binaryCallback, stringCallback](std::variant<binary, string> data) {
|
||||
onMessage([binaryCallback, stringCallback](variant<binary, string> data) {
|
||||
std::visit(overloaded{binaryCallback, stringCallback}, std::move(data));
|
||||
});
|
||||
}
|
||||
@ -64,11 +64,11 @@ void Channel::setBufferedAmountLowThreshold(size_t amount) {
|
||||
impl()->bufferedAmountLowThreshold = amount;
|
||||
}
|
||||
|
||||
std::optional<message_variant> Channel::receive() {
|
||||
optional<message_variant> Channel::receive() {
|
||||
return impl()->receive();
|
||||
}
|
||||
|
||||
std::optional<message_variant> Channel::peek() {
|
||||
optional<message_variant> Channel::peek() {
|
||||
return impl()->peek();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ IceServer::IceServer(const string &url) {
|
||||
if (!std::regex_match(url, m, r) || m[10].length() == 0)
|
||||
throw std::invalid_argument("Invalid ICE server URL: " + url);
|
||||
|
||||
std::vector<std::optional<string>> opt(m.size());
|
||||
std::vector<optional<string>> opt(m.size());
|
||||
std::transform(m.begin(), m.end(), opt.begin(), [](const auto &sm) {
|
||||
return sm.length() > 0 ? std::make_optional(string(sm)) : nullopt;
|
||||
});
|
||||
|
@ -76,7 +76,7 @@ Description::Description(const string &sdp, Type type, Role role)
|
||||
hintType(type);
|
||||
|
||||
int index = -1;
|
||||
std::shared_ptr<Entry> current;
|
||||
shared_ptr<Entry> current;
|
||||
std::istringstream ss(sdp);
|
||||
while (ss) {
|
||||
string line;
|
||||
@ -156,11 +156,11 @@ string Description::bundleMid() const {
|
||||
return !mEntries.empty() ? mEntries[0]->mid() : "0";
|
||||
}
|
||||
|
||||
std::optional<string> Description::iceUfrag() const { return mIceUfrag; }
|
||||
optional<string> Description::iceUfrag() const { return mIceUfrag; }
|
||||
|
||||
std::optional<string> Description::icePwd() const { return mIcePwd; }
|
||||
optional<string> Description::icePwd() const { return mIcePwd; }
|
||||
|
||||
std::optional<string> Description::fingerprint() const { return mFingerprint; }
|
||||
optional<string> Description::fingerprint() const { return mFingerprint; }
|
||||
|
||||
bool Description::ended() const { return mEnded; }
|
||||
|
||||
@ -319,9 +319,9 @@ string Description::generateApplicationSdp(string_view eol) const {
|
||||
return sdp.str();
|
||||
}
|
||||
|
||||
std::optional<Candidate> Description::defaultCandidate() const {
|
||||
optional<Candidate> Description::defaultCandidate() const {
|
||||
// Return the first host candidate with highest priority, favoring IPv4
|
||||
std::optional<Candidate> result;
|
||||
optional<Candidate> result;
|
||||
for (const auto &c : mCandidates) {
|
||||
if (c.type() == Candidate::Type::Host) {
|
||||
if (!result ||
|
||||
@ -401,7 +401,7 @@ int Description::addAudio(string mid, Direction dir) {
|
||||
return addMedia(Audio(std::move(mid), dir));
|
||||
}
|
||||
|
||||
std::variant<Description::Media *, Description::Application *>
|
||||
variant<Description::Media *, Description::Application *>
|
||||
Description::media(unsigned int index) {
|
||||
if (index >= mEntries.size())
|
||||
throw std::out_of_range("Media index out of range");
|
||||
@ -420,7 +420,7 @@ Description::media(unsigned int index) {
|
||||
}
|
||||
}
|
||||
|
||||
std::variant<const Description::Media *, const Description::Application *>
|
||||
variant<const Description::Media *, const Description::Application *>
|
||||
Description::media(unsigned int index) const {
|
||||
if (index >= mEntries.size())
|
||||
throw std::out_of_range("Media index out of range");
|
||||
@ -523,8 +523,8 @@ Description::Entry::removeAttribute(std::vector<string>::iterator it) {
|
||||
return mAttributes.erase(it);
|
||||
}
|
||||
|
||||
void Description::Media::addSSRC(uint32_t ssrc, std::optional<string> name,
|
||||
std::optional<string> msid, std::optional<string> trackID) {
|
||||
void Description::Media::addSSRC(uint32_t ssrc, optional<string> name,
|
||||
optional<string> msid, optional<string> trackID) {
|
||||
if (name)
|
||||
mAttributes.emplace_back("ssrc:" + std::to_string(ssrc) + " cname:" + *name);
|
||||
else
|
||||
@ -536,8 +536,8 @@ void Description::Media::addSSRC(uint32_t ssrc, std::optional<string> name,
|
||||
mSsrcs.emplace_back(ssrc);
|
||||
}
|
||||
|
||||
void Description::Media::replaceSSRC(uint32_t oldSSRC, uint32_t ssrc, std::optional<string> name,
|
||||
std::optional<string> msid, std::optional<string> trackID) {
|
||||
void Description::Media::replaceSSRC(uint32_t oldSSRC, uint32_t ssrc, optional<string> name,
|
||||
optional<string> msid, optional<string> trackID) {
|
||||
auto it = mAttributes.begin();
|
||||
while (it != mAttributes.end()) {
|
||||
if (it->find("ssrc:" + std::to_string(oldSSRC)) == 0) {
|
||||
@ -709,7 +709,7 @@ void Description::Media::removeFormat(const string &fmt) {
|
||||
}
|
||||
|
||||
void Description::Video::addVideoCodec(int payloadType, string codec,
|
||||
std::optional<string> profile) {
|
||||
optional<string> profile) {
|
||||
RTPMap map(std::to_string(payloadType) + ' ' + codec + "/90000");
|
||||
map.addFB("nack");
|
||||
map.addFB("nack pli");
|
||||
@ -734,7 +734,7 @@ void Description::Video::addVideoCodec(int payloadType, string codec,
|
||||
}
|
||||
|
||||
void Description::Audio::addAudioCodec(int payloadType, string codec,
|
||||
std::optional<string> profile) {
|
||||
optional<string> profile) {
|
||||
// TODO This 48000/2 should be parameterized
|
||||
RTPMap map(std::to_string(payloadType) + ' ' + codec + "/48000/2");
|
||||
if (profile)
|
||||
@ -749,7 +749,7 @@ void Description::Media::addRTXCodec(unsigned int payloadType, unsigned int orig
|
||||
addRTPMap(map);
|
||||
}
|
||||
|
||||
void Description::Video::addH264Codec(int pt, std::optional<string> profile) {
|
||||
void Description::Video::addH264Codec(int pt, optional<string> profile) {
|
||||
addVideoCodec(pt, "H264", profile);
|
||||
}
|
||||
|
||||
@ -912,7 +912,7 @@ void Description::Media::RTPMap::setMLine(string_view mline) {
|
||||
Description::Audio::Audio(string mid, Direction dir)
|
||||
: Media("audio 9 UDP/TLS/RTP/SAVPF", std::move(mid), dir) {}
|
||||
|
||||
void Description::Audio::addOpusCodec(int payloadType, std::optional<string> profile) {
|
||||
void Description::Audio::addOpusCodec(int payloadType, optional<string> profile) {
|
||||
addAudioCodec(payloadType, "OPUS", profile);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
H264PacketizationHandler::H264PacketizationHandler(std::shared_ptr<H264RtpPacketizer> packetizer): MediaChainableHandler(packetizer) { }
|
||||
H264PacketizationHandler::H264PacketizationHandler(shared_ptr<H264RtpPacketizer> packetizer): MediaChainableHandler(packetizer) { }
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
|
@ -128,11 +128,11 @@ shared_ptr<NalUnits> H264RtpPacketizer::splitMessage(binary_ptr message) {
|
||||
return nalus;
|
||||
}
|
||||
|
||||
H264RtpPacketizer::H264RtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
H264RtpPacketizer::H264RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
uint16_t maximumFragmentSize)
|
||||
: RtpPacketizer(rtpConfig), MediaHandlerRootElement(), maximumFragmentSize(maximumFragmentSize), separator(Separator::Length) {}
|
||||
|
||||
H264RtpPacketizer::H264RtpPacketizer(H264RtpPacketizer::Separator separator, std::shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
H264RtpPacketizer::H264RtpPacketizer(H264RtpPacketizer::Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
|
||||
uint16_t maximumFragmentSize)
|
||||
: RtpPacketizer(rtpConfig), MediaHandlerRootElement(), maximumFragmentSize(maximumFragmentSize), separator(separator) {}
|
||||
|
||||
|
@ -53,7 +53,7 @@ Certificate::Certificate(string crt_pem, string key_pem)
|
||||
gnutls_free(crt_list);
|
||||
};
|
||||
|
||||
std::unique_ptr<gnutls_x509_crt_t, decltype(free_crt_list)> crt_list(new_crt_list(),
|
||||
unique_ptr<gnutls_x509_crt_t, decltype(free_crt_list)> crt_list(new_crt_list(),
|
||||
free_crt_list);
|
||||
|
||||
mFingerprint = make_fingerprint(*crt_list);
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
Certificate(gnutls_x509_crt_t crt, gnutls_x509_privkey_t privkey);
|
||||
gnutls_certificate_credentials_t credentials() const;
|
||||
#else
|
||||
Certificate(std::shared_ptr<X509> x509, std::shared_ptr<EVP_PKEY> pkey);
|
||||
Certificate(shared_ptr<X509> x509, shared_ptr<EVP_PKEY> pkey);
|
||||
std::tuple<X509 *, EVP_PKEY *> credentials() const;
|
||||
#endif
|
||||
|
||||
@ -43,10 +43,10 @@ public:
|
||||
|
||||
private:
|
||||
#if USE_GNUTLS
|
||||
std::shared_ptr<gnutls_certificate_credentials_t> mCredentials;
|
||||
shared_ptr<gnutls_certificate_credentials_t> mCredentials;
|
||||
#else
|
||||
std::shared_ptr<X509> mX509;
|
||||
std::shared_ptr<EVP_PKEY> mPKey;
|
||||
shared_ptr<X509> mX509;
|
||||
shared_ptr<EVP_PKEY> mPKey;
|
||||
#endif
|
||||
|
||||
string mFingerprint;
|
||||
@ -58,7 +58,7 @@ string make_fingerprint(gnutls_x509_crt_t crt);
|
||||
string make_fingerprint(X509 *x509);
|
||||
#endif
|
||||
|
||||
using certificate_ptr = std::shared_ptr<Certificate>;
|
||||
using certificate_ptr = shared_ptr<Certificate>;
|
||||
using future_certificate_ptr = std::shared_future<certificate_ptr>;
|
||||
|
||||
future_certificate_ptr make_certificate(string commonName = "libdatachannel"); // cached
|
||||
|
@ -24,13 +24,12 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc::impl {
|
||||
|
||||
struct Channel {
|
||||
virtual std::optional<message_variant> receive() = 0;
|
||||
virtual std::optional<message_variant> peek() = 0;
|
||||
virtual optional<message_variant> receive() = 0;
|
||||
virtual optional<message_variant> peek() = 0;
|
||||
virtual size_t availableAmount() const = 0;
|
||||
|
||||
virtual void triggerOpen();
|
||||
|
@ -88,7 +88,7 @@ DataChannel::DataChannel(weak_ptr<PeerConnection> pc, uint16_t stream, string la
|
||||
DataChannel::~DataChannel() { close(); }
|
||||
|
||||
void DataChannel::close() {
|
||||
std::shared_ptr<SctpTransport> transport;
|
||||
shared_ptr<SctpTransport> transport;
|
||||
{
|
||||
std::shared_lock lock(mMutex);
|
||||
transport = mSctpTransport.lock();
|
||||
@ -108,7 +108,7 @@ void DataChannel::remoteClose() {
|
||||
mIsOpen = false;
|
||||
}
|
||||
|
||||
std::optional<message_variant> DataChannel::receive() {
|
||||
optional<message_variant> DataChannel::receive() {
|
||||
while (auto next = mRecvQueue.tryPop()) {
|
||||
message_ptr message = *next;
|
||||
if (message->type != Message::Control)
|
||||
@ -122,7 +122,7 @@ std::optional<message_variant> DataChannel::receive() {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
std::optional<message_variant> DataChannel::peek() {
|
||||
optional<message_variant> DataChannel::peek() {
|
||||
while (auto next = mRecvQueue.peek()) {
|
||||
message_ptr message = *next;
|
||||
if (message->type != Message::Control)
|
||||
@ -196,7 +196,7 @@ void DataChannel::processOpenMessage(message_ptr) {
|
||||
}
|
||||
|
||||
bool DataChannel::outgoing(message_ptr message) {
|
||||
std::shared_ptr<SctpTransport> transport;
|
||||
shared_ptr<SctpTransport> transport;
|
||||
{
|
||||
std::shared_lock lock(mMutex);
|
||||
transport = mSctpTransport.lock();
|
||||
@ -255,12 +255,12 @@ void DataChannel::incoming(message_ptr message) {
|
||||
}
|
||||
}
|
||||
|
||||
NegotiatedDataChannel::NegotiatedDataChannel(std::weak_ptr<PeerConnection> pc, uint16_t stream,
|
||||
NegotiatedDataChannel::NegotiatedDataChannel(weak_ptr<PeerConnection> pc, uint16_t stream,
|
||||
string label, string protocol, Reliability reliability)
|
||||
: DataChannel(pc, stream, std::move(label), std::move(protocol), std::move(reliability)) {}
|
||||
|
||||
NegotiatedDataChannel::NegotiatedDataChannel(std::weak_ptr<PeerConnection> pc,
|
||||
std::weak_ptr<SctpTransport> transport,
|
||||
NegotiatedDataChannel::NegotiatedDataChannel(weak_ptr<PeerConnection> pc,
|
||||
weak_ptr<SctpTransport> transport,
|
||||
uint16_t stream)
|
||||
: DataChannel(pc, stream, "", "", {}) {
|
||||
mSctpTransport = transport;
|
||||
|
@ -43,8 +43,8 @@ struct DataChannel : Channel, std::enable_shared_from_this<DataChannel> {
|
||||
bool outgoing(message_ptr message);
|
||||
void incoming(message_ptr message);
|
||||
|
||||
std::optional<message_variant> receive() override;
|
||||
std::optional<message_variant> peek() override;
|
||||
optional<message_variant> receive() override;
|
||||
optional<message_variant> peek() override;
|
||||
size_t availableAmount() const override;
|
||||
|
||||
uint16_t stream() const;
|
||||
|
@ -56,9 +56,9 @@ void DtlsSrtpTransport::Init() { srtp_init(); }
|
||||
|
||||
void DtlsSrtpTransport::Cleanup() { srtp_shutdown(); }
|
||||
|
||||
DtlsSrtpTransport::DtlsSrtpTransport(std::shared_ptr<IceTransport> lower,
|
||||
DtlsSrtpTransport::DtlsSrtpTransport(shared_ptr<IceTransport> lower,
|
||||
shared_ptr<Certificate> certificate,
|
||||
std::optional<size_t> mtu,
|
||||
optional<size_t> mtu,
|
||||
verifier_callback verifierCallback,
|
||||
message_callback srtpRecvCallback,
|
||||
state_callback stateChangeCallback)
|
||||
|
@ -39,8 +39,8 @@ public:
|
||||
static void Init();
|
||||
static void Cleanup();
|
||||
|
||||
DtlsSrtpTransport(std::shared_ptr<IceTransport> lower, certificate_ptr certificate,
|
||||
std::optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
DtlsSrtpTransport(shared_ptr<IceTransport> lower, certificate_ptr certificate,
|
||||
optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
message_callback srtpRecvCallback, state_callback stateChangeCallback);
|
||||
~DtlsSrtpTransport();
|
||||
|
||||
|
@ -46,7 +46,7 @@ void DtlsTransport::Init() {
|
||||
void DtlsTransport::Cleanup() { gnutls_global_deinit(); }
|
||||
|
||||
DtlsTransport::DtlsTransport(shared_ptr<IceTransport> lower, certificate_ptr certificate,
|
||||
std::optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
state_callback stateChangeCallback)
|
||||
: Transport(lower, std::move(stateChangeCallback)), mMtu(mtu), mCertificate(certificate),
|
||||
mVerifierCallback(std::move(verifierCallback)),
|
||||
@ -314,7 +314,7 @@ void DtlsTransport::Cleanup() {
|
||||
}
|
||||
|
||||
DtlsTransport::DtlsTransport(shared_ptr<IceTransport> lower, shared_ptr<Certificate> certificate,
|
||||
std::optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
state_callback stateChangeCallback)
|
||||
: Transport(lower, std::move(stateChangeCallback)), mMtu(mtu), mCertificate(certificate),
|
||||
mVerifierCallback(std::move(verifierCallback)),
|
||||
@ -486,7 +486,7 @@ void DtlsTransport::runRecvLoop() {
|
||||
}
|
||||
|
||||
// No more messages pending, retransmit and rearm timeout if connecting
|
||||
std::optional<milliseconds> duration;
|
||||
optional<milliseconds> duration;
|
||||
if (state() == State::Connecting) {
|
||||
// Warning: This function breaks the usual return value convention
|
||||
ret = DTLSv1_handle_timeout(mSsl);
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
|
||||
using verifier_callback = std::function<bool(const std::string &fingerprint)>;
|
||||
|
||||
DtlsTransport(std::shared_ptr<IceTransport> lower, certificate_ptr certificate,
|
||||
std::optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
DtlsTransport(shared_ptr<IceTransport> lower, certificate_ptr certificate,
|
||||
optional<size_t> mtu, verifier_callback verifierCallback,
|
||||
state_callback stateChangeCallback);
|
||||
~DtlsTransport();
|
||||
|
||||
@ -57,7 +57,7 @@ protected:
|
||||
virtual void postHandshake();
|
||||
void runRecvLoop();
|
||||
|
||||
const std::optional<size_t> mMtu;
|
||||
const optional<size_t> mMtu;
|
||||
const certificate_ptr mCertificate;
|
||||
const verifier_callback mVerifierCallback;
|
||||
const bool mIsClient;
|
||||
|
@ -197,7 +197,7 @@ void IceTransport::gatherLocalCandidates(string mid) {
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<string> IceTransport::getLocalAddress() const {
|
||||
optional<string> IceTransport::getLocalAddress() const {
|
||||
char str[JUICE_MAX_ADDRESS_STRING_LEN];
|
||||
if (juice_get_selected_addresses(mAgent.get(), str, JUICE_MAX_ADDRESS_STRING_LEN, NULL, 0) ==
|
||||
0) {
|
||||
@ -205,7 +205,7 @@ std::optional<string> IceTransport::getLocalAddress() const {
|
||||
}
|
||||
return nullopt;
|
||||
}
|
||||
std::optional<string> IceTransport::getRemoteAddress() const {
|
||||
optional<string> IceTransport::getRemoteAddress() const {
|
||||
char str[JUICE_MAX_ADDRESS_STRING_LEN];
|
||||
if (juice_get_selected_addresses(mAgent.get(), NULL, 0, str, JUICE_MAX_ADDRESS_STRING_LEN) ==
|
||||
0) {
|
||||
@ -553,7 +553,7 @@ Description IceTransport::getLocalDescription(Description::Type type) const {
|
||||
g_object_set(G_OBJECT(mNiceAgent.get()), "controlling-mode",
|
||||
type == Description::Type::Offer ? TRUE : FALSE, nullptr);
|
||||
|
||||
std::unique_ptr<gchar[], void (*)(void *)> sdp(nice_agent_generate_local_sdp(mNiceAgent.get()),
|
||||
unique_ptr<gchar[], void (*)(void *)> sdp(nice_agent_generate_local_sdp(mNiceAgent.get()),
|
||||
g_free);
|
||||
|
||||
// RFC 5763: The endpoint that is the offerer MUST use the setup attribute value of
|
||||
@ -612,7 +612,7 @@ void IceTransport::gatherLocalCandidates(string mid) {
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<string> IceTransport::getLocalAddress() const {
|
||||
optional<string> IceTransport::getLocalAddress() const {
|
||||
NiceCandidate *local = nullptr;
|
||||
NiceCandidate *remote = nullptr;
|
||||
if (nice_agent_get_selected_pair(mNiceAgent.get(), mStreamId, 1, &local, &remote)) {
|
||||
@ -621,7 +621,7 @@ std::optional<string> IceTransport::getLocalAddress() const {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
std::optional<string> IceTransport::getRemoteAddress() const {
|
||||
optional<string> IceTransport::getRemoteAddress() const {
|
||||
NiceCandidate *local = nullptr;
|
||||
NiceCandidate *remote = nullptr;
|
||||
if (nice_agent_get_selected_pair(mNiceAgent.get(), mStreamId, 1, &local, &remote)) {
|
||||
|
@ -58,8 +58,8 @@ public:
|
||||
bool addRemoteCandidate(const Candidate &candidate);
|
||||
void gatherLocalCandidates(string mid);
|
||||
|
||||
std::optional<string> getLocalAddress() const;
|
||||
std::optional<string> getRemoteAddress() const;
|
||||
optional<string> getLocalAddress() const;
|
||||
optional<string> getRemoteAddress() const;
|
||||
|
||||
bool stop() override;
|
||||
bool send(message_ptr message) override; // false if dropped
|
||||
@ -85,7 +85,7 @@ private:
|
||||
gathering_state_callback mGatheringStateChangeCallback;
|
||||
|
||||
#if !USE_NICE
|
||||
std::unique_ptr<juice_agent_t, void (*)(juice_agent_t *)> mAgent;
|
||||
unique_ptr<juice_agent_t, void (*)(juice_agent_t *)> mAgent;
|
||||
|
||||
static void StateChangeCallback(juice_agent_t *agent, juice_state_t state, void *user_ptr);
|
||||
static void CandidateCallback(juice_agent_t *agent, const char *sdp, void *user_ptr);
|
||||
@ -94,8 +94,8 @@ private:
|
||||
static void LogCallback(juice_log_level_t level, const char *message);
|
||||
#else
|
||||
uint32_t mStreamId = 0;
|
||||
std::unique_ptr<NiceAgent, void (*)(gpointer)> mNiceAgent;
|
||||
std::unique_ptr<GMainLoop, void (*)(GMainLoop *)> mMainLoop;
|
||||
unique_ptr<NiceAgent, void (*)(gpointer)> mNiceAgent;
|
||||
unique_ptr<GMainLoop, void (*)(GMainLoop *)> mMainLoop;
|
||||
std::thread mMainLoopThread;
|
||||
guint mTimeoutId = 0;
|
||||
std::mutex mOutgoingMutex;
|
||||
|
@ -32,7 +32,7 @@ LogCounter &LogCounter::operator++(int) {
|
||||
if (mData->mCount++ == 0) {
|
||||
ThreadPool::Instance().schedule(
|
||||
mData->mDuration,
|
||||
[](std::weak_ptr<LogData> data) {
|
||||
[](weak_ptr<LogData> data) {
|
||||
if (auto ptr = data.lock()) {
|
||||
int countCopy;
|
||||
countCopy = ptr->mCount.exchange(0);
|
||||
|
@ -37,7 +37,7 @@ private:
|
||||
std::atomic<int> mCount = 0;
|
||||
};
|
||||
|
||||
std::shared_ptr<LogData> mData;
|
||||
shared_ptr<LogData> mData;
|
||||
|
||||
public:
|
||||
LogCounter(plog::Severity severity, const std::string &text,
|
||||
|
@ -43,8 +43,8 @@ using namespace std::placeholders;
|
||||
#if __clang__ && defined(__APPLE__)
|
||||
namespace {
|
||||
template <typename To, typename From>
|
||||
inline std::shared_ptr<To> reinterpret_pointer_cast(std::shared_ptr<From> const &ptr) noexcept {
|
||||
return std::shared_ptr<To>(ptr, reinterpret_cast<To *>(ptr.get()));
|
||||
inline shared_ptr<To> reinterpret_pointer_cast(shared_ptr<From> const &ptr) noexcept {
|
||||
return shared_ptr<To>(ptr, reinterpret_cast<To *>(ptr.get()));
|
||||
}
|
||||
} // namespace
|
||||
#else
|
||||
@ -99,12 +99,12 @@ void PeerConnection::close() {
|
||||
closeTransports();
|
||||
}
|
||||
|
||||
std::optional<Description> PeerConnection::localDescription() const {
|
||||
optional<Description> PeerConnection::localDescription() const {
|
||||
std::lock_guard lock(mLocalDescriptionMutex);
|
||||
return mLocalDescription;
|
||||
}
|
||||
|
||||
std::optional<Description> PeerConnection::remoteDescription() const {
|
||||
optional<Description> PeerConnection::remoteDescription() const {
|
||||
std::lock_guard lock(mRemoteDescriptionMutex);
|
||||
return mRemoteDescription;
|
||||
}
|
||||
@ -300,15 +300,15 @@ shared_ptr<SctpTransport> PeerConnection::initSctpTransport() {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IceTransport> PeerConnection::getIceTransport() const {
|
||||
shared_ptr<IceTransport> PeerConnection::getIceTransport() const {
|
||||
return std::atomic_load(&mIceTransport);
|
||||
}
|
||||
|
||||
std::shared_ptr<DtlsTransport> PeerConnection::getDtlsTransport() const {
|
||||
shared_ptr<DtlsTransport> PeerConnection::getDtlsTransport() const {
|
||||
return std::atomic_load(&mDtlsTransport);
|
||||
}
|
||||
|
||||
std::shared_ptr<SctpTransport> PeerConnection::getSctpTransport() const {
|
||||
shared_ptr<SctpTransport> PeerConnection::getSctpTransport() const {
|
||||
return std::atomic_load(&mSctpTransport);
|
||||
}
|
||||
|
||||
@ -484,7 +484,7 @@ void PeerConnection::forwardMedia(message_ptr message) {
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> PeerConnection::getMidFromSsrc(uint32_t ssrc) {
|
||||
optional<std::string> PeerConnection::getMidFromSsrc(uint32_t ssrc) {
|
||||
if (auto it = mMidFromSsrc.find(ssrc); it != mMidFromSsrc.end())
|
||||
return it->second;
|
||||
|
||||
@ -494,10 +494,10 @@ std::optional<std::string> PeerConnection::getMidFromSsrc(uint32_t ssrc) {
|
||||
return nullopt;
|
||||
for (unsigned int i = 0; i < mRemoteDescription->mediaCount(); ++i) {
|
||||
if (auto found = std::visit(
|
||||
rtc::overloaded{[&](Description::Application *) -> std::optional<string> {
|
||||
rtc::overloaded{[&](Description::Application *) -> optional<string> {
|
||||
return std::nullopt;
|
||||
},
|
||||
[&](Description::Media *media) -> std::optional<string> {
|
||||
[&](Description::Media *media) -> optional<string> {
|
||||
return media->hasSSRC(ssrc)
|
||||
? std::make_optional(media->mid())
|
||||
: nullopt;
|
||||
@ -515,10 +515,10 @@ std::optional<std::string> PeerConnection::getMidFromSsrc(uint32_t ssrc) {
|
||||
return nullopt;
|
||||
for (unsigned int i = 0; i < mLocalDescription->mediaCount(); ++i) {
|
||||
if (auto found = std::visit(
|
||||
rtc::overloaded{[&](Description::Application *) -> std::optional<string> {
|
||||
rtc::overloaded{[&](Description::Application *) -> optional<string> {
|
||||
return std::nullopt;
|
||||
},
|
||||
[&](Description::Media *media) -> std::optional<string> {
|
||||
[&](Description::Media *media) -> optional<string> {
|
||||
return media->hasSSRC(ssrc)
|
||||
? std::make_optional(media->mid())
|
||||
: nullopt;
|
||||
@ -641,7 +641,7 @@ void PeerConnection::remoteCloseDataChannels() {
|
||||
}
|
||||
|
||||
shared_ptr<Track> PeerConnection::emplaceTrack(Description::Media description) {
|
||||
std::shared_ptr<Track> track;
|
||||
shared_ptr<Track> track;
|
||||
if (auto it = mTracks.find(description.mid()); it != mTracks.end())
|
||||
if (track = it->second.lock(); track)
|
||||
track->setDescription(std::move(description));
|
||||
@ -949,7 +949,7 @@ void PeerConnection::triggerDataChannel(weak_ptr<DataChannel> weakDataChannel) {
|
||||
std::make_shared<rtc::DataChannel>(std::move(dataChannel)));
|
||||
}
|
||||
|
||||
void PeerConnection::triggerTrack(std::shared_ptr<Track> track) {
|
||||
void PeerConnection::triggerTrack(shared_ptr<Track> track) {
|
||||
mProcessor->enqueue(trackCallback.wrap(), std::make_shared<rtc::Track>(std::move(track)));
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "rtc/peerconnection.hpp"
|
||||
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@ -46,8 +45,8 @@ struct PeerConnection : std::enable_shared_from_this<PeerConnection> {
|
||||
|
||||
void close();
|
||||
|
||||
std::optional<Description> localDescription() const;
|
||||
std::optional<Description> remoteDescription() const;
|
||||
optional<Description> localDescription() const;
|
||||
optional<Description> remoteDescription() const;
|
||||
|
||||
shared_ptr<IceTransport> initIceTransport();
|
||||
shared_ptr<DtlsTransport> initDtlsTransport();
|
||||
@ -63,7 +62,7 @@ struct PeerConnection : std::enable_shared_from_this<PeerConnection> {
|
||||
void forwardMessage(message_ptr message);
|
||||
void forwardMedia(message_ptr message);
|
||||
void forwardBufferedAmount(uint16_t stream, size_t amount);
|
||||
std::optional<string> getMidFromSsrc(uint32_t ssrc);
|
||||
optional<string> getMidFromSsrc(uint32_t ssrc);
|
||||
|
||||
shared_ptr<DataChannel> emplaceDataChannel(Description::Role role, string label,
|
||||
DataChannelInit init);
|
||||
@ -85,7 +84,7 @@ struct PeerConnection : std::enable_shared_from_this<PeerConnection> {
|
||||
void processRemoteCandidate(Candidate candidate);
|
||||
string localBundleMid() const;
|
||||
|
||||
void triggerDataChannel(std::weak_ptr<DataChannel> weakDataChannel);
|
||||
void triggerDataChannel(weak_ptr<DataChannel> weakDataChannel);
|
||||
void triggerTrack(shared_ptr<Track> track);
|
||||
bool changeState(State newState);
|
||||
bool changeGatheringState(GatheringState newState);
|
||||
@ -114,17 +113,17 @@ private:
|
||||
const future_certificate_ptr mCertificate;
|
||||
const unique_ptr<Processor> mProcessor;
|
||||
|
||||
std::optional<Description> mLocalDescription, mRemoteDescription;
|
||||
std::optional<Description> mCurrentLocalDescription;
|
||||
optional<Description> mLocalDescription, mRemoteDescription;
|
||||
optional<Description> mCurrentLocalDescription;
|
||||
mutable std::mutex mLocalDescriptionMutex, mRemoteDescriptionMutex;
|
||||
|
||||
shared_ptr<IceTransport> mIceTransport;
|
||||
shared_ptr<DtlsTransport> mDtlsTransport;
|
||||
shared_ptr<SctpTransport> mSctpTransport;
|
||||
|
||||
std::unordered_map<uint16_t, std::weak_ptr<DataChannel>> mDataChannels; // by stream ID
|
||||
std::unordered_map<string, std::weak_ptr<Track>> mTracks; // by mid
|
||||
std::vector<std::weak_ptr<Track>> mTrackLines; // by SDP order
|
||||
std::unordered_map<uint16_t, weak_ptr<DataChannel>> mDataChannels; // by stream ID
|
||||
std::unordered_map<string, weak_ptr<Track>> mTracks; // by mid
|
||||
std::vector<weak_ptr<Track>> mTrackLines; // by SDP order
|
||||
std::shared_mutex mDataChannelsMutex, mTracksMutex;
|
||||
|
||||
std::unordered_map<uint32_t, string> mMidFromSsrc; // cache
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
|
||||
namespace rtc::impl {
|
||||
@ -44,15 +43,15 @@ public:
|
||||
size_t size() const; // elements
|
||||
size_t amount() const; // amount
|
||||
void push(T element);
|
||||
std::optional<T> pop();
|
||||
std::optional<T> tryPop();
|
||||
std::optional<T> peek();
|
||||
std::optional<T> exchange(T element);
|
||||
bool wait(const std::optional<std::chrono::milliseconds> &duration = nullopt);
|
||||
optional<T> pop();
|
||||
optional<T> tryPop();
|
||||
optional<T> peek();
|
||||
optional<T> exchange(T element);
|
||||
bool wait(const optional<std::chrono::milliseconds> &duration = nullopt);
|
||||
|
||||
private:
|
||||
void pushImpl(T element);
|
||||
std::optional<T> popImpl();
|
||||
optional<T> popImpl();
|
||||
|
||||
const size_t mLimit;
|
||||
size_t mAmount;
|
||||
@ -112,23 +111,23 @@ template <typename T> void Queue<T>::push(T element) {
|
||||
pushImpl(std::move(element));
|
||||
}
|
||||
|
||||
template <typename T> std::optional<T> Queue<T>::pop() {
|
||||
template <typename T> optional<T> Queue<T>::pop() {
|
||||
std::unique_lock lock(mMutex);
|
||||
mPopCondition.wait(lock, [this]() { return !mQueue.empty() || mStopping; });
|
||||
return popImpl();
|
||||
}
|
||||
|
||||
template <typename T> std::optional<T> Queue<T>::tryPop() {
|
||||
template <typename T> optional<T> Queue<T>::tryPop() {
|
||||
std::unique_lock lock(mMutex);
|
||||
return popImpl();
|
||||
}
|
||||
|
||||
template <typename T> std::optional<T> Queue<T>::peek() {
|
||||
template <typename T> optional<T> Queue<T>::peek() {
|
||||
std::unique_lock lock(mMutex);
|
||||
return !mQueue.empty() ? std::make_optional(mQueue.front()) : nullopt;
|
||||
}
|
||||
|
||||
template <typename T> std::optional<T> Queue<T>::exchange(T element) {
|
||||
template <typename T> optional<T> Queue<T>::exchange(T element) {
|
||||
std::unique_lock lock(mMutex);
|
||||
if (mQueue.empty())
|
||||
return nullopt;
|
||||
@ -138,7 +137,7 @@ template <typename T> std::optional<T> Queue<T>::exchange(T element) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Queue<T>::wait(const std::optional<std::chrono::milliseconds> &duration) {
|
||||
bool Queue<T>::wait(const optional<std::chrono::milliseconds> &duration) {
|
||||
std::unique_lock lock(mMutex);
|
||||
if (duration)
|
||||
mPopCondition.wait_for(lock, *duration, [this]() { return !mQueue.empty() || mStopping; });
|
||||
@ -157,12 +156,12 @@ template <typename T> void Queue<T>::pushImpl(T element) {
|
||||
mPopCondition.notify_one();
|
||||
}
|
||||
|
||||
template <typename T> std::optional<T> Queue<T>::popImpl() {
|
||||
template <typename T> optional<T> Queue<T>::popImpl() {
|
||||
if (mQueue.empty())
|
||||
return nullopt;
|
||||
|
||||
mAmount -= mAmountFunction(mQueue.front());
|
||||
std::optional<T> element{std::move(mQueue.front())};
|
||||
optional<T> element{std::move(mQueue.front())};
|
||||
mQueue.pop();
|
||||
return element;
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ void SctpTransport::Cleanup() {
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
SctpTransport::SctpTransport(std::shared_ptr<Transport> lower, uint16_t port,
|
||||
std::optional<size_t> mtu, message_callback recvCallback,
|
||||
SctpTransport::SctpTransport(shared_ptr<Transport> lower, uint16_t port,
|
||||
optional<size_t> mtu, message_callback recvCallback,
|
||||
amount_callback bufferedAmountCallback,
|
||||
state_callback stateChangeCallback)
|
||||
: Transport(lower, std::move(stateChangeCallback)), mPort(port), mPendingRecvCount(0),
|
||||
@ -773,7 +773,7 @@ size_t SctpTransport::bytesSent() { return mBytesSent; }
|
||||
|
||||
size_t SctpTransport::bytesReceived() { return mBytesReceived; }
|
||||
|
||||
std::optional<milliseconds> SctpTransport::rtt() {
|
||||
optional<milliseconds> SctpTransport::rtt() {
|
||||
if (!mSock || state() != State::Connected)
|
||||
return nullopt;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
using amount_callback = std::function<void(uint16_t streamId, size_t amount)>;
|
||||
|
||||
SctpTransport(std::shared_ptr<Transport> lower, uint16_t port, std::optional<size_t> mtu,
|
||||
SctpTransport(shared_ptr<Transport> lower, uint16_t port, optional<size_t> mtu,
|
||||
message_callback recvCallback, amount_callback bufferedAmountCallback,
|
||||
state_callback stateChangeCallback);
|
||||
~SctpTransport();
|
||||
@ -57,7 +57,7 @@ public:
|
||||
void clearStats();
|
||||
size_t bytesSent();
|
||||
size_t bytesReceived();
|
||||
std::optional<std::chrono::milliseconds> rtt();
|
||||
optional<std::chrono::milliseconds> rtt();
|
||||
|
||||
private:
|
||||
// Order seems wrong but these are the actual values
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
static void Init();
|
||||
static void Cleanup();
|
||||
|
||||
TlsTransport(std::shared_ptr<TcpTransport> lower, string host, state_callback callback);
|
||||
TlsTransport(shared_ptr<TcpTransport> lower, string host, state_callback callback);
|
||||
virtual ~TlsTransport();
|
||||
|
||||
void start() override;
|
||||
|
@ -62,14 +62,14 @@ void Track::close() {
|
||||
resetCallbacks();
|
||||
}
|
||||
|
||||
std::optional<message_variant> Track::receive() {
|
||||
optional<message_variant> Track::receive() {
|
||||
if (auto next = mRecvQueue.tryPop())
|
||||
return to_variant(std::move(**next));
|
||||
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
std::optional<message_variant> Track::peek() {
|
||||
optional<message_variant> Track::peek() {
|
||||
if (auto next = mRecvQueue.peek())
|
||||
return to_variant(std::move(**next));
|
||||
|
||||
@ -90,7 +90,7 @@ bool Track::isOpen(void) const {
|
||||
bool Track::isClosed(void) const { return mIsClosed; }
|
||||
|
||||
size_t Track::maxMessageSize() const {
|
||||
std::optional<size_t> mtu;
|
||||
optional<size_t> mtu;
|
||||
if (auto pc = mPeerConnection.lock())
|
||||
mtu = pc->config.mtu;
|
||||
|
||||
@ -157,7 +157,7 @@ bool Track::outgoing(message_ptr message) {
|
||||
|
||||
bool Track::transportSend([[maybe_unused]] message_ptr message) {
|
||||
#if RTC_ENABLE_MEDIA
|
||||
std::shared_ptr<DtlsSrtpTransport> transport;
|
||||
shared_ptr<DtlsSrtpTransport> transport;
|
||||
{
|
||||
std::shared_lock lock(mMutex);
|
||||
transport = mDtlsSrtpTransport.lock();
|
||||
@ -179,7 +179,7 @@ bool Track::transportSend([[maybe_unused]] message_ptr message) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void Track::setRtcpHandler(std::shared_ptr<MediaHandler> handler) {
|
||||
void Track::setRtcpHandler(shared_ptr<MediaHandler> handler) {
|
||||
{
|
||||
std::unique_lock lock(mMutex);
|
||||
mRtcpHandler = handler;
|
||||
@ -188,7 +188,7 @@ void Track::setRtcpHandler(std::shared_ptr<MediaHandler> handler) {
|
||||
handler->onOutgoing(std::bind(&Track::transportSend, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::shared_ptr<MediaHandler> Track::getRtcpHandler() {
|
||||
shared_ptr<MediaHandler> Track::getRtcpHandler() {
|
||||
std::shared_lock lock(mMutex);
|
||||
return mRtcpHandler;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <shared_mutex>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc::impl {
|
||||
|
||||
@ -46,8 +45,8 @@ public:
|
||||
void incoming(message_ptr message);
|
||||
bool outgoing(message_ptr message);
|
||||
|
||||
std::optional<message_variant> receive() override;
|
||||
std::optional<message_variant> peek() override;
|
||||
optional<message_variant> receive() override;
|
||||
optional<message_variant> peek() override;
|
||||
size_t availableAmount() const override;
|
||||
|
||||
bool isOpen() const;
|
||||
@ -59,11 +58,11 @@ public:
|
||||
Description::Media description() const;
|
||||
void setDescription(Description::Media description);
|
||||
|
||||
std::shared_ptr<MediaHandler> getRtcpHandler();
|
||||
shared_ptr<MediaHandler> getRtcpHandler();
|
||||
void setRtcpHandler(shared_ptr<MediaHandler> handler);
|
||||
|
||||
#if RTC_ENABLE_MEDIA
|
||||
void open(std::shared_ptr<DtlsSrtpTransport> transport);
|
||||
void open(shared_ptr<DtlsSrtpTransport> transport);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
enum class State { Disconnected, Connecting, Connected, Completed, Failed };
|
||||
using state_callback = std::function<void(State state)>;
|
||||
|
||||
Transport(std::shared_ptr<Transport> lower = nullptr, state_callback callback = nullptr)
|
||||
Transport(shared_ptr<Transport> lower = nullptr, state_callback callback = nullptr)
|
||||
: mLower(std::move(lower)), mStateChangeCallback(std::move(callback)) {}
|
||||
|
||||
virtual ~Transport() { stop(); }
|
||||
@ -90,7 +90,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Transport> mLower;
|
||||
shared_ptr<Transport> mLower;
|
||||
synchronized_callback<State> mStateChangeCallback;
|
||||
synchronized_callback<message_ptr> mRecvCallback;
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace rtc::impl {
|
||||
|
||||
class VerifiedTlsTransport final : public TlsTransport {
|
||||
public:
|
||||
VerifiedTlsTransport(std::shared_ptr<TcpTransport> lower, string host, state_callback callback);
|
||||
VerifiedTlsTransport(shared_ptr<TcpTransport> lower, string host, state_callback callback);
|
||||
~VerifiedTlsTransport();
|
||||
};
|
||||
|
||||
|
@ -119,7 +119,7 @@ bool WebSocket::isClosed() const { return state == State::Closed; }
|
||||
|
||||
size_t WebSocket::maxMessageSize() const { return DEFAULT_MAX_MESSAGE_SIZE; }
|
||||
|
||||
std::optional<message_variant> WebSocket::receive() {
|
||||
optional<message_variant> WebSocket::receive() {
|
||||
while (auto next = mRecvQueue.tryPop()) {
|
||||
message_ptr message = *next;
|
||||
if (message->type != Message::Control)
|
||||
@ -128,7 +128,7 @@ std::optional<message_variant> WebSocket::receive() {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
std::optional<message_variant> WebSocket::peek() {
|
||||
optional<message_variant> WebSocket::peek() {
|
||||
while (auto next = mRecvQueue.peek()) {
|
||||
message_ptr message = *next;
|
||||
if (message->type != Message::Control)
|
||||
@ -325,15 +325,15 @@ shared_ptr<WsTransport> WebSocket::initWsTransport() {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<TcpTransport> WebSocket::getTcpTransport() const {
|
||||
shared_ptr<TcpTransport> WebSocket::getTcpTransport() const {
|
||||
return std::atomic_load(&mTcpTransport);
|
||||
}
|
||||
|
||||
std::shared_ptr<TlsTransport> WebSocket::getTlsTransport() const {
|
||||
shared_ptr<TlsTransport> WebSocket::getTlsTransport() const {
|
||||
return std::atomic_load(&mTlsTransport);
|
||||
}
|
||||
|
||||
std::shared_ptr<WsTransport> WebSocket::getWsTransport() const {
|
||||
shared_ptr<WsTransport> WebSocket::getWsTransport() const {
|
||||
return std::atomic_load(&mWsTransport);
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,7 @@
|
||||
#include "rtc/websocket.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <variant>
|
||||
|
||||
namespace rtc::impl {
|
||||
|
||||
@ -51,8 +49,8 @@ struct WebSocket final : public Channel, public std::enable_shared_from_this<Web
|
||||
bool outgoing(message_ptr message);
|
||||
void incoming(message_ptr message);
|
||||
|
||||
std::optional<message_variant> receive() override;
|
||||
std::optional<message_variant> peek() override;
|
||||
optional<message_variant> receive() override;
|
||||
optional<message_variant> peek() override;
|
||||
size_t availableAmount() const override;
|
||||
|
||||
bool isOpen() const;
|
||||
@ -62,12 +60,12 @@ struct WebSocket final : public Channel, public std::enable_shared_from_this<Web
|
||||
bool changeState(State state);
|
||||
void remoteClose();
|
||||
|
||||
std::shared_ptr<TcpTransport> initTcpTransport();
|
||||
std::shared_ptr<TlsTransport> initTlsTransport();
|
||||
std::shared_ptr<WsTransport> initWsTransport();
|
||||
std::shared_ptr<TcpTransport> getTcpTransport() const;
|
||||
std::shared_ptr<TlsTransport> getTlsTransport() const;
|
||||
std::shared_ptr<WsTransport> getWsTransport() const;
|
||||
shared_ptr<TcpTransport> initTcpTransport();
|
||||
shared_ptr<TlsTransport> initTlsTransport();
|
||||
shared_ptr<WsTransport> initWsTransport();
|
||||
shared_ptr<TcpTransport> getTcpTransport() const;
|
||||
shared_ptr<TlsTransport> getTlsTransport() const;
|
||||
shared_ptr<WsTransport> getWsTransport() const;
|
||||
|
||||
void closeTransports();
|
||||
|
||||
@ -77,9 +75,9 @@ struct WebSocket final : public Channel, public std::enable_shared_from_this<Web
|
||||
private:
|
||||
const init_token mInitToken = Init::Token();
|
||||
|
||||
std::shared_ptr<TcpTransport> mTcpTransport;
|
||||
std::shared_ptr<TlsTransport> mTlsTransport;
|
||||
std::shared_ptr<WsTransport> mWsTransport;
|
||||
shared_ptr<TcpTransport> mTcpTransport;
|
||||
shared_ptr<TlsTransport> mTlsTransport;
|
||||
shared_ptr<WsTransport> mWsTransport;
|
||||
|
||||
string mScheme, mHost, mHostname, mService, mPath;
|
||||
|
||||
|
@ -54,7 +54,7 @@ using std::to_string;
|
||||
using random_bytes_engine =
|
||||
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, unsigned short>;
|
||||
|
||||
WsTransport::WsTransport(std::shared_ptr<Transport> lower, Configuration config,
|
||||
WsTransport::WsTransport(shared_ptr<Transport> lower, Configuration config,
|
||||
message_callback recvCallback, state_callback stateCallback)
|
||||
: Transport(lower, std::move(stateCallback)), mConfig(std::move(config)) {
|
||||
onRecv(recvCallback);
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
std::vector<string> protocols;
|
||||
};
|
||||
|
||||
WsTransport(std::shared_ptr<Transport> lower, Configuration config,
|
||||
WsTransport(shared_ptr<Transport> lower, Configuration config,
|
||||
message_callback recvCallback, state_callback stateCallback);
|
||||
~WsTransport();
|
||||
|
||||
|
@ -90,8 +90,8 @@ void doCleanup() {
|
||||
|
||||
} // namespace
|
||||
|
||||
std::weak_ptr<void> Init::Weak;
|
||||
std::shared_ptr<void> *Init::Global = nullptr;
|
||||
weak_ptr<void> Init::Weak;
|
||||
shared_ptr<void> *Init::Global = nullptr;
|
||||
bool Init::Initialized = false;
|
||||
std::recursive_mutex Init::Mutex;
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
MediaChainableHandler::MediaChainableHandler(std::shared_ptr<MediaHandlerRootElement> root): MediaHandler(), root(root), leaf(root) { }
|
||||
MediaChainableHandler::MediaChainableHandler(shared_ptr<MediaHandlerRootElement> root): MediaHandler(), root(root), leaf(root) { }
|
||||
|
||||
MediaChainableHandler::~MediaChainableHandler() {
|
||||
leaf->recursiveRemoveChain();
|
||||
@ -157,7 +157,7 @@ bool MediaChainableHandler::send(message_ptr msg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MediaChainableHandler::addToChain(std::shared_ptr<MediaHandlerElement> chainable) {
|
||||
void MediaChainableHandler::addToChain(shared_ptr<MediaHandlerElement> chainable) {
|
||||
assert(leaf);
|
||||
leaf = leaf->chainWith(chainable);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ ChainedOutgoingProduct::ChainedOutgoingProduct(ChainedMessagesProduct messages,
|
||||
ChainedIncomingProduct::ChainedIncomingProduct(ChainedMessagesProduct incoming, ChainedMessagesProduct outgoing)
|
||||
: incoming(incoming), outgoing(outgoing) { }
|
||||
|
||||
ChainedIncomingControlProduct::ChainedIncomingControlProduct(message_ptr incoming, std::optional<ChainedOutgoingProduct> outgoing)
|
||||
ChainedIncomingControlProduct::ChainedIncomingControlProduct(message_ptr incoming, optional<ChainedOutgoingProduct> outgoing)
|
||||
: incoming(incoming), outgoing(outgoing) { }
|
||||
|
||||
MediaHandlerElement::MediaHandlerElement() { }
|
||||
@ -63,7 +63,7 @@ void MediaHandlerElement::recursiveRemoveChain() {
|
||||
removeFromChain();
|
||||
}
|
||||
|
||||
std::optional<ChainedOutgoingProduct> MediaHandlerElement::processOutgoingResponse(ChainedOutgoingProduct messages) {
|
||||
optional<ChainedOutgoingProduct> MediaHandlerElement::processOutgoingResponse(ChainedOutgoingProduct messages) {
|
||||
if (messages.messages) {
|
||||
if (upstream) {
|
||||
auto msgs = upstream->formOutgoingBinaryMessage(ChainedOutgoingProduct(messages.messages, messages.control));
|
||||
@ -93,7 +93,7 @@ std::optional<ChainedOutgoingProduct> MediaHandlerElement::processOutgoingRespon
|
||||
}
|
||||
}
|
||||
|
||||
void MediaHandlerElement::prepareAndSendResponse(std::optional<ChainedOutgoingProduct> outgoing, std::function<bool (ChainedOutgoingProduct)> send) {
|
||||
void MediaHandlerElement::prepareAndSendResponse(optional<ChainedOutgoingProduct> outgoing, std::function<bool (ChainedOutgoingProduct)> send) {
|
||||
if (outgoing.has_value()) {
|
||||
auto message = outgoing.value();
|
||||
auto response = processOutgoingResponse(message);
|
||||
@ -152,7 +152,7 @@ message_ptr MediaHandlerElement::formOutgoingControlMessage(message_ptr message)
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<ChainedOutgoingProduct> MediaHandlerElement::formOutgoingBinaryMessage(ChainedOutgoingProduct product) {
|
||||
optional<ChainedOutgoingProduct> MediaHandlerElement::formOutgoingBinaryMessage(ChainedOutgoingProduct product) {
|
||||
assert(product.messages && !product.messages->empty());
|
||||
auto newProduct = processOutgoingBinaryMessage(product.messages, product.control);
|
||||
assert(!product.control || newProduct.control);
|
||||
@ -188,7 +188,7 @@ ChainedOutgoingProduct MediaHandlerElement::processOutgoingBinaryMessage(Chained
|
||||
return {messages, control};
|
||||
}
|
||||
|
||||
std::shared_ptr<MediaHandlerElement> MediaHandlerElement::chainWith(std::shared_ptr<MediaHandlerElement> upstream) {
|
||||
shared_ptr<MediaHandlerElement> MediaHandlerElement::chainWith(shared_ptr<MediaHandlerElement> upstream) {
|
||||
assert(this->upstream == nullptr);
|
||||
assert(upstream->downstream == nullptr);
|
||||
this->upstream = upstream;
|
||||
|
@ -21,7 +21,7 @@
|
||||
namespace rtc {
|
||||
|
||||
message_ptr make_message(size_t size, Message::Type type, unsigned int stream,
|
||||
std::shared_ptr<Reliability> reliability) {
|
||||
shared_ptr<Reliability> reliability) {
|
||||
auto message = std::make_shared<Message>(size, type);
|
||||
message->stream = stream;
|
||||
message->reliability = reliability;
|
||||
@ -29,7 +29,7 @@ message_ptr make_message(size_t size, Message::Type type, unsigned int stream,
|
||||
}
|
||||
|
||||
message_ptr make_message(binary &&data, Message::Type type, unsigned int stream,
|
||||
std::shared_ptr<Reliability> reliability) {
|
||||
shared_ptr<Reliability> reliability) {
|
||||
auto message = std::make_shared<Message>(std::move(data), type);
|
||||
message->stream = stream;
|
||||
message->reliability = reliability;
|
||||
|
@ -36,7 +36,7 @@ NalUnitFragmentA::NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t
|
||||
copy(data.begin(), data.end(), begin() + 2);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<NalUnitFragmentA>> NalUnitFragmentA::fragmentsFrom(std::shared_ptr<NalUnit> nalu,
|
||||
std::vector<shared_ptr<NalUnitFragmentA>> NalUnitFragmentA::fragmentsFrom(shared_ptr<NalUnit> nalu,
|
||||
uint16_t maximumFragmentSize) {
|
||||
assert(nalu->size() > maximumFragmentSize);
|
||||
if (nalu->size() <= maximumFragmentSize) {
|
||||
@ -52,7 +52,7 @@ std::vector<std::shared_ptr<NalUnitFragmentA>> NalUnitFragmentA::fragmentsFrom(s
|
||||
uint8_t nri = nalu->nri() & 0x03;
|
||||
uint8_t naluType = nalu->unitType() & 0x1F;
|
||||
auto payload = nalu->payload();
|
||||
vector<std::shared_ptr<NalUnitFragmentA>> result{};
|
||||
vector<shared_ptr<NalUnitFragmentA>> result{};
|
||||
uint64_t offset = 0;
|
||||
while (offset < payload.size()) {
|
||||
vector<byte> fragmentData;
|
||||
@ -92,11 +92,11 @@ void NalUnitFragmentA::setFragmentType(FragmentType type) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<binary>> NalUnits::generateFragments(uint16_t maximumFragmentSize) {
|
||||
vector<std::shared_ptr<binary>> result{};
|
||||
std::vector<shared_ptr<binary>> NalUnits::generateFragments(uint16_t maximumFragmentSize) {
|
||||
vector<shared_ptr<binary>> result{};
|
||||
for (auto nalu : *this) {
|
||||
if (nalu->size() > maximumFragmentSize) {
|
||||
std::vector<std::shared_ptr<NalUnitFragmentA>> fragments =
|
||||
std::vector<shared_ptr<NalUnitFragmentA>> fragments =
|
||||
NalUnitFragmentA::fragmentsFrom(nalu, maximumFragmentSize);
|
||||
result.insert(result.end(), fragments.begin(), fragments.end());
|
||||
} else {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
OpusPacketizationHandler::OpusPacketizationHandler(std::shared_ptr<OpusRtpPacketizer> packetizer)
|
||||
OpusPacketizationHandler::OpusPacketizationHandler(shared_ptr<OpusRtpPacketizer> packetizer)
|
||||
: MediaChainableHandler(packetizer) { }
|
||||
|
||||
} // namespace rtc
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
OpusRtpPacketizer::OpusRtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
OpusRtpPacketizer::OpusRtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
: RtpPacketizer(rtpConfig), MediaHandlerRootElement() {}
|
||||
|
||||
binary_ptr OpusRtpPacketizer::packetize(binary_ptr payload, [[maybe_unused]] bool setMark) {
|
||||
|
@ -43,8 +43,8 @@ using namespace std::placeholders;
|
||||
#if __clang__ && defined(__APPLE__)
|
||||
namespace {
|
||||
template <typename To, typename From>
|
||||
inline std::shared_ptr<To> reinterpret_pointer_cast(std::shared_ptr<From> const &ptr) noexcept {
|
||||
return std::shared_ptr<To>(ptr, reinterpret_cast<To *>(ptr.get()));
|
||||
inline shared_ptr<To> reinterpret_pointer_cast(shared_ptr<From> const &ptr) noexcept {
|
||||
return shared_ptr<To>(ptr, reinterpret_cast<To *>(ptr.get()));
|
||||
}
|
||||
} // namespace
|
||||
#else
|
||||
@ -74,11 +74,11 @@ PeerConnection::SignalingState PeerConnection::signalingState() const {
|
||||
return impl()->signalingState;
|
||||
}
|
||||
|
||||
std::optional<Description> PeerConnection::localDescription() const {
|
||||
optional<Description> PeerConnection::localDescription() const {
|
||||
return impl()->localDescription();
|
||||
}
|
||||
|
||||
std::optional<Description> PeerConnection::remoteDescription() const {
|
||||
optional<Description> PeerConnection::remoteDescription() const {
|
||||
return impl()->remoteDescription();
|
||||
}
|
||||
|
||||
@ -250,12 +250,12 @@ void PeerConnection::addRemoteCandidate(Candidate candidate) {
|
||||
impl()->processRemoteCandidate(std::move(candidate));
|
||||
}
|
||||
|
||||
std::optional<string> PeerConnection::localAddress() const {
|
||||
optional<string> PeerConnection::localAddress() const {
|
||||
auto iceTransport = impl()->getIceTransport();
|
||||
return iceTransport ? iceTransport->getLocalAddress() : nullopt;
|
||||
}
|
||||
|
||||
std::optional<string> PeerConnection::remoteAddress() const {
|
||||
optional<string> PeerConnection::remoteAddress() const {
|
||||
auto iceTransport = impl()->getIceTransport();
|
||||
return iceTransport ? iceTransport->getRemoteAddress() : nullopt;
|
||||
}
|
||||
@ -345,7 +345,7 @@ size_t PeerConnection::bytesReceived() {
|
||||
return sctpTransport ? sctpTransport->bytesReceived() : 0;
|
||||
}
|
||||
|
||||
std::optional<std::chrono::milliseconds> PeerConnection::rtt() {
|
||||
optional<std::chrono::milliseconds> PeerConnection::rtt() {
|
||||
auto sctpTransport = impl()->getSctpTransport();
|
||||
return sctpTransport ? sctpTransport->rtt() : nullopt;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
RtcpNackResponder::Storage::Element::Element(binary_ptr packet, uint16_t sequenceNumber, std::shared_ptr<Element> next)
|
||||
RtcpNackResponder::Storage::Element::Element(binary_ptr packet, uint16_t sequenceNumber, shared_ptr<Element> next)
|
||||
: packet(packet), sequenceNumber(sequenceNumber), next(next) { }
|
||||
|
||||
unsigned RtcpNackResponder::Storage::size() { return storage.size(); }
|
||||
@ -31,7 +31,7 @@ RtcpNackResponder::Storage::Storage(unsigned _maximumSize): maximumSize(_maximum
|
||||
storage.reserve(maximumSize);
|
||||
}
|
||||
|
||||
std::optional<binary_ptr> RtcpNackResponder::Storage::get(uint16_t sequenceNumber) {
|
||||
optional<binary_ptr> RtcpNackResponder::Storage::get(uint16_t sequenceNumber) {
|
||||
auto position = storage.find(sequenceNumber);
|
||||
return position != storage.end() ? std::make_optional(storage.at(sequenceNumber)->packet) : nullopt;
|
||||
}
|
||||
@ -69,7 +69,7 @@ RtcpNackResponder::RtcpNackResponder(unsigned maxStoredPacketCount)
|
||||
: MediaHandlerElement(), storage(std::make_shared<Storage>(maxStoredPacketCount)) { }
|
||||
|
||||
ChainedIncomingControlProduct RtcpNackResponder::processIncomingControlMessage(message_ptr message) {
|
||||
std::optional<ChainedOutgoingProduct> optPackets = ChainedOutgoingProduct(nullptr);
|
||||
optional<ChainedOutgoingProduct> optPackets = ChainedOutgoingProduct(nullptr);
|
||||
auto packets = make_chained_messages_product();
|
||||
|
||||
unsigned int i = 0;
|
||||
|
@ -50,7 +50,7 @@ void RtcpSrReporter::addToReport(RTP *rtp, uint32_t rtpSize) {
|
||||
payloadOctets += rtpSize - rtp->getSize();
|
||||
}
|
||||
|
||||
RtcpSrReporter::RtcpSrReporter(std::shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
RtcpSrReporter::RtcpSrReporter(shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
: MediaHandlerElement(), rtpConfig(rtpConfig) {}
|
||||
|
||||
uint64_t RtcpSrReporter::secondsToNTP(double seconds) {
|
||||
|
@ -24,8 +24,8 @@ namespace rtc {
|
||||
|
||||
RtpPacketizationConfig::RtpPacketizationConfig(SSRC ssrc, string cname, uint8_t payloadType,
|
||||
uint32_t clockRate,
|
||||
std::optional<uint16_t> sequenceNumber,
|
||||
std::optional<uint32_t> timestamp)
|
||||
optional<uint16_t> sequenceNumber,
|
||||
optional<uint32_t> timestamp)
|
||||
: ssrc(ssrc), cname(cname), payloadType(payloadType), clockRate(clockRate) {
|
||||
assert(clockRate > 0);
|
||||
srand((unsigned)time(NULL));
|
||||
@ -43,7 +43,7 @@ RtpPacketizationConfig::RtpPacketizationConfig(SSRC ssrc, string cname, uint8_t
|
||||
}
|
||||
|
||||
void RtpPacketizationConfig::setStartTime(double startTime_s, EpochStart epochStart,
|
||||
std::optional<uint32_t> startTimestamp) {
|
||||
optional<uint32_t> startTimestamp) {
|
||||
this->_startTime_s = startTime_s + static_cast<unsigned long long>(epochStart);
|
||||
if (startTimestamp.has_value()) {
|
||||
this->_startTimestamp = startTimestamp.value();
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
RtpPacketizer::RtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
RtpPacketizer::RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
: rtpConfig(rtpConfig) {}
|
||||
|
||||
binary_ptr RtpPacketizer::packetize(std::shared_ptr<binary> payload, bool setMark) {
|
||||
binary_ptr RtpPacketizer::packetize(shared_ptr<binary> payload, bool setMark) {
|
||||
auto msg = std::make_shared<binary>(rtpHeaderSize + payload->size());
|
||||
auto *rtp = (RTP *)msg->data();
|
||||
rtp->setPayloadType(rtpConfig->payloadType);
|
||||
|
@ -50,7 +50,7 @@ size_t Track::maxMessageSize() const {
|
||||
return impl()->maxMessageSize();
|
||||
}
|
||||
|
||||
void Track::setRtcpHandler(std::shared_ptr<MediaHandler> handler) {
|
||||
void Track::setRtcpHandler(shared_ptr<MediaHandler> handler) {
|
||||
impl()->setRtcpHandler(std::move(handler));
|
||||
}
|
||||
|
||||
@ -61,6 +61,6 @@ bool Track::requestKeyframe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<MediaHandler> Track::getRtcpHandler() { return impl()->getRtcpHandler(); }
|
||||
shared_ptr<MediaHandler> Track::getRtcpHandler() { return impl()->getRtcpHandler(); }
|
||||
|
||||
} // namespace rtc
|
||||
|
Reference in New Issue
Block a user