Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeMPEGFile.h

Go to the documentation of this file.
00001 //
00002 // CascadeMPEGFile.h - header file for class CascadeMPEGFile
00003 //
00004 // Copyright (c) 2003, Roku, LLC.  All rights reserved.
00005 //
00008 
00009 #ifndef _ROKU_INCLUDE_CASCADE_AV_CASCADEMPEGFILE_H
00010 #define _ROKU_INCLUDE_CASCADE_AV_CASCADEMPEGFILE_H
00011 
00012 #include <cascade/util/CascadeStream.h>
00013 #include <cascade/util/CascadeArray.h>
00014 
00026 
00027 class CascadeMPEGFile : public CascadeObject
00028 {
00029 public:
00030         CascadeMPEGFile();
00034         virtual ~CascadeMPEGFile();
00038 public:
00039     enum MPEGFileType
00040     {
00041         kUnknownMPEGFileType = 0,
00042         kMPEG1ProgramStream = 1,
00043         kMPEG2ProgramStream,
00044         kMPEG2TransportStream,
00045     };
00046 
00047     enum AudioStreamType
00048     {
00049         kUnknownAudioStreamType = 0,
00050         kAC3 = 1,
00051         kPCM,
00052         kMPEG1Layer1,
00053         kMPEG1Layer2,
00054         kMPEG1Layer3,
00055     };
00056 
00057     class Program
00058     {
00059     public:
00060         u32     m_nProgramID;
00061         u32     m_nPCRPID;
00062     };
00063 
00064     class AudioStream
00065     {
00066     public:
00067         u32             m_nPIDorStreamID;
00068         u32             m_nSSID;            /* program streams with ac3 only! */
00069         AudioStreamType m_streamType;
00070         char            m_language[4];      /* null-terminated ISO 639-2/B - 3 letter bibliographic language code */
00071     };
00072 
00073     class VideoStream
00074     {
00075     public: 
00076         u32             m_nPIDorStreamID;
00077         u32             m_nPictureWidth;
00078         u32             m_nPictureHeight;
00079     };
00080 
00081 public:
00082     bool SetStream(CascadeStream & stream);
00083         // SetStream() will read from the stream at the current position and leave the stream read from
00084         // i.e. It won't reset the seek position in the stream
00085 
00086     bool SelectProgram(u32 nProgram, s32 nVideoStreamIndex, s32 nAudioStreamIndex);
00087         // -1 on a stream means no stream
00088     bool Serialize(u32 & nSizeToSet, void * & pSerializedDataToSet);
00089         // Serialize serializes the mpeg file info to a format suitable for inclusion
00090         // in a wormhole message.  pDataToSet is only valid for while this CascadeMPEGFile
00091         // refers to the data that has been serialized with a call to serialize.  (e.g. until
00092         // this is destructed or until SetFile has been called on another file or until SelectProgram()
00093         // has been called to select another program.  Clients should copy the data returned
00094         // by Serialize() right away for maximum safety.
00095     bool Deserialize(u32 nSize, void * pSerializedData);
00096         // Deserialize deserializes the serialized mpeg file info passed in and makes this
00097         // refer to the mpeg file identified by the serialized info passed in.
00098 public:
00099     MPEGFileType GetMPEGFileType() { return m_fileType; }
00100     const char * GetMPEGStreamURL() { return m_pStreamURL; }
00101     void GetSelectedProgram(u32 & nProgramToSet, s32 & nVideoStreamIndexToSet, s32 & nAudioStreamIndexToSet);
00102         // -1 on a stream means no stream
00103 
00104     u32 GetNumPrograms();
00105     u32 GetNumVideoStreams(u32 nProgramIndex);
00106     u32 GetNumAudioStreams(u32 nProgramIndex);
00107 
00108     Program     GetProgramAt(u32 nProgramIndex);
00109     AudioStream GetAudioStreamAt(u32 nProgramIndex, u32 nIndex);
00110     VideoStream GetVideoStreamAt(u32 nProgramIndex, u32 nIndex);
00111 
00112     void Dump();
00113 
00114 private:
00115     class ProgramRecord
00116     {
00117     public:
00118         Program m_program;
00119         CascadeTemplateArray<AudioStream> m_audioStreams;
00120         CascadeTemplateArray<VideoStream> m_videoStreams;
00121     };
00122 
00123 private:
00124     void Nullify();
00125     ProgramRecord * GetProgramRecordAt(u32 nProgram);
00126     void Parse(class ParseData & parseData);
00127     bool ParseAsTransportStream(class ParseData & parseData);
00128     bool ParseAsProgramStream2(class ParseData & parseData);
00129     bool ParseAsProgramStream1(class ParseData & parseData);
00130     static void StaticPATParseCB(void *, void *);
00131     static void StaticPMTParseCB(void *, void *);
00132 
00133         bool ExistPacketStartPrefix(u8 * pPacket);
00134         bool ExistSystemHeaderStartCode(u8 * pPacket);
00135         u16 ProgramStreamPackHeader(class ParseData & parseData, u8 * pPacket, u8 bVideoStreamId[], u16 * pnVideoStreamId, u8 bAudioStreamId[], u8 bAudioSubStreamId[], u8 bAudioStreamType[], u16 * pnAudioStreamId);
00136         u16 ProgramStreamPESPacket(class ParseData & parseData, u8 * pPacket, u8 bVideoStreamId[], u16 * pnVideoStreamId, u8 bAudioStreamId[], u8 bAudioSubStreamId[], u8 bAudioStreamType[], u16 * pnAudioStreamId);
00137 
00138 private:
00139     CascadeTemplateArray<ProgramRecord *> m_programs;
00140     MPEGFileType m_fileType;
00141     char * m_pStreamURL;
00142 
00143     u32 m_nSelectedProgram;
00144     s32 m_nSelectedVideoStreamIndex;
00145     s32 m_nSelectedAudioStreamIndex;
00146 
00147     u32 * m_pSerializedData;
00148 };
00149 
00150 #endif // #ifndef _ROKU_INCLUDE_CASCADE_AV_CASCADEMPEGFILE_H
00151 
00153 //  LOG
00155 //  02-Nov-03   dwoodward       created
00156 //  17-Aug-04   dwoodward   added SSID to AudioStream and change language to
00157 //                          iso 639-2/B code instead of enum
00158 //  19-Aug-04   hinamura    support for PS parsing
00159 //  13-May-05   dwoodward   replaced SetFile() with SetStream()

Generated on Sun Jul 24 14:27:17 2005 for Cascade Library by  doxygen 1.4.1