1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
|
/*
* vidcodec.h
*
* Uncompressed video handler
*
* Open Phone Abstraction Library
*
* Copyright (c) 2003 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s):
*
* $Log: vidcodec.h,v $
* Revision 2.12 2005/11/30 13:35:26 csoutheren
* Changed tags for Doxygen
*
* Revision 2.11 2005/10/21 17:58:31 dsandras
* Applied patch from Hannes Friederich <hannesf AATT ee.ethz.ch> to fix OpalVideoUpdatePicture - PIsDescendant problems. Thanks!
*
* Revision 2.10 2005/09/06 12:44:49 rjongbloed
* Many fixes to finalise the video processing: merging remote media
*
* Revision 2.9 2005/09/04 06:23:38 rjongbloed
* Added OpalMediaCommand mechanism (via PNotifier) for media streams
* and media transcoders to send commands back to remote.
*
* Revision 2.8 2005/08/31 13:19:25 rjongbloed
* Added mechanism for controlling media (especially codecs) including
* changing the OpalMediaFormat option list (eg bit rate) and a completely
* new OpalMediaCommand abstraction for things like video fast update.
*
* Revision 2.7 2005/08/28 07:59:17 rjongbloed
* Converted OpalTranscoder to use factory, requiring sme changes in making sure
* OpalMediaFormat instances are initialised before use.
*
* Revision 2.6 2005/07/24 07:33:07 rjongbloed
* Simplified "uncompressed" transcoder sp can test video media streams.
*
* Revision 2.5 2005/02/21 12:19:45 rjongbloed
* Added new "options list" to the OpalMediaFormat class.
*
* Revision 2.4 2004/09/01 12:21:27 rjongbloed
* Added initialisation of H323EndPoints capability table to be all codecs so can
* correctly build remote caps from fqast connect params. This had knock on effect
* with const keywords added in numerous places.
*
* Revision 2.3 2004/03/11 06:54:26 csoutheren
* Added ability to disable SIP or H.323 stacks
*
* Revision 2.2 2004/01/18 15:35:20 rjongbloed
* More work on video support
*
* Revision 2.1 2003/03/17 10:26:59 robertj
* Added video support.
*
*/
#ifndef __OPAL_VIDCODEC_H
#define __OPAL_VIDCODEC_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/transcoders.h>
#ifndef NO_H323
#include <h323/h323caps.h>
#endif
#define OPAL_RGB24 "RGB24"
#define OPAL_RGB32 "RGB32"
#define OPAL_YUV420P "YUV420P"
extern const OpalVideoFormat & GetOpalRGB24();
extern const OpalVideoFormat & GetOpalRGB32();
extern const OpalVideoFormat & GetOpalYUV420P();
#define OpalRGB24 GetOpalRGB24()
#define OpalRGB32 GetOpalRGB32()
#define OpalYUV420P GetOpalYUV420P()
///////////////////////////////////////////////////////////////////////////////
/**This class defines a transcoder implementation class that will
encode/decode video.
An application may create a descendent off this class and override
functions as required for descibing a specific transcoder.
*/
class OpalVideoTranscoder : public OpalTranscoder
{
PCLASSINFO(OpalVideoTranscoder, OpalTranscoder);
public:
struct FrameHeader {
PInt32l x;
PInt32l y;
PUInt32l width;
PUInt32l height;
BYTE data[1];
};
/**@name Construction */
//@{
/** Create a new video transcoder implementation.
*/
OpalVideoTranscoder(
const OpalMediaFormat & inputMediaFormat, ///< Input media format
const OpalMediaFormat & outputMediaFormat ///< Output media format
);
//@}
/**@name Operations */
//@{
/**Update the output media format. This can be used to adjust the
parameters of a codec at run time. Note you cannot change the basic
media format, eg change GSM0610 to G.711, only options for that
format, eg 6k3 mode to 5k3 mode in G.723.1.
The default behaviour updates the outputMediaFormat member variable
and sets the outputMediaFormatUpdated flag.
*/
virtual BOOL UpdateOutputMediaFormat(
const OpalMediaFormat & mediaFormat ///< New media format
);
/**Execute the command specified to the transcoder. The commands are
highly context sensitive, for example VideoFastUpdate would only apply
to a video transcoder.
The default behaviour checks for a OpalVideoUpdatePicture and sets the
updatePicture member variable if that is the command.
*/
virtual BOOL ExecuteCommand(
const OpalMediaCommand & command ///< Command to execute.
);
/**Convert the data from one format to another.
This function takes the input data as a RTP_DataFrame and converts it
to its output format, placing it into the RTP_DataFrame provided.
This is a dummy function as nearly all video conversion will does not
have a one to one input to output frames ratio, so the ConvertFrames()
function is used instead.
Returns FALSE if the conversion fails.
*/
virtual BOOL Convert(
const RTP_DataFrame & input, ///< Input data
RTP_DataFrame & output ///< Output data
);
//@}
protected:
unsigned frameWidth;
unsigned frameHeight;
unsigned videoQuality;
unsigned targetBitRate;
bool dynamicVideoQuality;
bool adaptivePacketDelay;
unsigned fillLevel;
bool updatePicture;
};
///////////////////////////////////////////////////////////////////////////////
OPAL_DEFINE_MEDIA_COMMAND(OpalVideoFreezePicture, "Freeze Picture");
class OpalVideoUpdatePicture : public OpalMediaCommand
{
PCLASSINFO(OpalVideoUpdatePicture, OpalMediaCommand);
public:
OpalVideoUpdatePicture(int firstGOB = -1, int firstMB = -1, int numBlocks = 0)
: m_firstGOB(firstGOB), m_firstMB(firstMB), m_numBlocks(numBlocks) { }
virtual PString GetName() const;
int GetFirstGOB() const { return m_firstGOB; }
int GetFirstMB() const { return m_firstMB; }
int GetNumBlocks() const { return m_numBlocks; }
protected:
int m_firstGOB;
int m_firstMB;
int m_numBlocks;
};
class OpalTemporalSpatialTradeOff : public OpalMediaCommand
{
PCLASSINFO(OpalTemporalSpatialTradeOff, OpalMediaCommand);
public:
OpalTemporalSpatialTradeOff(int quality) : m_quality(quality) { }
virtual PString GetName() const;
int GetQuality() const { return m_quality; }
protected:
int m_quality;
};
///////////////////////////////////////////////////////////////////////////////
#ifndef NO_H323
/**This class is a uncompressed video capability.
*/
class H323_UncompVideoCapability : public H323NonStandardVideoCapability
{
PCLASSINFO(H323_UncompVideoCapability, H323NonStandardVideoCapability)
public:
/**@name Construction */
//@{
/**Create a new uncompressed video Capability
*/
H323_UncompVideoCapability(
const H323EndPoint & endpoint, ///< Endpoint to get t35 information
const PString & colourFormat ///< Video colour format name
);
//@}
/**@name Overrides from class PObject */
//@{
/**Create a copy of the object.
*/
virtual PObject * Clone() const;
//@}
/**@name Identification functions */
//@{
/**Get the name of the media data format this class represents.
*/
virtual PString GetFormatName() const;
//@}
protected:
PString colourFormat;
};
#define OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323 \
H323_REGISTER_CAPABILITY_FUNCTION(H323_RGB24, OPAL_RGB24, ep) \
{ return new H323_UncompVideoCapability(ep, OpalRGB24); } \
H323_REGISTER_CAPABILITY_FUNCTION(H323_RGB32, OPAL_RGB32, ep) \
{ return new H323_UncompVideoCapability(ep, OpalRGB32); }
#else // ifndef NO_H323
#define OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323
#endif // ifndef NO_H323
///////////////////////////////////////////////////////////////////////////////
/**This class defines a transcoder implementation class that will
encode/decode uncompressed video.
*/
class OpalUncompVideoTranscoder : public OpalVideoTranscoder
{
PCLASSINFO(OpalUncompVideoTranscoder, OpalVideoTranscoder);
public:
/**@name Construction */
//@{
/** Create a new video transcoder implementation.
*/
OpalUncompVideoTranscoder(
const OpalMediaFormat & inputMediaFormat, ///< Input media format
const OpalMediaFormat & outputMediaFormat ///< Output media format
);
/**Destroy the video transcoder cleaning up the colour converter.
*/
~OpalUncompVideoTranscoder();
//@}
/**@name Operations */
//@{
/**Get the optimal size for data frames to be converted.
This function returns the size of frames that will be most efficient
in conversion. A RTP_DataFrame will attempt to provide or use data in
multiples of this size. Note that it may not do so, so the transcoder
must be able to handle any sized packets.
*/
virtual PINDEX GetOptimalDataFrameSize(
BOOL input ///< Flag for input or output data size
) const;
/**Convert the data from one format to another.
This function takes the input data as a RTP_DataFrame and converts it
to its output format, placing it (possibly) into multiple RTP_DataFrame
objects.
The default behaviour makes sure the output list has only one element
in it and calls the Convert() function.
Returns FALSE if the conversion fails.
*/
virtual BOOL ConvertFrames(
const RTP_DataFrame & input, ///< Input data
RTP_DataFrameList & output ///< Output data
);
//@}
};
class Opal_RGB24_RGB24 : public OpalUncompVideoTranscoder {
PCLASSINFO(Opal_RGB24_RGB24, OpalUncompVideoTranscoder);
public:
Opal_RGB24_RGB24() : OpalUncompVideoTranscoder(OpalRGB24, OpalRGB24) { }
};
class Opal_RGB32_RGB32 : public OpalUncompVideoTranscoder {
PCLASSINFO(Opal_RGB32_RGB32, OpalUncompVideoTranscoder);
public:
Opal_RGB32_RGB32() : OpalUncompVideoTranscoder(OpalRGB32, OpalRGB32) { }
};
///////////////////////////////////////////////////////////////////////////////
#define OPAL_REGISTER_UNCOMPRESSED_VIDEO() \
OPAL_REGISTER_UNCOMPRESSED_VIDEO_H323 \
OPAL_REGISTER_TRANSCODER(Opal_RGB32_RGB32, OpalRGB32, OpalRGB32); \
OPAL_REGISTER_TRANSCODER(Opal_RGB24_RGB24, OpalRGB24, OpalRGB24)
#endif // __OPAL_VIDCODEC_H
/////////////////////////////////////////////////////////////////////////////
|