Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 90d0cadb941eb3c64893f4267046aee5d3bdae76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package org.jivesoftware.smackx.provider;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smackx.jingle.ContentInfo;
import org.jivesoftware.smackx.packet.JingleContentInfo;
import org.xmlpull.v1.XmlPullParser;

/**
 * Jingle Audio media-info provider
 * 
 * @author Alvaro Saurin
 */
public class JingleContentInfoProvider implements PacketExtensionProvider {

	/**
	 * Creates a new provider. ProviderManager requires that every
	 * PacketExtensionProvider has a public, no-argument constructor
	 */
	public JingleContentInfoProvider() {
		super();
	}

	public PacketExtension parseExtension(final XmlPullParser parser) throws Exception {
		// This method must be overwritten by subclasses...
		return null;
	}

	/**
	 * JingleContentDescription.Audio info provider
	 */
	public static class Audio extends JingleContentInfoProvider {

		private PacketExtension audioInfo;

		/**
		 * Empty constructor.
		 */
		public Audio() {
			this(null);
		}

		/**
		 * Constructor with an audio info.
		 * 
		 * @param audioInfo the media info
		 */
		public Audio(final PacketExtension audioInfo) {
			super();
			this.audioInfo = audioInfo;
		}

		/**
		 * Parse a JingleContentDescription.Audio extension.
		 */
		public PacketExtension parseExtension(final XmlPullParser parser)
				throws Exception {
			PacketExtension result = null;
			
			if (audioInfo != null) {
				result = audioInfo;
			} else {
				String elementName = parser.getName();
				
				// Try to get an Audio content info
				ContentInfo mi = ContentInfo.Audio.fromString(elementName);
				if (mi != null) {
					result = new JingleContentInfo.Audio(mi);
				}
			}
			return result;
		}

		// Sub-elements

		public static class Busy extends Audio {
			public Busy() {
				super(new JingleContentInfo.Audio.Busy());
			}
		}

		public static class Hold extends Audio {
			public Hold() {
				super(new JingleContentInfo.Audio.Hold());
			}
		}

		public static class Mute extends Audio {
			public Mute() {
				super(new JingleContentInfo.Audio.Mute());
			}
		}

		public static class Queued extends Audio {
			public Queued() {
				super(new JingleContentInfo.Audio.Queued());
			}
		}

		public static class Ringing extends Audio {
			public Ringing() {
				super(new JingleContentInfo.Audio.Ringing());
			}
		}
	}
}

Back to the top