本文整理汇总了Java中org.jitsi.service.neomedia.format.MediaFormat类的典型用法代码示例。如果您正苦于以下问题:Java MediaFormat类的具体用法?Java MediaFormat怎么用?Java MediaFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaFormat类属于org.jitsi.service.neomedia.format包,在下文中一共展示了MediaFormat类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractFormats
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
/**
* Extracts and returns the list of <tt>MediaFormat</tt>s advertised in
* <tt>description</tt> preserving their oder and registering dynamic payload
* type numbers in the specified <tt>ptRegistry</tt>. Note that this method
* would only include in the result list <tt>MediaFormat</tt> instances
* that are currently supported by our <tt>MediaService</tt> implementation
* and enabled in its configuration. This means that the method could
* return an empty list even if there were actually some formats in the
* <tt>mediaDesc</tt> if we support none of them or if all these we support
* are not enabled in the <tt>MediaService</tt> configuration form.
*
* @param description the <tt>MediaDescription</tt> that we'd like to probe
* for a list of <tt>MediaFormat</tt>s
* @param ptRegistry a reference to the <tt>DynamycPayloadTypeRegistry</tt>
* where we should be registering newly added payload type number to format
* mappings.
*
* @return an ordered list of <tt>MediaFormat</tt>s that are both advertised
* in the <tt>description</tt> and supported by our <tt>MediaService</tt>
* implementation.
*/
public static List<MediaFormat> extractFormats(
NewRtpDescriptionPacketExtension description,
DynamicPayloadTypeRegistry ptRegistry)
{
List<MediaFormat> mediaFmts = new ArrayList<MediaFormat>();
List<NewPayloadTypePacketExtension> payloadTypes
= description.getPayloadTypes();
for(NewPayloadTypePacketExtension ptExt : payloadTypes)
{
MediaFormat format = payloadTypeToMediaFormat(ptExt, ptRegistry);
//continue if our media service does not know this format
if(format == null)
{
if(logger.isTraceEnabled())
logger.trace("Unsupported remote format: " + ptExt.toXML());
}
else
mediaFmts.add(format);
}
return mediaFmts;
}
示例2: getSupportedFormat
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
private MediaFormat getSupportedFormat( String name, PayloadTypePacketExtension payloadType ) {
MediaDevice dev = devices.get(name);
MediaType mediaType = dev.getMediaType();
for( MediaFormat mf : dev.getSupportedFormats() ) {
// if( ( mf.getRTPPayloadType() == MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN || mf.getRTPPayloadType() == payloadType.getID() ) //FIXME: will this work for locally defined ids?
// && mf.getClockRateString().equals( String.valueOf(payloadType.getClockrate())) //FIXME: does the clockrate really need to match? will the device report all available clock rates?
// && mf.getEncoding().equals(payloadType.getName()) ) {
//FIXME: we should probably check advanced attributes and format parameters, but my guess is
// that in most cases we can adapt.
if (mf.matches(mediaType, payloadType.getName(), payloadType.getClockrate(), payloadType.getChannels(), null)) {//formatParameters is not used by default
return mf;
}
}
return null;
}
示例3: createContentList
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
public List<ContentPacketExtension> createContentList(SendersEnum senders) {
this.senders = senders;
List<ContentPacketExtension> contentList = new ArrayList<ContentPacketExtension>();
for( Map.Entry<String,MediaDevice> e : devices.entrySet() ) {
String name = e.getKey();
MediaDevice dev = e.getValue();
contentList.add( createContentPacketExtention( senders, name, dev, null, MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN ) );
}
return contentList;
}
示例4: createContentPacketExtention
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
private ContentPacketExtension createContentPacketExtention(SendersEnum senders, String name, MediaDevice dev, MediaFormat fmt, int payloadId ) {
this.senders = senders;
ContentPacketExtension content = new ContentPacketExtension();
RtpDescriptionPacketExtension description = new RtpDescriptionPacketExtension();
// fill in the basic content:
content.setCreator(creator);
content.setName(name);
if (senders != null && senders != SendersEnum.both)
content.setSenders(senders);
// RTP description
content.addChildExtension(description);
// now fill in the RTP description
if (fmt == null) {
List<MediaFormat> formats = dev.getSupportedFormats();
description.setMedia(formats.get(0).getMediaType().toString());
for (MediaFormat mf : formats)
description.addPayloadType(formatToPayloadType(mf, dynamicPayloadTypes, payloadId));
} else {
description.setMedia(fmt.getMediaType().toString());
description.addPayloadType(formatToPayloadType(fmt, dynamicPayloadTypes, payloadId));
}
return content;
}
示例5: startStream
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
public JingleStream startStream(String name, IceAgent iceAgent ) throws IOException {
if( streamNameToMediaFormats.size() == 0 ) {
// media has not been negotiated. This seems to happen with jitsi.
// we will assume our requested formats are acceptable.
parseIncomingAndBuildMedia( createContentList( senders ), senders );
}
IceMediaStream stream = iceAgent.getAgent().getStream(name);
MediaFormat format = streamNameToMediaFormats.get(name);
Byte payloadTypeId = streamNameToPayloadTypeId.get(name);
if( stream == null || format == null || payloadTypeId == null )
throw new IOException("Stream \"" + name + "\" not found.");
Component rtpComponent = stream.getComponent(org.ice4j.ice.Component.RTP);
Component rtcpComponent = stream.getComponent(org.ice4j.ice.Component.RTCP);
if( rtpComponent == null )
throw new IOException("RTP component not found.");
if( rtcpComponent == null )
throw new IOException("RTCP Component not found.");
CandidatePair rtpPair = rtpComponent.getSelectedPair();
CandidatePair rtcpPair = rtcpComponent.getSelectedPair();
// System.out.println( "RTP : L " + rtpPair.getLocalCandidate().getDatagramSocket().getLocalPort() + " <-> " + rtpPair.getRemoteCandidate().getTransportAddress() + " R " );
// System.out.println( "RTCP: L " + rtcpPair.getLocalCandidate().getDatagramSocket().getLocalPort() + " <-> " + rtcpPair.getRemoteCandidate().getTransportAddress() + " R " );
return startStream( name,
payloadTypeId,
format,
rtpPair.getRemoteCandidate().getTransportAddress(),
rtcpPair.getRemoteCandidate().getTransportAddress(),
rtpPair.getLocalCandidate().getDatagramSocket(),
rtcpPair.getLocalCandidate().getDatagramSocket());
}
示例6: parseIncomingAndBuildMedia
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
public List<ContentPacketExtension> parseIncomingAndBuildMedia(List<ContentPacketExtension> cpes, SendersEnum senders) throws IOException {
this.senders = senders;
String name = null;
String toclean = null;
List<ContentPacketExtension> ret = new ArrayList<ContentPacketExtension>();
try {
for( ContentPacketExtension cpe : cpes ) {
toclean = name = cpe.getName();
if( name == null )
throw new IOException();
// SendersEnum senders = cpe.getSenders();
// CreatorEnum creator = cpe.getCreator();
String media = null;
List<RtpDescriptionPacketExtension> descriptions = cpe.getChildExtensionsOfType(RtpDescriptionPacketExtension.class);
for( RtpDescriptionPacketExtension description : descriptions ) {
System.out.println( description );
media = description.getMedia();
if( "audio".equals(media) ) {
if( !addDefaultMedia( MediaType.AUDIO, name ) )
throw new IOException( "Could not create audio device" );
} else if( "video".equals(media) ) {
if( !addDefaultMedia( MediaType.VIDEO, name ) )
throw new IOException( "Could not create video device" );
} else {
throw new IOException( "Unknown media type: " + media );
}
List<PayloadTypePacketExtension> payloadTypes = description.getPayloadTypes();
for( PayloadTypePacketExtension payloadType : payloadTypes ) {
MediaFormat mf = getSupportedFormat( name, payloadType );
if( mf == null )
continue; //no match
ret.add( createContentPacketExtention( senders, name, devices.get(name), mf, payloadType.getID() ) );
toclean = null;
streamNameToMediaFormats.put( name, mf );
streamNameToPayloadTypeId.put( name, (byte) payloadType.getID() );
break; //stop on first match
}
}
if( media == null )
throw new IOException();
}
if( ret.size() == 0 )
return null;
return ret;
} finally {
if( toclean != null )
devices.remove(toclean);
}
}
示例7: payloadTypeToMediaFormat
import org.jitsi.service.neomedia.format.MediaFormat; //导入依赖的package包/类
/**
* Returns the {@link MediaFormat} described in the <tt>payloadType</tt>
* extension or <tt>null</tt> if we don't recognize the format.
* This method uses <tt>LibJitsi</tt> instead of <tt>JabberActivator</tt>
*
* @param payloadType the {@link NewPayloadTypePacketExtension} which is to be
* parsed into a {@link MediaFormat}.
* @param ptRegistry the {@link DynamicPayloadTypeRegistry} that we would
* use for the registration of possible dynamic payload types or
* <tt>null</tt> the returned <tt>MediaFormat</tt> is to not be registered
* into a <tt>DynamicPayloadTypeRegistry</tt>.
*
* @return the {@link MediaFormat} described in the <tt>payloadType</tt>
* extension or <tt>null</tt> if we don't recognize the format.
*/
public static MediaFormat payloadTypeToMediaFormat(
NewPayloadTypePacketExtension payloadType,
DynamicPayloadTypeRegistry ptRegistry)
{
return
payloadTypeToMediaFormat(
payloadType,
LibJitsi.getMediaService(),
ptRegistry);
}