Exemplo n.º 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");
  }
Exemplo n.º 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();
 }
Exemplo n.º 3
0
  private String writeAudioDescriptor() {
    if (this.offeredAudioFormats == null) {
      throw new NullPointerException(
          "Supported audio formats is null. Cannot write audio descriptor.");
    }

    StringBuilder builder = new StringBuilder();
    builder.append("m=audio %s ").append(getMediaProfile()).append(" ");
    if (isAudioSupported()) {
      builder.append(payloads(this.negotiatedAudioFormats)).append("\n");
      builder.append("a=rtcp:%d\n");

      this.negotiatedAudioFormats.rewind();
      while (this.negotiatedAudioFormats.hasMore()) {
        RTPFormat f = this.negotiatedAudioFormats.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(String.format("a=%s\n", this.connectionMode));
      builder.append(getSdpSessionSetupAttribute());
      builder.append(getExtendedAudioAttributes()).append("\n");
      // XXX Firefox does not support SSRC attribute!!
      //            builder.append("a=ssrc:%d cname:%s").append("\n");
    } else {
      builder.append(payloads(this.offeredAudioFormats)).append("\n");
    }
    return builder.toString();
  }
Exemplo n.º 4
0
  private String writeVideoDescriptor() {
    if (this.offeredVideoFormats == null) {
      throw new NullPointerException(
          "Supported video formats is null. Cannot write video descriptor.");
    }

    StringBuilder builder = new StringBuilder();
    builder.append("m=video %s ").append(getMediaProfile()).append(" ");
    if (isVideoSupported()) {
      builder.append(payloads(this.negotiatedVideoFormats)).append("\n");

      this.negotiatedVideoFormats.rewind();
      while (this.negotiatedVideoFormats.hasMore()) {
        RTPFormat f = this.negotiatedVideoFormats.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
      }
      builder.append(this.getExtendedVideoAttributes()).append("\n");
    } else {
      // TODO No video formats are received because video is still not implemented
      builder.append(payloads(this.offeredVideoFormats)).append("\n");
      //			builder.append("100 116 117").append("\n");
    }
    return builder.toString();
  }
Exemplo n.º 5
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
    }
  }