This commit is contained in:
郭佳龙 2024-03-21 16:36:26 +08:00
commit c3c24a6e2e
288 changed files with 46403 additions and 0 deletions

52
CMakeLists.txt Normal file
View File

@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.7)
set(PROJECT_NAME project)
project(${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_definitions(-DLIVEMEDIA_API=)
add_definitions(-DNO_OPENSSL=1)
# target_compile_definitions(${PROJECT_NAME} INTERFACE LIVEMEDIA_API=)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/live555/groupsock)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/live555/UsageEnvironment)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/live555/BasicUsageEnvironment)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/live555/liveMedia)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/live555/EpollTaskScheduler)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/rtcp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/rtcp/rtc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/nlohmann)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/nlohmann/detail)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/includes/nlohmann/thirdparty)
set(LIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs)
# static
# for live555
link_directories(${LIBS_PATH})
link_libraries(UsageEnvironment)
link_libraries(BasicUsageEnvironment)
link_libraries(groupsock)
link_libraries(liveMedia)
link_libraries(EpollTaskScheduler)
# sender of RTCP
link_libraries(datachannel)
link_libraries(json)
aux_source_directory(./src DIR_SRCS)
add_executable(${PROJECT_NAME} ${DIR_SRCS})
# shared
# for sender
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads)
# target_link_libraries(${PROJECT_NAME} datachannel)
target_link_libraries(${PROJECT_NAME} ws2_32)
file(COPY ${CMAKE_SOURCE_DIR}/libs/datachannel.dll DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/rtsp.json DESTINATION ${CMAKE_BINARY_DIR})

6
auto_cmake.bat Normal file
View File

@ -0,0 +1,6 @@
for /F %%i in ('cd') do ( set dir=%%i)
rmdir /s /q build
mkdir build
cmake -B build -G "NMake Makefiles" && cd ./build && nmake
cd %dir%

16
includes/getData.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _GET_RTCP
#define _GET_RTCP
#include "BasicUsageEnvironment.hh"
#include "liveMedia.hh"
typedef void(callback)(u_int8_t* data, unsigned len, const char* name);
extern int getData(int argc, char **argv);
extern void openURL(UsageEnvironment &env,
char const *progName,
u_int32_t ssrc,
char const *rtspURL,
callback* cb);
#endif

115
includes/getopt.h Normal file
View File

@ -0,0 +1,115 @@
/* Getopt for Microsoft C
This code is a modification of the Free Software Foundation, Inc.
Getopt library for parsing command line argument the purpose was
to provide a Microsoft Visual C friendly derivative. This code
provides functionality for both Unicode and Multibyte builds.
Date: 02/03/2011 - Ludvik Jerabek - Initial Release
Version: 1.0
Comment: Supports getopt, getopt_long, and getopt_long_only
and POSIXLY_CORRECT environment flag
License: LGPL
Revisions:
02/03/2011 - Ludvik Jerabek - Initial Release
02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4
07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs
08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception
08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB
02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file
08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi
10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features
06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable
24/10/2020 - Paul-Louis Ageneau - Removed Unicode version
**DISCLAIMER**
THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT
APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY
DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY
USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST
PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON
YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE
EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef __GETOPT_H_
#define __GETOPT_H_
#ifdef _GETOPT_API
#undef _GETOPT_API
#endif
#if defined(EXPORTS_GETOPT) && defined(STATIC_GETOPT)
#error "The preprocessor definitions of EXPORTS_GETOPT and STATIC_GETOPT can only be used individually"
#elif defined(STATIC_GETOPT)
#pragma message("Warning static builds of getopt violate the Lesser GNU Public License")
#define _GETOPT_API
#elif defined(EXPORTS_GETOPT)
#pragma message("Exporting getopt library")
#define _GETOPT_API __declspec(dllexport)
#else
#pragma message("Importing getopt library")
#define _GETOPT_API __declspec(dllimport)
#endif
// Change behavior for C\C++
#ifdef __cplusplus
#define _BEGIN_EXTERN_C extern "C" {
#define _END_EXTERN_C }
#define _GETOPT_THROW throw()
#else
#define _BEGIN_EXTERN_C
#define _END_EXTERN_C
#define _GETOPT_THROW
#endif
// Standard GNU options
#define null_argument 0 /*Argument Null*/
#define no_argument 0 /*Argument Switch Only*/
#define required_argument 1 /*Argument Required*/
#define optional_argument 2 /*Argument Optional*/
// Shorter Options
#define ARG_NULL 0 /*Argument Null*/
#define ARG_NONE 0 /*Argument Switch Only*/
#define ARG_REQ 1 /*Argument Required*/
#define ARG_OPT 2 /*Argument Optional*/
#include <string.h>
_BEGIN_EXTERN_C
extern _GETOPT_API int optind;
extern _GETOPT_API int opterr;
extern _GETOPT_API int optopt;
struct option_a
{
const char* name;
int has_arg;
int *flag;
int val;
};
extern _GETOPT_API char *optarg_a;
extern _GETOPT_API int getopt_a(int argc, char *const *argv, const char *optstring) _GETOPT_THROW;
extern _GETOPT_API int getopt_long_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW;
extern _GETOPT_API int getopt_long_only_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW;
_END_EXTERN_C
#undef _BEGIN_EXTERN_C
#undef _END_EXTERN_C
#undef _GETOPT_THROW
#undef _GETOPT_API
#define getopt getopt_a
#define getopt_long getopt_long_a
#define getopt_long_only getopt_long_only_a
#define option option_a
#define optarg optarg_a
#endif // __GETOPT_H_

View File

@ -0,0 +1,104 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Basic Hash Table implementation
// C++ header
#ifndef _BASIC_HASH_TABLE_HH
#define _BASIC_HASH_TABLE_HH
#ifndef _HASH_TABLE_HH
#include "HashTable.hh"
#endif
#ifndef _NET_COMMON_H
#include <NetCommon.h> // to ensure that "uintptr_t" is defined
#endif
// A simple hash table implementation, inspired by the hash table
// implementation used in Tcl 7.6: <http://www.tcl.tk/>
#define SMALL_HASH_TABLE_SIZE 4
class LIVEMEDIA_API BasicHashTable: public HashTable {
private:
class TableEntry; // forward
public:
BasicHashTable(int keyType);
virtual ~BasicHashTable();
// Used to iterate through the members of the table:
class Iterator; friend class Iterator; // to make Sun's C++ compiler happy
class Iterator: public HashTable::Iterator {
public:
Iterator(BasicHashTable const& table);
private: // implementation of inherited pure virtual functions
void* next(char const*& key); // returns 0 if none
private:
BasicHashTable const& fTable;
unsigned fNextIndex; // index of next bucket to be enumerated after this
TableEntry* fNextEntry; // next entry in the current bucket
};
private: // implementation of inherited pure virtual functions
virtual void* Add(char const* key, void* value);
// Returns the old value if different, otherwise 0
virtual Boolean Remove(char const* key);
virtual void* Lookup(char const* key) const;
// Returns 0 if not found
virtual unsigned numEntries() const;
private:
class TableEntry {
public:
TableEntry* fNext;
char const* key;
void* value;
};
TableEntry* lookupKey(char const* key, unsigned& index) const;
// returns entry matching "key", or NULL if none
Boolean keyMatches(char const* key1, char const* key2) const;
// used to implement "lookupKey()"
TableEntry* insertNewEntry(unsigned index, char const* key);
// creates a new entry, and inserts it in the table
void assignKey(TableEntry* entry, char const* key);
// used to implement "insertNewEntry()"
void deleteEntry(unsigned index, TableEntry* entry);
void deleteKey(TableEntry* entry);
// used to implement "deleteEntry()"
void rebuild(); // rebuilds the table as its size increases
unsigned hashIndexFromKey(char const* key) const;
// used to implement many of the routines above
unsigned randomIndex(uintptr_t i) const {
return (unsigned)(((i*1103515245) >> fDownShift) & fMask);
}
private:
TableEntry** fBuckets; // pointer to bucket array
TableEntry* fStaticBuckets[SMALL_HASH_TABLE_SIZE];// used for small tables
unsigned fNumBuckets, fNumEntries, fRebuildSize, fDownShift, fMask;
int fKeyType;
};
#endif

View File

@ -0,0 +1,86 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Basic Usage Environment: for a simple, non-scripted, console application
// C++ header
#ifndef _BASIC_USAGE_ENVIRONMENT_HH
#define _BASIC_USAGE_ENVIRONMENT_HH
#ifndef _BASIC_USAGE_ENVIRONMENT0_HH
#include "BasicUsageEnvironment0.hh"
#endif
class LIVEMEDIA_API BasicUsageEnvironment: public BasicUsageEnvironment0 {
public:
static BasicUsageEnvironment* createNew(TaskScheduler& taskScheduler);
// redefined virtual functions:
virtual int getErrno() const;
virtual UsageEnvironment& operator<<(char const* str);
virtual UsageEnvironment& operator<<(int i);
virtual UsageEnvironment& operator<<(unsigned u);
virtual UsageEnvironment& operator<<(double d);
virtual UsageEnvironment& operator<<(void* p);
protected:
BasicUsageEnvironment(TaskScheduler& taskScheduler);
// called only by "createNew()" (or subclass constructors)
virtual ~BasicUsageEnvironment();
};
class LIVEMEDIA_API BasicTaskScheduler: public BasicTaskScheduler0 {
public:
static BasicTaskScheduler* createNew(unsigned maxSchedulerGranularity = 10000/*microseconds*/);
// "maxSchedulerGranularity" (default value: 10 ms) specifies the maximum time that we wait (in "select()") before
// returning to the event loop to handle non-socket or non-timer-based events, such as 'triggered events'.
// You can change this is you wish (but only if you know what you're doing!), or set it to 0, to specify no such maximum time.
// (You should set it to 0 only if you know that you will not be using 'event triggers'.)
virtual ~BasicTaskScheduler();
protected:
BasicTaskScheduler(unsigned maxSchedulerGranularity);
// called only by "createNew()"
static void schedulerTickTask(void* clientData);
void schedulerTickTask();
protected:
// Redefined virtual functions:
virtual void SingleStep(unsigned maxDelayTime);
virtual void setBackgroundHandling(int socketNum, int conditionSet, BackgroundHandlerProc* handlerProc, void* clientData);
virtual void moveSocketHandling(int oldSocketNum, int newSocketNum);
protected:
unsigned fMaxSchedulerGranularity;
// To implement background operations:
int fMaxNumSockets;
fd_set fReadSet;
fd_set fWriteSet;
fd_set fExceptionSet;
private:
#if defined(__WIN32__) || defined(_WIN32)
// Hack to work around a bug in Windows' "select()" implementation:
int fDummySocketNum;
#endif
};
#endif

View File

@ -0,0 +1,131 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Basic Usage Environment: for a simple, non-scripted, console application
// C++ header
#ifndef _BASIC_USAGE_ENVIRONMENT0_HH
#define _BASIC_USAGE_ENVIRONMENT0_HH
#ifndef _BASICUSAGEENVIRONMENT_VERSION_HH
#include "BasicUsageEnvironment_version.hh"
#endif
#ifndef _USAGE_ENVIRONMENT_HH
#include "UsageEnvironment.hh"
#endif
#ifndef _DELAY_QUEUE_HH
#include "DelayQueue.hh"
#endif
#ifndef NO_STD_LIB
#ifndef _LIBCPP_ATOMIC
#include <atomic>
#endif
#endif
#define RESULT_MSG_BUFFER_MAX 1000
// An abstract base class, useful for subclassing
// (e.g., to redefine the implementation of "operator<<")
class LIVEMEDIA_API BasicUsageEnvironment0: public UsageEnvironment {
public:
// redefined virtual functions:
virtual MsgString getResultMsg() const;
virtual void setResultMsg(MsgString msg);
virtual void setResultMsg(MsgString msg1,
MsgString msg2);
virtual void setResultMsg(MsgString msg1,
MsgString msg2,
MsgString msg3);
virtual void setResultErrMsg(MsgString msg, int err = 0);
virtual void appendToResultMsg(MsgString msg);
virtual void reportBackgroundError();
protected:
BasicUsageEnvironment0(TaskScheduler& taskScheduler);
virtual ~BasicUsageEnvironment0();
private:
void reset();
char fResultMsgBuffer[RESULT_MSG_BUFFER_MAX];
unsigned fCurBufferSize;
unsigned fBufferMaxSize;
};
class HandlerSet; // forward
// Note: You may redefine MAX_NUM_EVENT_TRIGGERS,
// but it must be <= the number of bits in an "EventTriggerId"
#ifndef MAX_NUM_EVENT_TRIGGERS
#define MAX_NUM_EVENT_TRIGGERS 32
#endif
#define EVENT_TRIGGER_ID_HIGH_BIT (1 << (MAX_NUM_EVENT_TRIGGERS-1))
// An abstract base class, useful for subclassing
// (e.g., to redefine the implementation of socket event handling)
class LIVEMEDIA_API BasicTaskScheduler0: public TaskScheduler {
public:
virtual ~BasicTaskScheduler0();
virtual void SingleStep(unsigned maxDelayTime = 0) = 0;
// "maxDelayTime" is in microseconds. It allows a subclass to impose a limit
// on how long "select()" can delay, in case it wants to also do polling.
// 0 (the default value) means: There's no maximum; just look at the delay queue
public:
// Redefined virtual functions:
virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc* proc,
void* clientData);
virtual void unscheduleDelayedTask(TaskToken& prevTask);
virtual void doEventLoop(char volatile* watchVariable);
virtual EventTriggerId createEventTrigger(TaskFunc* eventHandlerProc);
virtual void deleteEventTrigger(EventTriggerId eventTriggerId);
virtual void triggerEvent(EventTriggerId eventTriggerId, void* clientData = NULL);
protected:
BasicTaskScheduler0();
protected:
// To implement delayed operations:
intptr_t fTokenCounter;
DelayQueue fDelayQueue;
// To implement background reads:
HandlerSet* fHandlers;
int fLastHandledSocketNum;
// To implement event triggers:
#ifndef NO_STD_LIB
std::atomic_flag fTriggersAwaitingHandling[MAX_NUM_EVENT_TRIGGERS];
#else
Boolean volatile fTriggersAwaitingHandling[MAX_NUM_EVENT_TRIGGERS];
#endif
u_int32_t fLastUsedTriggerMask; // implemented as a 32-bit bitmap
TaskFunc* fTriggeredEventHandlers[MAX_NUM_EVENT_TRIGGERS];
void* fTriggeredEventClientDatas[MAX_NUM_EVENT_TRIGGERS];
unsigned fLastUsedTriggerNum; // in the range [0,MAX_NUM_EVENT_TRIGGERS)
Boolean fEventTriggersAreBeingUsed;
};
#endif

View File

@ -0,0 +1,25 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Version information for the "BasicUsageEnvironment" library
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
#ifndef _BASICUSAGEENVIRONMENT_VERSION_HH
#define _BASICUSAGEENVIRONMENT_VERSION_HH
#define BASICUSAGEENVIRONMENT_LIBRARY_VERSION_STRING "2024.02.15"
#define BASICUSAGEENVIRONMENT_LIBRARY_VERSION_INT 1707955200
#endif

View File

@ -0,0 +1,181 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024, Live Networks, Inc. All rights reserved
// Delay queue
// C++ header
#ifndef _DELAY_QUEUE_HH
#define _DELAY_QUEUE_HH
#ifndef _NET_COMMON_H
#include "NetCommon.h"
#endif
#ifdef TIME_BASE
typedef TIME_BASE time_base_seconds;
#else
typedef long time_base_seconds;
#endif
///// A "Timeval" can be either an absolute time, or a time interval /////
class LIVEMEDIA_API Timeval {
public:
time_base_seconds seconds() const {
return fTv.tv_sec;
}
time_base_seconds seconds() {
return fTv.tv_sec;
}
time_base_seconds useconds() const {
return fTv.tv_usec;
}
time_base_seconds useconds() {
return fTv.tv_usec;
}
int operator>=(Timeval const& arg2) const;
int operator<=(Timeval const& arg2) const {
return arg2 >= *this;
}
int operator<(Timeval const& arg2) const {
return !(*this >= arg2);
}
int operator>(Timeval const& arg2) const {
return arg2 < *this;
}
int operator==(Timeval const& arg2) const {
return *this >= arg2 && arg2 >= *this;
}
int operator!=(Timeval const& arg2) const {
return !(*this == arg2);
}
void operator+=(class DelayInterval const& arg2);
void operator-=(class DelayInterval const& arg2);
// returns ZERO iff arg2 >= arg1
protected:
Timeval(time_base_seconds seconds, time_base_seconds useconds) {
fTv.tv_sec = seconds; fTv.tv_usec = useconds;
}
private:
time_base_seconds& secs() {
return (time_base_seconds&)fTv.tv_sec;
}
time_base_seconds& usecs() {
return (time_base_seconds&)fTv.tv_usec;
}
struct timeval fTv;
};
#ifndef max
inline Timeval max(Timeval const& arg1, Timeval const& arg2) {
return arg1 >= arg2 ? arg1 : arg2;
}
#endif
#ifndef min
inline Timeval min(Timeval const& arg1, Timeval const& arg2) {
return arg1 <= arg2 ? arg1 : arg2;
}
#endif
class DelayInterval operator-(Timeval const& arg1, Timeval const& arg2);
// returns ZERO iff arg2 >= arg1
///// DelayInterval /////
class LIVEMEDIA_API DelayInterval: public Timeval {
public:
DelayInterval(time_base_seconds seconds, time_base_seconds useconds)
: Timeval(seconds, useconds) {}
};
DelayInterval operator*(short arg1, DelayInterval const& arg2);
extern DelayInterval const DELAY_ZERO;
extern DelayInterval const DELAY_SECOND;
extern DelayInterval const DELAY_MINUTE;
extern DelayInterval const DELAY_HOUR;
extern DelayInterval const DELAY_DAY;
///// _EventTime /////
class LIVEMEDIA_API _EventTime: public Timeval {
public:
_EventTime(unsigned secondsSinceEpoch = 0,
unsigned usecondsSinceEpoch = 0)
// We use the Unix standard epoch: January 1, 1970
: Timeval(secondsSinceEpoch, usecondsSinceEpoch) {}
};
_EventTime TimeNow();
extern _EventTime const THE_END_OF_TIME;
///// DelayQueueEntry /////
class LIVEMEDIA_API DelayQueueEntry {
public:
virtual ~DelayQueueEntry();
intptr_t token() {
return fToken;
}
protected: // abstract base class
DelayQueueEntry(DelayInterval delay, intptr_t token);
virtual void handleTimeout();
private:
friend class DelayQueue;
DelayQueueEntry* fNext;
DelayQueueEntry* fPrev;
DelayInterval fDeltaTimeRemaining;
intptr_t fToken;
};
///// DelayQueue /////
class LIVEMEDIA_API DelayQueue: public DelayQueueEntry {
public:
DelayQueue();
virtual ~DelayQueue();
void addEntry(DelayQueueEntry* newEntry); // returns a token for the entry
void updateEntry(DelayQueueEntry* entry, DelayInterval newDelay);
void updateEntry(intptr_t tokenToFind, DelayInterval newDelay);
void removeEntry(DelayQueueEntry* entry); // but doesn't delete it
DelayQueueEntry* removeEntry(intptr_t tokenToFind); // but doesn't delete it
DelayInterval const& timeToNextAlarm();
void handleAlarm();
private:
DelayQueueEntry* head() { return fNext; }
DelayQueueEntry* findEntryByToken(intptr_t token);
void synchronize(); // bring the 'time remaining' fields up-to-date
_EventTime fLastSyncTime;
};
#endif

View File

