sdp 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.infinity_test +2 -2
- data/ChangeLog.rdoc +10 -0
- data/features/sdp_get.feature +2 -0
- data/features/step_definitions/sdp_create_steps.rb +2 -0
- data/lib/sdp/description.rb +2 -0
- data/lib/sdp/parser.rb +8 -5
- data/lib/sdp/session_template.erb +3 -1
- data/lib/sdp/version.rb +1 -1
- data/sdp.gemspec +1 -1
- data/spec/sdp/description_spec.rb +10 -0
- data/spec/sdp/parser_spec.rb +37 -0
- data/spec/sdp_spec.rb +45 -37
- metadata +2 -2
data/.infinity_test
CHANGED
data/ChangeLog.rdoc
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 0.2.0 / 2011-01-22
|
2
|
+
|
3
|
+
* New features:
|
4
|
+
* Parse i=, c=, b=, k= when in media sections.
|
5
|
+
* connection_network_type and connection_address_type now separate
|
6
|
+
from network_type and address_type.
|
7
|
+
* Bug Fixes:
|
8
|
+
* Fixed attribute parsing so it treats anything but a :, \r, or \n as
|
9
|
+
part of the attribute.
|
10
|
+
|
1
11
|
=== 0.1.0 / 2011-01-21
|
2
12
|
|
3
13
|
* Initial release:
|
data/features/sdp_get.feature
CHANGED
@@ -19,6 +19,8 @@ Feature: Get SDP file fields and marshall into Ruby data types
|
|
19
19
|
| information | A Seminar on the session description protocol |
|
20
20
|
| uri | http://www.example.com/seminars/sdp.pdf |
|
21
21
|
| email_address | j.doe@example.com (Jane Doe) |
|
22
|
+
| connection_network_type | IN |
|
23
|
+
| connection_address_type | IP4 |
|
22
24
|
| connection_address | 224.2.17.12/127 |
|
23
25
|
| start_time | 2873397496 |
|
24
26
|
| stop_time | 2873404696 |
|
@@ -17,6 +17,8 @@ When /^I build the Ruby object with the appropriate fields$/ do
|
|
17
17
|
@session.information = "A Seminar on the session description protocol"
|
18
18
|
@session.uri = "http://www.example.com/seminars/sdp.pdf"
|
19
19
|
@session.email_address = "j.doe@example.com (Jane Doe)"
|
20
|
+
@session.connection_network_type = "IN"
|
21
|
+
@session.connection_address_type = "IP4"
|
20
22
|
@session.connection_address = "224.2.17.12/127"
|
21
23
|
@session.start_time = 2873397496
|
22
24
|
@session.stop_time = 2873404696
|
data/lib/sdp/description.rb
CHANGED
data/lib/sdp/parser.rb
CHANGED
@@ -25,7 +25,7 @@ class SDP::Parser < Parslet::Parser
|
|
25
25
|
|
26
26
|
rule(:session_name) { str('s=') >> field_value_string.as(:name) >> eol }
|
27
27
|
|
28
|
-
rule(:
|
28
|
+
rule(:information) do
|
29
29
|
str('i=') >> field_value_string.as(:information) >> eol
|
30
30
|
end
|
31
31
|
|
@@ -40,7 +40,9 @@ class SDP::Parser < Parslet::Parser
|
|
40
40
|
end
|
41
41
|
|
42
42
|
rule(:connection_data) do
|
43
|
-
str('c=') >>
|
43
|
+
str('c=') >>
|
44
|
+
field_value.as(:connection_network_type) >> space >>
|
45
|
+
field_value.as(:connection_address_type) >> space >>
|
44
46
|
field_value.as(:connection_address) >> eol
|
45
47
|
end
|
46
48
|
|
@@ -75,7 +77,7 @@ class SDP::Parser < Parslet::Parser
|
|
75
77
|
end
|
76
78
|
|
77
79
|
rule(:attribute) do
|
78
|
-
str('a=') >> match('[\
|
80
|
+
str('a=') >> match('[^:\r\n]').repeat(1).as(:attribute) >>
|
79
81
|
(str(':') >> field_value_string.as(:value)).maybe >> eol
|
80
82
|
end
|
81
83
|
|
@@ -97,14 +99,15 @@ class SDP::Parser < Parslet::Parser
|
|
97
99
|
# The SDP description
|
98
100
|
rule(:session_section) do
|
99
101
|
version.maybe >> origin.maybe >> session_name.maybe >>
|
100
|
-
|
102
|
+
information.maybe >> uri.maybe >> email_address.maybe >>
|
101
103
|
phone_number.maybe >> connection_data.maybe >> bandwidth.maybe >>
|
102
104
|
timing.maybe >> repeat_times.maybe >> time_zones.maybe >>
|
103
105
|
encryption_keys.maybe >> attributes.maybe
|
104
106
|
end
|
105
107
|
|
106
108
|
rule(:media_section) do
|
107
|
-
media_description >>
|
109
|
+
media_description >> information.maybe >> connection_data.maybe >>
|
110
|
+
bandwidth.maybe >> encryption_keys.maybe >> attributes.maybe
|
108
111
|
end
|
109
112
|
|
110
113
|
rule(:description) do
|
@@ -14,7 +14,9 @@ e=<%= email_address %>
|
|
14
14
|
<% if phone_number %>
|
15
15
|
p=<%= phone_number %>
|
16
16
|
<% end %>
|
17
|
-
|
17
|
+
<% if connection_network_type %>
|
18
|
+
c=<%= connection_network_type %> <%= connection_address_type %> <%= connection_address %>
|
19
|
+
<% end %>
|
18
20
|
<% if bandwidth %>
|
19
21
|
b=<%= bandwidth_type %>:<%= bandwidth %>
|
20
22
|
<% end %>
|
data/lib/sdp/version.rb
CHANGED
data/sdp.gemspec
CHANGED
@@ -82,6 +82,16 @@ describe SDP::Description do
|
|
82
82
|
@sdp.phone_number.should == "+1 555 123 4567"
|
83
83
|
end
|
84
84
|
|
85
|
+
it "connection_network_type" do
|
86
|
+
@sdp.connection_network_type = 'IN'
|
87
|
+
@sdp.connection_network_type.should == 'IN'
|
88
|
+
end
|
89
|
+
|
90
|
+
it "connection_address_type" do
|
91
|
+
@sdp.connection_address_type = 'IP4'
|
92
|
+
@sdp.connection_address_type.should == 'IP4'
|
93
|
+
end
|
94
|
+
|
85
95
|
it "connection_address" do
|
86
96
|
@sdp.connection_address = 'localhost'
|
87
97
|
@sdp.connection_address.should == 'localhost'
|
data/spec/sdp/parser_spec.rb
CHANGED
@@ -148,7 +148,44 @@ describe SDP::Parser do
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
|
+
|
152
|
+
context "attributes" do
|
153
|
+
it "attribute" do
|
154
|
+
sdp = "a=x-qt-text-cmt:Orban Opticodec-PC\r\n"
|
155
|
+
sdp_hash = @parser.parse sdp
|
156
|
+
sdp_hash[:session_section][:attributes].first[:attribute].should ==
|
157
|
+
"x-qt-text-cmt"
|
158
|
+
sdp_hash[:session_section][:attributes].first[:value].should ==
|
159
|
+
"Orban Opticodec-PC"
|
160
|
+
end
|
161
|
+
end
|
151
162
|
|
163
|
+
context "media sections" do
|
164
|
+
it "all possible fields in 1 section" do
|
165
|
+
sdp = "m=audio 0 RTP/AVP 96\r\ni=Test info\r\nc=IN IP4 0.0.0.0\r\nb=AS:40\r\nk=prompt\r\na=rtpmap:96 MP4A-LATM/44100/2\r\na=fmtp:96 cpresent=0;config=400027200000\r\n"
|
166
|
+
sdp_hash = @parser.parse sdp
|
167
|
+
sdp_hash[:media_sections].first[:media].should == "audio"
|
168
|
+
sdp_hash[:media_sections].first[:port].should == "0"
|
169
|
+
sdp_hash[:media_sections].first[:protocol].should == "RTP/AVP"
|
170
|
+
sdp_hash[:media_sections].first[:format].should == "96"
|
171
|
+
sdp_hash[:media_sections].first[:information].should == "Test info"
|
172
|
+
sdp_hash[:media_sections].first[:connection_network_type].should == "IN"
|
173
|
+
sdp_hash[:media_sections].first[:connection_address_type].should == "IP4"
|
174
|
+
sdp_hash[:media_sections].first[:connection_address].should == "0.0.0.0"
|
175
|
+
sdp_hash[:media_sections].first[:bandwidth_type].should == "AS"
|
176
|
+
sdp_hash[:media_sections].first[:bandwidth].should == "40"
|
177
|
+
sdp_hash[:media_sections].first[:encryption_method].should == "prompt"
|
178
|
+
sdp_hash[:media_sections].first[:attributes].first[:attribute].should ==
|
179
|
+
"rtpmap"
|
180
|
+
sdp_hash[:media_sections].first[:attributes].first[:value].should ==
|
181
|
+
"96 MP4A-LATM/44100/2"
|
182
|
+
sdp_hash[:media_sections].first[:attributes].last[:attribute].should ==
|
183
|
+
"fmtp"
|
184
|
+
sdp_hash[:media_sections].first[:attributes].last[:value].should ==
|
185
|
+
"96 cpresent=0;config=400027200000"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
152
189
|
context "parses EOLs" do
|
153
190
|
it "parses \\r\\n" do
|
154
191
|
sdp = "v=123\r\n"
|
data/spec/sdp_spec.rb
CHANGED
@@ -94,60 +94,68 @@ describe SDP do
|
|
94
94
|
@parsed_sdp.phone_number.class.should == String
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
context "bandwidth" do
|
98
|
+
it "has a bandwidth type of 'CT'" do
|
99
|
+
@parsed_sdp.bandwidth_type.should == "CT"
|
100
|
+
@parsed_sdp.bandwidth_type.class.should == String
|
101
|
+
end
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
it "has a bandwidth of '1000'" do
|
104
|
+
@parsed_sdp.bandwidth.should == "1000"
|
105
|
+
@parsed_sdp.bandwidth.class.should == String
|
106
|
+
end
|
105
107
|
end
|
106
108
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
context "timing" do
|
110
|
+
it "has a start time of '2873397496'" do
|
111
|
+
@parsed_sdp.start_time.should == '2873397496'
|
112
|
+
@parsed_sdp.start_time.class.should == String
|
113
|
+
end
|
111
114
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
+
it "has a stop time of '2873404696'" do
|
116
|
+
@parsed_sdp.stop_time.should == '2873404696'
|
117
|
+
@parsed_sdp.stop_time.class.should == String
|
118
|
+
end
|
115
119
|
end
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
+
context "repeat times" do
|
122
|
+
it "has a repeat interval of '604800'" do
|
123
|
+
@parsed_sdp.repeat_interval.should == '604800'
|
124
|
+
@parsed_sdp.repeat_interval.class.should == String
|
125
|
+
end
|
121
126
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
127
|
+
it "has an active duration of '3600'" do
|
128
|
+
@parsed_sdp.active_duration.should == '3600'
|
129
|
+
@parsed_sdp.active_duration.class.should == String
|
130
|
+
end
|
126
131
|
|
127
|
-
|
128
|
-
|
129
|
-
|
132
|
+
it "has a offsets from start time of '0 90000'" do
|
133
|
+
@parsed_sdp.offsets_from_start_time.should == '0 90000'
|
134
|
+
@parsed_sdp.offsets_from_start_time.class.should == String
|
135
|
+
end
|
130
136
|
end
|
131
137
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
138
|
+
context "time zones" do
|
139
|
+
it "has a time zone adjustment of '2882844526'" do
|
140
|
+
@parsed_sdp.time_zones[:adjustment_time].should == '2882844526'
|
141
|
+
@parsed_sdp.time_zones[:adjustment_time].class.should == String
|
142
|
+
end
|
136
143
|
|
137
|
-
|
138
|
-
|
139
|
-
|
144
|
+
it "has a time zone offset of '-1h'" do
|
145
|
+
@parsed_sdp.time_zones[:offset].should == '-1h'
|
146
|
+
@parsed_sdp.time_zones[:offset].class.should == String
|
147
|
+
end
|
140
148
|
end
|
141
149
|
|
142
150
|
context "connection data" do
|
143
|
-
it "has a
|
144
|
-
@parsed_sdp.
|
145
|
-
@parsed_sdp.
|
151
|
+
it "has a connection network type of 'IN'" do
|
152
|
+
@parsed_sdp.connection_network_type.should == "IN"
|
153
|
+
@parsed_sdp.connection_network_type.class.should == String
|
146
154
|
end
|
147
155
|
|
148
156
|
it "has a addrtype of :IP4" do
|
149
|
-
@parsed_sdp.
|
150
|
-
@parsed_sdp.
|
157
|
+
@parsed_sdp.connection_address_type.should == "IP4"
|
158
|
+
@parsed_sdp.connection_address_type.class.should == String
|
151
159
|
end
|
152
160
|
|
153
161
|
it "has a connection address of '224.2.17.12/127'" do
|