Skip to content

Commit

Permalink
Bump to srt up 1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Jan 5, 2025
1 parent dd5b8ca commit 6404c30
Show file tree
Hide file tree
Showing 229 changed files with 7,304 additions and 3,660 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ Carthage/*
.vscode/
.swiftpm/

HaishinKit.xcodeproj/project.xcworkspace/xcuserdata/shogo.xcuserdatad/WorkspaceSettings.xcsettings
*.xcsettings
docs/undocumented.json
fastlane/report.xml
docs/docsets/HaishinKit.docset/Contents/Resources/Documents/undocumented.json
Vendor/SRT/OpenSSL/
Vendor/SRT/srt/
Vendor/SRT/Includes/
HaishinKit.json
SRTHaishinKit.json
SRTHaishinKit/Vendor/SRT/OpenSSL/
SRTHaishinKit/Vendor/SRT/srt/
SRTHaishinKit/Vendor/SRT/Includes/
2 changes: 1 addition & 1 deletion SRTHaishinKit/Vendor/SRT/build-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if which $(pwd)/srt >/dev/null; then
else
git clone git@github.com:Haivision/srt.git
pushd srt
git checkout refs/tags/v1.5.3
git checkout refs/tags/v1.5.4
popd
fi

2 changes: 2 additions & 0 deletions SRTHaishinKit/Vendor/SRT/build-xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE file in the root directory of this source tree.

mkdir Includes
cp -f srt/srtcore/*.h Includes
cp module.modulemap Includes/module.modulemap
cp ./build/ios/OS/version.h Includes/version.h

Expand Down
36 changes: 18 additions & 18 deletions SRTHaishinKit/Vendor/SRT/libsrt.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,23 @@
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>tvos-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>tvos</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
<string>ios</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>libsrt.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>xros-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
Expand All @@ -38,7 +35,7 @@
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<string>xros</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
Expand All @@ -48,39 +45,40 @@
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>xros-arm64</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<string>xros</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>libsrt.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>xros-arm64</string>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>xros</string>
<string>macos</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>libsrt.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>xros-arm64_x86_64-simulator</string>
<string>tvos-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
Expand All @@ -89,7 +87,7 @@
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>xros</string>
<string>tvos</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
Expand All @@ -99,32 +97,34 @@
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>tvos-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>tvos</string>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>libsrt.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<string>tvos-arm64</string>
<key>LibraryPath</key>
<string>libsrt.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
<string>tvos</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
91 changes: 81 additions & 10 deletions SRTHaishinKit/Vendor/SRT/libsrt.xcframework/ios-arm64/Headers/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ class CUDTSocket

void construct();

private:
srt::sync::atomic<int> m_iBusy;
public:
void apiAcquire() { ++m_iBusy; }
void apiRelease() { --m_iBusy; }

int isStillBusy() const
{
return m_iBusy;
}


SRT_ATTR_GUARDED_BY(m_ControlLock)
sync::atomic<SRT_SOCKSTATUS> m_Status; //< current socket state

Expand All @@ -131,7 +143,8 @@ class CUDTSocket
/// of sockets in order to prevent other methods from accessing invalid address.
/// A timer is started and the socket will be removed after approximately
/// 1 second (see CUDTUnited::checkBrokenSockets()).
sync::steady_clock::time_point m_tsClosureTimeStamp;
//sync::steady_clock::time_point m_tsClosureTimeStamp;
sync::AtomicClock<sync::steady_clock> m_tsClosureTimeStamp;

sockaddr_any m_SelfAddr; //< local address of the socket
sockaddr_any m_PeerAddr; //< peer address of the socket
Expand All @@ -151,7 +164,7 @@ class CUDTSocket
CUDT m_UDT; //< internal SRT socket logic

public:
std::set<SRTSOCKET> m_QueuedSockets; //< set of connections waiting for accept()
std::map<SRTSOCKET, sockaddr_any> m_QueuedSockets; //< set of connections waiting for accept()

sync::Condition m_AcceptCond; //< used to block "accept" call
sync::Mutex m_AcceptLock; //< mutex associated to m_AcceptCond
Expand Down Expand Up @@ -324,7 +337,7 @@ class CUDTUnited
int epoll_release(const int eid);

#if ENABLE_BONDING
// [[using locked(m_GlobControlLock)]]
SRT_ATR_NODISCARD SRT_ATTR_REQUIRES(m_GlobControlLock)
CUDTGroup& addGroup(SRTSOCKET id, SRT_GROUP_TYPE type)
{
// This only ensures that the element exists.
Expand All @@ -346,7 +359,7 @@ class CUDTUnited
void deleteGroup(CUDTGroup* g);
void deleteGroup_LOCKED(CUDTGroup* g);

// [[using locked(m_GlobControlLock)]]
SRT_ATR_NODISCARD SRT_ATTR_REQUIRES(m_GlobControlLock)
CUDTGroup* findPeerGroup_LOCKED(SRTSOCKET peergroup)
{
for (groups_t::iterator i = m_Groups.begin(); i != m_Groups.end(); ++i)
Expand Down Expand Up @@ -385,11 +398,13 @@ class CUDTUnited

private:
typedef std::map<SRTSOCKET, CUDTSocket*> sockets_t; // stores all the socket structures
sockets_t m_Sockets;
SRT_ATTR_GUARDED_BY(m_GlobControlLock)
sockets_t m_Sockets;

#if ENABLE_BONDING
typedef std::map<SRTSOCKET, CUDTGroup*> groups_t;
groups_t m_Groups;
SRT_ATTR_GUARDED_BY(m_GlobControlLock)
groups_t m_Groups;
#endif

sync::Mutex m_GlobControlLock; // used to synchronize UDT API
Expand All @@ -399,6 +414,7 @@ class CUDTUnited
SRTSOCKET m_SocketIDGenerator; // seed to generate a new unique socket ID
SRTSOCKET m_SocketIDGenerator_init; // Keeps track of the very first one

SRT_ATTR_GUARDED_BY(m_GlobControlLock)
std::map<int64_t, std::set<SRTSOCKET> >
m_PeerRec; // record sockets from peers to avoid repeated connection request, int64_t = (socker_id << 30) + isn

Expand Down Expand Up @@ -442,8 +458,56 @@ class CUDTUnited
}
}
};

#endif

CUDTSocket* locateAcquireSocket(SRTSOCKET u, ErrorHandling erh = ERH_RETURN);
bool acquireSocket(CUDTSocket* s);

public:
struct SocketKeeper
{
CUDTSocket* socket;

SocketKeeper(): socket(NULL) {}

// This is intended for API functions to lock the socket's existence
// for the lifetime of their call.
SocketKeeper(CUDTUnited& glob, SRTSOCKET id, ErrorHandling erh = ERH_RETURN) { socket = glob.locateAcquireSocket(id, erh); }

// This is intended for TSBPD thread that should lock the socket's
// existence until it exits.
SocketKeeper(CUDTUnited& glob, CUDTSocket* s)
{
acquire(glob, s);
}

// Note: acquire doesn't check if the keeper already keeps anything.
// This is only for a use together with an empty constructor.
bool acquire(CUDTUnited& glob, CUDTSocket* s)
{
if (s == NULL)
{
socket = NULL;
return false;
}

const bool caught = glob.acquireSocket(s);
socket = caught ? s : NULL;
return caught;
}

~SocketKeeper()
{
if (socket)
{
SRT_ASSERT(socket->isStillBusy() > 0);
socket->apiRelease();
}
}
};

private:

void updateMux(CUDTSocket* s, const sockaddr_any& addr, const UDPSOCKET* = NULL);
bool updateListenerMux(CUDTSocket* s, const CUDTSocket* ls);

Expand All @@ -460,26 +524,33 @@ class CUDTUnited
const sockaddr_any& reqaddr, const CSrtMuxerConfig& cfgSocket);

private:
SRT_ATTR_GUARDED_BY(m_GlobControlLock)
std::map<int, CMultiplexer> m_mMultiplexer; // UDP multiplexer
sync::Mutex m_MultiplexerLock;

private:
CCache<CInfoBlock>* m_pCache; // UDT network information cache
/// UDT network information cache.
/// Existence is guarded by m_GlobControlLock, but the cache itself is thread-safe.
SRT_ATTR_GUARDED_BY(m_GlobControlLock)
CCache<CInfoBlock>* const m_pCache;

private:
srt::sync::atomic<bool> m_bClosing;
sync::Mutex m_GCStopLock;
sync::Condition m_GCStopCond;

sync::Mutex m_InitLock;
SRT_ATTR_GUARDED_BY(m_InitLock)
int m_iInstanceCount; // number of startup() called by application
SRT_ATTR_GUARDED_BY(m_InitLock)
bool m_bGCStatus; // if the GC thread is working (true)

SRT_ATTR_GUARDED_BY(m_InitLock)
sync::CThread m_GCThread;
static void* garbageCollect(void*);

SRT_ATTR_GUARDED_BY(m_GlobControlLock)
sockets_t m_ClosedSockets; // temporarily store closed sockets
#if ENABLE_BONDING
SRT_ATTR_GUARDED_BY(m_GlobControlLock)
groups_t m_ClosedGroups;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,22 @@ class atomic {
#endif
}

T operator|=(T i) {
#if defined(ATOMIC_USE_SRT_SYNC_MUTEX) && (ATOMIC_USE_SRT_SYNC_MUTEX == 1)
ScopedLock lg_(mutex_);
const T t = value_ |= i;
return t;
#elif defined(ATOMIC_USE_GCC_INTRINSICS)
return __atomic_or_fetch(&value_, i, __ATOMIC_SEQ_CST);
#elif defined(ATOMIC_USE_MSVC_INTRINSICS)
return msvc::interlocked<T>::or_fetch(&value_, i);
#elif defined(ATOMIC_USE_CPP11_ATOMIC)
return value_ |= i;
#else
#error "Implement Me."
#endif
}

/// @brief Performs an atomic compare-and-swap (CAS) operation.
///
/// The value of the atomic object is only updated to the new value if the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ struct interlocked<T, 1> {
return static_cast<T>(_InterlockedExchange8(
reinterpret_cast<volatile char*>(x), static_cast<const char>(new_val)));
}

static inline T or_fetch(T volatile* x, const T val) {
return static_cast<T>(_InterlockedOr8(
reinterpret_cast<volatile char*>(x), static_cast<const char>(val)));
}
};

template <typename T>
Expand Down
Loading

0 comments on commit 6404c30

Please sign in to comment.