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 #ifndef __OPAL_FFH263CODEC_H
00107 #define __OPAL_FFH263CODEC_H
00108
00109 #ifdef P_USE_PRAGMA
00110 #pragma interface
00111 #endif
00112
00113 #ifdef H323_RFC2190_AVCODEC
00114 #pragma message ("Non-standard H.263 codecs disabled as RFC2190 H.263 is enabled")
00115 #elif defined(H323_AVCODEC)
00116
00117 struct AVCodec;
00118 struct AVCodecContext;
00119 struct AVFrame;
00120
00122
00125 class H323_FFH263Capability : public H323NonStandardVideoCapability
00126 {
00127 PCLASSINFO(H323_FFH263Capability, H323NonStandardVideoCapability)
00128
00129 public:
00134 H323_FFH263Capability(
00135 unsigned sqcifMPI,
00136 unsigned qcifMPI,
00137 unsigned cifMPI,
00138 unsigned cif4MPI,
00139 unsigned cif16MPI,
00140 unsigned maxBitRate = 850,
00141 unsigned videoFrameRate = 25);
00143
00148 virtual PObject * Clone() const;
00150
00159 virtual unsigned GetSubType() const;
00160
00163 virtual PString GetFormatName() const;
00165
00175 virtual BOOL OnSendingPDU(
00176 H245_VideoCapability & pdu
00177 ) const;
00178
00186 virtual BOOL OnSendingPDU(
00187 H245_VideoMode & pdu
00188 ) const;
00189
00197 virtual BOOL OnReceivedPDU(
00198 const H245_VideoCapability & pdu
00199 );
00200
00203 virtual H323Codec * CreateCodec(
00204 H323Codec::Direction direction
00205 ) const;
00206
00207
00209
00210 protected:
00211
00212 signed sqcifMPI;
00213 signed qcifMPI;
00214 signed cifMPI;
00215 signed cif4MPI;
00216 signed cif16MPI;
00217
00218 unsigned maxBitRate;
00219 unsigned videoFrameRate;
00220
00221 };
00223
00224 class H263Packet : public PObject
00225 {
00226 PCLASSINFO(H263Packet, PObject)
00227
00228 public:
00229 H263Packet(void *newData, int newSize);
00230 ~H263Packet();
00231
00232 int GetSize() { return size; }
00233
00234 void *GetData() { return data; }
00235
00236 private:
00237 void *data;
00238 int size;
00239 };
00240
00242
00243 PDECLARE_LIST(H263FragmentList, H263Packet)
00244 #if 0
00245 {
00246 #endif
00247 public:
00248 ~H263FragmentList();
00249
00250 PINDEX GetFragmentsRemaining();
00251
00252 PINDEX GetFragmentIndex();
00253
00254 PINDEX GetFragmentsTotal();
00255
00256 virtual H263Packet *GetNextFragment();
00257
00258 void AppendH263Packet(H263Packet *packet);
00259
00260 void AppendH263Packet(unsigned char *data, int size);
00261
00262 void EmptyList();
00263
00264 private:
00265 PINDEX nPackets;
00266 };
00267
00268
00270
00272 class H323_FFH263Codec : public H323VideoCodec
00273 {
00274 PCLASSINFO(H323_FFH263Codec, H323VideoCodec)
00275
00276 public:
00279 H323_FFH263Codec(
00280 Direction direction,
00281 unsigned sqcifMPI,
00282 unsigned qcifMPI,
00283 unsigned cifMPI,
00284 unsigned cif4MPI,
00285 unsigned cif16MPI,
00286 unsigned maxBitRate,
00287 unsigned videoFrameRate
00288 );
00289
00290 ~H323_FFH263Codec();
00291
00308 virtual BOOL Read(
00309 BYTE * buffer,
00310 unsigned & length,
00311 RTP_DataFrame & rtpFrame
00312 );
00313
00326 virtual BOOL Write(
00327 const BYTE * buffer,
00328 unsigned length,
00329 const RTP_DataFrame & rtp,
00330 unsigned & written
00331 );
00332
00335 virtual unsigned GetFrameRate() const { return timestampDelta; }
00336
00342 void SetTxQualityLevel(int qLevel);
00343
00347 void SetBackgroundFill(int fillLevel);
00348
00352 virtual void OnLostPartialPicture();
00353
00358 virtual void OnLostPicture();
00359
00365 static void RtpCallback(void *data, int size, int packetNumber);
00366
00367 protected:
00368 BOOL Resize(int width, int height);
00369
00370 BOOL RenderFrame();
00371 BOOL RenderFrame(const void * buffer);
00372
00373 BOOL RenderFrame(AVFrame *pict);
00374 BOOL RawToPict(AVFrame *pict);
00375
00376 void InitialiseCodec();
00377 void CloseCodec();
00378
00379 H263FragmentList partialPackets;
00380 PINDEX currentFragment;
00381
00382 PBYTEArray encFrameBuffer;
00383 PBYTEArray rawFrameBuffer;
00384
00385 PINDEX encFrameLen;
00386 PINDEX rawFrameLen;
00387
00388 unsigned timestampDelta;
00389
00390 AVCodec *codec;
00391 AVCodecContext *context;
00392 AVFrame *picture;
00393
00394 PTime startTime;
00395 PINDEX bitsSent;
00396
00397 unsigned lastebits;
00398 };
00399
00400 #endif // H323_AVCODEC
00401
00402 #endif // __OPAL_FFH263CODEC_H
00403
00404