当前位置: 首页>>代码示例>>Java>>正文


Java MediaFormat.setString方法代码示例

本文整理汇总了Java中android.media.MediaFormat.setString方法的典型用法代码示例。如果您正苦于以下问题:Java MediaFormat.setString方法的具体用法?Java MediaFormat.setString怎么用?Java MediaFormat.setString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaFormat的用法示例。


在下文中一共展示了MediaFormat.setString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMediaCodec

import android.media.MediaFormat; //导入方法依赖的package包/类
private MediaCodec createMediaCodec(int bufferSize) throws IOException {
  MediaCodec  mediaCodec  = MediaCodec.createEncoderByType("audio/mp4a-latm");
  MediaFormat mediaFormat = new MediaFormat();

  mediaFormat.setString(MediaFormat.KEY_MIME, "audio/mp4a-latm");
  mediaFormat.setInteger(MediaFormat.KEY_SAMPLE_RATE, SAMPLE_RATE);
  mediaFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, CHANNELS);
  mediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, bufferSize);
  mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE);
  mediaFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectLC);

  try {
    mediaCodec.configure(mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
  } catch (Exception e) {
    Log.w(TAG, e);
    mediaCodec.release();
    throw new IOException(e);
  }

  return mediaCodec;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:AudioCodec.java

示例2: createMediaFormat

import android.media.MediaFormat; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static MediaFormat createMediaFormat(Type type, int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        MediaFormat format = new MediaFormat();
        // TODO: this causes a crash in MediaCodec.configure
        //format.setString(MediaFormat.KEY_FRAME_RATE, null);
        format.setInteger(MediaFormat.KEY_SAMPLE_RATE, sampleRate);
        format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 1);
        if (type == Type.AAC) {
            format.setString(MediaFormat.KEY_MIME, "audio/mp4a-latm");
            format.setInteger(MediaFormat.KEY_AAC_PROFILE, 2); // TODO: or 39?
            format.setInteger(MediaFormat.KEY_BIT_RATE, 64000);
        } else if (type == Type.FLAC) {
            //format.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_AUDIO_FLAC); // API=21
            format.setString(MediaFormat.KEY_MIME, "audio/flac");
            format.setInteger(MediaFormat.KEY_BIT_RATE, 64000);
            //TODO: use another bit rate, does not seem to have effect always
            //format.setInteger(MediaFormat.KEY_BIT_RATE, 128000);
        } else {
            format.setString(MediaFormat.KEY_MIME, "audio/amr-wb");
            format.setInteger(MediaFormat.KEY_BIT_RATE, 23050);
        }
        return format;
    }
    return null;
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:27,代码来源:MediaFormatFactory.java

示例3: getFrameworkMediaFormatV16

import android.media.MediaFormat; //导入方法依赖的package包/类
/**
 * Returns a {@link MediaFormat} representation of this format.
 */
@SuppressLint("InlinedApi")
@TargetApi(16)
public final MediaFormat getFrameworkMediaFormatV16() {
  MediaFormat format = new MediaFormat();
  format.setString(MediaFormat.KEY_MIME, sampleMimeType);
  maybeSetStringV16(format, MediaFormat.KEY_LANGUAGE, language);
  maybeSetIntegerV16(format, MediaFormat.KEY_MAX_INPUT_SIZE, maxInputSize);
  maybeSetIntegerV16(format, MediaFormat.KEY_WIDTH, width);
  maybeSetIntegerV16(format, MediaFormat.KEY_HEIGHT, height);
  maybeSetFloatV16(format, MediaFormat.KEY_FRAME_RATE, frameRate);
  maybeSetIntegerV16(format, "rotation-degrees", rotationDegrees);
  maybeSetIntegerV16(format, MediaFormat.KEY_CHANNEL_COUNT, channelCount);
  maybeSetIntegerV16(format, MediaFormat.KEY_SAMPLE_RATE, sampleRate);
  maybeSetIntegerV16(format, "encoder-delay", encoderDelay);
  maybeSetIntegerV16(format, "encoder-padding", encoderPadding);
  for (int i = 0; i < initializationData.size(); i++) {
    format.setByteBuffer("csd-" + i, ByteBuffer.wrap(initializationData.get(i)));
  }
  maybeSetColorInfoV24(format, colorInfo);
  return format;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:Format.java

示例4: CreateCodec

import android.media.MediaFormat; //导入方法依赖的package包/类
public  int CreateCodec(ByteBuffer bbcsd){
	Log.i(TAG, "HardwareDecoder:CreateCodec");
	
    int   videoHeight  	= mAPlayerAndroid.getVideoHeight();
    int   videoWidth   	= mAPlayerAndroid.getVideoWidth();
    long  duration      = mAPlayerAndroid.getDuration() * 1000L;

    Surface surface = null;
    if(mSurfaceType == 0){
        surface = mAPlayerAndroid.getInnerSurface();
    }else if(mSurfaceType == 2) {
        surface = mAPlayerAndroid.getInnerSurface();
        int surfaceWidth  = mAPlayerAndroid.getViewSurfaceWidth();
        int surfaceHeight = mAPlayerAndroid.getViewSurfaceHeight();
        mSurfaceRenderer = new SurfaceRenderer(mAPlayerAndroid,surface,surfaceWidth,surfaceHeight,videoHeight,videoWidth);
        surface =  mSurfaceRenderer.GetSurface();
    }else if(mSurfaceType == 3){

    }


    if(surface == null){
        Log.e(TAG,"HardWareDecoder CreateCodec surface == null");
        return -1;
    }
    
    mBbcsd = bbcsd;

    MediaFormat mediaFormat = new MediaFormat();
    mediaFormat.setInteger(MediaFormat.KEY_HEIGHT, videoHeight);
    mediaFormat.setInteger(MediaFormat.KEY_WIDTH, videoWidth);
    mediaFormat.setString(MediaFormat.KEY_MIME, mAVCodeIDToMime.get(mCodeId));
    mediaFormat.setLong(MediaFormat.KEY_DURATION, duration);

    if(mBbcsd != null){
        mediaFormat.setByteBuffer("csd-0", mBbcsd);
        mBbcsd.position(0);
    }


    return CreateCodec(mediaFormat, surface) ? 1 : 0;
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:43,代码来源:HardwareDecoder.java

示例5: maybeSetStringV16

import android.media.MediaFormat; //导入方法依赖的package包/类
@TargetApi(16)
private static void maybeSetStringV16(MediaFormat format, String key, String value) {
  if (value != null) {
    format.setString(key, value);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:7,代码来源:Format.java


注:本文中的android.media.MediaFormat.setString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。