예제 #1
0
 /**
  * Returns Media object with the specified properties.
  *
  * @param media the media type, eg "audio"
  * @param port port number on which to receive media
  * @param numPorts number of ports used for this media stream
  * @param transport transport type, eg "RTP/AVP"
  * @param staticRtpAvpTypes vector to set
  * @throws SdpException
  * @return Media
  */
 public Media createMedia(
     String media, int port, int numPorts, String transport, Vector staticRtpAvpTypes)
     throws SdpException {
   MediaField mediaImpl = new MediaField();
   mediaImpl.setMediaType(media);
   mediaImpl.setMediaPort(port);
   mediaImpl.setPortCount(numPorts);
   mediaImpl.setProtocol(transport);
   mediaImpl.setMediaFormats(staticRtpAvpTypes);
   return mediaImpl;
 }
예제 #2
0
 /**
  * Returns MediaDescription object with the specified properties. The returned object will respond
  * to Media.getMediaFormats(boolean) with a Vector of media formats.
  *
  * @param media media -
  * @param port port number on which to receive media
  * @param numPorts number of ports used for this media stream
  * @param transport transport type, eg "RTP/AVP"
  * @param staticRtpAvpTypes list of static RTP/AVP media payload types which should be specified
  *     by the returned MediaDescription throws IllegalArgumentException if passed an invalid
  *     RTP/AVP payload type
  * @throws IllegalArgumentException
  * @throws SdpException
  * @return MediaDescription
  */
 public MediaDescription createMediaDescription(
     String media, int port, int numPorts, String transport, int[] staticRtpAvpTypes)
     throws IllegalArgumentException, SdpException {
   MediaDescriptionImpl mediaDescriptionImpl = new MediaDescriptionImpl();
   MediaField mediaImpl = new MediaField();
   mediaImpl.setMediaType(media);
   mediaImpl.setMediaPort(port);
   mediaImpl.setPortCount(numPorts);
   mediaImpl.setProtocol(transport);
   mediaDescriptionImpl.setMedia(mediaImpl);
   // Bug fix contributed by Paloma Ortega.
   Vector payload = new Vector();
   for (int i = 0; i < staticRtpAvpTypes.length; i++)
     payload.add(new Integer(staticRtpAvpTypes[i]).toString());
   mediaImpl.setMediaFormats(payload);
   return mediaDescriptionImpl;
 }
예제 #3
0
  /**
   * Returns MediaDescription object with the specified properties. The returned object will respond
   * to Media.getMediaFormats(boolean) with a Vector of String objects specified by the 'formats
   * argument.
   *
   * @param media the media type, eg "audio"
   * @param port port number on which to receive media
   * @param numPorts number of ports used for this media stream
   * @param transport transport type, eg "RTP/AVP"
   * @param formats list of formats which should be specified by the returned MediaDescription
   * @return MediaDescription
   */
  public MediaDescription createMediaDescription(
      String media, int port, int numPorts, String transport, String[] formats) {
    MediaDescriptionImpl mediaDescriptionImpl = new MediaDescriptionImpl();
    try {

      MediaField mediaImpl = new MediaField();
      mediaImpl.setMediaType(media);
      mediaImpl.setMediaPort(port);
      mediaImpl.setPortCount(numPorts);
      mediaImpl.setProtocol(transport);

      Vector formatsV = new Vector(formats.length);
      for (int i = 0; i < formats.length; i++) formatsV.add(formats[i]);
      mediaImpl.setMediaFormats(formatsV);
      mediaDescriptionImpl.setMedia(mediaImpl);
    } catch (final SdpException e) {
      LOG.warn("Unexpected exception", e);
    }
    return mediaDescriptionImpl;
  }