001/** 002 * 003 * Copyright 2003-2005 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smackx.jingleold.provider; 018 019import org.jivesoftware.smack.packet.ExtensionElement; 020import org.jivesoftware.smack.provider.ExtensionElementProvider; 021 022import org.jivesoftware.smackx.jingleold.media.ContentInfo; 023import org.jivesoftware.smackx.jingleold.packet.JingleContentInfo; 024 025import org.xmlpull.v1.XmlPullParser; 026 027/** 028 * Jingle Audio jmf-info provider. 029 * 030 * @author Alvaro Saurin 031 */ 032public class JingleContentInfoProvider { 033 034 /** 035 * JingleDescription.Audio info provider. 036 */ 037 public static class Audio extends ExtensionElementProvider<ExtensionElement> { 038 039 private final ExtensionElement audioInfo; 040 041 /** 042 * Empty constructor. 043 */ 044 public Audio() { 045 this(null); 046 } 047 048 /** 049 * Constructor with an audio info. 050 * 051 * @param audioInfo the jmf info 052 */ 053 public Audio(final ExtensionElement audioInfo) { 054 super(); 055 this.audioInfo = audioInfo; 056 } 057 058 /** 059 * Parse a JingleDescription.Audio extension. 060 */ 061 @Override 062 public ExtensionElement parse(XmlPullParser parser, int initialDepth) { 063 ExtensionElement result = null; 064 065 if (audioInfo != null) { 066 result = audioInfo; 067 } else { 068 String elementName = parser.getName(); 069 070 // Try to get an Audio content info 071 ContentInfo mi = ContentInfo.Audio.fromString(elementName); 072 if (mi != null) { 073 result = new JingleContentInfo.Audio(mi); 074 } 075 } 076 return result; 077 } 078 079 // Sub-elements 080 081 public static class Busy extends Audio { 082 public Busy() { 083 super(new JingleContentInfo.Audio.Busy()); 084 } 085 } 086 087 public static class Hold extends Audio { 088 public Hold() { 089 super(new JingleContentInfo.Audio.Hold()); 090 } 091 } 092 093 public static class Mute extends Audio { 094 public Mute() { 095 super(new JingleContentInfo.Audio.Mute()); 096 } 097 } 098 099 public static class Queued extends Audio { 100 public Queued() { 101 super(new JingleContentInfo.Audio.Queued()); 102 } 103 } 104 105 public static class Ringing extends Audio { 106 public Ringing() { 107 super(new JingleContentInfo.Audio.Ringing()); 108 } 109 } 110 } 111}