@ -0,0 +1,77 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Basic Usage Environment: for a simple, non-scripted, console application
// C++ header
#ifndef _HANDLER_SET_HH
#define _HANDLER_SET_HH
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
////////// HandlerSet (etc.) definition //////////
class LIVEMEDIA_API HandlerDescriptor {
HandlerDescriptor(HandlerDescriptor* nextHandler);
virtual ~HandlerDescriptor();
public:
int socketNum;
int conditionSet;
TaskScheduler::BackgroundHandlerProc* handlerProc;
void* clientData;
private:
// Descriptors are linked together in a doubly-linked list:
friend class HandlerSet;
friend class HandlerIterator;
HandlerDescriptor* fNextHandler;
HandlerDescriptor* fPrevHandler;
};
class LIVEMEDIA_API HandlerSet {
public:
HandlerSet();
virtual ~HandlerSet();
void assignHandler(int socketNum, int conditionSet, TaskScheduler::BackgroundHandlerProc* handlerProc, void* clientData);
void clearHandler(int socketNum);
void moveHandler(int oldSocketNum, int newSocketNum);
private:
HandlerDescriptor* lookupHandler(int socketNum);
private:
friend class HandlerIterator;
HandlerDescriptor fHandlers;
};
class LIVEMEDIA_API HandlerIterator {
public:
HandlerIterator(HandlerSet& handlerSet);
virtual ~HandlerIterator();
HandlerDescriptor* next(); // returns NULL if none
void reset();
private:
HandlerSet& fOurSet;
HandlerDescriptor* fNextPtr;
};
#endif

View File

@ -0,0 +1,56 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2016 Live Networks, Inc. All rights reserved.
// Basic Usage Environment: for a simple, non-scripted, console application
// C++ header
#ifndef _EPOLL_TASK_SCHEDULER_HH
#define _EPOLL_TASK_SCHEDULER_HH
#include "BasicUsageEnvironment.hh"
#include "HandlerSet.hh"
class EpollTaskScheduler : public BasicTaskScheduler0 {
public:
static EpollTaskScheduler* createNew(unsigned maxSchedulerGranularity = 10000 /*microseconds*/);
virtual ~EpollTaskScheduler();
private:
EpollTaskScheduler(unsigned maxSchedulerGranularity);
static void schedulerTickTask(void* clientData);
void schedulerTickTask();
const HandlerDescriptor* lookupHandlerDescriptor(int socketNum) const;
private:
virtual void SingleStep(unsigned maxDelayTime);
virtual void setBackgroundHandling(int socketNum, int conditionSet, BackgroundHandlerProc* handlerProc, void* clientData);
virtual void moveSocketHandling(int oldSocketNum, int newSocketNum);
private:
unsigned fMaxSchedulerGranularity;
private:
#if defined(__WIN32__) || defined(_WIN32)
void* fEpollHandle;
#else
int fEpollHandle;
#endif
};
#endif

View File

@ -0,0 +1,37 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
#ifndef _BOOLEAN_HH
#define _BOOLEAN_HH
#if defined(__BORLANDC__) || (!defined(USE_LIVE555_BOOLEAN) && defined(_MSC_VER) && _MSC_VER >= 1400)
// Use the "bool" type defined by the Borland compiler, and MSVC++ 8.0, Visual Studio 2005 and higher
typedef bool Boolean;
#define False false
#define True true
#else
typedef unsigned char Boolean;
#ifndef __MSHTML_LIBRARY_DEFINED__
#ifndef False
const Boolean False = 0;
#endif
#ifndef True
const Boolean True = 1;
#endif
#endif
#endif
#endif

View File

@ -0,0 +1,76 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Generic Hash Table
// C++ header
#ifndef _HASH_TABLE_HH
#define _HASH_TABLE_HH
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
class LIVEMEDIA_API HashTable {
public:
virtual ~HashTable();
// The following must be implemented by a particular
// implementation (subclass):
static HashTable* create(int keyType);
virtual void* Add(char const* key, void* value) = 0;
// Returns the old value if different, otherwise 0
virtual Boolean Remove(char const* key) = 0;
virtual void* Lookup(char const* key) const = 0;
// Returns 0 if not found
virtual unsigned numEntries() const = 0;
Boolean IsEmpty() const { return numEntries() == 0; }
// Used to iterate through the members of the table:
class Iterator {
public:
// The following must be implemented by a particular
// implementation (subclass):
static Iterator* create(HashTable const& hashTable);
virtual ~Iterator();
virtual void* next(char const*& key) = 0; // returns 0 if none
protected:
Iterator(); // abstract base class
};
// A shortcut that can be used to successively remove each of
// the entries in the table (e.g., so that their values can be
// deleted, if they happen to be pointers to allocated memory).
void* RemoveNext();
// Returns the first entry in the table.
// (This is useful for deleting each entry in the table, if the entry's destructor also removes itself from the table.)
void* getFirst();
protected:
HashTable(); // abstract base class
};
// Warning: The following are deliberately the same as in
// Tcl's hash table implementation
int const STRING_HASH_KEYS = 0;
int const ONE_WORD_HASH_KEYS = 1;
#endif

View File

@ -0,0 +1,176 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Usage Environment
// C++ header
#ifndef _USAGE_ENVIRONMENT_HH
#define _USAGE_ENVIRONMENT_HH
#ifndef _USAGEENVIRONMENT_VERSION_HH
#include "UsageEnvironment_version.hh"
#endif
#ifndef _NETCOMMON_H
#include "NetCommon.h"
#endif
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
#ifndef _STRDUP_HH
// "strDup()" is used often, so include this here, so everyone gets it:
#include "strDup.hh"
#endif
#ifndef NULL
#define NULL 0
#endif
#ifdef __BORLANDC__
#define _setmode setmode
#define _O_BINARY O_BINARY
#endif
class TaskScheduler; // forward
// An abstract base class, subclassed for each use of the library
class LIVEMEDIA_API UsageEnvironment {
public:
Boolean reclaim();
// returns True iff we were actually able to delete our object
// task scheduler:
TaskScheduler& taskScheduler() const {return fScheduler;}
// result message handling:
typedef char const* MsgString;
virtual MsgString getResultMsg() const = 0;
virtual void setResultMsg(MsgString msg) = 0;
virtual void setResultMsg(MsgString msg1, MsgString msg2) = 0;
virtual void setResultMsg(MsgString msg1, MsgString msg2, MsgString msg3) = 0;
virtual void setResultErrMsg(MsgString msg, int err = 0) = 0;
// like setResultMsg(), except that an 'errno' message is appended. (If "err == 0", the "getErrno()" code is used instead.)
virtual void appendToResultMsg(MsgString msg) = 0;
virtual void reportBackgroundError() = 0;
// used to report a (previously set) error message within
// a background event
virtual void internalError(); // used to 'handle' a 'should not occur'-type error condition within the library.
// 'errno'
virtual int getErrno() const = 0;
// 'console' output:
virtual UsageEnvironment& operator<<(char const* str) = 0;
virtual UsageEnvironment& operator<<(int i) = 0;
virtual UsageEnvironment& operator<<(unsigned u) = 0;
virtual UsageEnvironment& operator<<(double d) = 0;
virtual UsageEnvironment& operator<<(void* p) = 0;
// a pointer to additional, optional, client-specific state
void* liveMediaPriv;
void* groupsockPriv;
protected:
UsageEnvironment(TaskScheduler& scheduler); // abstract base class
virtual ~UsageEnvironment(); // we are deleted only by reclaim()
private:
TaskScheduler& fScheduler;
};
typedef void TaskFunc(void* clientData);
typedef void* TaskToken;
typedef u_int32_t EventTriggerId;
class LIVEMEDIA_API TaskScheduler {
public:
virtual ~TaskScheduler();
virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc* proc,
void* clientData) = 0;
// Schedules a task to occur (after a delay) when we next
// reach a scheduling point.
// (Does not delay if "microseconds" <= 0)
// Returns a token that can be used in a subsequent call to
// unscheduleDelayedTask() or rescheduleDelayedTask()
// (but only if the task has not yet occurred).
virtual void unscheduleDelayedTask(TaskToken& prevTask) = 0;
// (Has no effect if "prevTask" == NULL)
// Sets "prevTask" to NULL afterwards.
// Note: This MUST NOT be called if the scheduled task has already occurred.
virtual void rescheduleDelayedTask(TaskToken& task,
int64_t microseconds, TaskFunc* proc,
void* clientData);
// Combines "unscheduleDelayedTask()" with "scheduleDelayedTask()"
// (setting "task" to the new task token).
// Note: This MUST NOT be called if the scheduled task has already occurred.
// For handling socket operations in the background (from the event loop):
typedef void BackgroundHandlerProc(void* clientData, int mask);
// Possible bits to set in "mask". (These are deliberately defined
// the same as those in Tcl, to make a Tcl-based subclass easy.)
#define SOCKET_READABLE (1<<1)
#define SOCKET_WRITABLE (1<<2)
#define SOCKET_EXCEPTION (1<<3)
virtual void setBackgroundHandling(int socketNum, int conditionSet, BackgroundHandlerProc* handlerProc, void* clientData) = 0;
void disableBackgroundHandling(int socketNum) { setBackgroundHandling(socketNum, 0, NULL, NULL); }
virtual void moveSocketHandling(int oldSocketNum, int newSocketNum) = 0;
// Changes any socket handling for "oldSocketNum" so that occurs with "newSocketNum" instead.
virtual void doEventLoop(char volatile* watchVariable = NULL) = 0;
// Causes further execution to take place within the event loop.
// Delayed tasks, background I/O handling, and other events are handled, sequentially (as a single thread of control).
// (If "watchVariable" is not NULL, then we return from this routine when *watchVariable != 0)
virtual EventTriggerId createEventTrigger(TaskFunc* eventHandlerProc) = 0;
// Creates a 'trigger' for an event, which - if it occurs - will be handled (from the event loop) using "eventHandlerProc".
// (Returns 0 iff no such trigger can be created (e.g., because of implementation limits on the number of triggers).)
virtual void deleteEventTrigger(EventTriggerId eventTriggerId) = 0;
virtual void triggerEvent(EventTriggerId eventTriggerId, void* clientData = NULL) = 0;
// Causes the (previously-registered) handler function for the specified event to be handled (from the event loop).
// The handler function is called with "clientData" as parameter.
// Note: This function (unlike other library functions) may be called from an external thread
// - to signal an external event.
// (In fact, this is the *only* LIVE555 function that can be called from a non-LIVE555 thread.)
// (However, "triggerEvent()" should not be called with the same 'event trigger id' from
// different threads. Also, once "triggerEvent()" is called with one 'event trigger id',
// it should not be called again with the same 'event trigger id' until after its event
// has been handled.)
// The following two functions are deprecated, and are provided for backwards-compatibility only:
void turnOnBackgroundReadHandling(int socketNum, BackgroundHandlerProc* handlerProc, void* clientData) {
setBackgroundHandling(socketNum, SOCKET_READABLE, handlerProc, clientData);
}
void turnOffBackgroundReadHandling(int socketNum) { disableBackgroundHandling(socketNum); }
virtual void internalError(); // used to 'handle' a 'should not occur'-type error condition within the library.
protected:
TaskScheduler(); // abstract base class
};
#endif

View File

@ -0,0 +1,25 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Version information for the "UsageEnvironment" library
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
#ifndef _USAGEENVIRONMENT_VERSION_HH
#define _USAGEENVIRONMENT_VERSION_HH
#define USAGEENVIRONMENT_LIBRARY_VERSION_STRING "2024.02.15"
#define USAGEENVIRONMENT_LIBRARY_VERSION_INT 1707955200
#endif

View File

@ -0,0 +1,37 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
#ifndef _STRDUP_HH
#define _STRDUP_HH
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A C++ equivalent to the standard C routine "strdup()".
// This generates a char* that can be deleted using "delete[]"
// Header
#include <string.h>
LIVEMEDIA_API char* strDup(char const* str);
// Note: strDup(NULL) returns NULL
LIVEMEDIA_API char* strDupSize(char const* str);
// Like "strDup()", except that it *doesn't* copy the original.
// (Instead, it just allocates a string of the same size as the original.)
LIVEMEDIA_API char* strDupSize(char const* str, size_t& resultBufSize);
// An alternative form of "strDupSize()" that also returns the size of the allocated buffer.
#endif

View File

@ -0,0 +1,64 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "multikit" Multicast Application Shell
// Copyright (c) 1996-2024, Live Networks, Inc. All rights reserved
// "Group Endpoint Id"
// C++ header
#ifndef _GROUPEID_HH
#define _GROUPEID_HH
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
#ifndef _NET_ADDRESS_HH
#include "NetAddress.hh"
#endif
class LIVEMEDIA_API GroupEId {
public:
GroupEId(struct sockaddr_storage const& groupAddr,
portNumBits portNum, u_int8_t ttl);
// used for a 'source-independent multicast' group
GroupEId(struct sockaddr_storage const& groupAddr,
struct sockaddr_storage const& sourceFilterAddr,
portNumBits portNum);
// used for a 'source-specific multicast' group
GroupEId(); // tmp default constructor, until "Groupsock" interface uses "sockaddr_storage"
struct sockaddr_storage const& groupAddress() const { return fGroupAddress; }
struct sockaddr_storage const& sourceFilterAddress() const { return fSourceFilterAddress; }
Boolean isSSM() const;
portNumBits portNum() const;
u_int8_t ttl() const { return fTTL; }
private:
void init(struct sockaddr_storage const& groupAddr,
struct sockaddr_storage const& sourceFilterAddr,
portNumBits portNum,
u_int8_t ttl);
private:
struct sockaddr_storage fGroupAddress; // also includes port number (in network byte order)
struct sockaddr_storage fSourceFilterAddress;
u_int8_t fTTL;
};
#endif

View File

@ -0,0 +1,201 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "groupsock"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// 'Group sockets'
// C++ header
#ifndef _GROUPSOCK_HH
#define _GROUPSOCK_HH
#ifndef _GROUPSOCK_VERSION_HH
#include "groupsock_version.hh"
#endif
#ifndef _NET_INTERFACE_HH
#include "NetInterface.hh"
#endif
#ifndef _GROUPEID_HH
#include "GroupEId.hh"
#endif
// An "OutputSocket" is (by default) used only to send packets.
// No packets are received on it (unless a subclass arranges this)
class LIVEMEDIA_API OutputSocket: public Socket {
public:
OutputSocket(UsageEnvironment& env, int family);
virtual ~OutputSocket();
virtual Boolean write(struct sockaddr_storage const& addressAndPort, u_int8_t ttl,
unsigned char* buffer, unsigned bufferSize);
protected:
OutputSocket(UsageEnvironment& env, Port port, int family);
portNumBits sourcePortNum() const {return fSourcePort.num();}
private: // redefined virtual function
virtual Boolean handleRead(unsigned char* buffer, unsigned bufferMaxSize,
unsigned& bytesRead,
struct sockaddr_storage& fromAddressAndPort);
private:
Port fSourcePort;
unsigned fLastSentTTL;
};
class LIVEMEDIA_API destRecord {
public:
destRecord(struct sockaddr_storage const& addr, Port const& port, u_int8_t ttl, unsigned sessionId,
destRecord* next);
virtual ~destRecord();
public:
destRecord* fNext;
GroupEId fGroupEId;
unsigned fSessionId;
};
// A "Groupsock" is used to both send and receive packets.
// As the name suggests, it was originally designed to send/receive
// multicast, but it can send/receive unicast as well.
class LIVEMEDIA_API Groupsock: public OutputSocket {
public:
Groupsock(UsageEnvironment& env, struct sockaddr_storage const& groupAddr,
Port port, u_int8_t ttl);
// used for a 'source-independent multicast' group
Groupsock(UsageEnvironment& env, struct sockaddr_storage const& groupAddr,
struct sockaddr_storage const& sourceFilterAddr,
Port port);
// used for a 'source-specific multicast' group
virtual ~Groupsock();
virtual destRecord* createNewDestRecord(struct sockaddr_storage const& addr, Port const& port, u_int8_t ttl, unsigned sessionId, destRecord* next);
// Can be redefined by subclasses that also subclass "destRecord"
void changeDestinationParameters(struct sockaddr_storage const& newDestAddr,
Port newDestPort, int newDestTTL,
unsigned sessionId = 0);
// By default, the destination address, port and ttl for
// outgoing packets are those that were specified in
// the constructor. This works OK for multicast sockets,
// but for unicast we usually want the destination port
// number, at least, to be different from the source port.
// (If a parameter is 0 (or ~0 for ttl), then no change is made to that parameter.)
// (If no existing "destRecord" exists with this "sessionId", then we add a new "destRecord".)
unsigned lookupSessionIdFromDestination(struct sockaddr_storage const& destAddrAndPort) const;
// returns 0 if not found
// As a special case, we also allow multiple destinations (addresses & ports)
// (This can be used to implement multi-unicast.)
virtual void addDestination(struct sockaddr_storage const& addr, Port const& port,
unsigned sessionId);
virtual void removeDestination(unsigned sessionId);
void removeAllDestinations();
Boolean hasMultipleDestinations() const { return fDests != NULL && fDests->fNext != NULL; }
struct sockaddr_storage const& groupAddress() const {
return fIncomingGroupEId.groupAddress();
}
struct sockaddr_storage const& sourceFilterAddress() const {
return fIncomingGroupEId.sourceFilterAddress();
}
Boolean isSSM() const {
return fIncomingGroupEId.isSSM();
}
u_int8_t ttl() const { return fIncomingGroupEId.ttl(); }
void multicastSendOnly(); // send, but don't receive any multicast packets
virtual Boolean output(UsageEnvironment& env, unsigned char* buffer, unsigned bufferSize);
static NetInterfaceTrafficStats statsIncoming;
static NetInterfaceTrafficStats statsOutgoing;
NetInterfaceTrafficStats statsGroupIncoming; // *not* static
NetInterfaceTrafficStats statsGroupOutgoing; // *not* static
Boolean wasLoopedBackFromUs(UsageEnvironment& env,
struct sockaddr_storage const& fromAddressAndPort);
public: // redefined virtual functions
virtual Boolean handleRead(unsigned char* buffer, unsigned bufferMaxSize,
unsigned& bytesRead,
struct sockaddr_storage& fromAddressAndPort);
protected:
destRecord* lookupDestRecordFromDestination(struct sockaddr_storage const& targetAddrAndPort) const;
private:
void removeDestinationFrom(destRecord*& dests, unsigned sessionId);
// used to implement (the public) "removeDestination()", and "changeDestinationParameters()"
protected:
destRecord* fDests;
private:
GroupEId fIncomingGroupEId;
};
UsageEnvironment& operator<<(UsageEnvironment& s, const Groupsock& g);
// A data structure for looking up a 'groupsock'
// by (multicast address, port), or by socket number
class LIVEMEDIA_API GroupsockLookupTable {
public:
Groupsock* Fetch(UsageEnvironment& env, struct sockaddr_storage const& groupAddress,
Port port, u_int8_t ttl, Boolean& isNew);
// Creates a new Groupsock if none already exists
Groupsock* Fetch(UsageEnvironment& env, struct sockaddr_storage const& groupAddress,
struct sockaddr_storage const& sourceFilterAddr,
Port port, Boolean& isNew);
// Creates a new Groupsock if none already exists
Groupsock* Lookup(struct sockaddr_storage const& groupAddress, Port port);
// Returns NULL if none already exists
Groupsock* Lookup(struct sockaddr_storage const& groupAddress,
struct sockaddr_storage const& sourceFilterAddr,
Port port);
// Returns NULL if none already exists
Groupsock* Lookup(UsageEnvironment& env, int sock);
// Returns NULL if none already exists
Boolean Remove(Groupsock const* groupsock);
// Used to iterate through the groupsocks in the table
class Iterator {
public:
Iterator(GroupsockLookupTable& groupsocks);
Groupsock* next(); // NULL iff none
private:
AddressPortLookupTable::Iterator fIter;
};
private:
Groupsock* AddNew(UsageEnvironment& env,
struct sockaddr_storage const& groupAddress,
struct sockaddr_storage const& sourceFilterAddress,
Port port, u_int8_t ttl);
private:
friend class Iterator;
AddressPortLookupTable fTable;
};
#endif

