00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
#ifndef __OPAL_FFH263CODEC_H
00110
#define __OPAL_FFH263CODEC_H
00111
00112
#ifdef P_USE_PRAGMA
00113
#pragma interface
00114
#endif
00115
00116
#ifdef H323_RFC2190_AVCODEC
00117
struct AVCodec;
00118
struct AVCodecContext;
00119
struct AVFrame;
00120
00122
00125
class H323_RFC2190_H263Capability :
public H323VideoCapability
00126 {
00127 PCLASSINFO(H323_RFC2190_H263Capability,
H323VideoCapability)
00128
00129 public:
00134 H323_RFC2190_H263Capability(
00135
unsigned sqcifMPI = 1,
00136
unsigned qcifMPI = 2,
00137
unsigned cifMPI = 4,
00138
unsigned cif4MPI = 8,
00139
unsigned cif16MPI = 32,
00140
unsigned maxBitRate = 400,
00141 BOOL unrestrictedVector = FALSE,
00142 BOOL arithmeticCoding = FALSE,
00143 BOOL advancedPrediction = FALSE,
00144 BOOL pbFrames = FALSE,
00145 BOOL temporalSpatialTradeOff = FALSE,
00146
unsigned hrd_B = 0,
00147
unsigned bppMaxKb = 0,
00148
unsigned slowSqcifMPI = 0,
00149
unsigned slowQcifMPI = 0,
00150
unsigned slowCifMPI = 0,
00151
unsigned slowCif4MPI = 0,
00152
unsigned slowCif16MPI = 0,
00153 BOOL errorCompensation = FALSE
00154 );
00156
00161 virtual PObject * Clone() const;
00163
00168 Comparison Compare(const PObject & obj) const;
00170
00179 virtual
unsigned GetSubType() const;
00180
00183 virtual PString GetFormatName() const;
00185
00195 virtual BOOL OnSendingPDU(
00196
H245_VideoCapability & pdu
00197 ) const;
00198
00206 virtual BOOL OnSendingPDU(
00207
H245_VideoMode & pdu
00208 ) const;
00209
00217 virtual BOOL OnReceivedPDU(
00218 const
H245_VideoCapability & pdu
00219 );
00220
00223 virtual
H323Codec * CreateCodec(
00224
H323Codec::Direction direction
00225 ) const;
00226
00229
unsigned GetSQCIFMPI()
const
00230
{
return sqcifMPI; }
00231
00234
unsigned GetQCIFMPI()
const
00235
{
return qcifMPI; }
00236
00239
unsigned GetCIFMPI()
const
00240
{
return cifMPI; }
00241
00244
unsigned GetCIF4MPI()
const
00245
{
return cif4MPI; }
00246
00249
unsigned GetCIF16MPI()
const
00250
{
return cif16MPI; }
00251
00254
unsigned GetMaxBitRate()
const
00255
{
return maxBitRate; }
00256
00259 BOOL GetUnrestrictedVectorCapability()
const
00260
{
return unrestrictedVector; }
00261
00264 BOOL GetArithmeticCodingCapability()
const
00265
{
return arithmeticCoding; }
00266
00269 BOOL GetAdvancedPredictionCapability()
const
00270
{
return advancedPrediction; }
00271
00274 BOOL GetPbFramesCapability()
const
00275
{
return pbFrames; }
00276
00279 BOOL GetTemporalSpatialTradeOffCapability()
const
00280
{
return temporalSpatialTradeOff; }
00281
00284 BOOL GetHrd_B()
const
00285
{
return hrd_B; }
00286
00289 BOOL GetBppMaxKb()
const
00290
{
return bppMaxKb; }
00291
00294
unsigned GetSlowSQCIFMPI()
const
00295
{
return (sqcifMPI<0?-sqcifMPI:0); }
00296
00299
unsigned GetSlowQCIFMPI()
const
00300
{
return (qcifMPI<0?-qcifMPI:0); }
00301
00304
unsigned GetSlowCIFMPI()
const
00305
{
return (cifMPI<0?-cifMPI:0); }
00306
00309
unsigned GetSlowCIF4MPI()
const
00310
{
return (cif4MPI<0?-cif4MPI:0); }
00311
00314
unsigned GetSlowCIF16MPI()
const
00315
{
return (cif16MPI<0?-cif16MPI:0); }
00316
00319 BOOL GetErrorCompensationCapability()
const
00320
{
return errorCompensation; }
00322
00323
protected:
00324
00325
signed sqcifMPI;
00326
signed qcifMPI;
00327
signed cifMPI;
00328
signed cif4MPI;
00329
signed cif16MPI;
00330
00331
unsigned maxBitRate;
00332
00333 BOOL unrestrictedVector;
00334 BOOL arithmeticCoding;
00335 BOOL advancedPrediction;
00336 BOOL pbFrames;
00337 BOOL temporalSpatialTradeOff;
00338
00339
long unsigned hrd_B;
00340
unsigned bppMaxKb;
00341
00342 BOOL errorCompensation;
00343 };
00344
00346
00347
class H263Packet :
public PObject
00348 {
00349 PCLASSINFO(H263Packet, PObject)
00350
00351 public:
00352
00353 H263Packet() { data_size = hdr_size = 0; hdr = data = NULL; };
00354 ~H263Packet() {};
00355
00356
void Store(
void *data,
int data_size,
void *hdr,
int hdr_size);
00357 BOOL Read(
unsigned & length,
RTP_DataFrame & frame);
00358
00359
private:
00360
00361
void *data;
00362
int data_size;
00363
void *hdr;
00364
int hdr_size;
00365 };
00366
00367 PDECLARE_LIST(H263PacketList, H263Packet)
00368 #
if 0
00369 {
00370
#endif
00371
};
00372
00374
00377
class H323_RFC2190_H263Codec :
public H323VideoCodec
00378 {
00379 PCLASSINFO(H323_RFC2190_H263Codec,
H323VideoCodec)
00380
00381 public:
00384 H323_RFC2190_H263Codec(
00385 Direction direction,
00386
signed sqcifMPI,
00387
signed qcifMPI,
00388
signed cifMPI,
00389
signed cif4MPI,
00390
signed cif16MPI,
00391
unsigned maxBitRate,
00392 BOOL unrestrictedVector,
00393 BOOL arithmeticCoding,
00394 BOOL advancedPrediction,
00395 BOOL pbFrames
00396 );
00397
00398 ~H323_RFC2190_H263Codec();
00399
00416 virtual BOOL Read(
00417 BYTE * buffer,
00418
unsigned & length,
00419
RTP_DataFrame & rtpFrame
00420 );
00421
00434 virtual BOOL Write(
00435 const BYTE * buffer,
00436
unsigned length,
00437 const
RTP_DataFrame & rtp,
00438
unsigned & written
00439 );
00440
00443 virtual
unsigned GetFrameRate()
const {
return rtpTimestampDelta; }
00444
00447
void SetTxQualityLevel(
int qLevel);
00448
00452
virtual void SetTxMinQuality(
int qlevel);
00453
00457
virtual void SetTxMaxQuality(
int qlevel);
00458
00462
void SetBackgroundFill(
int fillLevel);
00463
00467
virtual void SetVideoMode(
unsigned mode);
00468
00473
virtual BOOL SetMaxBitRate(
unsigned bitRate);
00474
00478
virtual void OnVideoTemporalSpatialTradeOff();
00479
00483
virtual void OnLostPartialPicture();
00484
00488
virtual void OnLostPicture();
00489
00495
static void RtpCallback(
void *data,
int data_size,
00496
void *hdr,
int hdr_size,
void *priv_data);
00497
00498
protected:
00499
00500 BOOL Resize(
int width,
int height);
00501
00502 BOOL RenderFrame(
const void *buffer);
00503 BOOL RenderFrame(
const AVFrame *pict);
00504
00505 BOOL OpenCodec();
00506
00507
void CloseCodec();
00508
00509 H263PacketList encodedPackets;
00510 H263PacketList unusedPackets;
00511
00512 PBYTEArray encFrameBuffer;
00513 PBYTEArray rawFrameBuffer;
00514
00515 PINDEX encFrameLen;
00516 PINDEX rawFrameLen;
00517
00518 AVCodec *codec;
00519 AVCodecContext *context;
00520 AVFrame *picture;
00521
00522 PTime lastFrameTime;
00523
unsigned rtpTimestampDelta;
00524 PTime lastPacketTime;
00525 PINDEX lastPacketBits;
00526
00527
enum StdSize {UnknownStdSize, SQCIF = 1, QCIF, CIF, CIF4, CIF16, NumStdSizes};
00528
00529
static int GetStdSize(
int width,
int height);
00530
static int GetStdWidth (StdSize size);
00531
static int GetStdHeight (StdSize size);
00532
00533
signed videoFrameRate[NumStdSizes];
00534 StdSize videoSize;
00535 BOOL unrestrictedVector;
00536 BOOL arithmeticCoding;
00537 BOOL advancedPrediction;
00538 BOOL pbFrames;
00539 };
00540
00541
#endif // H323_AVCODEC
00542
00543
#endif // __OPAL_FFH263CODEC_H
00544
00545