01: /*
02: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License version
07: * 2 only, as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful, but
10: * WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * General Public License version 2 for more details (a copy is
13: * included at /legal/license.txt).
14: *
15: * You should have received a copy of the GNU General Public License
16: * version 2 along with this work; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18: * 02110-1301 USA
19: *
20: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21: * Clara, CA 95054 or visit www.sun.com if you need additional
22: * information or have any questions.
23: */
24: package com.sun.mmedia.rtsp.sdp;
25:
26: import java.io.*;
27: import java.util.*;
28:
29: public class SdpParser extends Parser {
30: public SessionDescription sessionDescription;
31:
32: public SdpParser(byte data[]) {
33: init();
34:
35: ByteArrayInputStream bin = new ByteArrayInputStream(data);
36:
37: parseData(bin);
38: }
39:
40: public void parseData(ByteArrayInputStream bin) {
41: if (getTag(bin).equals("v=")) {
42: sessionDescription = new SessionDescription(bin);
43: }
44: }
45:
46: public MediaAttribute getSessionAttribute(String name) {
47: MediaAttribute attribute = null;
48:
49: if (sessionDescription != null) {
50: attribute = sessionDescription.getSessionAttribute(name);
51: }
52:
53: return attribute;
54: }
55:
56: public MediaDescription getMediaDescription(String name) {
57: MediaDescription description = null;
58:
59: if (sessionDescription != null) {
60: description = sessionDescription.getMediaDescription(name);
61: }
62:
63: return description;
64: }
65:
66: public Vector getMediaDescriptions() {
67: Vector descriptions = null;
68:
69: if (sessionDescription != null) {
70: descriptions = sessionDescription.getMediaDescriptions();
71: }
72:
73: return descriptions;
74: }
75: /*
76: static String msg= "v=0\r\n" +
77: "s=boiler_room_small_jpeg.mov\r\n" +
78: "u=http://jmserver2/\r\n" +
79: "e=admin@jmserver2\r\n" +
80: "c=IN IP4 129.144.89.52\r\n" +
81: "a=control:/\r\n" +
82: "a=range:npt=0- 139.80500\r\n" +
83: "m=video 0 RTP/AVP 97\r\n" +
84: "a=rtpmap:97 MP4V-ES\r\n" +
85: "a=control:trackID=6 \r\n" +
86: "a=fmtp:97 profile-level-id=1; config=000001B001000001B5090000010000000120008440FA282C2090A21F\r\n\r\n";
87:
88: public static void main( String[] args) {
89: SdpParser sdp= new SdpParser( msg.getBytes());
90:
91: MediaDescription desc = sdp.getMediaDescription( "video");
92:
93: MediaAttribute attribute = desc.getMediaAttribute( "fmtp");
94:
95: System.out.println( "attribute: " + attribute.getValue());
96: }
97: */
98: }
|