View File

@ -0,0 +1,166 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "groupsock"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Helper routines to implement 'group sockets'
// C++ header
#ifndef _GROUPSOCK_HELPER_HH
#define _GROUPSOCK_HELPER_HH
#ifndef _NET_ADDRESS_HH
#include "NetAddress.hh"
#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
LIVEMEDIA_API int setupDatagramSocket(UsageEnvironment& env, Port port, int domain);
LIVEMEDIA_API int setupStreamSocket(UsageEnvironment& env, Port port, int domain,
Boolean makeNonBlocking = True, Boolean setKeepAlive = False);
LIVEMEDIA_API int readSocket(UsageEnvironment& env,
int socket, unsigned char* buffer, unsigned bufferSize,
struct sockaddr_storage& fromAddress /*set only if we're a datagram socket*/);
LIVEMEDIA_API Boolean writeSocket(UsageEnvironment& env,
int socket, struct sockaddr_storage const& addressAndPort,
u_int8_t ttlArg,
unsigned char* buffer, unsigned bufferSize);
LIVEMEDIA_API Boolean writeSocket(UsageEnvironment& env,
int socket, struct sockaddr_storage const& addressAndPort,
unsigned char* buffer, unsigned bufferSize);
// An optimized version of "writeSocket" that omits the "setsockopt()" call to set the TTL.
LIVEMEDIA_API void ignoreSigPipeOnSocket(int socketNum);
LIVEMEDIA_API unsigned getSendBufferSize(UsageEnvironment& env, int socket);
LIVEMEDIA_API unsigned getReceiveBufferSize(UsageEnvironment& env, int socket);
LIVEMEDIA_API unsigned setSendBufferTo(UsageEnvironment& env,
int socket, unsigned requestedSize);
LIVEMEDIA_API unsigned setReceiveBufferTo(UsageEnvironment& env,
int socket, unsigned requestedSize);
LIVEMEDIA_API unsigned increaseSendBufferTo(UsageEnvironment& env,
int socket, unsigned requestedSize);
LIVEMEDIA_API unsigned increaseReceiveBufferTo(UsageEnvironment& env,
int socket, unsigned requestedSize);
LIVEMEDIA_API Boolean makeSocketNonBlocking(int sock);
LIVEMEDIA_API Boolean makeSocketBlocking(int sock, unsigned writeTimeoutInMilliseconds = 0);
// A "writeTimeoutInMilliseconds" value of 0 means: Don't timeout
LIVEMEDIA_API Boolean setSocketKeepAlive(int sock);
LIVEMEDIA_API Boolean socketJoinGroup(UsageEnvironment& env, int socket,
struct sockaddr_storage const& groupAddress);
LIVEMEDIA_API Boolean socketLeaveGroup(UsageEnvironment&, int socket,
struct sockaddr_storage const& groupAddress);
// source-specific multicast join/leave
LIVEMEDIA_API Boolean socketJoinGroupSSM(UsageEnvironment& env, int socket,
struct sockaddr_storage const& groupAddress,
struct sockaddr_storage const& sourceFilterAddr);
LIVEMEDIA_API Boolean socketLeaveGroupSSM(UsageEnvironment&, int socket,
struct sockaddr_storage const& groupAddress,
struct sockaddr_storage const& sourceFilterAddr);
LIVEMEDIA_API Boolean getSourcePort(UsageEnvironment& env, int socket, int domain, Port& port);
LIVEMEDIA_API ipv4AddressBits ourIPv4Address(UsageEnvironment& env); // in network order
LIVEMEDIA_API ipv6AddressBits const& ourIPv6Address(UsageEnvironment& env);
LIVEMEDIA_API Boolean weHaveAnIPv4Address(UsageEnvironment& env);
LIVEMEDIA_API Boolean weHaveAnIPv6Address(UsageEnvironment& env);
LIVEMEDIA_API Boolean weHaveAnIPAddress(UsageEnvironment& env);
// returns True if we have either an IPv4 or an IPv6 address
// IPv4 addresses of our sending and receiving interfaces. (By default, these
// are INADDR_ANY (i.e., 0), specifying the default interface.)
LIVEMEDIA_API extern ipv4AddressBits SendingInterfaceAddr;
LIVEMEDIA_API extern ipv4AddressBits ReceivingInterfaceAddr;
LIVEMEDIA_API extern in6_addr ReceivingInterfaceAddr6;
// Allocates a randomly-chosen IPv4 SSM (multicast) address:
LIVEMEDIA_API ipv4AddressBits chooseRandomIPv4SSMAddress(UsageEnvironment& env);
// Returns a simple "hh:mm:ss" string, for use in debugging output (e.g.)
LIVEMEDIA_API char const* timestampString();
#ifdef HAVE_SOCKADDR_LEN
#define SET_SOCKADDR_SIN_LEN(var) var.sin_len = sizeof var
#define SET_SOCKADDR_SIN6_LEN(var) var.sin6_len = sizeof var
#else
#define SET_SOCKADDR_SIN_LEN(var)
#define SET_SOCKADDR_SIN6_LEN(var)
#endif
#define MAKE_SOCKADDR_IN(var,adr,prt) /*adr,prt must be in network order*/\
struct sockaddr_in var;\
var.sin_family = AF_INET;\
var.sin_addr.s_addr = (adr);\
var.sin_port = (prt);\
SET_SOCKADDR_SIN_LEN(var);
#define MAKE_SOCKADDR_IN6(var,adr,prt) /*adr,prt must be in network order*/\
struct sockaddr_in6 var;\
memset(&var, 0, sizeof var);\
var.sin6_family = AF_INET6;\
var.sin6_addr=adr;\
var.sin6_port = (prt);\
SET_SOCKADDR_SIN6_LEN(var);
// By default, we create sockets with the SO_REUSE_* flag set.
// If, instead, you want to create sockets without the SO_REUSE_* flags,
// Then enclose the creation code with:
// {
// NoReuse dummy;
// ...
// }
class LIVEMEDIA_API NoReuse {
public:
NoReuse(UsageEnvironment& env);
~NoReuse();
private:
UsageEnvironment& fEnv;
};
// Define the "UsageEnvironment"-specific "groupsockPriv" structure:
struct LIVEMEDIA_API _groupsockPriv { // There should be only one of these allocated
HashTable* socketTable;
int reuseFlag;
};
LIVEMEDIA_API _groupsockPriv* groupsockPriv(UsageEnvironment& env); // allocates it if necessary
LIVEMEDIA_API void reclaimGroupsockPriv(UsageEnvironment& env);
#if (defined(__WIN32__) || defined(_WIN32)) && !defined(__MINGW32__)
// For Windoze, we need to implement our own gettimeofday()
extern LIVEMEDIA_API int gettimeofday(struct timeval*, int*);
#else
#include <sys/time.h>
#endif
// The following are implemented in inet.c:
extern "C" LIVEMEDIA_API void our_srandom(int x);
extern "C" LIVEMEDIA_API long our_random();
extern "C" LIVEMEDIA_API u_int32_t our_random32(); // because "our_random()" returns a 31-bit number
#endif

View File

@ -0,0 +1,31 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "groupsock"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// IO event handlers
// C++ header
#ifndef _IO_HANDLERS_HH
#define _IO_HANDLERS_HH
#ifndef _NET_INTERFACE_HH
#include "NetInterface.hh"
#endif
// Handles incoming data on sockets:
LIVEMEDIA_API void socketReadHandler(Socket* sock, int mask);
#endif

View File

@ -0,0 +1,209 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "groupsock"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Network Addresses
// C++ header
#ifndef _NET_ADDRESS_HH
#define _NET_ADDRESS_HH
#ifndef _HASH_TABLE_HH
#include "HashTable.hh"
#endif
#ifndef _NET_COMMON_H
#include "NetCommon.h"
#endif
#ifndef _USAGE_ENVIRONMENT_HH
#include "UsageEnvironment.hh"
#endif
// Definition of a type representing a low-level network address.
// Note that the type "netAddressBits" is no longer defined; use "ipv4AddressBits" instead.
typedef u_int32_t ipv4AddressBits;
typedef u_int8_t ipv6AddressBits[16]; // 128 bits
class LIVEMEDIA_API NetAddress {
public:
NetAddress(u_int8_t const* data,
unsigned length = 4 /* default: 32 bits (for IPv4); use 16 (128 bits) for IPv6 */);
NetAddress(unsigned length = 4); // sets address data to all-zeros
NetAddress(NetAddress const& orig);
NetAddress& operator=(NetAddress const& rightSide);
virtual ~NetAddress();
unsigned length() const { return fLength; }
u_int8_t const* data() const // always in network byte order
{ return fData; }
private:
void assign(u_int8_t const* data, unsigned length);
void clean();
unsigned fLength;
u_int8_t* fData;
};
LIVEMEDIA_API struct sockaddr_storage const& nullAddress(int addressFamily = AF_INET);
LIVEMEDIA_API Boolean addressIsNull(sockaddr_storage const& address);
LIVEMEDIA_API SOCKLEN_T addressSize(sockaddr_storage const& address);
LIVEMEDIA_API void copyAddress(struct sockaddr_storage& to, NetAddress const* from);
LIVEMEDIA_API Boolean operator==(struct sockaddr_storage const& left, struct sockaddr_storage const& right);
// compares the family and address parts only; not the port number or anything else
class LIVEMEDIA_API NetAddressList {
public:
NetAddressList(char const* hostname, int addressFamily = AF_UNSPEC);
NetAddressList(NetAddressList const& orig);
NetAddressList& operator=(NetAddressList const& rightSide);
virtual ~NetAddressList();
unsigned numAddresses() const { return fNumAddresses; }
NetAddress const* firstAddress() const;
// Used to iterate through the addresses in a list:
class Iterator {
public:
Iterator(NetAddressList const& addressList);
NetAddress const* nextAddress(); // NULL iff none
private:
NetAddressList const& fAddressList;
unsigned fNextIndex;
};
private:
void assign(unsigned numAddresses, NetAddress** addressArray);
void clean();
friend class Iterator;
unsigned fNumAddresses;
NetAddress** fAddressArray;
};
typedef u_int16_t portNumBits;
class LIVEMEDIA_API Port {
public:
Port(portNumBits num /* in host byte order */);
portNumBits num() const { return fPortNum; } // in network byte order
private:
portNumBits fPortNum; // stored in network byte order
#ifdef IRIX
portNumBits filler; // hack to overcome a bug in IRIX C++ compiler
#endif
};
UsageEnvironment& operator<<(UsageEnvironment& s, const Port& p);
// A generic table for looking up objects by (address1, address2, port)
class LIVEMEDIA_API AddressPortLookupTable {
public:
AddressPortLookupTable();
virtual ~AddressPortLookupTable();
void* Add(struct sockaddr_storage const& address1,
struct sockaddr_storage const& address2,
Port port,
void* value);
// Returns the old value if different, otherwise 0
void* Add(struct sockaddr_storage const& address1,
Port port,
void* value) {
return Add(address1, nullAddress(), port, value);
}
Boolean Remove(struct sockaddr_storage const& address1,
struct sockaddr_storage const& address2,
Port port);
Boolean Remove(struct sockaddr_storage const& address1,
Port port) {
return Remove(address1, nullAddress(), port);
}
void* Lookup(struct sockaddr_storage const& address1,
struct sockaddr_storage const& address2,
Port port);
// Returns 0 if not found
void* Lookup(struct sockaddr_storage const& address1,
Port port) {
return Lookup(address1, nullAddress(), port);
}
void* RemoveNext() { return fTable->RemoveNext(); }
// Used to iterate through the entries in the table
class Iterator {
public:
Iterator(AddressPortLookupTable& table);
virtual ~Iterator();
void* next(); // NULL iff none
private:
HashTable::Iterator* fIter;
};
private:
friend class Iterator;
HashTable* fTable;
};
LIVEMEDIA_API Boolean IsMulticastAddress(struct sockaddr_storage const& address);
// A mechanism for displaying an IP (v4 or v6) address in ASCII.
// (This encapsulates the "inet_ntop()" function.)
class LIVEMEDIA_API AddressString {
public:
// IPv4 input:
AddressString(struct sockaddr_in const& addr);
AddressString(struct in_addr const& addr);
AddressString(ipv4AddressBits const& addr); // "addr" is assumed to be in network byte order
// IPv6 input:
AddressString(struct sockaddr_in6 const& addr);
AddressString(struct in6_addr const& addr);
AddressString(ipv6AddressBits const& addr);
// IPv4 or IPv6 input:
AddressString(struct sockaddr_storage const& addr);
virtual ~AddressString();
char const* val() const { return fVal; }
private:
void init(ipv4AddressBits const& addr); // used to implement the IPv4 constructors
void init(ipv6AddressBits const& addr); // used to implement the IPv6 constructors
private:
char* fVal; // The result ASCII string: allocated by the constructor; deleted by the destructor
};
LIVEMEDIA_API portNumBits portNum(struct sockaddr_storage const& address);
LIVEMEDIA_API void setPortNum(struct sockaddr_storage& address, portNumBits portNum/*in network order*/);
#endif

View File

@ -0,0 +1,126 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
/* "groupsock" interface
* Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
* Common include files, typically used for networking
*/
#ifndef _NET_COMMON_H
#define _NET_COMMON_H
#if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE)
/* Windows */
#if defined(WINNT) || defined(_WINNT) || defined(__BORLANDC__) || defined(__MINGW32__) || defined(_WIN32_WCE) || defined (_MSC_VER)
#define _MSWSOCK_
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#include <windows.h>
#include <errno.h>
#include <string.h>
#define closeSocket closesocket
#ifdef EWOULDBLOCK
#undef EWOULDBLOCK
#endif
#ifdef EINPROGRESS
#undef EINPROGRESS
#endif
#ifdef EAGAIN
#undef EAGAIN
#endif
#ifdef EINTR
#undef EINTR
#endif
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEWOULDBLOCK
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#if defined(_WIN32_WCE)
#define NO_STRSTREAM 1
#endif
/* Definitions of size-specific types: */
typedef __int64 int64_t;
typedef unsigned __int64 u_int64_t;
typedef int int32_t;
typedef unsigned u_int32_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef unsigned char u_int8_t;
// For "uintptr_t" and "intptr_t", we assume that if they're not already defined, then this must be
// an old, 32-bit version of Windows:
#if !defined(_MSC_STDINT_H_) && !defined(_UINTPTR_T_DEFINED) && !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
typedef unsigned uintptr_t;
#endif
#if !defined(_MSC_STDINT_H_) && !defined(_INTPTR_T_DEFINED) && !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T)
typedef int intptr_t;
#endif
#elif defined(VXWORKS)
/* VxWorks */
#include <time.h>
#include <timers.h>
#include <sys/times.h>
#include <sockLib.h>
#include <hostLib.h>
#include <resolvLib.h>
#include <ioLib.h>
typedef unsigned int u_int32_t;
typedef unsigned short u_int16_t;
typedef unsigned char u_int8_t;
#else
/* Unix */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <ctype.h>
#include <stdint.h>
#if defined(_QNX4)
#include <sys/select.h>
#include <unix.h>
#endif
#define closeSocket close
#ifdef SOLARIS
#define u_int64_t uint64_t
#define u_int32_t uint32_t
#define u_int16_t uint16_t
#define u_int8_t uint8_t
#endif
#endif
#ifndef SOCKLEN_T
#define SOCKLEN_T int
#endif
#endif

View File

@ -0,0 +1,109 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "groupsock"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Network Interfaces
// C++ header
#ifndef _NET_INTERFACE_HH
#define _NET_INTERFACE_HH
#ifndef _NET_ADDRESS_HH
#include "NetAddress.hh"
#endif
class LIVEMEDIA_API NetInterface {
public:
virtual ~NetInterface();
static UsageEnvironment* DefaultUsageEnvironment;
// if non-NULL, used for each new interface
protected:
NetInterface(); // virtual base class
};
class LIVEMEDIA_API Socket: public NetInterface {
public:
virtual ~Socket();
void reset(); // closes the socket, and sets "fSocketNum" to -1
virtual Boolean handleRead(unsigned char* buffer, unsigned bufferMaxSize,
unsigned& bytesRead,
struct sockaddr_storage& fromAddress) = 0;
// Returns False on error; resultData == NULL if data ignored
int socketNum() const { return fSocketNum; }
Port port() const {
return fPort;
}
UsageEnvironment& env() const { return fEnv; }
static int DebugLevel;
protected:
Socket(UsageEnvironment& env, Port port, int family); // virtual base class
Boolean changePort(Port newPort); // will also cause socketNum() to change
private:
int fSocketNum;
UsageEnvironment& fEnv;
Port fPort;
int fFamily;
};
UsageEnvironment& operator<<(UsageEnvironment& s, const Socket& sock);
// A data structure for looking up a Socket by port:
class LIVEMEDIA_API SocketLookupTable {
public:
virtual ~SocketLookupTable();
Socket* Fetch(UsageEnvironment& env, Port port, Boolean& isNew);
// Creates a new Socket if none already exists
Boolean Remove(Socket const* sock);
protected:
SocketLookupTable(); // abstract base class
virtual Socket* CreateNew(UsageEnvironment& env, Port port) = 0;
private:
HashTable* fTable;
};
// A data structure for counting traffic:
class LIVEMEDIA_API NetInterfaceTrafficStats {
public:
NetInterfaceTrafficStats();
void countPacket(unsigned packetSize);
float totNumPackets() const {return fTotNumPackets;}
float totNumBytes() const {return fTotNumBytes;}
Boolean haveSeenTraffic() const;
private:
float fTotNumPackets;
float fTotNumBytes;
};
#endif

View File

