live
Media.hh
Go to the documentation of this file.
1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2019 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 
50 class Medium {
51 public:
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;
70  virtual Boolean isServerMediaSession() const;
71 
72 protected:
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 
81 private:
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.)
92 public:
94  HashTable const& getTable() { return *fTable; }
95 
96 protected:
98  virtual ~MediaLookupTable();
99 
100 private:
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 
111 private:
114  unsigned fNameGenerator;
115 };
116 
117 
118 // The structure pointed to by the "liveMediaPriv" UsageEnvironment field:
119 class _Tables {
120 public:
121  static _Tables* getOurTables(UsageEnvironment& env, Boolean createIfNotPresent = True);
122  // returns a pointer to a "_Tables" structure (creating it if necessary)
123  void reclaimIfPossible();
124  // used to delete ourselves when we're no longer used
125 
127  void* socketTable;
128 
129 protected:
131  virtual ~_Tables();
132 
133 private:
135 };
136 
137 #endif
unsigned char Boolean
Definition: Boolean.hh:25
HashTable const & getTable()
Definition: Media.hh:94
virtual Boolean isRTSPClient() const
virtual Boolean isSink() const
_Tables(UsageEnvironment &env)
MediaLookupTable(UsageEnvironment &env)
char const * name() const
Definition: Media.hh:61
virtual ~Medium()
static Boolean lookupByName(UsageEnvironment &env, char const *mediumName, Medium *&resultMedium)
MediaLookupTable * mediaTable
Definition: Media.hh:126
TaskToken & nextTask()
Definition: Media.hh:77
virtual Boolean isRTSPServer() const
void generateNewName(char *mediumName, unsigned maxLen)
UsageEnvironment & fEnv
Definition: Media.hh:112
UsageEnvironment & envir() const
Definition: Media.hh:59
unsigned fNameGenerator
Definition: Media.hh:114
static _Tables * getOurTables(UsageEnvironment &env, Boolean createIfNotPresent=True)
Medium * lookup(char const *name) const
TaskToken fNextTask
Definition: Media.hh:84
void * TaskToken
#define mediumNameMaxLen
Definition: Media.hh:48
static MediaLookupTable * ourMedia(UsageEnvironment &env)
virtual Boolean isMediaSession() const
UsageEnvironment & fEnv
Definition: Media.hh:134
Definition: Media.hh:50
void * socketTable
Definition: Media.hh:127
char fMediumName[mediumNameMaxLen]
Definition: Media.hh:83
void addNew(Medium *medium, char *mediumName)
UsageEnvironment & fEnviron
Definition: Media.hh:82
virtual Boolean isRTCPInstance() const
void reclaimIfPossible()
static void close(UsageEnvironment &env, char const *mediumName)
const Boolean True
Definition: Boolean.hh:31
HashTable * fTable
Definition: Media.hh:113
Medium(UsageEnvironment &env)
virtual Boolean isServerMediaSession() const
virtual ~_Tables()
virtual Boolean isSource() const
virtual ~MediaLookupTable()