home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / openh323.tar.gz / openh323.tar / openh323 / include / opalwavfile.h < prev    next >
C/C++ Source or Header  |  2002-09-15  |  4KB  |  133 lines

  1. /*
  2.  * OpalWavFile.h
  3.  *
  4.  * WAV file class with auto-PCM conversion
  5.  *
  6.  * OpenH323 Library
  7.  *
  8.  * Copyright (c) 2002 Equivalence Pty. Ltd.
  9.  *
  10.  * The contents of this file are subject to the Mozilla Public License
  11.  * Version 1.0 (the "License"); you may not use this file except in
  12.  * compliance with the License. You may obtain a copy of the License at
  13.  * http://www.mozilla.org/MPL/
  14.  *
  15.  * Software distributed under the License is distributed on an "AS IS"
  16.  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  17.  * the License for the specific language governing rights and limitations
  18.  * under the License.
  19.  *
  20.  * The Original Code is Open H323 Library.
  21.  *
  22.  * Contributor(s): ______________________________________.
  23.  *
  24.  * $Log: opalwavfile.h,v $
  25.  * Revision 1.5  2002/09/16 01:14:15  robertj
  26.  * Added #define so can select if #pragma interface/implementation is used on
  27.  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
  28.  *
  29.  * Revision 1.4  2002/09/06 06:20:37  robertj
  30.  * More cosmetic changes
  31.  *
  32.  * Revision 1.3  2002/08/08 13:00:02  craigs
  33.  * Remove unused definition of LastReadCount thanks to Peter 'Luna' Runestig
  34.  *
  35.  * Revision 1.2  2002/08/05 10:03:47  robertj
  36.  * Cosmetic changes to normalise the usage of pragma interface/implementation.
  37.  *
  38.  * Revision 1.1  2002/06/20 01:21:03  craigs
  39.  * Initial version
  40.  *
  41.  */
  42.  
  43. #ifndef __OPALWAVFILE_H
  44. #define __OPALWAVFILE_H
  45.  
  46. #ifdef P_USE_PRAGMA
  47. #pragma interface
  48. #endif
  49.  
  50.  
  51. #include <ptclib/pwavfile.h>
  52.  
  53.  
  54.  
  55. /**This class is similar to the PWavFile class found in the PWlib
  56.    components library. However, it will tranparently convert all data
  57.    to/from PCM format, allowing applications to be unconcerned with 
  58.    the underlying data format. Note that this will only work with
  59.    sample-based formats that can be converted to/from PCM data, such as
  60.    uLaw and aLaw
  61.   */
  62.  
  63. class OpalWAVFile : public PWAVFile
  64. {
  65.   PCLASSINFO(OpalWAVFile, PWAVFile);
  66.   public:
  67.     OpalWAVFile(
  68.       unsigned format = fmt_PCM /// Type of WAV File to create
  69.     );
  70.  
  71.     /**Create a unique temporary file name, and open the file in the specified
  72.        mode and using the specified options. Note that opening a new, unique,
  73.        temporary file name in ReadOnly mode will always fail. This would only
  74.        be usefull in a mode and options that will create the file.
  75.  
  76.        If a WAV file is being created, the type parameter can be used
  77.        to create a PCM Wave file or a G.723.1 Wave file by using
  78.        #WaveType enum#
  79.  
  80.        The #PChannel::IsOpen()# function may be used after object
  81.        construction to determine if the file was successfully opened.
  82.      */
  83.     OpalWAVFile(
  84.       OpenMode mode,            /// Mode in which to open the file.
  85.       int opts = ModeDefault,   /// #OpenOptions enum# for open operation.
  86.       unsigned format = fmt_PCM /// Type of WAV File to create
  87.     );
  88.  
  89.     /**Create a WAV file object with the specified name and open it in
  90.        the specified mode and with the specified options.
  91.        If a WAV file is being created, the type parameter can be used
  92.        to create a PCM Wave file or a G.723.1 Wave file by using
  93.        #WaveType enum#
  94.  
  95.        The #PChannel::IsOpen()# function may be used after object
  96.        construction to determine if the file was successfully opened.
  97.      */
  98.     OpalWAVFile(
  99.       const PFilePath & name,     /// Name of file to open.
  100.       OpenMode mode = ReadWrite,  /// Mode in which to open the file.
  101.       int opts = ModeDefault,     /// #OpenOptions enum# for open operation.
  102.       unsigned format = fmt_PCM /// Type of WAV File to create
  103.     );
  104.  
  105.     /** All of the following functions are the same for their PWavFile equivalents,
  106.         but will automatically adjust if uLaw or ALaw format
  107.       */
  108.     unsigned GetFormat() const;
  109.  
  110.     BOOL Read(void * buf, PINDEX len);
  111.  
  112.     BOOL Write(const void * buf, PINDEX len);
  113.  
  114.     off_t GetPosition() const;
  115.  
  116.     BOOL SetPosition(off_t pos, FilePositionOrigin origin = Start);
  117.  
  118.     unsigned GetSampleSize() const;
  119.  
  120.     off_t GetDataLength();
  121.  
  122.   protected:
  123.     void SetUnderlyingFormat(unsigned format);
  124.     BOOL IsFormatXLaw() const;
  125.     unsigned realFormat;
  126.     BOOL translate;
  127. };
  128.  
  129. #endif // __OPALWAVFILE_H
  130.  
  131.  
  132. // End of File ///////////////////////////////////////////////////////////////
  133.