@ -0,0 +1,101 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "mTunnel" multicast access service
// Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved.
// Encapsulation trailer for tunnels
// C++ header
#ifndef _TUNNEL_ENCAPS_HH
#define _TUNNEL_ENCAPS_HH
#ifndef _NET_ADDRESS_HH
#include "NetAddress.hh"
#endif
typedef u_int16_t Cookie;
class LIVEMEDIA_API TunnelEncapsulationTrailer {
// The trailer is layed out as follows:
// bytes 0-1: source 'cookie'
// bytes 2-3: destination 'cookie'
// bytes 4-7: address
// bytes 8-9: port
// byte 10: ttl
// byte 11: command
// Optionally, there may also be a 4-byte 'auxilliary address'
// (e.g., for 'source-specific multicast' preceding this)
// bytes -4 through -1: auxilliary address
public:
Cookie& srcCookie()
{ return *(Cookie*)byteOffset(0); }
Cookie& dstCookie()
{ return *(Cookie*)byteOffset(2); }
u_int32_t& address()
{ return *(u_int32_t*)byteOffset(4); }
Port& port()
{ return *(Port*)byteOffset(8); }
u_int8_t& ttl()
{ return *(u_int8_t*)byteOffset(10); }
u_int8_t& command()
{ return *(u_int8_t*)byteOffset(11); }
u_int32_t& auxAddress()
{ return *(u_int32_t*)byteOffset(-4); }
private:
inline char* byteOffset(int charIndex)
{ return ((char*)this) + charIndex; }
};
const unsigned TunnelEncapsulationTrailerSize = 12; // bytes
const unsigned TunnelEncapsulationTrailerAuxSize = 4; // bytes
const unsigned TunnelEncapsulationTrailerMaxSize
= TunnelEncapsulationTrailerSize + TunnelEncapsulationTrailerAuxSize;
// Command codes:
// 0: unused
const u_int8_t TunnelDataCmd = 1;
const u_int8_t TunnelJoinGroupCmd = 2;
const u_int8_t TunnelLeaveGroupCmd = 3;
const u_int8_t TunnelTearDownCmd = 4;
const u_int8_t TunnelProbeCmd = 5;
const u_int8_t TunnelProbeAckCmd = 6;
const u_int8_t TunnelProbeNackCmd = 7;
const u_int8_t TunnelJoinRTPGroupCmd = 8;
const u_int8_t TunnelLeaveRTPGroupCmd = 9;
// 0x0A through 0x10: currently unused.
const u_int8_t TunnelExtensionFlag = 0x80; // a flag, not a cmd code
const u_int8_t TunnelDataAuxCmd
= (TunnelExtensionFlag|TunnelDataCmd);
const u_int8_t TunnelJoinGroupAuxCmd
= (TunnelExtensionFlag|TunnelJoinGroupCmd);
const u_int8_t TunnelLeaveGroupAuxCmd
= (TunnelExtensionFlag|TunnelLeaveGroupCmd);
// Note: the TearDown, Probe, ProbeAck, ProbeNack cmds have no Aux version
// 0x84 through 0x87: currently unused.
const u_int8_t TunnelJoinRTPGroupAuxCmd
= (TunnelExtensionFlag|TunnelJoinRTPGroupCmd);
const u_int8_t TunnelLeaveRTPGroupAuxCmd
= (TunnelExtensionFlag|TunnelLeaveRTPGroupCmd);
// 0x8A through 0xFF: currently unused
inline Boolean TunnelIsAuxCmd(u_int8_t cmd) {
return (cmd&TunnelExtensionFlag) != 0;
}
#endif

View File

@ -0,0 +1,25 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Version information for the "groupsock" library
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
#ifndef _GROUPSOCK_VERSION_HH
#define _GROUPSOCK_VERSION_HH
#define GROUPSOCK_LIBRARY_VERSION_STRING "2024.02.15"
#define GROUPSOCK_LIBRARY_VERSION_INT 1707955200
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from an AC3 audio file.
// C++ header
#ifndef _AC3_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _AC3_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API AC3AudioFileServerMediaSubsession: public FileServerMediaSubsession{
public:
static AC3AudioFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
private:
AC3AudioFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~AC3AudioFileServerMediaSubsession();
private: // redefined virtual functions
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
};
#endif

View File

@ -0,0 +1,57 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for AC3 audio
// C++ header
#ifndef _AC3_AUDIO_RTP_SINK_HH
#define _AC3_AUDIO_RTP_SINK_HH
#ifndef _AUDIO_RTP_SINK_HH
#include "AudioRTPSink.hh"
#endif
class LIVEMEDIA_API AC3AudioRTPSink: public AudioRTPSink {
public:
static AC3AudioRTPSink* createNew(UsageEnvironment& env,
Groupsock* RTPgs,
u_int8_t rtpPayloadFormat,
u_int32_t rtpTimestampFrequency);
protected:
AC3AudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
u_int8_t rtpPayloadFormat,
u_int32_t rtpTimestampFrequency);
// called only by createNew()
virtual ~AC3AudioRTPSink();
private: // redefined virtual functions:
virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
unsigned numBytesInFrame) const;
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual unsigned specialHeaderSize() const;
private:
unsigned char fTotNumFragmentsUsed; // used only if a frame gets fragmented across multiple packets
};
#endif

View File

@ -0,0 +1,51 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// AC3 Audio RTP Sources
// C++ header
#ifndef _AC3_AUDIO_RTP_SOURCE_HH
#define _AC3_AUDIO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API AC3AudioRTPSource: public MultiFramedRTPSource {
public:
static AC3AudioRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
protected:
virtual ~AC3AudioRTPSource();
private:
AC3AudioRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
// called only by createNew()
private:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
};
#endif

View File

@ -0,0 +1,70 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that breaks up an AC3 audio elementary stream into frames
// C++ header
#ifndef _AC3_AUDIO_STREAM_FRAMER_HH
#define _AC3_AUDIO_STREAM_FRAMER_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
class LIVEMEDIA_API AC3AudioStreamFramer: public FramedFilter {
public:
static AC3AudioStreamFramer*
createNew(UsageEnvironment& env, FramedSource* inputSource,
unsigned char streamCode = 0);
// If "streamCode" != 0, then we assume that there's a 1-byte code at the beginning of each chunk of data that we read from
// our source. If that code is not the value we want, we discard the chunk of data.
// However, if "streamCode" == 0 (the default), then we don't expect this 1-byte code.
unsigned samplingRate();
void flushInput(); // called if there is a discontinuity (seeking) in the input
private:
AC3AudioStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
unsigned char streamCode);
// called only by createNew()
virtual ~AC3AudioStreamFramer();
static void handleNewData(void* clientData,
unsigned char* ptr, unsigned size,
struct timeval presentationTime);
void handleNewData(unsigned char* ptr, unsigned size);
void parseNextFrame();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
private:
struct timeval currentFramePlayTime() const;
private:
struct timeval fNextFramePresentationTime;
private: // parsing state
class AC3AudioStreamParser* fParser;
unsigned char fOurStreamCode;
friend class AC3AudioStreamParser; // hack
};
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from an AAC audio file in ADTS format
// C++ header
#ifndef _ADTS_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _ADTS_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API ADTSAudioFileServerMediaSubsession: public FileServerMediaSubsession{
public:
static ADTSAudioFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
protected:
ADTSAudioFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~ADTSAudioFileServerMediaSubsession();
protected: // redefined virtual functions
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
};
#endif

View File

@ -0,0 +1,56 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A source object for AAC audio files in ADTS format
// C++ header
#ifndef _ADTS_AUDIO_FILE_SOURCE_HH
#define _ADTS_AUDIO_FILE_SOURCE_HH
#ifndef _FRAMED_FILE_SOURCE_HH
#include "FramedFileSource.hh"
#endif
class LIVEMEDIA_API ADTSAudioFileSource: public FramedFileSource {
public:
static ADTSAudioFileSource* createNew(UsageEnvironment& env,
char const* fileName);
unsigned samplingFrequency() const { return fSamplingFrequency; }
unsigned numChannels() const { return fNumChannels; }
char const* configStr() const { return fConfigStr; }
// returns the 'AudioSpecificConfig' for this stream (in ASCII form)
private:
ADTSAudioFileSource(UsageEnvironment& env, FILE* fid, u_int8_t profile,
u_int8_t samplingFrequencyIndex, u_int8_t channelConfiguration);
// called only by createNew()
virtual ~ADTSAudioFileSource();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
private:
unsigned fSamplingFrequency;
unsigned fNumChannels;
unsigned fuSecsPerFrame;
char fConfigStr[5];
};
#endif

View File

@ -0,0 +1,61 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that reads (discrete) AAC audio frames, and outputs each frame with
// a preceding ADTS header.
// C++ header
#ifndef _ADTS_AUDIO_STREAM_DISCRETE_FRAMER_HH
#define _ADTS_AUDIO_STREAM_DISCRETE_FRAMER_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
#define ADTS_HEADER_SIZE 7 // we don't include a checksum
class LIVEMEDIA_API ADTSAudioStreamDiscreteFramer: public FramedFilter {
public:
static ADTSAudioStreamDiscreteFramer*
createNew(UsageEnvironment& env, FramedSource* inputSource, char const* configStr);
// "configStr" should be a 4-character hexadecimal string for a 2-byte value
protected:
ADTSAudioStreamDiscreteFramer(UsageEnvironment& env, FramedSource* inputSource,
u_int8_t profile, u_int8_t samplingFrequencyIndex, u_int8_t channelConfiguration);
// called only by createNew()
virtual ~ADTSAudioStreamDiscreteFramer();
protected:
// redefined virtual functions:
virtual void doGetNextFrame();
protected:
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
void afterGettingFrame1(unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
private:
u_int8_t fADTSHeader[ADTS_HEADER_SIZE];
};
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from an AMR audio file.
// C++ header
#ifndef _AMR_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _AMR_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API AMRAudioFileServerMediaSubsession: public FileServerMediaSubsession{
public:
static AMRAudioFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
private:
AMRAudioFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~AMRAudioFileServerMediaSubsession();
private: // redefined virtual functions
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
};
#endif

View File

@ -0,0 +1,51 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// AMR Audio File Sinks
// C++ header
#ifndef _AMR_AUDIO_FILE_SINK_HH
#define _AMR_AUDIO_FILE_SINK_HH
#ifndef _FILE_SINK_HH
#include "FileSink.hh"
#endif
class LIVEMEDIA_API AMRAudioFileSink: public FileSink {
public:
static AMRAudioFileSink* createNew(UsageEnvironment& env, char const* fileName,
unsigned bufferSize = 10000,
Boolean oneFilePerFrame = False);
// (See "FileSink.hh" for a description of these parameters.)
protected:
AMRAudioFileSink(UsageEnvironment& env, FILE* fid, unsigned bufferSize,
char const* perFrameFileNamePrefix);
// called only by createNew()
virtual ~AMRAudioFileSink();
protected: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
virtual void afterGettingFrame(unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime);
protected:
Boolean fHaveWrittenHeader;
};
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A source object for AMR audio files (as defined in RFC 4867, section 5)
// C++ header
#ifndef _AMR_AUDIO_FILE_SOURCE_HH
#define _AMR_AUDIO_FILE_SOURCE_HH
#ifndef _AMR_AUDIO_SOURCE_HH
#include "AMRAudioSource.hh"
#endif
class LIVEMEDIA_API AMRAudioFileSource: public AMRAudioSource {
public:
static AMRAudioFileSource* createNew(UsageEnvironment& env,
char const* fileName);
private:
AMRAudioFileSource(UsageEnvironment& env, FILE* fid,
Boolean isWideband, unsigned numChannels);
// called only by createNew()
virtual ~AMRAudioFileSource();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
private:
FILE* fFid;
};
#endif

View File

@ -0,0 +1,65 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for AMR audio (RFC 4867)
// C++ header
#ifndef _AMR_AUDIO_RTP_SINK_HH
#define _AMR_AUDIO_RTP_SINK_HH
#ifndef _AUDIO_RTP_SINK_HH
#include "AudioRTPSink.hh"
#endif
class LIVEMEDIA_API AMRAudioRTPSink: public AudioRTPSink {
public:
static AMRAudioRTPSink* createNew(UsageEnvironment& env,
Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
Boolean sourceIsWideband = False,
unsigned numChannelsInSource = 1);
Boolean sourceIsWideband() const { return fSourceIsWideband; }
protected:
AMRAudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
Boolean sourceIsWideband, unsigned numChannelsInSource);
// called only by createNew()
virtual ~AMRAudioRTPSink();
private: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual Boolean
frameCanAppearAfterPacketStart(unsigned char const* frameStart,
unsigned numBytesInFrame) const;
virtual unsigned specialHeaderSize() const;
virtual char const* auxSDPLine();
private:
Boolean fSourceIsWideband;
char* fFmtpSDPLine;
};
#endif

View File

@ -0,0 +1,53 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// AMR Audio RTP Sources (RFC 4867)
// C++ header
#ifndef _AMR_AUDIO_RTP_SOURCE_HH
#define _AMR_AUDIO_RTP_SOURCE_HH
#ifndef _RTP_SOURCE_HH
#include "RTPSource.hh"
#endif
#ifndef _AMR_AUDIO_SOURCE_HH
#include "AMRAudioSource.hh"
#endif
class LIVEMEDIA_API AMRAudioRTPSource {
public:
static AMRAudioSource* createNew(UsageEnvironment& env,
Groupsock* RTPgs,
RTPSource*& resultRTPSource,
unsigned char rtpPayloadFormat,
Boolean isWideband = False,
unsigned numChannels = 1,
Boolean isOctetAligned = True,
unsigned interleaving = 0,
// relevant only if "isOctetAligned"
// The maximum # of frame-blocks in a group
// 0 means: no interleaving
Boolean robustSortingOrder = False,
// relevant only if "isOctetAligned"
Boolean CRCsArePresent = False
// relevant only if "isOctetAligned"
);
// This returns a source to read from, but "resultRTPSource" will
// point to RTP-related state.
};
#endif

View File

@ -0,0 +1,52 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A source object for AMR audio sources
// C++ header
#ifndef _AMR_AUDIO_SOURCE_HH
#define _AMR_AUDIO_SOURCE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
class LIVEMEDIA_API AMRAudioSource: public FramedSource {
public:
Boolean isWideband() const { return fIsWideband; }
unsigned numChannels() const { return fNumChannels; }
u_int8_t lastFrameHeader() const { return fLastFrameHeader; }
// The frame header for the most recently read frame (RFC 4867, sec. 5.3)
protected:
AMRAudioSource(UsageEnvironment& env, Boolean isWideband, unsigned numChannels);
// virtual base class
virtual ~AMRAudioSource();
private:
// redefined virtual functions:
virtual char const* MIMEtype() const;
virtual Boolean isAMRAudioSource() const;
protected:
Boolean fIsWideband;
unsigned fNumChannels;
u_int8_t fLastFrameHeader;
};
#endif

View File

@ -0,0 +1,115 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A sink that generates an AVI file from a composite media session
// C++ header
#ifndef _AVI_FILE_SINK_HH
#define _AVI_FILE_SINK_HH
#ifndef _MEDIA_SESSION_HH
#include "MediaSession.hh"
#endif
class LIVEMEDIA_API AVIFileSink: public Medium {
public:
static AVIFileSink* createNew(UsageEnvironment& env,
MediaSession& inputSession,
char const* outputFileName,
unsigned bufferSize = 20000,
unsigned short movieWidth = 240,
unsigned short movieHeight = 180,
unsigned movieFPS = 15,
Boolean packetLossCompensate = False);
typedef void (afterPlayingFunc)(void* clientData);
Boolean startPlaying(afterPlayingFunc* afterFunc,
void* afterClientData);
unsigned numActiveSubsessions() const { return fNumSubsessions; }
private:
AVIFileSink(UsageEnvironment& env, MediaSession& inputSession,
char const* outputFileName, unsigned bufferSize,
unsigned short movieWidth, unsigned short movieHeight,
unsigned movieFPS, Boolean packetLossCompensate);
// called only by createNew()
virtual ~AVIFileSink();
Boolean continuePlaying();
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
static void onSourceClosure(void* clientData);
void onSourceClosure1();
static void onRTCPBye(void* clientData);
void addIndexRecord(class AVIIndexRecord* newIndexRecord);
void completeOutputFile();
private:
friend class AVISubsessionIOState;
MediaSession& fInputSession;
FILE* fOutFid;
class AVIIndexRecord *fIndexRecordsHead, *fIndexRecordsTail;
unsigned fNumIndexRecords;
unsigned fBufferSize;
Boolean fPacketLossCompensate;
Boolean fAreCurrentlyBeingPlayed;
afterPlayingFunc* fAfterFunc;
void* fAfterClientData;
unsigned fNumSubsessions;
unsigned fNumBytesWritten;
struct timeval fStartTime;
Boolean fHaveCompletedOutputFile;
private:
///// Definitions specific to the AVI file format:
unsigned addWord(unsigned word); // outputs "word" in little-endian order
unsigned addHalfWord(unsigned short halfWord);
unsigned addByte(unsigned char byte) {
putc(byte, fOutFid);
return 1;
}
unsigned addZeroWords(unsigned numWords);
unsigned add4ByteString(char const* str);
void setWord(unsigned filePosn, unsigned size);
// Define member functions for outputting various types of file header:
#define _header(name) unsigned addFileHeader_##name()
_header(AVI);
_header(hdrl);
_header(avih);
_header(strl);
_header(strh);
_header(strf);
_header(JUNK);
// _header(JUNK);
_header(movi);
private:
unsigned short fMovieWidth, fMovieHeight;
unsigned fMovieFPS;
unsigned fRIFFSizePosition, fRIFFSizeValue;
unsigned fAVIHMaxBytesPerSecondPosition;
unsigned fAVIHFrameCountPosition;
unsigned fMoviSizePosition, fMoviSizeValue;
class AVISubsessionIOState* fCurrentIOState;
unsigned fJunkNumber;
};
#endif

View File

@ -0,0 +1,71 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Generic audio input device (such as a microphone, or an input sound card)
// C++ header
#ifndef _AUDIO_INPUT_DEVICE_HH
#define _AUDIO_INPUT_DEVICE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
class LIVEMEDIA_API AudioPortNames {
public:
AudioPortNames();
virtual ~AudioPortNames();
unsigned numPorts;
char** portName;
};
class LIVEMEDIA_API AudioInputDevice: public FramedSource {
public:
unsigned char bitsPerSample() const { return fBitsPerSample; }
unsigned char numChannels() const { return fNumChannels; }
unsigned samplingFrequency() const { return fSamplingFrequency; }
virtual Boolean setInputPort(int portIndex) = 0;
virtual double getAverageLevel() const = 0;
static AudioInputDevice*
createNew(UsageEnvironment& env, int inputPortNumber,
unsigned char bitsPerSample, unsigned char numChannels,
unsigned samplingFrequency, unsigned granularityInMS = 20);
static AudioPortNames* getPortNames();
static char** allowedDeviceNames;
// If this is set to non-NULL, then it's a NULL-terminated array of strings
// of device names that we are allowed to access.
protected:
AudioInputDevice(UsageEnvironment& env,
unsigned char bitsPerSample,
unsigned char numChannels,
unsigned samplingFrequency,
unsigned granularityInMS);
// we're an abstract base class
virtual ~AudioInputDevice();
protected:
unsigned char fBitsPerSample, fNumChannels;
unsigned fSamplingFrequency;
unsigned fGranularityInMS;
};
#endif

View File

@ -0,0 +1,42 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A generic RTP sink for audio codecs (abstract base class)
// C++ header
#ifndef _AUDIO_RTP_SINK_HH
#define _AUDIO_RTP_SINK_HH
#ifndef _MULTI_FRAMED_RTP_SINK_HH
#include "MultiFramedRTPSink.hh"
#endif
class LIVEMEDIA_API AudioRTPSink: public MultiFramedRTPSink {
protected:
AudioRTPSink(UsageEnvironment& env,
Groupsock* rtpgs, unsigned char rtpPayloadType,
unsigned rtpTimestampFrequency,
char const* rtpPayloadFormatName,
unsigned numChannels = 1);
// (we're an abstract base class)
virtual ~AudioRTPSink();
private: // redefined virtual functions:
virtual char const* sdpMediaType() const;
};
#endif

View File

@ -0,0 +1,43 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Base64 encoding and decoding
// C++ header
#ifndef _BASE64_HH
#define _BASE64_HH
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
LIVEMEDIA_API unsigned char* base64Decode(char const* in, unsigned& resultSize,
Boolean trimTrailingZeros = True);
// returns a newly allocated array - of size "resultSize" - that
// the caller is responsible for delete[]ing.
LIVEMEDIA_API unsigned char* base64Decode(char const* in, unsigned inSize,
unsigned& resultSize,
Boolean trimTrailingZeros = True);
// As above, but includes the size of the input string (i.e., the number of bytes to decode) as a parameter.
// This saves an extra call to "strlen()" if we already know the length of the input string.
LIVEMEDIA_API char* base64Encode(char const* orig, unsigned origLength);
// returns a 0-terminated string that
// the caller is responsible for delete[]ing.
#endif

View File

