本文整理汇总了Java中javax.media.control.TrackControl.getSupportedFormats方法的典型用法代码示例。如果您正苦于以下问题:Java TrackControl.getSupportedFormats方法的具体用法?Java TrackControl.getSupportedFormats怎么用?Java TrackControl.getSupportedFormats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.control.TrackControl
的用法示例。
在下文中一共展示了TrackControl.getSupportedFormats方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryTranscode
import javax.media.control.TrackControl; //导入方法依赖的package包/类
/**
* Try different transcoded formats for concatenation.
*/
public boolean tryTranscode(ProcInfo pInfo[], int procID, int type,
int trackID, Format candidate) {
if (procID >= pInfo.length)
return true;
boolean matched = false;
TrackControl tc = pInfo[procID].tracksByType[type][trackID].tc;
Format supported[] = tc.getSupportedFormats();
for (int i = 0; i < supported.length; i++) {
if (candidate.matches(supported[i]) &&
tryTranscode(pInfo, procID+1, type, trackID, candidate)) {
matched = true;
break;
}
}
return matched;
}
示例2: tryMatch
import javax.media.control.TrackControl; //导入方法依赖的package包/类
/**
* Try matching the data formats and find common ones for concatenation.
*/
public boolean tryMatch(ProcInfo pInfo[], int type, int trackID) {
TrackControl tc = pInfo[0].tracksByType[type][trackID].tc;
Format origFmt = tc.getFormat();
Format newFmt, oldFmt;
Format supported[] = tc.getSupportedFormats();
for (int i = 0; i < supported.length; i++) {
if (supported[i] instanceof AudioFormat) {
// If it's not the original format, then for audio, we'll
// only do linear since it's more accurate to compute the
// audio times.
if (!supported[i].matches(tc.getFormat()) &&
!supported[i].getEncoding().equalsIgnoreCase(AudioFormat.LINEAR))
continue;
}
if (tryTranscode(pInfo, 1, type, trackID, supported[i])) {
// We've found the right format to transcode all the
// tracks to. We'll set it on the corresponding
// TrackControl on each processor.
for (int j = 0; j < pInfo.length; j++) {
tc = pInfo[j].tracksByType[type][trackID].tc;
oldFmt = tc.getFormat();
newFmt = supported[i];
// Check if it requires transcoding.
if (!oldFmt.matches(newFmt)) {
if (!transcodeMsg) {
transcodeMsg = true;
System.err.println(TRANSCODE_MSG);
}
System.err.println("- Transcoding: " + pInfo[j].ml);
System.err.println(" " + oldFmt);
System.err.println(" to:");
System.err.println(" " + newFmt);
}
// For video, check if it requires scaling.
if (oldFmt instanceof VideoFormat) {
Dimension newSize = ((VideoFormat)origFmt).getSize();
Dimension oldSize = ((VideoFormat)oldFmt).getSize();
if (oldSize != null && !oldSize.equals(newSize)) {
// It requires scaling.
if (!transcodeMsg) {
transcodeMsg = true;
System.err.println(TRANSCODE_MSG);
}
System.err.println("- Scaling: " + pInfo[j].ml);
System.err.println(" from: " + oldSize.width +
" x " + oldSize.height);
System.err.println(" to: " + newSize.width +
" x " + newSize.height);
newFmt = (new VideoFormat(null,
newSize,
Format.NOT_SPECIFIED,
null,
Format.NOT_SPECIFIED)).intersects(newFmt);
}
}
tc.setFormat(newFmt);
}
return true;
}
}
return false;
}
示例3: setMyVideoFormat
import javax.media.control.TrackControl; //导入方法依赖的package包/类
protected boolean setMyVideoFormat(VideoFormat v, TrackControl track) {
boolean found = false;
if(HiloCliente.DEBUG){
Format[] supported = track.getSupportedFormats();
for (int n = 0; n < supported.length; n++)
System.out.println("Formato de Video soportados: " + supported[n]);
}
if (v.isSameEncoding(VideoFormat.MPEG)) {
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.MPEG_RTP));
found = true;
}
if (v.isSameEncoding(VideoFormat.JPEG_RTP)) {// para la webcam
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.JPEG_RTP));
found = true;
}
if (v.isSameEncoding(VideoFormat.H263)) {
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.H263_RTP));
found = true;
}
if (v.isSameEncoding(VideoFormat.JPEG)) {
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.JPEG_RTP));
found = true;
}
if (v.isSameEncoding(VideoFormat.MJPG)) {
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.JPEG_RTP));
found = true;
}
if (v.isSameEncoding(VideoFormat.YUV)) {// para la webcam
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.JPEG_RTP));
found = true;
}
if (v.isSameEncoding(VideoFormat.RGB)) {// para el escritorio
((FormatControl) track).setFormat(new VideoFormat(
VideoFormat.JPEG_RTP));
found = true;
}
if(HiloCliente.DEBUG){
String s="";
if(found){
s="Formato de video encontrado ("+v.toString()+"). " +
"\nSe transforma a ("+((FormatControl) track).getFormat().toString()+").";
}else{
s="Formato de video ("+v.toString()+") NO encontrado.";
}
System.out.println(s);
}
track.setEnabled(found);
return found;
}
示例4: setMyAudioFormat
import javax.media.control.TrackControl; //导入方法依赖的package包/类
protected boolean setMyAudioFormat(AudioFormat a, TrackControl track) {
boolean found = false;
if(HiloCliente.DEBUG){
Format[] supported = track.getSupportedFormats();
for (int n = 0; n < supported.length; n++)
System.out.println("Formato de Audio soportados: " + supported[n]);
}
if (a.isSameEncoding(AudioFormat.MPEG)) {
((FormatControl) track).setFormat(new AudioFormat(
AudioFormat.MPEG_RTP));
found = true;
}
if (a.isSameEncoding(AudioFormat.MPEGLAYER3)) {
((FormatControl) track).setFormat(new AudioFormat(
AudioFormat.MPEG_RTP));
found = true;
}
if (a.isSameEncoding(AudioFormat.LINEAR)) {
((FormatControl) track).setFormat(new AudioFormat(
AudioFormat.DVI_RTP));
found = true;
}
if (a.isSameEncoding(AudioFormat.ULAW)) {
((FormatControl) track).setFormat(new AudioFormat(
AudioFormat.ULAW_RTP));
found = true;
}
if(HiloCliente.DEBUG){
String s="";
if(found){
s="Formato de audio encontrado.";
}else{
s="Formato de audio ("+a.toString()+") NO encontrado.";
}
System.out.println(s);
}
track.setEnabled(found);
return found;
}