MediaProfileReader.java revision 1619367ab823150fa8856d419abe02ceb75886f1
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 void createVideoProfileTable() { 36 // push all the property into one big table 37 String encoderType = getVideoCodecProperty(); 38 String encoder[] = encoderType.split(","); 39 for (int i = 0; i < encoder.length; i++) { 40 for (int j = 0; j < VIDEO_ENCODER_PROPERTY.length; j++) { 41 String propertyName = MEDIA_ENC_VID + encoder[i] + VIDEO_ENCODER_PROPERTY[j]; 42 String prop = SystemProperties.get(propertyName); 43 //push to the table 44 String propRange[] = prop.split(","); 45 OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_low"), 46 Integer.parseInt(propRange[0])); 47 OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_high"), 48 Integer.parseInt(propRange[1])); 49 } 50 51 } 52 } 53 54 public static void createAudioProfileTable() { 55 // push all the property into one big table 56 String audioType = getAudioCodecProperty(); 57 String encoder[] = audioType.split(","); 58 for (int i = 0; i < encoder.length; i++) { 59 for (int j = 0; j < AUDIO_ENCODER_PROPERTY.length; j++) { 60 String propertyName = MEDIA_AUD_VID + encoder[i] + AUDIO_ENCODER_PROPERTY[j]; 61 String prop = SystemProperties.get(propertyName); 62 //push to the table 63 String propRange[] = prop.split(","); 64 OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_low"), 65 Integer.parseInt(propRange[0])); 66 OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_high"), 67 Integer.parseInt(propRange[1])); 68 } 69 70 } 71 } 72 73 public static void createEncoderTable(){ 74 OUTPUT_FORMAT_TABLE.put("h263", MediaRecorder.VideoEncoder.H263); 75 OUTPUT_FORMAT_TABLE.put("h264", MediaRecorder.VideoEncoder.H264); 76 OUTPUT_FORMAT_TABLE.put("m4v", MediaRecorder.VideoEncoder.MPEG_4_SP); 77 OUTPUT_FORMAT_TABLE.put("amrnb", MediaRecorder.AudioEncoder.AMR_NB); 78 OUTPUT_FORMAT_TABLE.put("amrwb", MediaRecorder.AudioEncoder.AMR_WB); 79 OUTPUT_FORMAT_TABLE.put("aac", MediaRecorder.AudioEncoder.AAC); 80 OUTPUT_FORMAT_TABLE.put("aacplus", MediaRecorder.AudioEncoder.AAC_PLUS); 81 OUTPUT_FORMAT_TABLE.put("eaacplus", 82 MediaRecorder.AudioEncoder.EAAC_PLUS); 83 } 84} 85