@ -0,0 +1,62 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A simple UDP sink (i.e., without RTP or other headers added); one frame per packet
// C++ header
#ifndef _BASIC_UDP_SINK_HH
#define _BASIC_UDP_SINK_HH
#ifndef _MEDIA_SINK_HH
#include "MediaSink.hh"
#endif
#ifndef _GROUPSOCK_HH
#include <Groupsock.hh>
#endif
class LIVEMEDIA_API BasicUDPSink: public MediaSink {
public:
static BasicUDPSink* createNew(UsageEnvironment& env, Groupsock* gs,
unsigned maxPayloadSize = 1450);
protected:
BasicUDPSink(UsageEnvironment& env, Groupsock* gs, unsigned maxPayloadSize);
// called only by createNew()
virtual ~BasicUDPSink();
private: // redefined virtual functions:
virtual Boolean continuePlaying();
private:
void continuePlaying1();
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
void afterGettingFrame1(unsigned frameSize, unsigned numTruncatedBytes,
unsigned durationInMicroseconds);
static void sendNext(void* firstArg);
private:
Groupsock* fGS;
unsigned fMaxPayloadSize;
unsigned char* fOutputBuffer;
struct timeval fNextSendTime;
};
#endif

View File

@ -0,0 +1,56 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A simple UDP source, where every UDP payload is a complete frame
// C++ header
#ifndef _BASIC_UDP_SOURCE_HH
#define _BASIC_UDP_SOURCE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
#ifndef _GROUPSOCK_HH
#include "Groupsock.hh"
#endif
class LIVEMEDIA_API BasicUDPSource: public FramedSource {
public:
static BasicUDPSource* createNew(UsageEnvironment& env, Groupsock* inputGS);
virtual ~BasicUDPSource();
Groupsock* gs() const { return fInputGS; }
private:
BasicUDPSource(UsageEnvironment& env, Groupsock* inputGS);
// called only by createNew()
static void incomingPacketHandler(BasicUDPSource* source, int mask);
void incomingPacketHandler1();
private: // redefined virtual functions:
virtual unsigned maxFrameSize() const;
virtual void doGetNextFrame();
virtual void doStopGettingFrames();
private:
Groupsock* fInputGS;
Boolean fHaveStartedReading;
};
#endif

View File

@ -0,0 +1,67 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Bit Vector data structure
// C++ header
#ifndef _BIT_VECTOR_HH
#define _BIT_VECTOR_HH
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
class LIVEMEDIA_API BitVector {
public:
BitVector(unsigned char* baseBytePtr,
unsigned baseBitOffset,
unsigned totNumBits);
void setup(unsigned char* baseBytePtr,
unsigned baseBitOffset,
unsigned totNumBits);
void putBits(unsigned from, unsigned numBits); // "numBits" <= 32
void put1Bit(unsigned bit);
unsigned getBits(unsigned numBits); // "numBits" <= 32
unsigned get1Bit();
Boolean get1BitBoolean() { return get1Bit() != 0; }
void skipBits(unsigned numBits);
unsigned curBitIndex() const { return fCurBitIndex; }
unsigned totNumBits() const { return fTotNumBits; }
unsigned numBitsRemaining() const { return fTotNumBits - fCurBitIndex; }
unsigned get_expGolomb();
// Returns the value of the next bits, assuming that they were encoded using an exponential-Golomb code of order 0
int get_expGolombSigned(); // signed version of the above
private:
unsigned char* fBaseBytePtr;
unsigned fBaseBitOffset;
unsigned fTotNumBits;
unsigned fCurBitIndex;
};
// A general bit copy operation:
void shiftBits(unsigned char* toBasePtr, unsigned toBitOffset,
unsigned char const* fromBasePtr, unsigned fromBitOffset,
unsigned numBits);
#endif

View File

@ -0,0 +1,82 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A file source that is a plain byte stream (rather than frames)
// C++ header
#ifndef _BYTE_STREAM_FILE_SOURCE_HH
#define _BYTE_STREAM_FILE_SOURCE_HH
#ifndef _FRAMED_FILE_SOURCE_HH
#include "FramedFileSource.hh"
#endif
class LIVEMEDIA_API ByteStreamFileSource: public FramedFileSource {
public:
static ByteStreamFileSource* createNew(UsageEnvironment& env,
char const* fileName,
unsigned preferredFrameSize = 0,
unsigned playTimePerFrame = 0);
// "preferredFrameSize" == 0 means 'no preference'
// "playTimePerFrame" is in microseconds
static ByteStreamFileSource* createNew(UsageEnvironment& env,
FILE* fid,
unsigned preferredFrameSize = 0,
unsigned playTimePerFrame = 0);
// an alternative version of "createNew()" that's used if you already have
// an open file.
u_int64_t fileSize() const { return fFileSize; }
// 0 means zero-length, unbounded, or unknown
void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream = 0);
// if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF
void seekToByteRelative(int64_t offset, u_int64_t numBytesToStream = 0);
void seekToEnd(); // to force EOF handling on the next read
protected:
ByteStreamFileSource(UsageEnvironment& env,
FILE* fid,
unsigned preferredFrameSize,
unsigned playTimePerFrame);
// called only by createNew()
virtual ~ByteStreamFileSource();
static void fileReadableHandler(ByteStreamFileSource* source, int mask);
void doReadFromFile();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
virtual void doStopGettingFrames();
protected:
u_int64_t fFileSize;
private:
unsigned fPreferredFrameSize;
unsigned fPlayTimePerFrame;
Boolean fFidIsSeekable;
unsigned fLastPlayTime;
Boolean fHaveStartedReading;
Boolean fLimitNumBytesToStream;
u_int64_t fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
};
#endif

View File

@ -0,0 +1,70 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A class for streaming data from a (static) memory buffer, as if it were a file.
// C++ header
#ifndef _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH
#define _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
class LIVEMEDIA_API ByteStreamMemoryBufferSource: public FramedSource {
public:
static ByteStreamMemoryBufferSource* createNew(UsageEnvironment& env,
u_int8_t* buffer, u_int64_t bufferSize,
Boolean deleteBufferOnClose = True,
unsigned preferredFrameSize = 0,
unsigned playTimePerFrame = 0);
// "preferredFrameSize" == 0 means 'no preference'
// "playTimePerFrame" is in microseconds
u_int64_t bufferSize() const { return fBufferSize; }
void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream = 0);
// if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF
void seekToByteRelative(int64_t offset, u_int64_t numBytesToStream = 0);
protected:
ByteStreamMemoryBufferSource(UsageEnvironment& env,
u_int8_t* buffer, u_int64_t bufferSize,
Boolean deleteBufferOnClose,
unsigned preferredFrameSize,
unsigned playTimePerFrame);
// called only by createNew()
virtual ~ByteStreamMemoryBufferSource();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
private:
u_int8_t* fBuffer;
u_int64_t fBufferSize;
u_int64_t fCurIndex;
Boolean fDeleteBufferOnClose;
unsigned fPreferredFrameSize;
unsigned fPlayTimePerFrame;
unsigned fLastPlayTime;
Boolean fLimitNumBytesToStream;
u_int64_t fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
};
#endif

View File

@ -0,0 +1,69 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A source that consists of multiple byte-stream files, read sequentially.
// (The input is an array of file names, with a terminating 'file name' of NULL.)
// C++ header
#ifndef _BYTE_STREAM_MULTI_FILE_SOURCE_HH
#define _BYTE_STREAM_MULTI_FILE_SOURCE_HH
#ifndef _BYTE_STREAM_FILE_SOURCE_HH
#include "ByteStreamFileSource.hh"
#endif
class LIVEMEDIA_API ByteStreamMultiFileSource: public FramedSource {
public:
static ByteStreamMultiFileSource*
createNew(UsageEnvironment& env, char const** fileNameArray,
unsigned preferredFrameSize = 0, unsigned playTimePerFrame = 0);
// "fileNameArray" is a pointer to an array of (char const*) file names, with
// A 'file name' of NULL indicating the end of the array
Boolean haveStartedNewFile() const { return fHaveStartedNewFile; }
// True iff the most recently delivered frame was the first from a newly-opened file
protected:
ByteStreamMultiFileSource(UsageEnvironment& env, char const** fileNameArray,
unsigned preferredFrameSize, unsigned playTimePerFrame);
// called only by createNew()
virtual ~ByteStreamMultiFileSource();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
private:
static void onSourceClosure(void* clientData);
void onSourceClosure1();
static void afterGettingFrame(void* clientData,
unsigned frameSize, unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
private:
unsigned fPreferredFrameSize;
unsigned fPlayTimePerFrame;
unsigned fNumSources;
unsigned fCurrentlyReadSourceNumber;
Boolean fHaveStartedNewFile;
char const** fFileNameArray;
ByteStreamFileSource** fSourceArray;
};
#endif

View File

@ -0,0 +1,51 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from a DV video file.
// C++ header
#ifndef _DV_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _DV_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API DVVideoFileServerMediaSubsession: public FileServerMediaSubsession{
public:
static DVVideoFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
private:
DVVideoFileServerMediaSubsession(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~DVVideoFileServerMediaSubsession();
private: // redefined virtual functions
virtual char const* getAuxSDPLine(RTPSink* rtpSink, FramedSource* inputSource);
virtual void seekStreamSource(FramedSource* inputSource, double& seekNPT, double streamDuration, u_int64_t& numBytes);
virtual void setStreamSourceDuration(FramedSource* inputSource, double streamDuration, u_int64_t& numBytes);
virtual FramedSource* createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource* inputSource);
virtual float duration() const;
private:
float fFileDuration; // in seconds
};
#endif

View File

@ -0,0 +1,57 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for DV video (RFC 3189)
// (Thanks to Ben Hutchings for prototyping this.)
// C++ header
#ifndef _DV_VIDEO_RTP_SINK_HH
#define _DV_VIDEO_RTP_SINK_HH
#ifndef _VIDEO_RTP_SINK_HH
#include "VideoRTPSink.hh"
#endif
#ifndef _DV_VIDEO_STREAM_FRAMER_HH
#include "DVVideoStreamFramer.hh"
#endif
class LIVEMEDIA_API DVVideoRTPSink: public VideoRTPSink {
public:
static DVVideoRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);
char const* auxSDPLineFromFramer(DVVideoStreamFramer* framerSource);
protected:
DVVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);
// called only by createNew()
virtual ~DVVideoRTPSink();
private: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual unsigned computeOverflowForNewFrame(unsigned newFrameSize) const;
virtual char const* auxSDPLine();
private:
char* fFmtpSDPLine;
};
#endif

View File

@ -0,0 +1,51 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// DV Video RTP Sources
// C++ header
#ifndef _DV_VIDEO_RTP_SOURCE_HH
#define _DV_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API DVVideoRTPSource: public MultiFramedRTPSource {
public:
static DVVideoRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
protected:
virtual ~DVVideoRTPSource();
private:
DVVideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
// called only by createNew()
private:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
};
#endif

View File

@ -0,0 +1,72 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that parses a DV input stream into DV frames to deliver to the downstream object
// C++ header
#ifndef _DV_VIDEO_STREAM_FRAMER_HH
#define _DV_VIDEO_STREAM_FRAMER_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
#define DV_DIF_BLOCK_SIZE 80
#define DV_NUM_BLOCKS_PER_SEQUENCE 150
#define DV_SAVED_INITIAL_BLOCKS_SIZE ((DV_NUM_BLOCKS_PER_SEQUENCE+6-1)*DV_DIF_BLOCK_SIZE)
/* enough data to ensure that it contains an intact 6-block header (which occurs at the start of a 150-block sequence) */
class LIVEMEDIA_API DVVideoStreamFramer: public FramedFilter {
public:
static DVVideoStreamFramer*
createNew(UsageEnvironment& env, FramedSource* inputSource,
Boolean sourceIsSeekable = False, Boolean leavePresentationTimesUnmodified = False);
// Set "sourceIsSeekable" to True if the input source is a seekable object (e.g. a file), and the server that uses us
// does a seek-to-zero on the source before reading from it. (Our RTSP server implementation does this.)
char const* profileName();
Boolean getFrameParameters(unsigned& frameSize/*bytes*/, double& frameDuration/*microseconds*/);
protected:
DVVideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
Boolean sourceIsSeekable, Boolean leavePresentationTimesUnmodified);
// called only by createNew(), or by subclass constructors
virtual ~DVVideoStreamFramer();
protected:
// redefined virtual functions:
virtual Boolean isDVVideoStreamFramer() const;
virtual void doGetNextFrame();
protected:
void getAndDeliverData(); // used to implement "doGetNextFrame()"
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime);
void getProfile();
protected:
Boolean fLeavePresentationTimesUnmodified;
void const* fOurProfile;
struct timeval fNextFramePresentationTime;
unsigned char fSavedInitialBlocks[DV_SAVED_INITIAL_BLOCKS_SIZE];
char fInitialBlocksPresent;
Boolean fSourceIsSeekable;
};
#endif

View File

@ -0,0 +1,66 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A template for a MediaSource encapsulating an audio/video input device
//
// NOTE: Sections of this code labeled "%%% TO BE WRITTEN %%%" are incomplete, and needto be written by the programmer
// (depending on the features of the particulardevice).
// C++ header
#ifndef _DEVICE_SOURCE_HH
#define _DEVICE_SOURCE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
// The following class can be used to define specific encoder parameters
class LIVEMEDIA_API DeviceParameters {
//%%% TO BE WRITTEN %%%
};
class LIVEMEDIA_API DeviceSource: public FramedSource {
public:
static DeviceSource* createNew(UsageEnvironment& env,
DeviceParameters params);
public:
static EventTriggerId eventTriggerId;
// Note that this is defined here to be a static class variable, because this code is intended to illustrate how to
// encapsulate a *single* device - not a set of devices.
// You can, however, redefine this to be a non-static member variable.
protected:
DeviceSource(UsageEnvironment& env, DeviceParameters params);
// called only by createNew(), or by subclass constructors
virtual ~DeviceSource();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
//virtual void doStopGettingFrames(); // optional
private:
static void deliverFrame0(void* clientData);
void deliverFrame();
private:
static unsigned referenceCount; // used to count how many instances of this class currently exist
DeviceParameters fParams;
};
#endif

View File

@ -0,0 +1,75 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A class used for digest authentication.
// C++ header
#ifndef _DIGEST_AUTHENTICATION_HH
#define _DIGEST_AUTHENTICATION_HH
#ifndef _BOOLEAN_HH
#include <Boolean.hh>
#endif
// A class used for digest authentication.
// The "realm", and "nonce" fields are supplied by the server
// (in a "401 Unauthorized" response).
// The "username" and "password" fields are supplied by the client.
class LIVEMEDIA_API Authenticator {
public:
Authenticator();
Authenticator(char const* username, char const* password, Boolean passwordIsMD5 = False);
// If "passwordIsMD5" is True, then "password" is actually the value computed
// by md5(<username>:<realm>:<actual-password>)
Authenticator(const Authenticator& orig);
Authenticator& operator=(const Authenticator& rightSide);
Boolean operator<(const Authenticator* rightSide);
virtual ~Authenticator();
void reset();
void setRealmAndNonce(char const* realm, char const* nonce);
void setRealmAndRandomNonce(char const* realm);
// as above, except that the nonce is created randomly.
// (This is used by servers.)
void setUsernameAndPassword(char const* username, char const* password, Boolean passwordIsMD5 = False);
// If "passwordIsMD5" is True, then "password" is actually the value computed
// by md5(<username>:<realm>:<actual-password>)
char const* realm() const { return fRealm; }
char const* nonce() const { return fNonce; }
char const* username() const { return fUsername; }
char const* password() const { return fPassword; }
char const* computeDigestResponse(char const* cmd, char const* url) const;
// The returned string from this function must later be freed by calling:
void reclaimDigestResponse(char const* responseStr) const;
private:
void resetRealmAndNonce();
void resetUsernameAndPassword();
void assignRealmAndNonce(char const* realm, char const* nonce);
void assignUsernameAndPassword(char const* username, char const* password, Boolean passwordIsMD5);
void assign(char const* realm, char const* nonce,
char const* username, char const* password, Boolean passwordIsMD5);
private:
char* fRealm; char* fNonce;
char* fUsername; char* fPassword;
Boolean fPasswordIsMD5;
};
#endif

View File

@ -0,0 +1,43 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from a file.
// C++ header
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#define _FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _SERVER_MEDIA_SESSION_HH
#include "ServerMediaSession.hh"
#endif
#ifndef _ON_DEMAND_SERVER_MEDIA_SUBSESSION_HH
#include "OnDemandServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API FileServerMediaSubsession: public OnDemandServerMediaSubsession {
protected: // we're a virtual base class
FileServerMediaSubsession(UsageEnvironment& env, char const* fileName,
Boolean reuseFirstSource);
virtual ~FileServerMediaSubsession();
protected:
char const* fFileName;
u_int64_t fFileSize; // if known
};
#endif

View File

@ -0,0 +1,71 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// File Sinks
// C++ header
#ifndef _FILE_SINK_HH
#define _FILE_SINK_HH
#ifndef _MEDIA_SINK_HH
#include "MediaSink.hh"
#endif
class LIVEMEDIA_API FileSink: public MediaSink {
public:
static FileSink* createNew(UsageEnvironment& env, char const* fileName,
unsigned bufferSize = 20000,
Boolean oneFilePerFrame = False);
// "bufferSize" should be at least as large as the largest expected
// input frame.
// "oneFilePerFrame" - if True - specifies that each input frame will
// be written to a separate file (using the presentation time as a
// file name suffix). The default behavior ("oneFilePerFrame" == False)
// is to output all incoming data into a single file.
virtual void addData(unsigned char const* data, unsigned dataSize,
struct timeval presentationTime);
// (Available in case a client wants to add extra data to the output file)
protected:
FileSink(UsageEnvironment& env, FILE* fid, unsigned bufferSize,
char const* perFrameFileNamePrefix);
// called only by createNew()
virtual ~FileSink();
protected: // redefined virtual functions:
virtual Boolean continuePlaying();
protected:
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
virtual void afterGettingFrame(unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime);
FILE* fOutFid;
unsigned char* fBuffer;
unsigned fBufferSize;
char* fPerFrameFileNamePrefix; // used if "oneFilePerFrame" is True
char* fPerFrameFileNameBuffer; // used if "oneFilePerFrame" is True
struct timeval fPrevPresentationTime;
unsigned fSamePresentationTimeCounter;
};
#endif

View File

@ -0,0 +1,37 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Framed File Sources
// C++ header
#ifndef _FRAMED_FILE_SOURCE_HH
#define _FRAMED_FILE_SOURCE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
class LIVEMEDIA_API FramedFileSource: public FramedSource {
protected:
FramedFileSource(UsageEnvironment& env, FILE* fid); // abstract base class
virtual ~FramedFileSource();
protected:
FILE* fFid;
};
#endif

View File

@ -0,0 +1,52 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Framed Filters
// C++ header
#ifndef _FRAMED_FILTER_HH
#define _FRAMED_FILTER_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
class LIVEMEDIA_API FramedFilter: public FramedSource {
public:
FramedSource* inputSource() const { return fInputSource; }
void reassignInputSource(FramedSource* newInputSource) { fInputSource = newInputSource; }
// Call before destruction if you want to prevent the destructor from closing the input source
void detachInputSource();
protected:
FramedFilter(UsageEnvironment& env, FramedSource* inputSource);
// abstract base class
virtual ~FramedFilter();
protected:
// Redefined virtual functions (with default 'null' implementations):
virtual char const* MIMEtype() const;
virtual void getAttributes() const;
virtual void doStopGettingFrames();
protected:
FramedSource* fInputSource;
};
#endif

View File

