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
00110
00111
00112
00113
00114
00115
00116
00117
00118 #ifndef __OPAL_FFH263CODEC_H
00119 #define __OPAL_FFH263CODEC_H
00120
00121 #ifdef P_USE_PRAGMA
00122 #pragma interface
00123 #endif
00124
00125 #ifdef H323_RFC2190_AVCODEC
00126 struct AVCodec;
00127 struct AVCodecContext;
00128 struct AVFrame;
00129
00130 #include <ptclib/delaychan.h>
00131
00133
00136 class H323_RFC2190_H263Capability : public H323VideoCapability
00137 {
00138 PCLASSINFO(H323_RFC2190_H263Capability, H323VideoCapability)
00139
00140 public:
00145 H323_RFC2190_H263Capability(
00146 unsigned sqcifMPI = 1,
00147 unsigned qcifMPI = 2,
00148 unsigned cifMPI = 4,
00149 unsigned cif4MPI = 8,
00150 unsigned cif16MPI = 32,
00151 unsigned maxBitRate = 400,
00152 BOOL unrestrictedVector = FALSE,
00153 BOOL arithmeticCoding = FALSE,
00154 BOOL advancedPrediction = FALSE,
00155 BOOL pbFrames = FALSE,
00156 BOOL temporalSpatialTradeOff = FALSE,
00157 unsigned hrd_B = 0,
00158 unsigned bppMaxKb = 0,
00159 unsigned slowSqcifMPI = 0,
00160 unsigned slowQcifMPI = 0,
00161 unsigned slowCifMPI = 0,
00162 unsigned slowCif4MPI = 0,
00163 unsigned slowCif16MPI = 0,
00164 BOOL errorCompensation = FALSE
00165 );
00167
00172 virtual PObject * Clone() const;
00174
00179 Comparison Compare(const PObject & obj) const;
00181
00190 virtual unsigned GetSubType() const;
00191
00194 virtual PString GetFormatName() const;
00196
00206 virtual BOOL OnSendingPDU(
00207 H245_VideoCapability & pdu
00208 ) const;
00209
00217 virtual BOOL OnSendingPDU(
00218 H245_VideoMode & pdu
00219 ) const;
00220
00228 virtual BOOL OnReceivedPDU(
00229 const H245_VideoCapability & pdu
00230 );
00231
00234 virtual H323Codec * CreateCodec(
00235 H323Codec::Direction direction
00236 ) const;
00237
00240 unsigned GetSQCIFMPI() const
00241 { return sqcifMPI; }
00242
00245 unsigned GetQCIFMPI() const
00246 { return qcifMPI; }
00247
00250 unsigned GetCIFMPI() const
00251 { return cifMPI; }
00252
00255 unsigned GetCIF4MPI() const
00256 { return cif4MPI; }
00257
00260 unsigned GetCIF16MPI() const
00261 { return cif16MPI; }
00262
00265 unsigned GetMaxBitRate() const
00266 { return maxBitRate; }
00267
00270 BOOL GetUnrestrictedVectorCapability() const
00271 { return unrestrictedVector; }
00272
00275 BOOL GetArithmeticCodingCapability() const
00276 { return arithmeticCoding; }
00277
00280 BOOL GetAdvancedPredictionCapability() const
00281 { return advancedPrediction; }
00282
00285 BOOL GetPbFramesCapability() const
00286 { return pbFrames; }
00287
00290 BOOL GetTemporalSpatialTradeOffCapability() const
00291 { return temporalSpatialTradeOff; }
00292
00295 BOOL GetHrd_B() const
00296 { return hrd_B; }
00297
00300 BOOL GetBppMaxKb() const
00301 { return bppMaxKb; }
00302
00305 unsigned GetSlowSQCIFMPI() const
00306 { return (sqcifMPI<0?-sqcifMPI:0); }
00307
00310 unsigned GetSlowQCIFMPI() const
00311 { return (qcifMPI<0?-qcifMPI:0); }
00312
00315 unsigned GetSlowCIFMPI() const
00316 { return (cifMPI<0?-cifMPI:0); }
00317
00320 unsigned GetSlowCIF4MPI() const
00321 { return (cif4MPI<0?-cif4MPI:0); }
00322
00325 unsigned GetSlowCIF16MPI() const
00326 { return (cif16MPI<0?-cif16MPI:0); }
00327
00330 BOOL GetErrorCompensationCapability() const
00331 { return errorCompensation; }
00333
00334 protected:
00335
00336 signed sqcifMPI;
00337 signed qcifMPI;
00338 signed cifMPI;
00339 signed cif4MPI;
00340 signed cif16MPI;
00341
00342 unsigned maxBitRate;
00343
00344 BOOL unrestrictedVector;
00345 BOOL arithmeticCoding;
00346 BOOL advancedPrediction;
00347 BOOL pbFrames;
00348 BOOL temporalSpatialTradeOff;
00349
00350 long unsigned hrd_B;
00351 unsigned bppMaxKb;
00352
00353 BOOL errorCompensation;
00354 };
00355
00357
00358 class H263Packet : public PObject
00359 {
00360 PCLASSINFO(H263Packet, PObject)
00361
00362 public:
00363
00364 H263Packet() { data_size = hdr_size = 0; hdr = data = NULL; };
00365 ~H263Packet() {};
00366
00367 void Store(void *data, int data_size, void *hdr, int hdr_size);
00368 BOOL Read(unsigned & length, RTP_DataFrame & frame);
00369
00370 private:
00371
00372 void *data;
00373 int data_size;
00374 void *hdr;
00375 int hdr_size;
00376 };
00377
00378 PDECLARE_LIST(H263PacketList, H263Packet)
00379 #if 0
00380 {
00381 #endif
00382 };
00383
00385
00388 class H323_RFC2190_H263Codec : public H323VideoCodec
00389 {
00390 PCLASSINFO(H323_RFC2190_H263Codec, H323VideoCodec)
00391
00392 public:
00395 H323_RFC2190_H263Codec(
00396 Direction direction,
00397 signed sqcifMPI,
00398 signed qcifMPI,
00399 signed cifMPI,
00400 signed cif4MPI,
00401 signed cif16MPI,
00402 unsigned maxBitRate,
00403 BOOL unrestrictedVector,
00404 BOOL arithmeticCoding,
00405 BOOL advancedPrediction,
00406 BOOL pbFrames
00407 );
00408
00409 ~H323_RFC2190_H263Codec();
00410
00427 virtual BOOL Read(
00428 BYTE * buffer,
00429 unsigned & length,
00430 RTP_DataFrame & rtpFrame
00431 );
00432
00445 virtual BOOL Write(
00446 const BYTE * buffer,
00447 unsigned length,
00448 const RTP_DataFrame & rtp,
00449 unsigned & written
00450 );
00451
00454 virtual unsigned GetFrameRate() const { return rtpTimestampDelta; }
00455
00458 void SetTxQualityLevel(int qLevel);
00459
00463 virtual void SetTxMinQuality(int qlevel);
00464
00468 virtual void SetTxMaxQuality(int qlevel);
00469
00473 void SetBackgroundFill(int fillLevel);
00474
00478 virtual void SetVideoMode(unsigned mode);
00479
00491 virtual BOOL SetMaxBitRate(unsigned bitRate);
00492
00497 virtual unsigned GetMaxBitRate() const { return bitRateHighLimit; }
00498
00502 virtual void OnVideoTemporalSpatialTradeOff();
00503
00507 virtual void OnLostPartialPicture();
00508
00512 virtual void OnLostPicture();
00513
00519 static void RtpCallback(void *data, int data_size,
00520 void *hdr, int hdr_size, void *priv_data);
00521
00522 protected:
00523
00524 BOOL Resize(int width, int height);
00525
00526 BOOL RenderFrame(const void *buffer);
00527 BOOL RenderFrame(const AVFrame *pict);
00528
00529 BOOL OpenCodec();
00530
00531 void CloseCodec();
00532
00533 H263PacketList encodedPackets;
00534 H263PacketList unusedPackets;
00535
00536 PBYTEArray encFrameBuffer;
00537 PBYTEArray rawFrameBuffer;
00538
00539 PINDEX encFrameLen;
00540 PINDEX rawFrameLen;
00541
00542 AVCodec *codec;
00543 AVCodecContext *context;
00544 AVFrame *picture;
00545
00546 PTime lastFrameTime;
00547 unsigned rtpTimestampDelta;
00548 PAdaptiveDelay packetDelay;
00549 PTime lastPacketTime;
00550 PINDEX lastPacketBits;
00551
00552 enum StdSize {UnknownStdSize, SQCIF = 1, QCIF, CIF, CIF4, CIF16, NumStdSizes};
00553
00554 static int GetStdSize(int width, int height);
00555 static int GetStdWidth (StdSize size);
00556 static int GetStdHeight (StdSize size);
00557
00558 signed videoFrameRate[NumStdSizes];
00559 StdSize videoSize;
00560 BOOL unrestrictedVector;
00561 BOOL arithmeticCoding;
00562 BOOL advancedPrediction;
00563 BOOL pbFrames;
00564 };
00565
00566 #endif // H323_AVCODEC
00567
00568 #endif // __OPAL_FFH263CODEC_H
00569
00570