live
Media.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// Medium
19// C++ header
20
21#ifndef _MEDIA_HH
22#define _MEDIA_HH
23
24#ifndef _LIVEMEDIA_VERSION_HH
25#include "liveMedia_version.hh"
26#endif
27
28#ifndef _HASH_TABLE_HH
29#include "HashTable.hh"
30#endif
31
32#ifndef _USAGE_ENVIRONMENT_HH
33#include "UsageEnvironment.hh"
34#endif
35
36// Lots of files end up needing the following, so just #include them here:
37#ifndef _NET_COMMON_H
38#include "NetCommon.h"
39#endif
40#include <stdio.h>
41
42// The following makes the Borland compiler happy:
43#ifdef __BORLANDC__
44#define _strnicmp strnicmp
45#define fabsf(x) fabs(x)
46#endif
47
48#define mediumNameMaxLen 30
49
50class Medium {
51public:
53 char const* mediumName,
54 Medium*& resultMedium);
55 static void close(UsageEnvironment& env, char const* mediumName);
56 static void close(Medium* medium); // alternative close() method using ptrs
57 // (has no effect if medium == NULL)
58
59 UsageEnvironment& envir() const {return fEnviron;}
60
61 char const* name() const {return fMediumName;}
62
63 // Test for specific types of media:
64 virtual Boolean isSource() const;
65 virtual Boolean isSink() const;
66 virtual Boolean isRTCPInstance() const;
67 virtual Boolean isRTSPClient() const;
68 virtual Boolean isRTSPServer() const;
69 virtual Boolean isMediaSession() const;
71
72protected:
73 friend class MediaLookupTable;
74 Medium(UsageEnvironment& env); // abstract base class
75 virtual ~Medium(); // instances are deleted using close() only
76
78 return fNextTask;
79 }
80
81private:
85};
86
87
88// A data structure for looking up a Medium by its string name.
89// (It is used only to implement "Medium", but we make it visible here, in case developers want to use it to iterate over
90// the whole set of "Medium" objects that we've created.)
92public:
94 HashTable const& getTable() { return *fTable; }
95
96protected:
99
100private:
101 friend class Medium;
102
103 Medium* lookup(char const* name) const;
104 // Returns NULL if none already exists
105
106 void addNew(Medium* medium, char* mediumName);
107 void remove(char const* name);
108
109 void generateNewName(char* mediumName, unsigned maxLen);
110
111private:
115};
116
117
118// The structure pointed to by the "liveMediaPriv" UsageEnvironment field:
119class _Tables {
120public:
121 static _Tables* getOurTables(UsageEnvironment& env, Boolean createIfNotPresent = True);
122 // returns a pointer to a "_Tables" structure (creating it if necessary)
124 // used to delete ourselves when we're no longer used
125
128
129protected:
131 virtual ~_Tables();
132
133private:
135};
136
137#endif
const Boolean True
Definition: Boolean.hh:31
unsigned char Boolean
Definition: Boolean.hh:25
#define mediumNameMaxLen
Definition: Media.hh:48
void * TaskToken
void generateNewName(char *mediumName, unsigned maxLen)
static MediaLookupTable * ourMedia(UsageEnvironment &env)
unsigned fNameGenerator
Definition: Media.hh:114
Medium * lookup(char const *name) const
virtual ~MediaLookupTable()
void addNew(Medium *medium, char *mediumName)
HashTable * fTable
Definition: Media.hh:113
MediaLookupTable(UsageEnvironment &env)
void remove(char const *name)
UsageEnvironment & fEnv
Definition: Media.hh:112
HashTable const & getTable()
Definition: Media.hh:94
Definition: Media.hh:50
virtual Boolean isRTSPServer() const
virtual Boolean isRTCPInstance() const
TaskToken fNextTask
Definition: Media.hh:84
static Boolean lookupByName(UsageEnvironment &env, char const *mediumName, Medium *&resultMedium)
UsageEnvironment & envir() const
Definition: Media.hh:59
virtual ~Medium()
virtual Boolean isRTSPClient() const
virtual Boolean isSource() const
char const * name() const
Definition: Media.hh:61
static void close(UsageEnvironment &env, char const *mediumName)
Medium(UsageEnvironment &env)
char fMediumName[mediumNameMaxLen]
Definition: Media.hh:83
UsageEnvironment & fEnviron
Definition: Media.hh:82
TaskToken & nextTask()
Definition: Media.hh:77
virtual Boolean isServerMediaSession() const
virtual Boolean isSink() const
static void close(Medium *medium)
virtual Boolean isMediaSession() const
MediaLookupTable * mediaTable
Definition: Media.hh:126
UsageEnvironment & fEnv
Definition: Media.hh:134
void * socketTable
Definition: Media.hh:127
static _Tables * getOurTables(UsageEnvironment &env, Boolean createIfNotPresent=True)
_Tables(UsageEnvironment &env)
void reclaimIfPossible()
virtual ~_Tables()