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 #ifndef __OPAL_FFH263CODEC_H
00104 #define __OPAL_FFH263CODEC_H
00105
00106 #ifdef P_USE_PRAGMA
00107 #pragma interface
00108 #endif
00109
00110 #ifdef H323_RFC2190_AVCODEC
00111 #pragma message ("Non-standard H.263 codecs disabled as RFC2190 H.263 is enabled")
00112 #elif defined(H323_AVCODEC)
00113
00114 struct AVCodec;
00115 struct AVCodecContext;
00116 struct AVFrame;
00117
00119
00122 class H323_FFH263Capability : public H323NonStandardVideoCapability
00123 {
00124 PCLASSINFO(H323_FFH263Capability, H323NonStandardVideoCapability)
00125
00126 public:
00131 H323_FFH263Capability(
00132 unsigned sqcifMPI,
00133 unsigned qcifMPI,
00134 unsigned cifMPI,
00135 unsigned cif4MPI,
00136 unsigned cif16MPI,
00137 unsigned maxBitRate = 850,
00138 unsigned videoFrameRate = 25);
00140
00145 virtual PObject * Clone() const;
00147
00156 virtual unsigned GetSubType() const;
00157
00160 virtual PString GetFormatName() const;
00162
00172 virtual BOOL OnSendingPDU(
00173 H245_VideoCapability & pdu
00174 ) const;
00175
00183 virtual BOOL OnSendingPDU(
00184 H245_VideoMode & pdu
00185 ) const;
00186
00194 virtual BOOL OnReceivedPDU(
00195 const H245_VideoCapability & pdu
00196 );
00197
00200 virtual H323Codec * CreateCodec(
00201 H323Codec::Direction direction
00202 ) const;
00203
00204
00206
00207 protected:
00208
00209 signed sqcifMPI;
00210 signed qcifMPI;
00211 signed cifMPI;
00212 signed cif4MPI;
00213 signed cif16MPI;
00214
00215 unsigned maxBitRate;
00216 unsigned videoFrameRate;
00217
00218 };
00220
00221 class H263Packet : public PObject
00222 {
00223 PCLASSINFO(H263Packet, PObject)
00224
00225 public:
00226 H263Packet(void *newData, int newSize);
00227 ~H263Packet();
00228
00229 int GetSize() { return size; }
00230
00231 void *GetData() { return data; }
00232
00233 private:
00234 void *data;
00235 int size;
00236 };
00237
00239
00240 PDECLARE_LIST(H263FragmentList, H263Packet)
00241 #if 0
00242 {
00243 #endif
00244 public:
00245 ~H263FragmentList();
00246
00247 PINDEX GetFragmentsRemaining();
00248
00249 PINDEX GetFragmentIndex();
00250
00251 PINDEX GetFragmentsTotal();
00252
00253 virtual H263Packet *GetNextFragment();
00254
00255 void AppendH263Packet(H263Packet *packet);
00256
00257 void AppendH263Packet(unsigned char *data, int size);
00258
00259 void EmptyList();
00260
00261 private:
00262 PINDEX nPackets;
00263 };
00264
00265
00267
00269 class H323_FFH263Codec : public H323VideoCodec
00270 {
00271 PCLASSINFO(H323_FFH263Codec, H323VideoCodec)
00272
00273 public:
00276 H323_FFH263Codec(
00277 Direction direction,
00278 unsigned sqcifMPI,
00279 unsigned qcifMPI,
00280 unsigned cifMPI,
00281 unsigned cif4MPI,
00282 unsigned cif16MPI,
00283 unsigned maxBitRate,
00284 unsigned videoFrameRate
00285 );
00286
00287 ~H323_FFH263Codec();
00288
00305 virtual BOOL Read(
00306 BYTE * buffer,
00307 unsigned & length,
00308 RTP_DataFrame & rtpFrame
00309 );
00310
00323 virtual BOOL Write(
00324 const BYTE * buffer,
00325 unsigned length,
00326 const RTP_DataFrame & rtp,
00327 unsigned & written
00328 );
00329
00332 virtual unsigned GetFrameRate() const { return timestampDelta; }
00333
00339 void SetTxQualityLevel(int qLevel);
00340
00344 void SetBackgroundFill(int fillLevel);
00345
00349 virtual void OnLostPartialPicture();
00350
00355 virtual void OnLostPicture();
00356
00362 static void RtpCallback(void *data, int size, int packetNumber);
00363
00364 protected:
00365 BOOL Resize(int width, int height);
00366
00367 BOOL RenderFrame();
00368 BOOL RenderFrame(const void * buffer);
00369
00370 BOOL RenderFrame(AVFrame *pict);
00371 BOOL RawToPict(AVFrame *pict);
00372
00373 void InitialiseCodec();
00374 void CloseCodec();
00375
00376 H263FragmentList partialPackets;
00377 PINDEX currentFragment;
00378
00379 PBYTEArray encFrameBuffer;
00380 PBYTEArray rawFrameBuffer;
00381
00382 PINDEX encFrameLen;
00383 PINDEX rawFrameLen;
00384
00385 unsigned timestampDelta;
00386
00387 AVCodec *codec;
00388 AVCodecContext *context;
00389 AVFrame *picture;
00390
00391 PTime startTime;
00392 PINDEX bitsSent;
00393
00394 unsigned lastebits;
00395 };
00396
00397 #endif // H323_AVCODEC
00398
00399 #endif // __OPAL_FFH263CODEC_H
00400
00401