@ -0,0 +1,95 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Framed Sources
// C++ header
#ifndef _FRAMED_SOURCE_HH
#define _FRAMED_SOURCE_HH
#ifndef _NET_COMMON_H
#include "NetCommon.h"
#endif
#ifndef _MEDIA_SOURCE_HH
#include "MediaSource.hh"
#endif
class LIVEMEDIA_API FramedSource: public MediaSource {
public:
static Boolean lookupByName(UsageEnvironment& env, char const* sourceName,
FramedSource*& resultSource);
typedef void (afterGettingFunc)(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
typedef void (onCloseFunc)(void* clientData);
void getNextFrame(unsigned char* to, unsigned maxSize,
afterGettingFunc* afterGettingFunc,
void* afterGettingClientData,
onCloseFunc* onCloseFunc,
void* onCloseClientData);
static void handleClosure(void* clientData);
void handleClosure();
// This should be called (on ourself) if the source is discovered
// to be closed (i.e., no longer readable)
void stopGettingFrames();
virtual unsigned maxFrameSize() const;
// size of the largest possible frame that we may serve, or 0
// if no such maximum is known (default)
virtual void doGetNextFrame() = 0;
// called by getNextFrame()
Boolean isCurrentlyAwaitingData() const {return fIsCurrentlyAwaitingData;}
static void afterGetting(FramedSource* source);
// doGetNextFrame() should arrange for this to be called after the
// frame has been read (*iff* it is read successfully)
protected:
FramedSource(UsageEnvironment& env); // abstract base class
virtual ~FramedSource();
virtual void doStopGettingFrames();
protected:
// The following variables are typically accessed/set by doGetNextFrame()
unsigned char* fTo; // in
unsigned fMaxSize; // in
unsigned fFrameSize; // out
unsigned fNumTruncatedBytes; // out
struct timeval fPresentationTime; // out
unsigned fDurationInMicroseconds; // out
private:
// redefined virtual functions:
virtual Boolean isFramedSource() const;
private:
afterGettingFunc* fAfterGettingFunc;
void* fAfterGettingClientData;
onCloseFunc* fOnCloseFunc;
void* fOnCloseClientData;
Boolean fIsCurrentlyAwaitingData;
};
#endif

View File

@ -0,0 +1,44 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for GSM audio
// C++ header
#ifndef _GSM_AUDIO_RTP_SINK_HH
#define _GSM_AUDIO_RTP_SINK_HH
#ifndef _AUDIO_RTP_SINK_HH
#include "AudioRTPSink.hh"
#endif
class LIVEMEDIA_API GSMAudioRTPSink: public AudioRTPSink {
public:
static GSMAudioRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs);
protected:
GSMAudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs);
// called only by createNew()
virtual ~GSMAudioRTPSink();
private: // redefined virtual functions:
virtual
Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
unsigned numBytesInFrame) const;
};
#endif

View File

@ -0,0 +1,224 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A generic media server class, used to implement a RTSP server, and any other server that uses
// "ServerMediaSession" objects to describe media to be served.
// C++ header
#ifndef _GENERIC_MEDIA_SERVER_HH
#define _GENERIC_MEDIA_SERVER_HH
#ifndef _MEDIA_HH
#include "Media.hh"
#endif
#ifndef _SERVER_MEDIA_SESSION_HH
#include "ServerMediaSession.hh"
#endif
#ifndef REQUEST_BUFFER_SIZE
#define REQUEST_BUFFER_SIZE 20000 // for incoming requests
#endif
#ifndef RESPONSE_BUFFER_SIZE
#define RESPONSE_BUFFER_SIZE 20000
#endif
// Typedef for a handler function that gets called when "lookupServerMediaSession()"
// (defined below) completes:
typedef void lookupServerMediaSessionCompletionFunc(void* clientData,
ServerMediaSession* sessionLookedUp);
class LIVEMEDIA_API GenericMediaServer: public Medium {
public:
virtual void addServerMediaSession(ServerMediaSession* serverMediaSession);
virtual void lookupServerMediaSession(char const* streamName,
lookupServerMediaSessionCompletionFunc* completionFunc,
void* completionClientData,
Boolean isFirstLookupInSession = True);
// Note: This is a virtual function, so can be reimplemented by subclasses.
void lookupServerMediaSession(char const* streamName,
void (GenericMediaServer::*memberFunc)(ServerMediaSession*));
// Special case of "lookupServerMediaSession()" where the 'completion function' is a
// member function of "GenericMediaServer" (and the 'completion client data' is "this".)
void removeServerMediaSession(ServerMediaSession* serverMediaSession);
// Removes the "ServerMediaSession" object from our lookup table, so it will no longer be accessible by new clients.
// (However, any *existing* client sessions that use this "ServerMediaSession" object will continue streaming.
// The "ServerMediaSession" object will not get deleted until all of these client sessions have closed.)
// (To both delete the "ServerMediaSession" object *and* close all client sessions that use it,
// call "deleteServerMediaSession(serverMediaSession)" instead.)
virtual void removeServerMediaSession(char const* streamName);
// ditto
void closeAllClientSessionsForServerMediaSession(ServerMediaSession* serverMediaSession);
// Closes (from the server) all client sessions that are currently using this "ServerMediaSession" object.
// Note, however, that the "ServerMediaSession" object remains accessible by new clients.
virtual void closeAllClientSessionsForServerMediaSession(char const* streamName);
// ditto
void deleteServerMediaSession(ServerMediaSession* serverMediaSession);
// Equivalent to:
// "closeAllClientSessionsForServerMediaSession(serverMediaSession); removeServerMediaSession(serverMediaSession);"
virtual void deleteServerMediaSession(char const* streamName);
// Equivalent to:
// "closeAllClientSessionsForServerMediaSession(streamName); removeServerMediaSession(streamName);
unsigned numClientSessions() const { return fClientSessions->numEntries(); }
protected:
GenericMediaServer(UsageEnvironment& env, int ourSocketIPv4, int ourSocketIPv6, Port ourPort,
unsigned reclamationSeconds);
// If "reclamationSeconds" > 0, then the "ClientSession" state for each client will get
// reclaimed if no activity from the client is detected in at least "reclamationSeconds".
// we're an abstract base class
virtual ~GenericMediaServer();
void cleanup(); // MUST be called in the destructor of any subclass of us
static int setUpOurSocket(UsageEnvironment& env, Port& ourPort, int domain);
static void incomingConnectionHandlerIPv4(void*, int /*mask*/);
static void incomingConnectionHandlerIPv6(void*, int /*mask*/);
void incomingConnectionHandlerIPv4();
void incomingConnectionHandlerIPv6();
void incomingConnectionHandlerOnSocket(int serverSocket);
void setTLSFileNames(char const* certFileName, char const* privKeyFileName);
public: // should be protected, but some old compilers complain otherwise
// The state of a TCP connection used by a client:
class ClientConnection {
protected:
ClientConnection(GenericMediaServer& ourServer,
int clientSocket, struct sockaddr_storage const& clientAddr,
Boolean useTLS);
virtual ~ClientConnection();
UsageEnvironment& envir() { return fOurServer.envir(); }
void closeSockets();
static void incomingRequestHandler(void*, int /*mask*/);
void incomingRequestHandler();
virtual void handleRequestBytes(int newBytesRead) = 0;
void resetRequestBuffer();
protected:
friend class GenericMediaServer;
friend class ClientSession;
friend class RTSPServer; // needed to make some broken Windows compilers work; remove this in the future when we end support for Windows
GenericMediaServer& fOurServer;
int fOurSocket;
struct sockaddr_storage fClientAddr;
unsigned char fRequestBuffer[REQUEST_BUFFER_SIZE];
unsigned char fResponseBuffer[RESPONSE_BUFFER_SIZE];
unsigned fRequestBytesAlreadySeen, fRequestBufferBytesLeft;
// Optional support for TLS:
ServerTLSState fTLS;
ServerTLSState* fInputTLS; // by default, just points to "fTLS", but subclasses may change
ServerTLSState* fOutputTLS; // ditto
};
// The state of an individual client session (using one or more sequential TCP connections) handled by a server:
class LIVEMEDIA_API ClientSession {
protected:
ClientSession(GenericMediaServer& ourServer, u_int32_t sessionId);
virtual ~ClientSession();
UsageEnvironment& envir() { return fOurServer.envir(); }
void noteLiveness();
static void noteClientLiveness(ClientSession* clientSession);
static void livenessTimeoutTask(ClientSession* clientSession);
protected:
friend class GenericMediaServer;
friend class ClientConnection;
GenericMediaServer& fOurServer;
u_int32_t fOurSessionId;
ServerMediaSession* fOurServerMediaSession;
TaskToken fLivenessCheckTask;
};
protected:
virtual ClientConnection* createNewClientConnection(int clientSocket, struct sockaddr_storage const& clientAddr) = 0;
virtual ClientSession* createNewClientSession(u_int32_t sessionId) = 0;
ClientSession* createNewClientSessionWithId();
// Generates a new (unused) random session id, and calls the "createNewClientSession()"
// virtual function with this session id as parameter.
// Lookup a "ClientSession" object by sessionId (integer, and string):
ClientSession* lookupClientSession(u_int32_t sessionId);
ClientSession* lookupClientSession(char const* sessionIdStr);
// An iterator over our "ServerMediaSession" objects:
class ServerMediaSessionIterator {
public:
ServerMediaSessionIterator(GenericMediaServer& server);
virtual ~ServerMediaSessionIterator();
ServerMediaSession* next();
private:
HashTable::Iterator* fOurIterator;
};
// The basic, synchronous "ServerMediaSession" lookup operation; only for subclasses:
ServerMediaSession* getServerMediaSession(char const* streamName);
protected:
friend class ClientConnection;
friend class ClientSession;
friend class ServerMediaSessionIterator;
int fServerSocketIPv4, fServerSocketIPv6;
Port fServerPort;
unsigned fReclamationSeconds;
HashTable* fServerMediaSessions; // maps 'stream name' strings to "ServerMediaSession" objects
HashTable* fClientConnections; // the "ClientConnection" objects that we're using
HashTable* fClientSessions; // maps 'session id' strings to "ClientSession" objects
private:
u_int32_t fPreviousClientSessionId;
char const* fTLSCertificateFileName;
char const* fTLSPrivateKeyFileName;
};
// A data structure used for optional user/password authentication:
class LIVEMEDIA_API UserAuthenticationDatabase {
public:
UserAuthenticationDatabase(char const* realm = NULL,
Boolean passwordsAreMD5 = False);
// If "passwordsAreMD5" is True, then each password stored into, or removed from,
// the database is actually the value computed
// by md5(<username>:<realm>:<actual-password>)
virtual ~UserAuthenticationDatabase();
virtual void addUserRecord(char const* username, char const* password);
virtual void removeUserRecord(char const* username);
virtual char const* lookupPassword(char const* username);
// returns NULL if the user name was not present
char const* realm() { return fRealm; }
Boolean passwordsAreMD5() { return fPasswordsAreMD5; }
protected:
HashTable* fTable;
char* fRealm;
Boolean fPasswordsAreMD5;
};
#endif

View File

@ -0,0 +1,56 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.261 Video RTP Sources
// C++ header
#ifndef _H261_VIDEO_RTP_SOURCE_HH
#define _H261_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API H261VideoRTPSource: public MultiFramedRTPSource {
public:
static H261VideoRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat = 31,
unsigned rtpTimestampFrequency = 90000);
u_int32_t lastSpecialHeader() const {return fLastSpecialHeader;}
protected:
virtual ~H261VideoRTPSource();
private:
H261VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
// called only by createNew()
private:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
private:
u_int32_t fLastSpecialHeader;
};
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from a H.263 video file.
// C++ header
#ifndef _H263PLUS_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _H263PLUS_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API H263plusVideoFileServerMediaSubsession: public FileServerMediaSubsession{
public:
static H263plusVideoFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
private:
H263plusVideoFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~H263plusVideoFileServerMediaSubsession();
private: // redefined virtual functions
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
};
#endif

View File

@ -0,0 +1,54 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for H.263+ video (RFC 4629)
// C++ header
#ifndef _H263_PLUS_VIDEO_RTP_SINK_HH
#define _H263_PLUS_VIDEO_RTP_SINK_HH
#ifndef _VIDEO_RTP_SINK_HH
#include "VideoRTPSink.hh"
#endif
class LIVEMEDIA_API H263plusVideoRTPSink: public VideoRTPSink {
public:
static H263plusVideoRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
u_int32_t rtpTimestampFrequency = 90000);
protected:
H263plusVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
u_int32_t rtpTimestampFrequency);
// called only by createNew()
virtual ~H263plusVideoRTPSink();
private: // redefined virtual functions:
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual
Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
unsigned numBytesInFrame) const;
virtual unsigned specialHeaderSize() const;
};
#endif

View File

@ -0,0 +1,60 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.263+ Video RTP Sources
// C++ header
#ifndef _H263_PLUS_VIDEO_RTP_SOURCE_HH
#define _H263_PLUS_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
#define SPECIAL_HEADER_BUFFER_SIZE 1000
class LIVEMEDIA_API H263plusVideoRTPSource: public MultiFramedRTPSource {
public:
static H263plusVideoRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency = 90000);
// A data structure that stores copies of the special header bytes
// from the most recent frame's RTP packets:
unsigned char fNumSpecialHeaders;
unsigned fSpecialHeaderBytesLength;
unsigned char fSpecialHeaderBytes[SPECIAL_HEADER_BUFFER_SIZE];
unsigned fPacketSizes[256];
protected:
virtual ~H263plusVideoRTPSource();
private:
H263plusVideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
// called only by createNew()
private:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
};
#endif

View File

@ -0,0 +1,64 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that breaks up an H263 video elementary stream into frames.
// Author Benhard Feiten
#ifndef _H263PLUS_VIDEO_STREAM_FRAMER_HH
#define _H263PLUS_VIDEO_STREAM_FRAMER_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
class LIVEMEDIA_API H263plusVideoStreamFramer: public FramedFilter {
public:
static H263plusVideoStreamFramer* createNew(UsageEnvironment& env, FramedSource* inputSource);
Boolean& pictureEndMarker() { return fPictureEndMarker; } // a hack for implementing the RTP 'M' bit
protected:
// Constructor called only by createNew(), or by subclass constructors
H263plusVideoStreamFramer(UsageEnvironment& env,
FramedSource* inputSource,
Boolean createParser = True);
virtual ~H263plusVideoStreamFramer();
public:
static void continueReadProcessing(void* clientData,
unsigned char* ptr, unsigned size,
struct timeval presentationTime);
void continueReadProcessing();
private:
virtual void doGetNextFrame();
virtual Boolean isH263plusVideoStreamFramer() const;
protected:
double fFrameRate;
unsigned fPictureCount; // hack used to implement doGetNextFrame() ??
Boolean fPictureEndMarker;
private:
class H263plusVideoStreamParser* fParser;
struct timeval fPresentationTimeBase;
};
#endif

View File

@ -0,0 +1,61 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from a H264 Elementary Stream video file.
// C++ header
#ifndef _H264_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _H264_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API H264VideoFileServerMediaSubsession: public FileServerMediaSubsession {
public:
static H264VideoFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
// Used to implement "getAuxSDPLine()":
void checkForAuxSDPLine1();
void afterPlayingDummy1();
protected:
H264VideoFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~H264VideoFileServerMediaSubsession();
void setDoneFlag() { fDoneFlag = ~0; }
protected: // redefined virtual functions
virtual char const* getAuxSDPLine(RTPSink* rtpSink,
FramedSource* inputSource);
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
private:
char* fAuxSDPLine;
char fDoneFlag; // used when setting up "fAuxSDPLine"
RTPSink* fDummyRTPSink; // ditto
};
#endif

View File

@ -0,0 +1,47 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.264 Video File Sinks
// C++ header
#ifndef _H264_VIDEO_FILE_SINK_HH
#define _H264_VIDEO_FILE_SINK_HH
#ifndef _H264_OR_5_VIDEO_FILE_SINK_HH
#include "H264or5VideoFileSink.hh"
#endif
class LIVEMEDIA_API H264VideoFileSink: public H264or5VideoFileSink {
public:
static H264VideoFileSink* createNew(UsageEnvironment& env, char const* fileName,
char const* sPropParameterSetsStr = NULL,
// "sPropParameterSetsStr" is an optional 'SDP format' string
// (comma-separated Base64-encoded) representing SPS and/or PPS NAL-units
// to prepend to the output
unsigned bufferSize = 100000,
Boolean oneFilePerFrame = False);
// See "FileSink.hh" for a description of these parameters.
protected:
H264VideoFileSink(UsageEnvironment& env, FILE* fid,
char const* sPropParameterSetsStr,
unsigned bufferSize, char const* perFrameFileNamePrefix);
// called only by createNew()
virtual ~H264VideoFileSink();
};
#endif

View File

@ -0,0 +1,59 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for H.264 video (RFC 3984)
// C++ header
#ifndef _H264_VIDEO_RTP_SINK_HH
#define _H264_VIDEO_RTP_SINK_HH
#ifndef _H264_OR_5_VIDEO_RTP_SINK_HH
#include "H264or5VideoRTPSink.hh"
#endif
class LIVEMEDIA_API H264VideoRTPSink: public H264or5VideoRTPSink {
public:
static H264VideoRTPSink*
createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);
static H264VideoRTPSink*
createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
u_int8_t const* sps, unsigned spsSize, u_int8_t const* pps, unsigned ppsSize);
// an optional variant of "createNew()", useful if we know, in advance,
// the stream's SPS and PPS NAL units.
// This avoids us having to 'pre-read' from the input source in order to get these values.
static H264VideoRTPSink*
createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
char const* sPropParameterSetsStr);
// an optional variant of "createNew()", useful if we know, in advance,
// the stream's SPS and PPS NAL units.
// This avoids us having to 'pre-read' from the input source in order to get these values.
protected:
H264VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
u_int8_t const* sps = NULL, unsigned spsSize = 0,
u_int8_t const* pps = NULL, unsigned ppsSize = 0);
// called only by createNew()
virtual ~H264VideoRTPSink();
protected: // redefined virtual functions:
virtual char const* auxSDPLine();
private: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
};
#endif

View File

@ -0,0 +1,70 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.264 Video RTP Sources
// C++ header
#ifndef _H264_VIDEO_RTP_SOURCE_HH
#define _H264_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API H264VideoRTPSource: public MultiFramedRTPSource {
public:
static H264VideoRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency = 90000);
protected:
H264VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
// called only by createNew()
virtual ~H264VideoRTPSource();
protected:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
private:
friend class H264BufferedPacket;
unsigned char fCurPacketNALUnitType;
};
class LIVEMEDIA_API SPropRecord {
public:
~SPropRecord() { delete[] sPropBytes; }
unsigned sPropLength; // in bytes
unsigned char* sPropBytes;
};
LIVEMEDIA_API SPropRecord* parseSPropParameterSets(char const* sPropParameterSetsStr,
// result parameter:
unsigned& numSPropRecords);
// Returns the binary value of each 'parameter set' specified in a
// "sprop-parameter-sets" string (in the SDP description for a H.264/RTP stream).
// The value is returned as an array (length "numSPropRecords") of "SPropRecord"s.
// This array is dynamically allocated by this routine, and must be delete[]d by the caller.
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A simplified version of "H264VideoStreamFramer" that takes only complete,
// discrete frames (rather than an arbitrary byte stream) as input.
// This avoids the parsing and data copying overhead of the full
// "H264VideoStreamFramer".
// C++ header
#ifndef _H264_VIDEO_STREAM_DISCRETE_FRAMER_HH
#define _H264_VIDEO_STREAM_DISCRETE_FRAMER_HH
#ifndef _H264_OR_5_VIDEO_STREAM_DISCRETE_FRAMER_HH
#include "H264or5VideoStreamDiscreteFramer.hh"
#endif
class LIVEMEDIA_API H264VideoStreamDiscreteFramer: public H264or5VideoStreamDiscreteFramer {
public:
static H264VideoStreamDiscreteFramer*
createNew(UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput = False, Boolean insertAccessUnitDelimiters = False);
protected:
H264VideoStreamDiscreteFramer(UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters);
// called only by createNew()
virtual ~H264VideoStreamDiscreteFramer();
private:
// redefined virtual functions:
virtual Boolean isH264VideoStreamFramer() const;
};
#endif

