MediaProfileReader.java revision dc1af5befaa21e92c41dd6e173b2d6fb859cdd23
1package com.android.mediaframeworktest; 2 3import android.media.MediaRecorder; 4import android.os.SystemProperties; 5import java.util.HashMap; 6 7public class MediaProfileReader { 8 9 public static final HashMap<String, Integer> 10 OUTPUT_FORMAT_TABLE = new HashMap<String, Integer>(); 11 public static String MEDIA_ENC_VID = "ro.media.enc.vid."; 12 public static String MEDIA_AUD_VID = "ro.media.enc.aud."; 13 public static String[] VIDEO_ENCODER_PROPERTY = {".width", ".height", ".bps", ".fps",}; 14 public static String[] AUDIO_ENCODER_PROPERTY = {".bps", ".hz", ".ch",}; 15 16 public static String getVideoCodecProperty() { 17 String s; 18 s = SystemProperties.get("ro.media.enc.vid.codec"); 19 return s; 20 } 21 22 public static String getAudioCodecProperty() { 23 String s; 24 s = SystemProperties.get("ro.media.enc.aud.codec"); 25 return s; 26 } 27 28 public static String getDeviceType() { 29 // push all the property into one big table 30 String s; 31 s = SystemProperties.get("ro.product.name"); 32 return s; 33 } 34 35 public static boolean getWMAEnable() { 36 // push all the property into one big table 37 int wmaEnable = 1; 38 wmaEnable = SystemProperties.getInt("ro.media.dec.aud.wma.enabled", 39 wmaEnable); 40 if (wmaEnable == 1) { 41 return true; 42 } else { 43 return false; 44 } 45 } 46 47 public static boolean getWMVEnable(){ 48 int wmvEnable = 1; 49 wmvEnable = SystemProperties.getInt("ro.media.dec.vid.wmv.enabled", 50 wmvEnable); 51 if (wmvEnable == 1) { 52 return true; 53 } else { 54 return false; 55 } 56 } 57 58 public static void createVideoProfileTable() { 59 // push all the property into one big table 60 String encoderType = getVideoCodecProperty(); 61 String encoder[] = encoderType.split(","); 62 for (int i = 0; i < encoder.length; i++) { 63 for (int j = 0; j < VIDEO_ENCODER_PROPERTY.length; j++) { 64 String propertyName = MEDIA_ENC_VID + encoder[i] + VIDEO_ENCODER_PROPERTY[j]; 65 String prop = SystemProperties.get(propertyName); 66 //push to the table 67 String propRange[] = prop.split(","); 68 OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_low"), 69 Integer.parseInt(propRange[0])); 70 OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_high"), 71 Integer.parseInt(propRange[1])); 72 } 73 74 } 75 } 76 77 public static void createAudioProfileTable() { 78 // push all the property into one big table 79 String audioType = getAudioCodecProperty(); 80 String encoder[] = audioType.split(","); 81 for (int i = 0; i < encoder.length; i++) { 82 for (int j = 0; j < AUDIO_ENCODER_PROPERTY.length; j++) { 83 String propertyName = MEDIA_AUD_VID + encoder[i] + AUDIO_ENCODER_PROPERTY[j]; 84 String prop = SystemProperties.get(propertyName); 85 //push to the table 86 String propRange[] = prop.split(","); 87 OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_low"), 88 Integer.parseInt(propRange[0])); 89 OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_high"), 90 Integer.parseInt(propRange[1])); 91 } 92 93 } 94 } 95 96 public static void createEncoderTable(){ 97 OUTPUT_FORMAT_TABLE.put("h263", MediaRecorder.VideoEncoder.H263); 98 OUTPUT_FORMAT_TABLE.put("h264", MediaRecorder.VideoEncoder.H264); 99 OUTPUT_FORMAT_TABLE.put("m4v", MediaRecorder.VideoEncoder.MPEG_4_SP); 100 OUTPUT_FORMAT_TABLE.put("amrnb", MediaRecorder.AudioEncoder.AMR_NB); 101 OUTPUT_FORMAT_TABLE.put("amrwb", MediaRecorder.AudioEncoder.AMR_WB); 102 OUTPUT_FORMAT_TABLE.put("aac", MediaRecorder.AudioEncoder.AAC); 103 OUTPUT_FORMAT_TABLE.put("aacplus", MediaRecorder.AudioEncoder.AAC_PLUS); 104 OUTPUT_FORMAT_TABLE.put("eaacplus", 105 MediaRecorder.AudioEncoder.EAAC_PLUS); 106 } 107} 108