AudioSource和VideoSource都是MediaSource的子類(lèi),它們同樣是包裹在C++外的一層,它們的功能是承載一個(gè)或多個(gè)AudioTrack/VideoTrack。
//AudioSource完全繼承了父類(lèi),并沒(méi)有任何的重寫(xiě)
public class AudioSource extends MediaSource {
public AudioSource(long nativeSource) {
super(nativeSource);
}
}
//同樣是繼承了父類(lèi)的所有的方法,但是新增了一個(gè)方法是,適應(yīng)外界輸出的分辨率
public VideoSource(long nativeSource) {
super(nativeSource);
}
/**
* Calling this function will cause frames to be scaled down to the requested resolution. Also,
* frames will be cropped to match the requested aspect ratio, and frames will be dropped to match
* the requested fps. The requested aspect ratio is orientation agnostic and will be adjusted to
* maintain the input orientation, so it doesn't matter if e.g. 1280x720 or 720x1280 is requested.
*/
public void adaptOutputFormat(int width, int height, int fps) {
nativeAdaptOutputFormat(nativeSource, width, height, fps);
}
private static native void nativeAdaptOutputFormat(
long nativeSource, int width, int height, int fps);