View File

@ -0,0 +1,45 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that breaks up a H.264 Video Elementary Stream into NAL units.
// C++ header
#ifndef _H264_VIDEO_STREAM_FRAMER_HH
#define _H264_VIDEO_STREAM_FRAMER_HH
#ifndef _H264_OR_5_VIDEO_STREAM_FRAMER_HH
#include "H264or5VideoStreamFramer.hh"
#endif
class LIVEMEDIA_API H264VideoStreamFramer: public H264or5VideoStreamFramer {
public:
static H264VideoStreamFramer* createNew(UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput = False,
Boolean insertAccessUnitDelimiters = False);
protected:
H264VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
Boolean createParser,
Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters);
// called only by "createNew()"
virtual ~H264VideoStreamFramer();
// redefined virtual functions:
virtual Boolean isH264VideoStreamFramer() const;
};
#endif

View File

@ -0,0 +1,46 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.264 or H.265 Video File Sinks
// C++ header
#ifndef _H264_OR_5_VIDEO_FILE_SINK_HH
#define _H264_OR_5_VIDEO_FILE_SINK_HH
#ifndef _FILE_SINK_HH
#include "FileSink.hh"
#endif
class LIVEMEDIA_API H264or5VideoFileSink: public FileSink {
protected:
H264or5VideoFileSink(UsageEnvironment& env, FILE* fid,
unsigned bufferSize, char const* perFrameFileNamePrefix,
char const* sPropParameterSetsStr1,
char const* sPropParameterSetsStr2 = NULL,
char const* sPropParameterSetsStr3 = NULL);
// we're an abstract base class
virtual ~H264or5VideoFileSink();
protected: // redefined virtual functions:
virtual void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime);
private:
char const* fSPropParameterSetsStr[3];
Boolean fHaveWrittenFirstFrame;
};
#endif

View File

@ -0,0 +1,60 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for H.264 or H.265 video
// C++ header
#ifndef _H264_OR_5_VIDEO_RTP_SINK_HH
#define _H264_OR_5_VIDEO_RTP_SINK_HH
#ifndef _VIDEO_RTP_SINK_HH
#include "VideoRTPSink.hh"
#endif
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
class LIVEMEDIA_API H264or5VideoRTPSink: public VideoRTPSink {
protected:
H264or5VideoRTPSink(int hNumber, // 264 or 265
UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
u_int8_t const* vps = NULL, unsigned vpsSize = 0,
u_int8_t const* sps = NULL, unsigned spsSize = 0,
u_int8_t const* pps = NULL, unsigned ppsSize = 0);
// we're an abstrace base class
virtual ~H264or5VideoRTPSink();
private: // redefined virtual functions:
virtual Boolean continuePlaying();
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
unsigned numBytesInFrame) const;
protected:
int fHNumber;
FramedFilter* fOurFragmenter;
char* fFmtpSDPLine;
u_int8_t* fVPS; unsigned fVPSSize;
u_int8_t* fSPS; unsigned fSPSSize;
u_int8_t* fPPS; unsigned fPPSSize;
};
#endif

View File

@ -0,0 +1,56 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A simplified version of "H264or5VideoStreamFramer" that takes only complete,
// discrete frames (rather than an arbitrary byte stream) as input.
// This avoids the parsing and data copying overhead of the full
// "H264or5VideoStreamFramer".
// C++ header
#ifndef _H264_OR_5_VIDEO_STREAM_DISCRETE_FRAMER_HH
#define _H264_OR_5_VIDEO_STREAM_DISCRETE_FRAMER_HH
#ifndef _H264_OR_5_VIDEO_STREAM_FRAMER_HH
#include "H264or5VideoStreamFramer.hh"
#endif
class LIVEMEDIA_API H264or5VideoStreamDiscreteFramer: public H264or5VideoStreamFramer {
protected:
H264or5VideoStreamDiscreteFramer(int hNumber, UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput,
Boolean insertAccessUnitDelimiters);
// we're an abstract base class
virtual ~H264or5VideoStreamDiscreteFramer();
protected:
// redefined virtual functions:
virtual void doGetNextFrame();
protected:
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
void afterGettingFrame1(unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
virtual Boolean nalUnitEndsAccessUnit(u_int8_t nal_unit_type);
};
#endif

View File

@ -0,0 +1,92 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that breaks up a H.264 or H.265 Video Elementary Stream into NAL units.
// C++ header
#ifndef _H264_OR_5_VIDEO_STREAM_FRAMER_HH
#define _H264_OR_5_VIDEO_STREAM_FRAMER_HH
#ifndef _MPEG_VIDEO_STREAM_FRAMER_HH
#include "MPEGVideoStreamFramer.hh"
#endif
class LIVEMEDIA_API H264or5VideoStreamFramer: public MPEGVideoStreamFramer {
public:
void getVPSandSPSandPPS(u_int8_t*& vps, unsigned& vpsSize,
u_int8_t*& sps, unsigned& spsSize,
u_int8_t*& pps, unsigned& ppsSize) const {
// Returns pointers to copies of the most recently seen VPS (video parameter set)
// SPS (sequence parameter set) and PPS (picture parameter set) NAL units.
// (NULL pointers are returned if the NAL units have not yet been seen.)
vps = fLastSeenVPS; vpsSize = fLastSeenVPSSize;
sps = fLastSeenSPS; spsSize = fLastSeenSPSSize;
pps = fLastSeenPPS; ppsSize = fLastSeenPPSSize;
}
void setVPSandSPSandPPS(u_int8_t* vps, unsigned vpsSize,
u_int8_t* sps, unsigned spsSize,
u_int8_t* pps, unsigned ppsSize) {
// Assigns copies of the VPS, SPS and PPS NAL units. If this function is not called,
// then these NAL units are assigned only if/when they appear in the input stream.
saveCopyOfVPS(vps, vpsSize);
saveCopyOfSPS(sps, spsSize);
saveCopyOfPPS(pps, ppsSize);
}
protected:
H264or5VideoStreamFramer(int hNumber, // 264 or 265
UsageEnvironment& env, FramedSource* inputSource,
Boolean createParser,
Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters);
// We're an abstract base class.
virtual ~H264or5VideoStreamFramer();
void saveCopyOfVPS(u_int8_t* from, unsigned size);
void saveCopyOfSPS(u_int8_t* from, unsigned size);
void saveCopyOfPPS(u_int8_t* from, unsigned size);
void setPresentationTime();
Boolean isVPS(u_int8_t nal_unit_type);
Boolean isSPS(u_int8_t nal_unit_type);
Boolean isPPS(u_int8_t nal_unit_type);
Boolean isVCL(u_int8_t nal_unit_type);
protected: // redefined virtual functions
virtual void doGetNextFrame();
protected:
int fHNumber;
Boolean fIncludeStartCodeInOutput, fInsertAccessUnitDelimiters;
u_int8_t* fLastSeenVPS;
unsigned fLastSeenVPSSize;
u_int8_t* fLastSeenSPS;
unsigned fLastSeenSPSSize;
u_int8_t* fLastSeenPPS;
unsigned fLastSeenPPSSize;
struct timeval fNextPresentationTime; // the presentation time to be used for the next NAL unit to be parsed/delivered after this
friend class H264or5VideoStreamParser; // hack
};
// A general routine for making a copy of a (H.264 or H.265) NAL unit,
// removing 'emulation' bytes from the copy:
unsigned removeH264or5EmulationBytes(u_int8_t* to, unsigned toMaxSize,
u_int8_t const* from, unsigned fromSize);
// returns the size of the copy; it will be <= min(toMaxSize,fromSize)
#endif

View File

@ -0,0 +1,61 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from a H265 Elementary Stream video file.
// C++ header
#ifndef _H265_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _H265_VIDEO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
class LIVEMEDIA_API H265VideoFileServerMediaSubsession: public FileServerMediaSubsession {
public:
static H265VideoFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource);
// Used to implement "getAuxSDPLine()":
void checkForAuxSDPLine1();
void afterPlayingDummy1();
protected:
H265VideoFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource);
// called only by createNew();
virtual ~H265VideoFileServerMediaSubsession();
void setDoneFlag() { fDoneFlag = ~0; }
protected: // redefined virtual functions
virtual char const* getAuxSDPLine(RTPSink* rtpSink,
FramedSource* inputSource);
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
private:
char* fAuxSDPLine;
char fDoneFlag; // used when setting up "fAuxSDPLine"
RTPSink* fDummyRTPSink; // ditto
};
#endif

View File

@ -0,0 +1,51 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.265 Video File Sinks
// C++ header
#ifndef _H265_VIDEO_FILE_SINK_HH
#define _H265_VIDEO_FILE_SINK_HH
#ifndef _H264_OR_5_VIDEO_FILE_SINK_HH
#include "H264or5VideoFileSink.hh"
#endif
class LIVEMEDIA_API H265VideoFileSink: public H264or5VideoFileSink {
public:
static H265VideoFileSink* createNew(UsageEnvironment& env, char const* fileName,
char const* sPropVPSStr = NULL,
char const* sPropSPSStr = NULL,
char const* sPropPPSStr = NULL,
// The "sProp*Str" parameters are optional 'SDP format' strings
// (comma-separated Base64-encoded) representing VPS, SPS, and/or PPS NAL-units
// to prepend to the output
unsigned bufferSize = 100000,
Boolean oneFilePerFrame = False);
// See "FileSink.hh" for a description of these parameters.
protected:
H265VideoFileSink(UsageEnvironment& env, FILE* fid,
char const* sPropVPSStr,
char const* sPropSPSStr,
char const* sPropPPSStr,
unsigned bufferSize, char const* perFrameFileNamePrefix);
// called only by createNew()
virtual ~H265VideoFileSink();
};
#endif

View File

@ -0,0 +1,62 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for H.265 video
// C++ header
#ifndef _H265_VIDEO_RTP_SINK_HH
#define _H265_VIDEO_RTP_SINK_HH
#ifndef _H264_OR_5_VIDEO_RTP_SINK_HH
#include "H264or5VideoRTPSink.hh"
#endif
class LIVEMEDIA_API H265VideoRTPSink: public H264or5VideoRTPSink {
public:
static H265VideoRTPSink*
createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);
static H265VideoRTPSink*
createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
u_int8_t const* vps, unsigned vpsSize,
u_int8_t const* sps, unsigned spsSize,
u_int8_t const* pps, unsigned ppsSize);
// an optional variant of "createNew()", useful if we know, in advance,
// the stream's VPS, SPS and PPS NAL units.
// This avoids us having to 'pre-read' from the input source in order to get these values.
static H265VideoRTPSink*
createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
char const* sPropVPSStr, char const* sPropSPSStr, char const* sPropPPSStr);
// an optional variant of "createNew()", useful if we know, in advance,
// the stream's VPS, SPS and PPS NAL units.
// This avoids us having to 'pre-read' from the input source in order to get these values.
protected:
H265VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat,
u_int8_t const* vps = NULL, unsigned vpsSize = 0,
u_int8_t const* sps = NULL, unsigned spsSize = 0,
u_int8_t const* pps = NULL, unsigned ppsSize = 0);
// called only by createNew()
virtual ~H265VideoRTPSink();
protected: // redefined virtual functions:
virtual char const* auxSDPLine();
private: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
};
#endif

View File

@ -0,0 +1,67 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// H.265 Video RTP Sources
// C++ header
#ifndef _H265_VIDEO_RTP_SOURCE_HH
#define _H265_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API H265VideoRTPSource: public MultiFramedRTPSource {
public:
static H265VideoRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
Boolean expectDONFields = False,
unsigned rtpTimestampFrequency = 90000);
// "expectDONFields" is True iff we expect incoming H.265/RTP packets to contain
// DONL and DOND fields. I.e., if "tx-mode == "MST" or sprop-depack-buf-nalus > 0".
u_int64_t currentNALUnitAbsDon() const { return fCurrentNALUnitAbsDon; }
// the 'absolute decoding order number (AbsDon)' for the most-recently delivered NAL unit
protected:
H265VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
Boolean expectDONFields,
unsigned rtpTimestampFrequency);
// called only by createNew()
virtual ~H265VideoRTPSource();
protected:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
private:
void computeAbsDonFromDON(u_int16_t DON);
private:
friend class H265BufferedPacket;
Boolean fExpectDONFields;
unsigned char fCurPacketNALUnitType;
u_int16_t fPreviousNALUnitDON;
u_int64_t fCurrentNALUnitAbsDon;
};
#endif

View File

@ -0,0 +1,48 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A simplified version of "H265VideoStreamFramer" that takes only complete,
// discrete frames (rather than an arbitrary byte stream) as input.
// This avoids the parsing and data copying overhead of the full
// "H265VideoStreamFramer".
// C++ header
#ifndef _H265_VIDEO_STREAM_DISCRETE_FRAMER_HH
#define _H265_VIDEO_STREAM_DISCRETE_FRAMER_HH
#ifndef _H264_OR_5_VIDEO_STREAM_DISCRETE_FRAMER_HH
#include "H264or5VideoStreamDiscreteFramer.hh"
#endif
class LIVEMEDIA_API H265VideoStreamDiscreteFramer: public H264or5VideoStreamDiscreteFramer {
public:
static H265VideoStreamDiscreteFramer*
createNew(UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput = False, Boolean insertAccessUnitDelimiters = False);
protected:
H265VideoStreamDiscreteFramer(UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters);
// called only by createNew()
virtual ~H265VideoStreamDiscreteFramer();
private:
// redefined virtual functions:
virtual Boolean isH265VideoStreamFramer() const;
};
#endif

View File

@ -0,0 +1,45 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A filter that breaks up a H.265 Video Elementary Stream into NAL units.
// C++ header
#ifndef _H265_VIDEO_STREAM_FRAMER_HH
#define _H265_VIDEO_STREAM_FRAMER_HH
#ifndef _H264_OR_5_VIDEO_STREAM_FRAMER_HH
#include "H264or5VideoStreamFramer.hh"
#endif
class LIVEMEDIA_API H265VideoStreamFramer: public H264or5VideoStreamFramer {
public:
static H265VideoStreamFramer* createNew(UsageEnvironment& env, FramedSource* inputSource,
Boolean includeStartCodeInOutput = False,
Boolean insertAccessUnitDelimiters = False);
protected:
H265VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
Boolean createParser,
Boolean includeStartCodeInOutput, Boolean insertAccessUnitDelimiters);
// called only by "createNew()"
virtual ~H265VideoStreamFramer();
// redefined virtual functions:
virtual Boolean isH265VideoStreamFramer() const;
};
#endif

View File

@ -0,0 +1,76 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A media sink that takes - as input - a MPEG Transport Stream, and outputs a series
// of MPEG Transport Stream files, each representing a segment of the input stream,
// suitable for HLS (Apple's "HTTP Live Streaming").
// C++ header
#ifndef _HLS_SEGMENTER_HH
#define _HLS_SEGMENTER_HH
#ifndef _MEDIA_SINK_HH
#include "MediaSink.hh"
#endif
class LIVEMEDIA_API HLSSegmenter: public MediaSink {
public:
typedef void (onEndOfSegmentFunc)(void* clientData,
char const* segmentFileName, double segmentDuration);
static HLSSegmenter* createNew(UsageEnvironment& env,
unsigned segmentationDuration, char const* fileNamePrefix,
onEndOfSegmentFunc* onEndOfSegmentFunc = NULL,
void* onEndOfSegmentClientData = NULL);
private:
HLSSegmenter(UsageEnvironment& env, unsigned segmentationDuration, char const* fileNamePrefix,
onEndOfSegmentFunc* onEndOfSegmentFunc, void* onEndOfSegmentClientData);
// called only by createNew()
virtual ~HLSSegmenter();
static void ourEndOfSegmentHandler(void* clientData, double segmentDuration);
void ourEndOfSegmentHandler(double segmentDuration);
Boolean openNextOutputSegment();
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
virtual void afterGettingFrame(unsigned frameSize,
unsigned numTruncatedBytes);
static void ourOnSourceClosure(void* clientData);
void ourOnSourceClosure();
private: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
virtual Boolean continuePlaying();
private:
unsigned fSegmentationDuration;
char const* fFileNamePrefix;
onEndOfSegmentFunc* fOnEndOfSegmentFunc;
void* fOnEndOfSegmentClientData;
Boolean fHaveConfiguredUpstreamSource;
unsigned fCurrentSegmentCounter;
char* fOutputSegmentFileName;
FILE* fOutFid;
unsigned char* fOutputFileBuffer;
};
#endif

View File

@ -0,0 +1,34 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024, Live Networks, Inc. All rights reserved
//
// A function for computing the HMAC_SHA1 digest
// Definition
#ifndef _HMAC_SHA1_HH
#define _HMAC_SHA1_HH
#ifndef NO_OPENSSL
#ifndef _HMAC_HASH_HH
#include "HMAC_hash.hh"
#endif
#define SHA1_DIGEST_LEN 20
HMAC_hash HMAC_SHA1;
#endif
#endif

View File

@ -0,0 +1,37 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024, Live Networks, Inc. All rights reserved
//
// Generic HMA_HASH functions
// Definition
#ifndef _HMAC_HASH_HH
#define _HMAC_HASH_HH
#ifndef _NET_COMMON_H
#include "NetCommon.h"
#endif
// All HMAC hash functions have the following signature:
typedef void HMAC_hash(u_int8_t const* key, unsigned keyLength,
u_int8_t const* text, unsigned textLength,
u_int8_t* resultDigest);
// "resultDigest" must point to an array of sufficient size to hold the digest
#define HMAC_BLOCK_SIZE 64
#endif

View File

@ -0,0 +1,67 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Common routines for opening/closing named input files
// C++ header
#ifndef _INPUT_FILE_HH
#define _INPUT_FILE_HH
#include <UsageEnvironment.hh>
#include <stdio.h>
#if (defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE))
#ifndef _WIN32_WCE
// Include header files that might be needed by Windows (in code that uses this header file):
#include <io.h>
#include <fcntl.h>
#endif
#define READ_FROM_FILES_SYNCHRONOUSLY 1
// Because Windows is a silly toy operating system that doesn't (reliably) treat
// open files as being readable sockets (which can be handled within the default
// "BasicTaskScheduler" event loop, using "select()"), we implement file reading
// in Windows using synchronous, rather than asynchronous, I/O. This can severely
// limit the scalability of servers using this code that run on Windows.
// If this is a problem for you, then either use a better operating system,
// or else write your own Windows-specific event loop ("TaskScheduler" subclass)
// that can handle readable data in Windows open files as an event.
#endif
#ifndef _WIN32_WCE
#include <sys/stat.h>
#endif
FILE* OpenInputFile(UsageEnvironment& env, char const* fileName);
void CloseInputFile(FILE* fid);
#undef GetFileSize // because some platforms already define this as a macro
u_int64_t GetFileSize(char const* fileName, FILE* fid);
// 0 means zero-length, unbounded, or unknown
int64_t SeekFile64(FILE *fid, int64_t offset, int whence);
// A platform-independent routine for seeking within (possibly) large files
int64_t TellFile64(FILE *fid);
// A platform-independent routine for reporting the position within
// (possibly) large files
Boolean FileIsSeekable(FILE *fid);
// Tests whether "fid" is seekable, by trying to seek within it.
#endif

View File

