home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / LINUX / gopchop-1.1.7.tar.tar / gopchop-1.1.7.tar / gopchop-1.1.7 / src / MPEG2Parser.h < prev    next >
C/C++ Source or Header  |  2005-05-01  |  3KB  |  118 lines

  1. /*
  2. #
  3. # header for MPEG2Parser class
  4. #
  5. # $Id: MPEG2Parser.h,v 1.12 2005/05/01 17:59:23 keescook Exp $
  6. #
  7. # Copyright (C) 2001-2003 Kees Cook
  8. # kees@outflux.net, http://outflux.net/
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public License
  11. # as published by the Free Software Foundation; either version 2
  12. # of the License, or (at your option) any later version.
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20. # http://www.gnu.org/copyleft/gpl.html
  21. #
  22. */
  23.  
  24. #ifndef _MPEG2PARSER_H_
  25. #define _MPEG2PARSER_H_
  26.  
  27. #include "GOPchop.h"
  28. // FIXME: shouldn't I use config.h macros somewhere?
  29. // open
  30. #include <sys/types.h>
  31. #include <sys/stat.h>
  32. #include <fcntl.h>
  33. // everything
  34. #include <stdlib.h>
  35. #include <unistd.h>
  36. #include <stdio.h>
  37. // mmap
  38. #include <sys/mman.h>
  39. // strlen
  40. #include <string.h>
  41.  
  42. #ifdef HAVE_INTTYPES_H
  43. # include <inttypes.h>
  44. #endif
  45.  
  46. #include "Parser.h"
  47. #include "List.h"
  48.  
  49. #include "mpeg2structs.h"
  50.  
  51. #include "Pack.h"
  52. #include "GroupOfPictures.h"
  53. #include "ElementStream.h"
  54. #include "FirstPack.h"  //TI!
  55.  
  56.  
  57. class MPEG2Parser:public Parser
  58. {
  59.   public:
  60.     MPEG2Parser();
  61.     virtual ~ MPEG2Parser();
  62.  
  63.     // bind to parent
  64.     int parse(char ignore_errors = FALSE);
  65.  
  66.     // MPEG2
  67.     List *getGOPs();
  68.     List *getPackets();
  69.     List *getVideo();
  70.     List *getAudio();
  71.     List *getPictures();
  72.     
  73.     FirstPack *getFirstPack();  //TI!
  74.     
  75.     uint32_t numGOPs();
  76.     
  77.     // searches a vector for a certain byte string
  78.     Vector *findCode(Vector * area, uint8_t * code, size_t size);
  79.  
  80.     // behavior adjustment
  81.     void set_ignore_endcode(bool setting);
  82.  
  83.   protected:
  84.     // MPEG2
  85.     List * GOP_list;          // all GOPs in MPEG2
  86.  
  87.     // functional parsing globals
  88.     off_t pack_start;           // where packet started
  89.     off_t GOP_start;            // where GOP started
  90.     off_t picture_start;        // where picture started
  91.  
  92.     List *packet_list;          // All packets in MPEG2
  93.     List *picture_list;         // All pictures in MPEG2
  94.     List *video_list;           // All video ES fragments
  95.     List *audio_list;           // All audio ES fragments
  96.  
  97.     FirstPack* first_pack;      // TI! first dummy pack
  98.     
  99.     // section parsers
  100.     void parse_PES_packet(void);
  101.     void parse_system_header(void);
  102.     void parse_pack_header(void);
  103.     void parse_pack(void);
  104.     void parse_MPEG2_program_stream(void);
  105.  
  106.     // behavior settings
  107.     bool ignore_endcode;
  108.  
  109.     void buildGOPs(void);
  110. };
  111.  
  112. #endif // _MPEG2PARSER_H_
  113.  
  114. /* vi:set ai ts=4 sw=4 expandtab: */
  115.