Beispiel #1
0
  @Deprecated
  private void writeAudioDescriptor(StringBuilder builder, RTPFormats formats) {
    builder.append("m=audio %s ");
    builder.append(getMediaProfile());
    builder.append(" ");
    builder.append(payloads(formats));
    builder.append("\n");
    formats.rewind();
    while (formats.hasMore()) {
      RTPFormat f = formats.next();
      String rtpmap = null;
      AudioFormat fmt = (AudioFormat) f.getFormat();

      if (fmt.getChannels() == 1) {
        rtpmap = String.format("a=rtpmap:%d %s/%d\n", f.getID(), fmt.getName(), f.getClockRate());
      } else {
        rtpmap =
            String.format(
                "a=rtpmap:%d %s/%d/%d\n",
                f.getID(), fmt.getName(), f.getClockRate(), fmt.getChannels());
      }

      builder.append(rtpmap);

      if (f.getFormat().getOptions() != null) {
        builder.append(String.format("a=fmtp:%d %s\n", f.getID(), f.getFormat().getOptions()));
      }

      if (f.getFormat().shouldSendPTime()) {
        builder.append("a=ptime:20\n");
      }
    }
    builder.append(getSdpSessionSetupAttribute());
    builder.append(getExtendedAudioAttributes()).append("\n");
  }
Beispiel #2
0
 /**
  * List of payloads.
  *
  * @param formats the RTP format objects.
  * @return the string which with payload numbers
  */
 private String payloads(RTPFormats formats) {
   StringBuilder builder = new StringBuilder();
   formats.rewind();
   while (formats.hasMore()) {
     RTPFormat f = formats.next();
     builder.append(f.getID());
     builder.append(" ");
   }
   return builder.toString().trim();
 }
Beispiel #3
0
  @Deprecated
  private void writeVideoDescriptor(StringBuilder builder, RTPFormats formats) {
    builder.append("m=video %s ").append(getMediaProfile()).append(" ");
    // builder.append("100 116 117");
    builder.append(payloads(formats)).append("\n");

    formats.rewind();
    while (formats.hasMore()) {
      RTPFormat f = formats.next();
      builder.append(
          String.format(
              "a=rtpmap:%d %s/%d\n", f.getID(), f.getFormat().getName(), f.getClockRate()));
      if (f.getFormat().getOptions() != null) {
        builder.append(
            String.format("a=fmtp: %d %s\n", f.getID(), f.getFormat().getOptions().toString()));
      }
      // TODO Finish implementing video description
    }
  }
Beispiel #4
0
  public void setSupportedAudioFormats(RTPFormats supported) {
    this.supportedAudioFormats = supported;

    if (this.offeredAudioFormats != null && !offeredAudioFormats.isEmpty()) {
      this.negotiatedAudioFormats =
          this.sdpComparator.negotiateAudio(this.sessionDescription, this.supportedAudioFormats);
    } else {
      this.negotiatedAudioFormats = null;
    }
  }
Beispiel #5
0
  @Deprecated
  public SdpTemplate(RTPFormats audio, RTPFormats video) {
    StringBuilder builder = new StringBuilder();

    // prepare header part
    writeHeader(builder);

    // prepare media descriptors if required

    if (audio != null && !audio.isEmpty()) {
      this.isAudioSupported = true;
      this.writeAudioDescriptor(builder, audio);
    }

    if (video != null && !video.isEmpty()) {
      this.isVideoSupported = true;
      this.writeVideoDescriptor(builder, video);
    }
    template = builder.toString();
  }