- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# Ap4Utils.h

    00001 /*****************************************************************
    00002 |
    00003 |    AP4 - Utilities
    00004 |
    00005 |    Copyright 2002 Gilles Boccon-Gibod
    00006 |
    00007 |
    00008 |    This file is part of Bento4/AP4 (MP4 Atom Processing Library).
    00009 |
    00010 |    Unless you have obtained Bento4 under a difference license,
    00011 |    this version of Bento4 is Bento4|GPL.
    00012 |    Bento4|GPL is free software; you can redistribute it and/or modify
    00013 |    it under the terms of the GNU General Public License as published by
    00014 |    the Free Software Foundation; either version 2, or (at your option)
    00015 |    any later version.
    00016 |
    00017 |    Bento4|GPL is distributed in the hope that it will be useful,
    00018 |    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00020 |    GNU General Public License for more details.
    00021 |
    00022 |    You should have received a copy of the GNU General Public License
    00023 |    along with Bento4|GPL; see the file COPYING.  If not, write to the
    00024 |    Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    00025 |    02111-1307, USA.
    00026 |
    00027  ****************************************************************/
    00028
    00029 #ifndef _AP4_UTILS_H_
    00030 #define _AP4_UTILS_H_
    00031
    00032 /*----------------------------------------------------------------------
    00033 |       includes
    00034 +---------------------------------------------------------------------*/
    00035 #include "Ap4.h"
    00036 #include "Ap4Config.h"
    00037 #include "Ap4Atom.h"
    00038
    00039 /*----------------------------------------------------------------------
    00040 |       MIN & MAX
    00041 +---------------------------------------------------------------------*/
    00042 #define MIN(a,b) (a<b)?a:b
    00043 #define MAX(a,b) (a>b)?a:b
    00044
    00045 /*----------------------------------------------------------------------
    00046 |       byte I/O
    00047 +---------------------------------------------------------------------*/
    00048 unsigned long long AP4_BytesToUInt64BE(const unsigned char* bytes);
    00049 unsigned long AP4_BytesToUInt32BE(const unsigned char* bytes);
    00050 unsigned long AP4_BytesToUInt24BE(const unsigned char* bytes);
    00051 unsigned short AP4_BytesToUInt16BE(const unsigned char* bytes);
    00052 void AP4_BytesFromUInt64BE(unsigned char* bytes, unsigned long long value);
    00053 void AP4_BytesFromUInt32BE(unsigned char* bytes, unsigned long value);
    00054 void AP4_BytesFromUInt24BE(unsigned char* bytes, unsigned long value);
    00055 void AP4_BytesFromUInt16BE(unsigned char* bytes, unsigned short value);
    00056 unsigned long AP4_DurationMsFromUnits(unsigned long units,
    00057                                                                           unsigned long units_per_second);
    00058 unsigned long AP4_ConvertTime(unsigned long time_value,
    00059                               unsigned long from_time_scale,
    00060                               unsigned long to_time_scale);
    00061
    00062 /*----------------------------------------------------------------------
    00063 |       string utils
    00064 +---------------------------------------------------------------------*/
    00065 #if defined (AP4_CONFIG_HAVE_STDIO_H)
    00066 #include <stdio.h>
    00067 #endif
    00068
    00069 #if defined (AP4_CONFIG_HAVE_SNPRINTF)
    00070 #define AP4_StringFormat snprintf
    00071 #else
    00072 int AP4_StringFormat(char* str, AP4_Size size, const char* format, ...);
    00073 #endif
    00074
    00075 void AP4_FormatFourChars(char* str, AP4_UI32 value);
    00076 AP4_Result
    00077 AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count);
    00078 AP4_Result
    00079 AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2);
    00080 AP4_Result
    00081 AP4_SplitArgs(char* arg, char*& arg0, char*& arg1);
    00082
    00083 /*----------------------------------------------------------------------
    00084 |       AP4_PrintInspector
    00085 +---------------------------------------------------------------------*/
    00086 class AP4_PrintInspector : public AP4_AtomInspector {
    00087 public:
    00088     AP4_PrintInspector(AP4_ByteStream& stream);
    00089     ~AP4_PrintInspector();
    00090
    00091     // methods
    00092     void StartElement(const char* name, const char* info);
    00093     void EndElement();
    00094     void AddField(const char* name, AP4_UI32 value, FormatHint hint);
    00095     void AddField(const char* name, const char* value, FormatHint hint);
    00096
    00097 private:
    00098     // members
    00099     AP4_ByteStream* m_Stream;
    00100     AP4_Cardinal    m_Indent;
    00101 };
    00102
    00103 #endif // _AP4_UTILS_H_