Commits

shuerhaaken committed 695656f

factory creation from mime type

  • Participants
  • Parent commits 63f0ce5

Comments (0)

Files changed (5)

File bindings/c/taginfo_c.cc

                                                                               (MediaFileType)media_file_type)
     );
 }
+
+TagInfo_Info *taginfo_info_factory_make_from_mime(const char *filename, const char *mime_type) {
+    return reinterpret_cast<TagInfo_Info *>(Info::create_tag_info_from_mime(filename, 
+                                                                            mime_type)
+    );
+}
 //*****************/FACTORY CREATION*****************************************************
 
 

File bindings/c/taginfo_c.h

     MEDIA_FILE_TYPE_WAV,
     MEDIA_FILE_TYPE_WMA,
     MEDIA_FILE_TYPE_WV,
-    MEDIA_FILE_TYPE_SPEEX
+    MEDIA_FILE_TYPE_SPEEX,
+    MEDIA_FILE_TYPE_WMV
 } TagInfo_MediaFileType;
 
 /*!
 
 TagInfo_Info *taginfo_info_factory_make_with_format(const char *filename, TagInfo_MediaFileType format);
 
+TagInfo_Info *taginfo_info_factory_make_from_mime(const char *filename, const char *mime_type);
+
 
 /*!
  * Frees and closes the file.

File bindings/vala/libtaginfo_c.vapi

 		WAV,
 		WMA,
 		WV,
-		SPEEX
+		SPEEX,
+		WMV
 	}
 	
 	[CCode (free_function = "taginfo_info_free")]
 		//creation method for known formats/mimetypes
 		public static Info factory_make_with_format (string filename, MediaFileType media_file_type);
 		
+		//creation method using mimetype
+		public static Info factory_make_from_mime (string filename, string mimetype);
+		
 		public bool read ();
 		
 		public bool write ();

File libtaginfo/info.cc

         case  MEDIA_FILE_TYPE_AAC : 
             return new Mp4Info(filename);
         case  MEDIA_FILE_TYPE_WMA :
+        case  MEDIA_FILE_TYPE_WMV :
         case  MEDIA_FILE_TYPE_ASF :
             return new ASFInfo(filename);
         case MEDIA_FILE_TYPE_APE :
         format = MEDIA_FILE_TYPE_MPC; 
     else if(fnex == "SPX")
         format = MEDIA_FILE_TYPE_SPEEX; 
+    else if(fnex == "WMV")
+        format = MEDIA_FILE_TYPE_WMV; 
     
     return Info::create_tag_info_with_format(filename, format);
 }
 
+Info * Info::create_tag_info_from_mime(const string &filename, const string &mime_type) {
+    MediaFileType format = MEDIA_FILE_TYPE_UNKNOWN;
+    String mime = mime_type;
+    
+    if(mime == "audio/mpeg" || mime == "audio/x-mpegurl")
+        format = MEDIA_FILE_TYPE_MP3; 
+    else if(mime == "audio/x-vorbis+ogg" || mime == "audio/ogg")
+        format = MEDIA_FILE_TYPE_OGG; 
+    else if(mime == "audio/flac" || mime == "audio/x-flac+ogg" || mime == "audio/x-flac")
+        format = MEDIA_FILE_TYPE_FLAC; 
+    else if(mime == "audio/x-ms-wma")
+        format = MEDIA_FILE_TYPE_WMA; 
+    else if(mime == "video/x-ms-wmv" || mime == "video/x-msvideo")
+        format = MEDIA_FILE_TYPE_WMV; 
+//    else if(mime == "OGA")
+//        format = MEDIA_FILE_TYPE_OGA; 
+    else if(mime == "audio/mp4" || mime == "video/mp4")
+        format = MEDIA_FILE_TYPE_MP4; 
+    else if(mime == "audio/mp4a-latm")
+        format = MEDIA_FILE_TYPE_M4A; 
+//    else if(mime == "M4B")
+//        format = MEDIA_FILE_TYPE_M4B; 
+//    else if(mime == "M4P")
+//        format = MEDIA_FILE_TYPE_M4P; 
+    else if(mime == "audio/aac" || mime == "audio/x-aac")
+        format = MEDIA_FILE_TYPE_AAC; 
+    else if(mime == "audio/x-ms-asf" || mime == "video/x-ms-asf")
+        format = MEDIA_FILE_TYPE_ASF; 
+    else if(mime == "audio/ape")
+        format = MEDIA_FILE_TYPE_APE; 
+    else if(mime == "audio/x-wav")
+        format = MEDIA_FILE_TYPE_WAV; 
+    else if(mime == "audio/x-aiff")
+        format = MEDIA_FILE_TYPE_AIF; 
+    else if(mime == "application/x-wavpack" || mime == "audio/wavpack" || mime == "audio/x-wavpack")
+        format = MEDIA_FILE_TYPE_WV; 
+//    else if(mime == "TTA")
+//        format = MEDIA_FILE_TYPE_TTA; 
+    else if(mime == "audio/mpc" || mime == "audio/x-musepack")
+        format = MEDIA_FILE_TYPE_MPC; 
+    else if(mime == "audio/x-spx" || mime == "audio/x-speex" || mime == "audio/x-speex+ogg")
+        format = MEDIA_FILE_TYPE_SPEEX; 
+    return Info::create_tag_info_with_format(filename, format);
+}
+
 
 // Info
 

File libtaginfo/taginfo.h

         MEDIA_FILE_TYPE_WAV,
         MEDIA_FILE_TYPE_WMA,
         MEDIA_FILE_TYPE_WV,
-        MEDIA_FILE_TYPE_SPEEX
+        MEDIA_FILE_TYPE_SPEEX,
+        MEDIA_FILE_TYPE_WMV
     };
     
     
             virtual String get_lyrics(void) const;
             virtual bool set_lyrics(const String &lyrics);
             
-            static Info * create_tag_info_with_format(const string &file, MediaFileType format);
             static Info * create_tag_info(const string &file);
+            static Info * create_tag_info_with_format(const string &file, MediaFileType format);
+            static Info * create_tag_info_from_mime(const string &filename, const string &mime_type);
     };