/** * Creates a new, empty SessionDescription. The session is set as follows: * * <p>v=0 * * <p>o=this.createOrigin ("user", InetAddress.getLocalHost().toString()); * * <p>s=- * * <p>t=0 0 * * @throws SdpException SdpException, - if there is a problem constructing the SessionDescription. * @return a new, empty SessionDescription. */ public SessionDescription createSessionDescription() throws SdpException { SessionDescriptionImpl sessionDescriptionImpl = new SessionDescriptionImpl(); ProtoVersionField ProtoVersionField = new ProtoVersionField(); ProtoVersionField.setVersion(0); sessionDescriptionImpl.setVersion(ProtoVersionField); OriginField originImpl = null; try { originImpl = (OriginField) this.createOrigin("user", InetAddress.getLocalHost().getHostAddress()); } catch (UnknownHostException e) { e.printStackTrace(); } sessionDescriptionImpl.setOrigin(originImpl); SessionNameField sessionNameImpl = new SessionNameField(); sessionNameImpl.setValue("-"); sessionDescriptionImpl.setSessionName(sessionNameImpl); TimeDescriptionImpl timeDescriptionImpl = new TimeDescriptionImpl(); TimeField timeImpl = new TimeField(); timeImpl.setZero(); timeDescriptionImpl.setTime(timeImpl); Vector times = new Vector(); times.addElement(timeDescriptionImpl); sessionDescriptionImpl.setTimeDescriptions(times); sessionDescriptionsList.addElement(sessionDescriptionImpl); return sessionDescriptionImpl; }
public static void main(String[] args) throws ParseException { String session[] = {"s=SDP Seminar \n", "s= Session SDP\n"}; for (int i = 0; i < session.length; i++) { SessionNameFieldParser sessionNameFieldParser = new SessionNameFieldParser(session[i]); SessionNameField sessionNameField = sessionNameFieldParser.sessionNameField(); System.out.println("encoded: " + sessionNameField.encode()); } }
/** * Returns SessionName object with the specified name. * * @param name the string containing the name of the session. * @return SessionName */ public SessionName createSessionName(String name) { SessionNameField sessionNameImpl = new SessionNameField(); try { sessionNameImpl.setValue(name); } catch (SdpException s) { s.printStackTrace(); } return sessionNameImpl; }
/** * Get the SessionNameField * * @return SessionNameField */ public SessionNameField sessionNameField() throws ParseException { try { this.lexer.match('s'); this.lexer.SPorHT(); this.lexer.match('='); this.lexer.SPorHT(); SessionNameField sessionNameField = new SessionNameField(); String rest = lexer.getRest(); sessionNameField.setSessionName(rest.trim()); return sessionNameField; } catch (Exception e) { throw lexer.createParseException(); } }