1 // MediaFormatIO.h 2 // * PURPOSE 3 // Wrapper class for media_format, providing XML 4 // serialization support using the Cortex::XML package. 5 // 6 // * TO DO +++++ 7 // - import & export user data? 8 // - import & export metadata? 9 // 10 // * HISTORY 11 // e.moon 1jul99 Begun. 12 13 #ifndef __MediaFormatIO_H__ 14 #define __MediaFormatIO_H__ 15 16 #include "XML.h" 17 #include <MediaDefs.h> 18 #include <String.h> 19 20 #include "cortex_defs.h" 21 __BEGIN_CORTEX_NAMESPACE 22 23 class MediaFormatIO : 24 public IPersistent { 25 26 public: // *** ctor/dtor 27 virtual ~MediaFormatIO(); 28 29 MediaFormatIO(); 30 MediaFormatIO(const media_format& format); 31 32 public: // *** accessors 33 // returns B_OK if the object contains a valid format, 34 // or B_ERROR if not. 35 status_t getFormat(media_format& outFormat) const; 36 37 public: // *** static setup method 38 // call this method to install hooks for the tags needed by 39 // MediaFormatIO into the given document type 40 static void AddTo(XML::DocumentType* pDocType); 41 42 public: // *** top-level tags 43 44 // these tags map directly to MediaFormatIO 45 static const char* const s_multi_audio_tag; 46 static const char* const s_raw_audio_tag; 47 static const char* const s_raw_video_tag; 48 static const char* const s_multistream_tag; 49 static const char* const s_encoded_audio_tag; 50 static const char* const s_encoded_video_tag; 51 52 public: // *** nested tags 53 54 static const char* const s_video_display_info_tag; 55 56 static const char* const s_multistream_flags_tag; 57 static const char* const s_multistream_vid_info_tag; 58 static const char* const s_multistream_avi_info_tag; 59 60 static const char* const s_multi_audio_info_tag; 61 62 static const char* const s_media_type_tag; 63 64 public: // *** IPersistent 65 66 // void xmlExport( 67 // ostream& stream, 68 // ExportContext& context) const; 69 70 // EXPORT: 71 72 void xmlExportBegin( 73 ExportContext& context) const; 74 75 void xmlExportAttributes( 76 ExportContext& context) const; 77 78 void xmlExportContent( 79 ExportContext& context) const; 80 81 void xmlExportEnd( 82 ExportContext& context) const; 83 84 // IMPORT 85 86 void xmlImportBegin( 87 ImportContext& context); 88 89 void xmlImportAttribute( 90 const char* key, 91 const char* value, 92 ImportContext& context); 93 94 void xmlImportContent( 95 const char* data, 96 uint32 length, 97 ImportContext& context); 98 99 void xmlImportChild( 100 IPersistent* child, 101 ImportContext& context); 102 103 void xmlImportComplete( 104 ImportContext& context); 105 106 void xmlImportChildBegin( 107 const char* name, 108 ImportContext& context); 109 110 void xmlImportChildAttribute( 111 const char* key, 112 const char* value, 113 ImportContext& context); 114 115 void xmlImportChildContent( 116 const char* data, 117 uint32 length, 118 ImportContext& context); 119 120 void xmlImportChildComplete( 121 const char* name, 122 ImportContext& context); 123 124 private: // *** state 125 bool m_complete; 126 media_format m_format; 127 128 BString m_mediaType; 129 }; 130 131 __END_CORTEX_NAMESPACE 132 #endif /*__MediaFormatIO_H__*/ 133