001: /*
002: *
003: * Copyright (c) 2000-2001 Silvere Martin-Michiellot All Rights Reserved.
004: *
005: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
006: * royalty free, license to use, modify but not to redistribute this
007: * software in source and binary code form,
008: * provided that i) this copyright notice and license appear on all copies of
009: * the software; and ii) Licensee does not utilize the software in a manner
010: * which is disparaging to Silvere Martin-Michiellot.
011: *
012: * This software is provided "AS IS," without a warranty of any kind. ALL
013: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
014: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
015: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
016: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
017: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
018: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
019: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
020: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
024: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
025: *
026: * This software is not designed or intended for use in on-line control of
027: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028: * the design, construction, operation or maintenance of any nuclear
029: * facility. Licensee represents and warrants that it will not use or
030: * redistribute the Software for such purposes.
031: *
032: *
033: */
034:
035: package com.db.media.rtp;
036:
037: import javax.media.rtp.RTPPushDataSource;
038: import javax.media.rtp.RTPControl;
039: import javax.media.rtp.SessionManager;
040: import javax.media.Format;
041: import javax.media.format.AudioFormat;
042:
043: /**
044: * This is a utility class which configures a RTP datasource with
045: * dynamic payload information using the interface defined in
046: * javax.media.rtp.RTPControl.The main method is the Init() method which
047: * will take in a datasource as an argument. Currently, the datasource
048: * is configured for dynamic payload types used by ShowmeTvT, which
049: * tranmits DVI compressed audio at 44.1 KHz at
050: * dynamic RTP payloads 18. The JMF RTP handlers
051: * are capable of handling these content types. The RTP datasource must
052: * be configured with dynamic payload information prior to attempting to
053: * playback these streams.
054: */
055: public class EncodingUtil {
056: private static final String rtpcontrol = "javax.media.rtp.RTPControl";
057:
058: public static void Init(RTPPushDataSource ds) {
059:
060: RTPControl control = (RTPControl) ds.getControl(rtpcontrol);
061: if (control == null) {
062: //System.out.println("The datasource " + ds +
063: // "\n does not support the RTPControl interface..." +
064: // "\nexiting from EncodingUtil.Init()");
065: return;
066: }
067: Init(control);
068: }
069:
070: public static void Init(SessionManager mgr) {
071:
072: Format format = null;
073:
074: if (mgr == null)
075: return;
076: // since we have a handle over the RTPControl interface, now
077: // add our dynamic payload types for DVI. These are
078: // PT encoding audio/video clock rate channels
079: // name (A/V) (Hz) (audio)
080: // 18 DVI4 A 44100 1
081: // for each of the payloads, we will create a
082: // Format (defined in
083: // javax.media.Format) and add this to the
084: // RTPControl interface. Note: as explained in the RTPControl
085: // inteface, addEncoding() can be called repeatedly in order
086: // to enter dynamic payload encoding information.
087: format = new AudioFormat(AudioFormat.DVI, 44100, 8, 1);
088: mgr.addFormat(format, 18);
089:
090: }
091:
092: public static void Init(RTPControl control) {
093:
094: Format format = null;
095: if (control == null)
096: return;
097: // since we have a handle over the RTPControl interface, now
098: // add our dynamic payload types for DVI. These are
099: // PT encoding audio/video clock rate channels
100: // name (A/V) (Hz) (audio)
101: // 18 DVI4 A 44100 1
102: // for each of the payloads, we will create a
103: // Format (defined in
104: // javax.media.Format) and add this to the
105: // RTPControl interface. Note: as explained in the RTPControl
106: // inteface, addEncoding() can be called repeatedly in order
107: // to enter dynamic payload encoding information.
108: format = new AudioFormat(AudioFormat.DVI, 44100, 8, 1);
109: control.addFormat(format, 18);
110:
111: }
112:
113: }
|