/usr/include/openh323/rfc2190avcodec.h is in libopenh323-dev 1.18.0.dfsg-10build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | /*
* rfc2190avcodec.h
*
* H.323 protocol handler
*
* Open H323 Library
*
* Copyright (c) 2001 March Networks Corporation
* Copyright (c) 1999-2000 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 H323 Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): Guilhem Tardy (gtardy@salyens.com)
*
* $Log: rfc2190avcodec.h,v $
* Revision 1.4 2004/05/12 23:18:44 csoutheren
* Adjusted copyright notices for ffh263 and rfc2190 files
*
* Revision 1.3 2004/04/24 00:41:14 rjongbloed
* Fixed file names in header comment.
*
* Revision 1.2 2004/04/22 22:35:00 csoutheren
* Fixed mispelling of Guilhem Tardy - my apologies to him
*
* Revision 1.1 2004/04/22 22:20:34 csoutheren
* New files for RFC2190 H.263 video codec
* Added RFC 2190 H.263 code as created by Guilhem Tardy and AliceStreet
* Many thanks to them for their contributions.
*
* Revision 1.5 2003/10/31 00:00:00 Guilhem Tardy
* Restored RFC2190 compliance.
*
* Revision 1.4 2003/10/05 00:00:00 Guilhem Tardy
* Reintroduce ffmpeg own packet slicing technique (now working better).
*
* Revision 1.3 2003/08/04 00:03:16 dereksmithies
* Reorganise tests for enabled
*
* Revision 1.2 2003/07/31 05:08:24 dereksmithies
* Switch to manual packet fragment technique. Much more reliable, especially so on windows.
*
* Revision 1.1 2003/07/24 05:23:06 dereksmithies
* Move ffmpeg h263 support to this file, and designate non standard.
*
* Revision 1.12 2003/06/06 05:18:54 dereksmithies
* Fix startup delay bug. Remove all large packets from the network. Improve reliability.
*
* Revision 1.11 2003/05/27 09:22:55 dereksmithies
* Updates for code revisions in h263 codec
*
* Revision 1.10 2003/05/14 13:47:58 rjongbloed
* Removed static "initialisation" function as this should be done
* internally and not in the application.
*
* Revision 1.9 2003/05/05 11:59:21 robertj
* Changed to use autoconf style selection of options and subsystems.
*
* Revision 1.8 2003/05/02 04:22:10 craigs
* Added lots of extra H.263 support
*
* Revision 1.7 2003/04/27 09:16:38 rogerh
* use PBYTE_ORDER instead of endian.h
*
* Revision 1.6 2003/04/21 21:50:22 dereks
* Implement suggestion from Guilhem Tardy. Many thanks.
*
* Revision 1.5 2003/04/16 04:26:57 dereks
* Initial release of h263 codec, which utilises the ffmpeg library.
* Thanks to Guilhem Tardy, and to AliceStreet.
*
* Revision 1.4 2002/09/16 01:14:15 robertj
* Added #define so can select if #pragma interface/implementation is used on
* platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
*
* Revision 1.3 2002/09/03 06:19:36 robertj
* Normalised the multi-include header prevention ifdef/define symbol.
*
* Revision 1.2 2002/08/05 10:03:47 robertj
* Cosmetic changes to normalise the usage of pragma interface/implementation.
*
* Revision 1.1 2002/05/19 22:32:46 dereks
* Initial release of stub file for h263 codec. Thanks Guilhem Tardy.
*
*
*
*/
/*
* Initial release notes from Guilhem Tardy::
*
* Added support for video capabilities & codec, only tested under Linux!
* The code for varying bit rate is copied from h261codec.cxx,
* until it is moved to a separate file common to both video codecs.
*
*/
#ifndef __OPAL_FFH263CODEC_H
#define __OPAL_FFH263CODEC_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#ifdef H323_RFC2190_AVCODEC
struct AVCodec;
struct AVCodecContext;
struct AVFrame;
///////////////////////////////////////////////////////////////////////////////
/**This class is a H.263 video capability.
*/
class H323_RFC2190_H263Capability : public H323VideoCapability
{
PCLASSINFO(H323_RFC2190_H263Capability, H323VideoCapability)
public:
/**@name Construction */
//@{
/**Create a new FFH263 Capability
*/
H323_RFC2190_H263Capability(
unsigned sqcifMPI = 1, // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz}
unsigned qcifMPI = 2,
unsigned cifMPI = 4,
unsigned cif4MPI = 8,
unsigned cif16MPI = 32,
unsigned maxBitRate = 400,
BOOL unrestrictedVector = FALSE,
BOOL arithmeticCoding = FALSE, // not supported
BOOL advancedPrediction = FALSE,
BOOL pbFrames = FALSE,
BOOL temporalSpatialTradeOff = FALSE, // not supported
unsigned hrd_B = 0, // not supported
unsigned bppMaxKb = 0, // not supported
unsigned slowSqcifMPI = 0,
unsigned slowQcifMPI = 0,
unsigned slowCifMPI = 0,
unsigned slowCif4MPI = 0,
unsigned slowCif16MPI = 0,
BOOL errorCompensation = FALSE // not supported
);
//@}
/**@name Overrides from class PObject */
//@{
/**Create a copy of the object.
*/
virtual PObject * Clone() const;
//@}
/**@name Overrides from class PObject */
//@{
/**Compare object
*/
Comparison Compare(const PObject & obj) const;
//@}
/**@name Identification functions */
//@{
/**Get the sub-type of the capability. This is a code dependent on the
main type of the capability.
This returns one of the four possible combinations of mode and speed
using the enum values of the protocol ASN H245_AudioCapability class.
*/
virtual unsigned GetSubType() const;
/**Get the name of the media data format this class represents.
*/
virtual PString GetFormatName() const;
//@}
/**@name Protocol manipulation */
//@{
/**This function is called whenever and outgoing TerminalCapabilitySet
or OpenLogicalChannel PDU is being constructed for the control channel.
It allows the capability to set the PDU fields from information in
members specific to the class.
The default behaviour sets the data rate field in the PDU.
*/
virtual BOOL OnSendingPDU(
H245_VideoCapability & pdu /// PDU to set information on
) const;
/**This function is called whenever and outgoing RequestMode
PDU is being constructed for the control channel. It allows the
capability to set the PDU fields from information in members specific
to the class.
The default behaviour sets the resolution and bit rate.
*/
virtual BOOL OnSendingPDU(
H245_VideoMode & pdu /// PDU to set information on
) const;
/**This function is called whenever and incoming TerminalCapabilitySet
or OpenLogicalChannel PDU has been used to construct the control
channel. It allows the capability to set from the PDU fields,
information in members specific to the class.
The default behaviour gets the data rate field from the PDU.
*/
virtual BOOL OnReceivedPDU(
const H245_VideoCapability & pdu /// PDU to set information on
);
/**Create the codec instance, allocating resources as required.
*/
virtual H323Codec * CreateCodec(
H323Codec::Direction direction /// Direction in which this instance runs
) const;
/** Get sqcifMPI
*/
unsigned GetSQCIFMPI() const
{ return sqcifMPI; }
/** Get qcifMPI
*/
unsigned GetQCIFMPI() const
{ return qcifMPI; }
/** Get cifMPI
*/
unsigned GetCIFMPI() const
{ return cifMPI; }
/** Get cif4MPI
*/
unsigned GetCIF4MPI() const
{ return cif4MPI; }
/** Get cif16MPI
*/
unsigned GetCIF16MPI() const
{ return cif16MPI; }
/** Get maximum bit rate
*/
unsigned GetMaxBitRate() const
{ return maxBitRate; }
/** Get unrestrictedVector capabilty
*/
BOOL GetUnrestrictedVectorCapability() const
{ return unrestrictedVector; }
/** Get arithmeticCoding capabilty
*/
BOOL GetArithmeticCodingCapability() const
{ return arithmeticCoding; }
/** Get advancedPrediction capabilty
*/
BOOL GetAdvancedPredictionCapability() const
{ return advancedPrediction; }
/** Get pbFrames capabilty
*/
BOOL GetPbFramesCapability() const
{ return pbFrames; }
/** Get temporal/spatial tradeoff capabilty
*/
BOOL GetTemporalSpatialTradeOffCapability() const
{ return temporalSpatialTradeOff; }
/** Get hrd_B
*/
BOOL GetHrd_B() const
{ return hrd_B; }
/** Get bppMaxKb
*/
BOOL GetBppMaxKb() const
{ return bppMaxKb; }
/** Get slowSqcifMPI
*/
unsigned GetSlowSQCIFMPI() const
{ return (sqcifMPI<0?-sqcifMPI:0); }
/** Get slowQcifMPI
*/
unsigned GetSlowQCIFMPI() const
{ return (qcifMPI<0?-qcifMPI:0); }
/** Get slowCifMPI
*/
unsigned GetSlowCIFMPI() const
{ return (cifMPI<0?-cifMPI:0); }
/** Get slowCif4MPI
*/
unsigned GetSlowCIF4MPI() const
{ return (cif4MPI<0?-cif4MPI:0); }
/** Get slowCif16MPI
*/
unsigned GetSlowCIF16MPI() const
{ return (cif16MPI<0?-cif16MPI:0); }
/** Get errorCompensation capabilty
*/
BOOL GetErrorCompensationCapability() const
{ return errorCompensation; }
//@}
protected:
signed sqcifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz}
signed qcifMPI;
signed cifMPI;
signed cif4MPI;
signed cif16MPI;
unsigned maxBitRate; // units of bit/s
BOOL unrestrictedVector;
BOOL arithmeticCoding;
BOOL advancedPrediction;
BOOL pbFrames;
BOOL temporalSpatialTradeOff;
long unsigned hrd_B; // units of 128 bits
unsigned bppMaxKb; // units of 1024 bits
BOOL errorCompensation;
};
////////////////////////////////////////////////////////////////
class H263Packet : public PObject
{
PCLASSINFO(H263Packet, PObject)
public:
H263Packet() { data_size = hdr_size = 0; hdr = data = NULL; };
~H263Packet() {};
void Store(void *data, int data_size, void *hdr, int hdr_size);
BOOL Read(unsigned & length, RTP_DataFrame & frame);
private:
void *data;
int data_size;
void *hdr;
int hdr_size;
};
PDECLARE_LIST(H263PacketList, H263Packet)
#if 0
{
#endif
};
//////////////////////////////////////////////////////////////////////
/**This class is a H.263 video codec.
*/
class H323_RFC2190_H263Codec : public H323VideoCodec
{
PCLASSINFO(H323_RFC2190_H263Codec, H323VideoCodec)
public:
/**Create a new H263 video codec
*/
H323_RFC2190_H263Codec(
Direction direction, /// Direction in which this instance runs
signed sqcifMPI, /// {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz}
signed qcifMPI,
signed cifMPI,
signed cif4MPI,
signed cif16MPI,
unsigned maxBitRate,
BOOL unrestrictedVector,
BOOL arithmeticCoding,
BOOL advancedPrediction,
BOOL pbFrames
);
~H323_RFC2190_H263Codec();
/**Encode the data from the appropriate device.
This will encode a frame of data for transmission. The exact size and
description of the data placed in the buffer is codec dependent but
should be less than H323Capability::GetTxFramesInPacket() *
OpalMediaFormat::GetFrameSize() in length.
The length parameter is filled with the actual length of the encoded
data, often this will be the same as the size parameter.
This function is called every GetFrameRate() timestamp units, so MUST
take less than (or equal to) that amount of time to complete!
Note that a returned length of zero indicates that time has passed but
there is no data encoded. This is typically used for silence detection
in an audio codec.
*/
virtual BOOL Read(
BYTE * buffer, /// Buffer of encoded data
unsigned & length, /// Actual length of encoded data buffer
RTP_DataFrame & rtpFrame /// RTP data frame
);
/**Decode the data and output it to appropriate device.
This will decode a single frame of received data. The exact size and
description of the data required in the buffer is codec dependent but
should be less than H323Capability::GetRxFramesInPacket() *
OpalMediaFormat::GetFrameSize() in length.
It is expected this function anunciates the data. That is, for example
with audio data, the sound is output on a speaker.
This function is called every GetFrameRate() timestamp units, so MUST
take less than that amount of time to complete!
*/
virtual BOOL Write(
const BYTE * buffer, /// Buffer of encoded data
unsigned length, /// Length of encoded data buffer
const RTP_DataFrame & rtp, /// RTP data frame
unsigned & written /// Number of bytes used from data buffer
);
/**Get the frame rate in RTP timestamp units.
*/
virtual unsigned GetFrameRate() const { return rtpTimestampDelta; }
/**Quality of the transmitted video. 1 is good, 31 is poor.
*/
void SetTxQualityLevel(int qLevel);
/**Minimum quality limit for the transmitted video.
* Default is 1. Encode quality will not be set below this value.
*/
virtual void SetTxMinQuality(int qlevel);
/**Maximum quality limit for the transmitted video.
* Default is 24. Encode quality will not be set above this value.
*/
virtual void SetTxMaxQuality(int qlevel);
/**Number of blocks (that haven't changed) transmitted with each
* frame. These blocks fill in the background.
*/
void SetBackgroundFill(int fillLevel);
/**Set the current value for video control mode
* return the resulting value video control mode
*/
virtual void SetVideoMode(unsigned mode);
/**Set maximum bitrate when transmitting video. A value of 0 disables bit rate
control. The average bitrate will be less depending on channel dead time,
i.e. time that the channel could be transmitting bits but is not.
*/
virtual BOOL SetMaxBitRate(unsigned bitRate);
/**Process a OnVideoTemporalSpatialTradeOff indication from remote endpoint.
The default behaviour does nothing.
*/
virtual void OnVideoTemporalSpatialTradeOff();
/**Process a request for a new frame,
as part of the picture has been lost.
*/
virtual void OnLostPartialPicture();
/**Process a request for a new frame,
as the entire picture has been lost.
*/
virtual void OnLostPicture();
/**
The ffmpeg library calls this routine, everytime it has a new packet to
send. Note that for every encode thread, this one method is called. Consequently,
the 'priv_data' is used to separate out packets from different encode threads.
*/
static void RtpCallback(void *data, int data_size,
void *hdr, int hdr_size, void *priv_data);
protected:
BOOL Resize(int width, int height);
BOOL RenderFrame(const void *buffer);
BOOL RenderFrame(const AVFrame *pict);
BOOL OpenCodec();
void CloseCodec();
H263PacketList encodedPackets;
H263PacketList unusedPackets;
PBYTEArray encFrameBuffer;
PBYTEArray rawFrameBuffer;
PINDEX encFrameLen;
PINDEX rawFrameLen;
AVCodec *codec;
AVCodecContext *context;
AVFrame *picture;
PTime lastFrameTime;
unsigned rtpTimestampDelta;
PTime lastPacketTime;
PINDEX lastPacketBits;
enum StdSize {UnknownStdSize, SQCIF = 1, QCIF, CIF, CIF4, CIF16, NumStdSizes};
static int GetStdSize(int width, int height); //
static int GetStdWidth (StdSize size);
static int GetStdHeight (StdSize size);
signed videoFrameRate[NumStdSizes]; /// {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz}
StdSize videoSize;
BOOL unrestrictedVector;
BOOL arithmeticCoding;
BOOL advancedPrediction;
BOOL pbFrames;
};
#endif // H323_AVCODEC
#endif // __OPAL_FFH263CODEC_H
/////////////////////////////////////////////////////////////////////////////
|