@ -0,0 +1,46 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
#ifndef _JPEG2000_VIDEO_RTP_SINK_HH
#define _JPEG2000_VIDEO_RTP_SINK_HH
#ifndef _VIDEO_RTP_SINK_HH
#include "VideoRTPSink.hh"
#endif
class LIVEMEDIA_API JPEG2000VideoRTPSink: public VideoRTPSink {
public:
static JPEG2000VideoRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs);
protected:
JPEG2000VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs);
// called only by createNew()
virtual ~JPEG2000VideoRTPSink();
private: // redefined virtual functions:
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual unsigned specialHeaderSize() const;
};
#endif

View File

@ -0,0 +1,53 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
#ifndef _JPEG2000_VIDEO_RTP_SOURCE_HH
#define _JPEG2000_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API JPEG2000VideoRTPSource: public MultiFramedRTPSource {
public:
static JPEG2000VideoRTPSource* createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency,
char const* sampling);
protected:
virtual ~JPEG2000VideoRTPSource();
protected:
JPEG2000VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency,
char const* sampling);
// called only by createNew()
private:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
private:
char* fSampling;
};
#endif

View File

@ -0,0 +1,52 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for JPEG video (RFC 2435)
// C++ header
#ifndef _JPEG_VIDEO_RTP_SINK_HH
#define _JPEG_VIDEO_RTP_SINK_HH
#ifndef _VIDEO_RTP_SINK_HH
#include "VideoRTPSink.hh"
#endif
class LIVEMEDIA_API JPEGVideoRTPSink: public VideoRTPSink {
public:
static JPEGVideoRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs);
protected:
JPEGVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs);
// called only by createNew()
virtual ~JPEGVideoRTPSink();
private: // redefined virtual functions:
virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual
Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
unsigned numBytesInFrame) const;
virtual unsigned specialHeaderSize() const;
};
#endif

View File

@ -0,0 +1,59 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// JPEG Video (RFC 2435) RTP Sources
// C++ header
#ifndef _JPEG_VIDEO_RTP_SOURCE_HH
#define _JPEG_VIDEO_RTP_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
#define MAX_JPEG_HEADER_SIZE 1024
class LIVEMEDIA_API JPEGVideoRTPSource: public MultiFramedRTPSource {
public:
static JPEGVideoRTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat = 26,
unsigned rtpPayloadFrequency = 90000,
unsigned defaultWidth = 0, unsigned defaultHeight = 0);
protected:
virtual ~JPEGVideoRTPSource();
private:
JPEGVideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency,
unsigned defaultWidth, unsigned defaultHeight);
// called only by createNew()
// Image dimensions from the SDP description, if any
unsigned fDefaultWidth, fDefaultHeight;
private:
// redefined virtual functions:
virtual Boolean processSpecialHeader(BufferedPacket* packet,
unsigned& resultSpecialHeaderSize);
virtual char const* MIMEtype() const;
};
#endif

View File

@ -0,0 +1,55 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// JPEG video sources
// C++ header
#ifndef _JPEG_VIDEO_SOURCE_HH
#define _JPEG_VIDEO_SOURCE_HH
#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif
class LIVEMEDIA_API JPEGVideoSource: public FramedSource {
public:
virtual u_int8_t type() = 0;
virtual u_int8_t qFactor() = 0;
virtual u_int8_t width() = 0; // # pixels/8 (or 0 for 2048 pixels)
virtual u_int8_t height() = 0; // # pixels/8 (or 0 for 2048 pixels)
virtual u_int8_t const* quantizationTables(u_int8_t& precision,
u_int16_t& length);
// If "qFactor()" returns a value >= 128, then this function is called
// to tell us the quantization tables that are being used.
// (The default implementation of this function just returns NULL.)
// "precision" and "length" are as defined in RFC 2435, section 3.1.8.
virtual u_int16_t restartInterval();
// If restart intervals are being used (i.e., 64 <= type() <= 127), then this function must be
// redefined - by a subclass - to return a non-zero value.
protected:
JPEGVideoSource(UsageEnvironment& env); // abstract base class
virtual ~JPEGVideoSource();
private:
// redefined virtual functions:
virtual Boolean isJPEGVideoSource() const;
};
#endif

View File

@ -0,0 +1,75 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Support for temporarily setting the locale (e.g., to "C" or "POSIX") for (e.g.) parsing or printing
// floating-point numbers in protocol headers, or calling toupper()/tolower() on human-input strings.
// C++ header
#ifndef _LOCALE_HH
#define _LOCALE_HH
// If you're on a system that (for whatever reason) doesn't have either the "setlocale()" or the "newlocale()" function, then
// add "-DLOCALE_NOT_USED" to your "config.*" file.
// If you're on a system that (for whatever reason) has "setlocale()" but not "newlocale()", then
// add "-DNEWLOCALE_NOT_USED" to your "config.*" file.
// (Note that -DLOCALE_NOT_USED implies -DNEWLOCALE_NOT_USED; you do not need both.)
// Also, for Windows systems, we define "NEWLOCALE_NOT_USED" by default, because at least some Windows systems
// (or their development environments) don't have "newlocale()". If, however, your Windows system *does* have "newlocale()",
// then you can override this by defining "NEWLOCALE_USED" before #including this file.
// Finally, some old development environments need a header file "xlocale.h" to use "newlocale()".
// Should you need this header file, add "-DNEED_XLOCALE_H" to your "config.*" file.
#ifdef NEWLOCALE_USED
#undef LOCALE_NOT_USED
#undef NEWLOCALE_NOT_USED
#else
#if defined(__WIN32__) || defined(_WIN32)
#define NEWLOCALE_NOT_USED 1
#endif
#endif
#ifndef LOCALE_NOT_USED
#include <locale.h>
#ifndef NEWLOCALE_NOT_USED
#ifdef NEED_XLOCALE_H
#include <xlocale.h>
#endif
#endif
#endif
enum LocaleCategory { All, Numeric }; // define and implement more categories later, as needed
class Locale {
public:
Locale(char const* newLocale, LocaleCategory category = All);
virtual ~Locale();
private:
#ifndef LOCALE_NOT_USED
#ifndef NEWLOCALE_NOT_USED
locale_t fLocale, fPrevLocale;
#else
int fCategoryNum;
char* fPrevLocale;
#endif
#endif
};
#endif

View File

@ -0,0 +1,75 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A data structure that implements a MIKEY message (RFC 3830)
// C++ header
#ifndef _MIKEY_HH
#define _MIKEY_HH
#ifndef _NET_COMMON_H
#include "NetCommon.h"
#endif
#ifndef _BOOLEAN_HH
#include "Boolean.hh"
#endif
class LIVEMEDIA_API MIKEYState {
public:
MIKEYState(Boolean useEncryption = True); // initialize with default parameters
virtual ~MIKEYState();
static MIKEYState* createNew(u_int8_t const* messageToParse, unsigned messageSize);
// (Attempts to) parse a binary MIKEY message, returning a new "MIKEYState" if successful
// (or NULL if unsuccessful).
u_int8_t* generateMessage(unsigned& messageSize) const;
// Returns a binary message representing the current MIKEY state, of size "messageSize" bytes.
// This array is dynamically allocated by this routine, and must be delete[]d by the caller.
// Accessors for the encryption/authentication parameters:
Boolean encryptSRTP() const { return fEncryptSRTP; }
Boolean encryptSRTCP() const { return fEncryptSRTCP; }
u_int8_t const* keyData() const { return fKeyData; }
u_int32_t MKI() const { return fMKI; }
Boolean useAuthentication() const { return fUseAuthentication; }
private:
MIKEYState(u_int8_t const* messageToParse, unsigned messageSize, Boolean& parsedOK);
// called only by "createNew()"
void addNewPayload(class MIKEYPayload* newPayload);
Boolean parseHDRPayload(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType);
Boolean parseNonHDRPayload(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType);
private:
// Encryption/authentication parameters, either set by default
// (if the first (parameterless) constructor is used), or set by parsing an input message
// (if the second constructor is used):
Boolean fEncryptSRTP;
Boolean fEncryptSRTCP;
u_int8_t fKeyData[16+14]; // encryption key + salt
u_int32_t fMKI; // used only if encryption is used. (We assume a MKI length of 4.)
Boolean fUseAuthentication;
// Our internal binary representation of the MIKEY payloads:
class MIKEYPayload* fHeaderPayload;
class MIKEYPayload* fTailPayload;
unsigned fTotalPayloadByteCount;
};
#endif

View File

@ -0,0 +1,94 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// 'ADU' MP3 streams (for improved loss-tolerance)
// C++ header
#ifndef _MP3_ADU_HH
#define _MP3_ADU_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
class LIVEMEDIA_API ADUFromMP3Source: public FramedFilter {
public:
static ADUFromMP3Source* createNew(UsageEnvironment& env,
FramedSource* inputSource,
Boolean includeADUdescriptors = True);
void resetInput();
// This is called whenever there's a discontinuity in the input MP3 source
// (e.g., due to seeking within the source). It causes any still-unprocessed
// MP3 frame data within our queue to be discarded, so that it does not
// erroneously get used by backpointers from the new MP3 frames.
Boolean setScaleFactor(int scale);
protected:
ADUFromMP3Source(UsageEnvironment& env,
FramedSource* inputSource,
Boolean includeADUdescriptors);
// called only by createNew()
virtual ~ADUFromMP3Source();
private:
// Redefined virtual functions:
virtual void doGetNextFrame();
virtual char const* MIMEtype() const;
private:
Boolean doGetNextFrame1();
private:
Boolean fAreEnqueueingMP3Frame;
class SegmentQueue* fSegments;
Boolean fIncludeADUdescriptors;
unsigned fTotalDataSizeBeforePreviousRead;
int fScale;
unsigned fFrameCounter;
};
class LIVEMEDIA_API MP3FromADUSource: public FramedFilter {
public:
static MP3FromADUSource* createNew(UsageEnvironment& env,
FramedSource* inputSource,
Boolean includeADUdescriptors = True);
protected:
MP3FromADUSource(UsageEnvironment& env,
FramedSource* inputSource,
Boolean includeADUdescriptors);
// called only by createNew()
virtual ~MP3FromADUSource();
private:
// Redefined virtual functions:
virtual void doGetNextFrame();
virtual char const* MIMEtype() const;
private:
Boolean needToGetAnADU();
void insertDummyADUsIfNecessary();
Boolean generateFrameFromHeadADU();
private:
Boolean fAreEnqueueingADU;
class SegmentQueue* fSegments;
};
#endif

View File

@ -0,0 +1,55 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP sink for 'ADUized' MP3 frames ("mpa-robust")
// C++ header
#ifndef _MP3_ADU_RTP_SINK_HH
#define _MP3_ADU_RTP_SINK_HH
#ifndef _AUDIO_RTP_SINK_HH
#include "AudioRTPSink.hh"
#endif
class LIVEMEDIA_API MP3ADURTPSink: public AudioRTPSink {
public:
static MP3ADURTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char RTPPayloadType);
protected:
virtual ~MP3ADURTPSink();
private:
MP3ADURTPSink(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char RTPPayloadType);
// called only by createNew()
private:
// Redefined virtual functions:
virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval framePresentationTime,
unsigned numRemainingBytes);
virtual unsigned specialHeaderSize() const;
private:
unsigned fCurADUSize; // used when fragmenting over multiple RTP packets
};
#endif

View File

@ -0,0 +1,49 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// RTP source for 'ADUized' MP3 frames ("mpa-robust")
// C++ header
#ifndef _MP3_ADU_SOURCE_HH
#define _MP3_ADU_SOURCE_HH
#ifndef _MULTI_FRAMED_RTP_SOURCE_HH
#include "MultiFramedRTPSource.hh"
#endif
class LIVEMEDIA_API MP3ADURTPSource: public MultiFramedRTPSource {
public:
static MP3ADURTPSource*
createNew(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency = 90000);
protected:
virtual ~MP3ADURTPSource();
private:
MP3ADURTPSource(UsageEnvironment& env, Groupsock* RTPgs,
unsigned char rtpPayloadFormat,
unsigned rtpTimestampFrequency);
// called only by createNew()
private:
// redefined virtual functions:
virtual char const* MIMEtype() const;
};
#endif

View File

@ -0,0 +1,64 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Transcoder for ADUized MP3 frames
// C++ header
#ifndef _MP3_ADU_TRANSCODER_HH
#define _MP3_ADU_TRANSCODER_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
class LIVEMEDIA_API MP3ADUTranscoder: public FramedFilter {
public:
static MP3ADUTranscoder* createNew(UsageEnvironment& env,
unsigned outBitrate /* in kbps */,
FramedSource* inputSource);
unsigned outBitrate() const { return fOutBitrate; }
protected:
MP3ADUTranscoder(UsageEnvironment& env,
unsigned outBitrate /* in kbps */,
FramedSource* inputSource);
// called only by createNew()
virtual ~MP3ADUTranscoder();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
virtual void getAttributes() const;
private:
static void afterGettingFrame(void* clientData,
unsigned numBytesRead, unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
void afterGettingFrame1(unsigned numBytesRead, unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
private:
unsigned fOutBitrate; // in kbps
unsigned fAvailableBytesForBackpointer;
unsigned char* fOrigADU;
// used to store incoming ADU prior to transcoding
};
#endif

View File

@ -0,0 +1,129 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// Interleaving of MP3 ADUs
// C++ header
#ifndef _MP3_ADU_INTERLEAVING_HH
#define _MP3_ADU_INTERLEAVING_HH
#ifndef _FRAMED_FILTER_HH
#include "FramedFilter.hh"
#endif
// A data structure used to represent an interleaving
#define MAX_CYCLE_SIZE 256
class LIVEMEDIA_API Interleaving {
public:
Interleaving(unsigned cycleSize, unsigned char const* cycleArray);
virtual ~Interleaving();
unsigned cycleSize() const {return fCycleSize;}
unsigned char lookupInverseCycle(unsigned char index) const {
return fInverseCycle[index];
}
private:
unsigned fCycleSize;
unsigned char fInverseCycle[MAX_CYCLE_SIZE];
};
// This class is used only as a base for the following two:
class LIVEMEDIA_API MP3ADUinterleaverBase: public FramedFilter {
protected:
MP3ADUinterleaverBase(UsageEnvironment& env,
FramedSource* inputSource);
// abstract base class
virtual ~MP3ADUinterleaverBase();
static FramedSource* getInputSource(UsageEnvironment& env,
char const* inputSourceName);
static void afterGettingFrame(void* clientData,
unsigned numBytesRead,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
virtual void afterGettingFrame(unsigned numBytesRead,
struct timeval presentationTime,
unsigned durationInMicroseconds) = 0;
};
// This class is used to convert an ADU sequence from non-interleaved
// to interleaved form:
class LIVEMEDIA_API MP3ADUinterleaver: public MP3ADUinterleaverBase {
public:
static MP3ADUinterleaver* createNew(UsageEnvironment& env,
Interleaving const& interleaving,
FramedSource* inputSource);
protected:
MP3ADUinterleaver(UsageEnvironment& env,
Interleaving const& interleaving,
FramedSource* inputSource);
// called only by createNew()
virtual ~MP3ADUinterleaver();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
virtual void afterGettingFrame(unsigned numBytesRead,
struct timeval presentationTime,
unsigned durationInMicroseconds);
private:
void releaseOutgoingFrame();
private:
Interleaving const fInterleaving;
class InterleavingFrames* fFrames;
unsigned char fPositionOfNextIncomingFrame;
unsigned fII, fICC;
};
// This class is used to convert an ADU sequence from interleaved
// to non-interleaved form:
class LIVEMEDIA_API MP3ADUdeinterleaver: public MP3ADUinterleaverBase {
public:
static MP3ADUdeinterleaver* createNew(UsageEnvironment& env,
FramedSource* inputSource);
protected:
MP3ADUdeinterleaver(UsageEnvironment& env,
FramedSource* inputSource);
// called only by createNew()
virtual ~MP3ADUdeinterleaver();
private:
// redefined virtual functions:
virtual void doGetNextFrame();
virtual void afterGettingFrame(unsigned numBytesRead,
struct timeval presentationTime,
unsigned durationInMicroseconds);
private:
void releaseOutgoingFrame();
private:
class DeinterleavingFrames* fFrames;
unsigned fIIlastSeen, fICClastSeen;
};
#endif

View File

@ -0,0 +1,73 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
// on demand, from an MP3 audio file.
// (Actually, any MPEG-1 or MPEG-2 audio file should work.)
// C++ header
#ifndef _MP3_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#define _MP3_AUDIO_FILE_SERVER_MEDIA_SUBSESSION_HH
#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
#include "FileServerMediaSubsession.hh"
#endif
#ifndef _MP3_ADU_INTERLEAVING_HH
#include "MP3ADUinterleaving.hh"
#endif
#ifndef _MP3_ADU_HH
#include "MP3ADU.hh"
#endif
class LIVEMEDIA_API MP3AudioFileServerMediaSubsession: public FileServerMediaSubsession{
public:
static MP3AudioFileServerMediaSubsession*
createNew(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource,
Boolean generateADUs, Interleaving* interleaving);
// Note: "interleaving" is used only if "generateADUs" is True,
// (and a value of NULL means 'no interleaving')
protected:
MP3AudioFileServerMediaSubsession(UsageEnvironment& env,
char const* fileName, Boolean reuseFirstSource,
Boolean generateADUs,
Interleaving* interleaving);
// called only by createNew();
virtual ~MP3AudioFileServerMediaSubsession();
FramedSource* createNewStreamSourceCommon(FramedSource* baseMP3Source, unsigned mp3NumBytes, unsigned& estBitrate);
void getBaseStreams(FramedSource* frontStream,
FramedSource*& sourceMP3Stream, ADUFromMP3Source*& aduStream/*if any*/);
protected: // redefined virtual functions
virtual void seekStreamSource(FramedSource* inputSource, double& seekNPT, double streamDuration, u_int64_t& numBytes);
virtual void setStreamSourceScale(FramedSource* inputSource, float scale);
virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
unsigned& estBitrate);
virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,
FramedSource* inputSource);
virtual void testScaleFactor(float& scale);
virtual float duration() const;
protected:
Boolean fGenerateADUs;
Interleaving* fInterleaving;
float fFileDuration;
};
#endif

View File

@ -0,0 +1,71 @@
/**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "liveMedia"
// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
// MP3 File Sources
// C++ header
#ifndef _MP3_FILE_SOURCE_HH
#define _MP3_FILE_SOURCE_HH
#ifndef _FRAMED_FILE_SOURCE_HH
#include "FramedFileSource.hh"
#endif
class MP3StreamState; // forward
class LIVEMEDIA_API MP3FileSource: public FramedFileSource {
public:
static MP3FileSource* createNew(UsageEnvironment& env, char const* fileName);
float filePlayTime() const;
unsigned fileSize() const;
void setPresentationTimeScale(unsigned scale);
void seekWithinFile(double seekNPT, double streamDuration);
// if "streamDuration" is >0.0, then we limit the stream to that duration, before treating it as EOF
protected:
MP3FileSource(UsageEnvironment& env, FILE* fid);
// called only by createNew()
virtual ~MP3FileSource();
protected:
void assignStream(FILE* fid, unsigned filesize);
Boolean initializeStream();
MP3StreamState* streamState() {return fStreamState;}
private:
// redefined virtual functions:
virtual void doGetNextFrame();
virtual char const* MIMEtype() const;
virtual void getAttributes() const;
private:
static void fileReadableHandler(MP3FileSource* source, int mask);
private:
MP3StreamState* fStreamState;
Boolean fFidIsSeekable;
Boolean fHaveStartedReading;
unsigned fHaveBeenInitialized;
struct timeval fFirstFramePresentationTime; // set on stream init
Boolean fLimitNumBytesToStream;
unsigned fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
};
#endif

Some files were not shown because too many files have changed in this diff Show More