Skip to content

Commit 6ffb101

Browse files
committed
Updated to live555 2025.09.17
2025.09.17: - The previous release was not quite correct. This fixes it. 2025.09.16: - Fixed an issue in the "decodeURL()" function in "RTSPCommon.cpp" that was supposedly causing a crash when run in Windows. (Thanks to Eric Beuque for the report.) 2025.07.19: - Fixed the server handling of incoming TLS connections to close the connection if the call to "ServerTLSState::accept()" fails with an error (so that the server doesn't go into an infinite loop trying to keep handling the connection). (Thanks to Yahia Benmoussa for reporting this.) 2025.07.10: - Updated the "ClientTLSState" code to allow for the possibility of performing extra checking (e.g. on the server certificate) during the setup of a TLS connection. See the "TLSState.hh" header file for details. (Thanks to Yahia Benmoussa and Jonatahn Brady for this suggestion.) 2025.05.24: - Updated the "Makefile.tail" templates to fix a minor bug in dependencies if Makefiles are generated for the "linux-with-shared-libraries" configuration, and then make is run in parallel. (Thanks to Sergei Trofimovich for the report.) 2025.05.08: - In the "BufferedPacket" destructor (in "MultiFramedRTPSource.cpp"), explicitly replace tail recursion with iteration, in case the compiler isn't smart enough to do this. (Thanks to Eric Beuque for the report.) 2025.04.25: - Updated the "rtcp_from_spec" code to use the same (LGPL) license as the rest of the code. 2025.01.17: - In the "SRTPCryptographicContext" constructor, make sure that "fSendingROC" is initialized, to fix a potential 'reference when uninitialized' error. (Thanks to Christian Haas for reporting this.) 2024.11.28: - Updated the signature of "doEventLoop()" to match that of "triggerEvent()", by using "std::atomic_char" as the 'watch variable' type (if NO_STD_LIB is not defined) - Performed the annual update of the copyright years near the start of each file 2024.10.31: - Yet another fix to the (excrutiatingly tricky) SRTP/ROC-handling code. (Thanks to Jean-Baptiste Renou.) 2024.10.30: - Another fix to the code for SRTP streaming: Make sure that the RTCP instance's cryptographic context gets updated whenever the RTP sink's cryptographic context changes. (Thanks again to Jean-Claude Saget.) 2024.10.29: - A fix to the previous release fixing code for streaming SRTP to a new client from an ongoing stream. (Thanks again to Jean-Claude Saget.) 2024.10.24: - Another change to the code for streaming SRTP to a new client from an ongoing stream: If the ROC changes, then generate a new SDP description, but not a new stream source or RTP sink. (Thanks to Jean-Claude Saget for reporting this issue.) 2024.10.11: - Fixed another RTSP server bug in the implementation of RTP-over-TCP streaming. (Thanks again to Sangjun Park.) 2024.10.10: - Fixed a stack-use-after-return bug in the RTSP server implementation. (Thanks to Sangjun Park for reporting this.) 2024.10.09: - Fixed a RTSP server bug in the implementation of RTP-over-TCP streaming that could cause a "RTSPClientConnection" object to be accessed after it had been deleted. (Thanks to Sangjun Park for reporting this issue.) 2024.09.29: - Fixed a bug in "ProxyServerMediaSession.cpp" that could cause an 'access after free' error if the proxy server's "-V" option were used. (Thanks to Andrey Radchenko for reporting this.) 2024.09.25: - Fixed another bug in SRTP streaming from a "reuseFirstSource" stream: Make sure we use the same keying material for each client. 2024.09.24: - Removed an experimental version of "testOnDemandRTSPServer.cpp" (for streaming via SRTP) that had acceidentally been left in the previous release. 2024.09.20: - Ensure that, when streaming SRTP, any change to the server's ROC (rollover counter) gets sent to the RTSP client (in the SDP description), if it joins an ongoing stream. (Thanks to Yahia Benmoussa for reporting this issue.) 2024.08.01: - Updated "ServerMediaSession::generateSDPDescription()" to treat "time_t" as (long long). (Thanks to Godmar for reporting this.) 2024.06.26: - Updated the "OnDemandServerMediaSubsession" implementation to output an error message if the "sink->startPlaying()" call failed (e.g., due to its source not being compatible with the sink). This makes some common errors (e.g, a proper 'framer' not being used) easier to detect. 2024.05.30: - Fixed a mistake that caused the config file "config.raspberrypi" to not appear in the distribution. (It's there now.) 2024.05.15: - Added a new config file "config.raspberrypi" that is known to work for building the code on/for a Raspberry Pi 5. 2024.05.05: - Updated "QuickTimeFileSink" to add support for recording H.265 video streams. (This is not fully working yet; it appears to have some bugs.) 2024.04.19: - Updated "MPEG2TransportStreamFramer" to ignore big jumps (2x or more) in the estimate for the duration of each Transport packet. This is likely caused by an unexpected jump in the PCR (not indicated by "discontinuity_indicator"). (This is in response to a report from Andy Hawkins.) 2024.04.14: - Added constant strings and ints to each library that allow you to get the library version at runtime, rather than just at compile time. For example, for the "liveMedia" library, these are: extern char const* const liveMediaLibraryVersionStr; extern int const liveMediaLibraryVersionInt; (Thanks to Paul Westlund for this suggestion.) 2024.03.08: - Changed "ServerTLSState::setup()" (in "TLSState.cpp") to call "SSL_CTX_use_certificate_chain_file()" instead of "SSL_CTX_use_certificate_file()", to allow the server operator to specify a chain of certificates, rather than just one. (Thanks to Raphael Schlarb for this suggestion.) 2024.02.28: - Updated the code for "dateHeader()" (in "RTSPCommon.cpp") to avoid using "strftime()", because that can produce a localized date string that violates the RTSP specification (which uses section 3.3.1 of RFC 2068 (the HTTP/1.1 specification) to define the "Date:" header). (Thanks to Lauri Nurmi for reporting the problem, and providing a patch.) 2024.02.23: - Updated the code for "dateHeader()" (in "RTSPCommon.cpp") to use "NULL" instead of "nullptr"; the latter was causing compilation problems for someone. 2024.02.15: - Updated the RTCP implementation so that reception stats for a SSRC are no longer deleted, even if a SSRC is reaped due to RTCP inactivity (no RTCP "SR" reports received recently). 2023.11.30: - In the implementation of the "MPEGVideoStreamFramer" class, gave "TimeCode::operator==()" the "const" qualifier, to make some compilers happy. (Thanks to Dmitry Bely for the report) - Performed the annual update of the copyright years near the start of each file 2023.11.08: - Changed the signature to the virtual function "getRTPSinkandRTCP()" (in "ServerMediaSubession", and its subclasses "OnDemandServerMediaSession" and "PassiveServerMediaSubsession") to make its 'result' arguments "rtpSink" and "rtcp" no longer "const *". There was no real reason to make those "const *". (Thanks to Andy Hawkins for prompting this.) 2023.11.07: - In the class "GenericMediaServer", made the variables "fServerMediaSessions", "fClientConnections", and "fClientSessions" 'protected' rather than 'private', to allow subclasses to access them if desired. 2023.10.30: - Fixed a bug in "deleteEventTrigger()" that had accidentally been introduced during the change to 'event trigger' implementation back in June. (Thanks to Jörg Dommaschk for reporting this.) 2023.07.24: - Updated the event trigger implementation once again, to allow for the possibility of developers redefining MAX_NUM_EVENT_TRIGGERS (it must always be <= the number of bits in an "EventTriggerId", though. (Thanks to Jan Rørgaard Hansen for this suggestion.) 2023.06.20: - Updated the event trigger implementation again - in the case where "NO_STD_LIB" is defined. In this case, "fTriggersAwaitingHandling" is implemented as an array of "Boolean volatile"s, rather than as a 32-bit bitmap. This should make 'race conditions' less likely even if "NO_STD_LIB" is defined (though you should use the preferred, default implementation - that uses an array of "std::atomic_flag"s - if possible). 2023.06.16: - Changed the (default) implementation of 'event triggers' in "BasicTaskScheduler" to implement "fTriggersAwaitingHandling" using "std:atomic_flag"s, rather than as a bitmap. This should overcome 'race conditions' that some users experienced when calling "triggerEvent()" from a non-LIVE555 thread. (Thanks to Jan Rørgaard Hansen for reporting this issue.) Note that this is the first time the LIVE555 code has required the C++ standard library. (If you cannot use the C++ standard library, then you can compile the code - but getting the old behavior - by defining "NO_STD_LIB".) - Minor change to "RTSPCommon.cpp" to overcome a compilation error in XCode on Mac OS X. 2023.06.14: - Fixed a bug in the Matroska file parsing code that could sometimes cause a 'use after free' error. (Thanks to Meng Ruijie, Martin Mirchev, and "jerry testing" for reporting this.) 2023.06.10: - Minor change to "GroupsockHelper.cpp" to overcome a compilation error in XCode on Mac OS X. 2023.06.08: - Updated the "dateHeader()" function in "RTSPCommon.cpp" to use "gmtime_r()" instead of the older, non-thread-safe "gmtime()". (Thanks to Russell Greene for the patch.) 2023.05.10: - Fixed a minor memory leak in the "RTSPServer" code. (Thanks to Zhudong Jie for reporting this.) 2023.03.30: - Calls to "send()" and "sendto()" now explicitly take "MSG_NOSIGNAL" rather than 0 as the 'flags' parameter. In most systems, 0 seems to work, but apparently not in Debian Linux. (Thanks to Eric Beuque for reporting this.) 2023.01.19: - By default, we no longer compile "groupsock/NetAddress.cpp" for Windows to use "gethostbyname()", because of a report that this breaks IPv6 name resolution. (From now on, if you still want to use "gethostbyname()" for Windows, edit the "win32config" file before running "genWindowsMakefiles".) 2023.01.11: - Updated the "BasicTaskScheduler"/"DelayQueue" implementation to make the 'token counter' a field of the task scheduler object, rather than having it be a static variable. This avoids potential problems if an application uses more than one thread (with each thread having its own task scheduler). (Thanks to Jan Rørgaard Hansen for reporting this issue.) - Performed the annual update of the copyright years near the start of each file 2022.12.01: - Yet another fix to the previous fix for RTSP-over-HTTP streaming. 2022.11.30: - The previous version's fix to "RTSPClient" (for RTSP-over-HTTP streaming) was incomplete. This should fix it for real. 2022.11.29: - Fixed a bug in "RTSPClient" that would cause RTSP-over-HTTP streaming over TLS to sometimes fail. (Thanks to Johannes Gajdosik for reporting this.) - Fixed a bug that would cause a RTSP server to use an incorrect URL if it accepted connections via TLS, but *without* streaming SRTP. 2022.11.19: - Added a new global variable "ReceivingInterfaceAddr6" (analogous to the existing variable "ReceivingInterfaceAddr" for IPv4) to allow applications to optionally change the default receiving address for IPv6. (Thanks to Yahia Benmoussa for the patch.) 2022.10.01: - Updated the previous revision so that the virtual function "specialHandlingOfAuthenticationFailure()" is now called only if there is an actual authentication failure - not on the first time that we send back a "401 Unauthorized" response. 2022.09.30: - Added a new virtual function "specialHandlingOfAuthenticationFailure()" to "RTSPServer" to allow a subclassed "RTSPServer" to take special action (e.g., statistics logging) whenever an authentication failure occurs. (By default, the function does nothing.) (Thanks to Joerg Dommaschk for this suggestion.) 2022.07.14: - (This does not change the code at all.) We now use SHA-1 rather than MD5 to hash the latest tarball of our code (as SHA-1 is considered a more secure hash than MD5). 2022.06.16: - Both our RTSP client and RTSP server implementations now support (optional) RTSP-over-HTTPS streaming, when RTSP-over-TLS would otherwise be available. (This does not apply to a RTSP server that streams SRTP/SRTCP. In that case, sending SRTP/SRTCP over a TLS connection would add unnecessary overhead, so is not supported.) 2022.06.14: - Added optional support (via #ifdefs) to the "testOnDemandRTSPServer" demo application for streaming via RTSPS (RTSP-over-TLS) and optionally SRTP (encrypted RTP/RTCP). To use this, you would need to define SERVER_USE_TLS, and PATHNAME_TO_CERTIFICATE_FILE and PATHNAME_TO_PRIVATE_KEY_FILE. 2022.04.26: - A minor update to the previous release, to ensure that we don't call "delete[]" on an uninitialized pointer. 2022.04.25: - Updated "RTSPClient" so that it can optionally include a "Require:" header in RTSP commands. (See the definition of "setRequireValue()" in "include/RTSPClient.hh") (Thanks to Gregory Chiapa from Thales Group for suggesting this.) 2022.04.15: - Fixed a "fprintf()" argument-order-evaluation bug in the "mikeyParse" demo application. (Thanks to Taeho Kim for reporting this.) 2022.04.12: - Updated the "openRTSP" application (RTSP command-line client) to add an option '-L', meaning: receive only an "application" (e.g., 'metadata') track, if present, outputting the data to 'stdout'. (This is analogous to the existing '-a' and '-v' options, for receiving only audio or video.)
1 parent fab62ee commit 6ffb101

458 files changed

Lines changed: 2373 additions & 847 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BasicUsageEnvironment/BasicHashTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Hash Table implementation
1818
// Implementation
1919

BasicUsageEnvironment/BasicTaskScheduler.cpp

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Usage Environment: for a simple, non-scripted, console application
1818
// Implementation
1919

@@ -177,35 +177,32 @@ void BasicTaskScheduler::SingleStep(unsigned maxDelayTime) {
177177

178178
// Also handle any newly-triggered event (Note that we do this *after* calling a socket handler,
179179
// in case the triggered event handler modifies The set of readable sockets.)
180-
if (fTriggersAwaitingHandling != 0) {
181-
if (fTriggersAwaitingHandling == fLastUsedTriggerMask) {
182-
// Common-case optimization for a single event trigger:
183-
fTriggersAwaitingHandling &=~ fLastUsedTriggerMask;
184-
if (fTriggeredEventHandlers[fLastUsedTriggerNum] != NULL) {
185-
(*fTriggeredEventHandlers[fLastUsedTriggerNum])(fTriggeredEventClientDatas[fLastUsedTriggerNum]);
186-
}
187-
} else {
188-
// Look for an event trigger that needs handling (making sure that we make forward progress through all possible triggers):
189-
unsigned i = fLastUsedTriggerNum;
190-
EventTriggerId mask = fLastUsedTriggerMask;
191-
192-
do {
193-
i = (i+1)%MAX_NUM_EVENT_TRIGGERS;
194-
mask >>= 1;
195-
if (mask == 0) mask = 0x80000000;
196-
197-
if ((fTriggersAwaitingHandling&mask) != 0) {
198-
fTriggersAwaitingHandling &=~ mask;
199-
if (fTriggeredEventHandlers[i] != NULL) {
200-
(*fTriggeredEventHandlers[i])(fTriggeredEventClientDatas[i]);
201-
}
202-
203-
fLastUsedTriggerMask = mask;
204-
fLastUsedTriggerNum = i;
205-
break;
180+
if (fEventTriggersAreBeingUsed) {
181+
// Look for an event trigger that needs handling (making sure that we make forward progress through all possible triggers):
182+
unsigned i = fLastUsedTriggerNum;
183+
EventTriggerId mask = fLastUsedTriggerMask;
184+
185+
do {
186+
i = (i+1)%MAX_NUM_EVENT_TRIGGERS;
187+
mask >>= 1;
188+
if (mask == 0) mask = EVENT_TRIGGER_ID_HIGH_BIT;
189+
190+
#ifndef NO_STD_LIB
191+
if (fTriggersAwaitingHandling[i].test()) {
192+
fTriggersAwaitingHandling[i].clear();
193+
#else
194+
if (fTriggersAwaitingHandling[i]) {
195+
fTriggersAwaitingHandling[i] = False;
196+
#endif
197+
if (fTriggeredEventHandlers[i] != NULL) {
198+
(*fTriggeredEventHandlers[i])(fTriggeredEventClientDatas[i]);
206199
}
207-
} while (i != fLastUsedTriggerNum);
208-
}
200+
201+
fLastUsedTriggerMask = mask;
202+
fLastUsedTriggerNum = i;
203+
break;
204+
}
205+
} while (i != fLastUsedTriggerNum);
209206
}
210207

211208
// Also handle any delayed event that may have come due.

BasicUsageEnvironment/BasicTaskScheduler0.cpp

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Usage Environment: for a simple, non-scripted, console application
1818
// Implementation
1919

@@ -25,8 +25,8 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
2525

2626
class AlarmHandler: public DelayQueueEntry {
2727
public:
28-
AlarmHandler(TaskFunc* proc, void* clientData, DelayInterval timeToDelay)
29-
: DelayQueueEntry(timeToDelay), fProc(proc), fClientData(clientData) {
28+
AlarmHandler(TaskFunc* proc, void* clientData, DelayInterval timeToDelay, intptr_t token)
29+
: DelayQueueEntry(timeToDelay, token), fProc(proc), fClientData(clientData) {
3030
}
3131

3232
private: // redefined virtual functions
@@ -44,9 +44,16 @@ class AlarmHandler: public DelayQueueEntry {
4444
////////// BasicTaskScheduler0 //////////
4545

4646
BasicTaskScheduler0::BasicTaskScheduler0()
47-
: fLastHandledSocketNum(-1), fTriggersAwaitingHandling(0), fLastUsedTriggerMask(1), fLastUsedTriggerNum(MAX_NUM_EVENT_TRIGGERS-1) {
47+
: fTokenCounter(0), fLastHandledSocketNum(-1),
48+
fLastUsedTriggerMask(1), fLastUsedTriggerNum(MAX_NUM_EVENT_TRIGGERS-1),
49+
fEventTriggersAreBeingUsed(False) {
4850
fHandlers = new HandlerSet;
4951
for (unsigned i = 0; i < MAX_NUM_EVENT_TRIGGERS; ++i) {
52+
#ifndef NO_STD_LIB
53+
fTriggersAwaitingHandling[i].clear();
54+
#else
55+
fTriggersAwaitingHandling[i] = False;
56+
#endif
5057
fTriggeredEventHandlers[i] = NULL;
5158
fTriggeredEventClientDatas[i] = NULL;
5259
}
@@ -57,11 +64,11 @@ BasicTaskScheduler0::~BasicTaskScheduler0() {
5764
}
5865

5966
TaskToken BasicTaskScheduler0::scheduleDelayedTask(int64_t microseconds,
60-
TaskFunc* proc,
61-
void* clientData) {
67+
TaskFunc* proc,
68+
void* clientData) {
6269
if (microseconds < 0) microseconds = 0;
6370
DelayInterval timeToDelay((long)(microseconds/1000000), (long)(microseconds%1000000));
64-
AlarmHandler* alarmHandler = new AlarmHandler(proc, clientData, timeToDelay);
71+
AlarmHandler* alarmHandler = new AlarmHandler(proc, clientData, timeToDelay, ++fTokenCounter);
6572
fDelayQueue.addEntry(alarmHandler);
6673

6774
return (void*)(alarmHandler->token());
@@ -73,7 +80,7 @@ void BasicTaskScheduler0::unscheduleDelayedTask(TaskToken& prevTask) {
7380
delete alarmHandler;
7481
}
7582

76-
void BasicTaskScheduler0::doEventLoop(char volatile* watchVariable) {
83+
void BasicTaskScheduler0::doEventLoop(EventLoopWatchVariable* watchVariable) {
7784
// Repeatedly loop, handling readble sockets and timed events:
7885
while (1) {
7986
if (watchVariable != NULL && *watchVariable != 0) break;
@@ -83,12 +90,12 @@ void BasicTaskScheduler0::doEventLoop(char volatile* watchVariable) {
8390

8491
EventTriggerId BasicTaskScheduler0::createEventTrigger(TaskFunc* eventHandlerProc) {
8592
unsigned i = fLastUsedTriggerNum;
86-
EventTriggerId mask = fLastUsedTriggerMask;
93+
u_int32_t mask = fLastUsedTriggerMask;
8794

8895
do {
8996
i = (i+1)%MAX_NUM_EVENT_TRIGGERS;
9097
mask >>= 1;
91-
if (mask == 0) mask = 0x80000000;
98+
if (mask == 0) mask = EVENT_TRIGGER_ID_HIGH_BIT;
9299

93100
if (fTriggeredEventHandlers[i] == NULL) {
94101
// This trigger number is free; use it:
@@ -97,6 +104,7 @@ EventTriggerId BasicTaskScheduler0::createEventTrigger(TaskFunc* eventHandlerPro
97104

98105
fLastUsedTriggerMask = mask;
99106
fLastUsedTriggerNum = i;
107+
fEventTriggersAreBeingUsed = True;
100108

101109
return mask;
102110
}
@@ -107,39 +115,43 @@ EventTriggerId BasicTaskScheduler0::createEventTrigger(TaskFunc* eventHandlerPro
107115
}
108116

109117
void BasicTaskScheduler0::deleteEventTrigger(EventTriggerId eventTriggerId) {
110-
fTriggersAwaitingHandling &=~ eventTriggerId;
118+
// "eventTriggerId" should have just one bit set.
119+
// However, we do the reasonable thing if the user happened to 'or' together two or more "EventTriggerId"s:
120+
EventTriggerId mask = EVENT_TRIGGER_ID_HIGH_BIT;
121+
Boolean eventTriggersAreBeingUsed = False;
111122

112-
if (eventTriggerId == fLastUsedTriggerMask) { // common-case optimization:
113-
fTriggeredEventHandlers[fLastUsedTriggerNum] = NULL;
114-
fTriggeredEventClientDatas[fLastUsedTriggerNum] = NULL;
115-
} else {
116-
// "eventTriggerId" should have just one bit set.
117-
// However, we do the reasonable thing if the user happened to 'or' together two or more "EventTriggerId"s:
118-
EventTriggerId mask = 0x80000000;
119-
for (unsigned i = 0; i < MAX_NUM_EVENT_TRIGGERS; ++i) {
120-
if ((eventTriggerId&mask) != 0) {
121-
fTriggeredEventHandlers[i] = NULL;
122-
fTriggeredEventClientDatas[i] = NULL;
123-
}
124-
mask >>= 1;
123+
for (unsigned i = 0; i < MAX_NUM_EVENT_TRIGGERS; ++i) {
124+
if ((eventTriggerId&mask) != 0) {
125+
#ifndef NO_STD_LIB
126+
fTriggersAwaitingHandling[i].clear();
127+
#else
128+
fTriggersAwaitingHandling[i] = False;
129+
#endif
130+
fTriggeredEventHandlers[i] = NULL;
131+
fTriggeredEventClientDatas[i] = NULL;
132+
} else if (fTriggeredEventHandlers[i] != NULL) {
133+
eventTriggersAreBeingUsed = True;
125134
}
135+
mask >>= 1;
126136
}
137+
138+
fEventTriggersAreBeingUsed = eventTriggersAreBeingUsed;
127139
}
128140

129141
void BasicTaskScheduler0::triggerEvent(EventTriggerId eventTriggerId, void* clientData) {
130142
// First, record the "clientData". (Note that we allow "eventTriggerId" to be a combination of bits for multiple events.)
131-
EventTriggerId mask = 0x80000000;
143+
EventTriggerId mask = EVENT_TRIGGER_ID_HIGH_BIT;
132144
for (unsigned i = 0; i < MAX_NUM_EVENT_TRIGGERS; ++i) {
133145
if ((eventTriggerId&mask) != 0) {
134146
fTriggeredEventClientDatas[i] = clientData;
147+
#ifndef NO_STD_LIB
148+
(void)fTriggersAwaitingHandling[i].test_and_set();
149+
#else
150+
fTriggersAwaitingHandling[i] = True;
151+
#endif
135152
}
136153
mask >>= 1;
137154
}
138-
139-
// Then, note this event as being ready to be handled.
140-
// (Note that because this function (unlike others in the library) can be called from an external thread, we do this last, to
141-
// reduce the risk of a race condition.)
142-
fTriggersAwaitingHandling |= eventTriggerId;
143155
}
144156

145157

BasicUsageEnvironment/BasicUsageEnvironment.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Usage Environment: for a simple, non-scripted, console application
1818
// Implementation
1919

2020
#include "BasicUsageEnvironment.hh"
2121
#include <stdio.h>
2222

23+
////////// library version constants //////////
24+
25+
extern char const* const BasicUsageEnvironmentLibraryVersionStr = BASICUSAGEENVIRONMENT_LIBRARY_VERSION_STRING;
26+
extern int const BasicUsageEnvironmentLibraryVersionInt = BASICUSAGEENVIRONMENT_LIBRARY_VERSION_INT;
27+
2328
////////// BasicUsageEnvironment //////////
2429

2530
#if defined(__WIN32__) || defined(_WIN32)

BasicUsageEnvironment/BasicUsageEnvironment0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Usage Environment: for a simple, non-scripted, console application
1818
// Implementation
1919

BasicUsageEnvironment/DelayQueue.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022, Live Networks, Inc. All rights reserved
16+
// Copyright (c) 1996-2025, Live Networks, Inc. All rights reserved
1717
// Help by Carlo Bonamico to get working for Windows
1818
// Delay queue
1919
// Implementation
@@ -92,12 +92,9 @@ const DelayInterval ETERNITY(INT_MAX, MILLION-1);
9292

9393
///// DelayQueueEntry /////
9494

95-
intptr_t DelayQueueEntry::tokenCounter = 0;
96-
97-
DelayQueueEntry::DelayQueueEntry(DelayInterval delay)
98-
: fDeltaTimeRemaining(delay) {
95+
DelayQueueEntry::DelayQueueEntry(DelayInterval delay, intptr_t token)
96+
: fDeltaTimeRemaining(delay), fToken(token) {
9997
fNext = fPrev = this;
100-
fToken = ++tokenCounter;
10198
}
10299

103100
DelayQueueEntry::~DelayQueueEntry() {
@@ -111,7 +108,7 @@ void DelayQueueEntry::handleTimeout() {
111108
///// DelayQueue /////
112109

113110
DelayQueue::DelayQueue()
114-
: DelayQueueEntry(ETERNITY) {
111+
: DelayQueueEntry(ETERNITY, 0) {
115112
fLastSyncTime = TimeNow();
116113
}
117114

BasicUsageEnvironment/Makefile.tail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ install1: libBasicUsageEnvironment.$(LIB_SUFFIX)
3636
install -d $(DESTDIR)$(PREFIX)/include/BasicUsageEnvironment $(DESTDIR)$(LIBDIR)
3737
install -m 644 include/*.hh $(DESTDIR)$(PREFIX)/include/BasicUsageEnvironment
3838
install -m 644 libBasicUsageEnvironment.$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)
39-
install_shared_libraries: libBasicUsageEnvironment.$(LIB_SUFFIX)
39+
install_shared_libraries: install1
4040
ln -fs $(NAME).$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)/$(NAME).$(SHORT_LIB_SUFFIX)
4141
ln -fs $(NAME).$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)/$(NAME).so
4242

BasicUsageEnvironment/include/BasicHashTable.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Hash Table implementation
1818
// C++ header
1919

BasicUsageEnvironment/include/BasicUsageEnvironment.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Usage Environment: for a simple, non-scripted, console application
1818
// C++ header
1919

BasicUsageEnvironment/include/BasicUsageEnvironment0.hh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License
1313
along with this library; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1515
**********/
16-
// Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
16+
// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
1717
// Basic Usage Environment: for a simple, non-scripted, console application
1818
// C++ header
1919

@@ -67,7 +67,12 @@ private:
6767

6868
class HandlerSet; // forward
6969

70+
// Note: You may redefine MAX_NUM_EVENT_TRIGGERS,
71+
// but it must be <= the number of bits in an "EventTriggerId"
72+
#ifndef MAX_NUM_EVENT_TRIGGERS
7073
#define MAX_NUM_EVENT_TRIGGERS 32
74+
#endif
75+
#define EVENT_TRIGGER_ID_HIGH_BIT (1 << (MAX_NUM_EVENT_TRIGGERS-1))
7176

7277
// An abstract base class, useful for subclassing
7378
// (e.g., to redefine the implementation of socket event handling)
@@ -86,7 +91,7 @@ public:
8691
void* clientData);
8792
virtual void unscheduleDelayedTask(TaskToken& prevTask);
8893

89-
virtual void doEventLoop(char volatile* watchVariable);
94+
virtual void doEventLoop(EventLoopWatchVariable* watchVariable);
9095

9196
virtual EventTriggerId createEventTrigger(TaskFunc* eventHandlerProc);
9297
virtual void deleteEventTrigger(EventTriggerId eventTriggerId);
@@ -97,18 +102,24 @@ protected:
97102

98103
protected:
99104
// To implement delayed operations:
105+
intptr_t fTokenCounter;
100106
DelayQueue fDelayQueue;
101107

102108
// To implement background reads:
103109
HandlerSet* fHandlers;
104110
int fLastHandledSocketNum;
105111

106112
// To implement event triggers:
107-
EventTriggerId volatile fTriggersAwaitingHandling; // implemented as a 32-bit bitmap
108-
EventTriggerId fLastUsedTriggerMask; // implemented as a 32-bit bitmap
113+
#ifndef NO_STD_LIB
114+
std::atomic_flag fTriggersAwaitingHandling[MAX_NUM_EVENT_TRIGGERS];
115+
#else
116+
Boolean volatile fTriggersAwaitingHandling[MAX_NUM_EVENT_TRIGGERS];
117+
#endif
118+
u_int32_t fLastUsedTriggerMask; // implemented as a 32-bit bitmap
109119
TaskFunc* fTriggeredEventHandlers[MAX_NUM_EVENT_TRIGGERS];
110120
void* fTriggeredEventClientDatas[MAX_NUM_EVENT_TRIGGERS];
111121
unsigned fLastUsedTriggerNum; // in the range [0,MAX_NUM_EVENT_TRIGGERS)
122+
Boolean fEventTriggersAreBeingUsed;
112123
};
113124

114125
#endif

0 commit comments

Comments
 (0)