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 CHANGED
@@ -1,4 +1,4 @@
1
- infinity_test do
1
+ infinity_test do
2
2
  use :rubies => %w(1.8.7 1.9.1 1.9.2), :test_framework => :rspec
3
3
  notifications :growl
4
- end
4
+ end
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:
@@ -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
@@ -76,6 +76,8 @@ class SDP
76
76
  :uri,
77
77
  :email_address,
78
78
  :phone_number,
79
+ :connection_network_type,
80
+ :connection_address_type,
79
81
  :connection_address,
80
82
  :bandwidth_type,
81
83
  :bandwidth,
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(:session_information) do
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=') >> field_value >> space >> field_value >> space >>
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('[\w]').repeat(1).as(:attribute) >>
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
- session_information.maybe >> uri.maybe >> email_address.maybe >>
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 >> attributes.maybe
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
- c=<%= network_type %> <%= address_type %> <%= connection_address %>
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
@@ -1,4 +1,4 @@
1
1
  class SDP
2
2
  # sdp version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
data/sdp.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sdp}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["sloveless"]
@@ -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'
@@ -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
- it "has a bandwidth type of 'CT'" do
98
- @parsed_sdp.bandwidth_type.should == "CT"
99
- @parsed_sdp.bandwidth_type.class.should == String
100
- end
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
- it "has a bandwidth of '1000'" do
103
- @parsed_sdp.bandwidth.should == "1000"
104
- @parsed_sdp.bandwidth.class.should == String
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
- it "has a start time of '2873397496'" do
108
- @parsed_sdp.start_time.should == '2873397496'
109
- @parsed_sdp.start_time.class.should == String
110
- end
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
- it "has a stop time of '2873404696'" do
113
- @parsed_sdp.stop_time.should == '2873404696'
114
- @parsed_sdp.stop_time.class.should == String
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
- it "has a repeat interval of '604800'" do
118
- @parsed_sdp.repeat_interval.should == '604800'
119
- @parsed_sdp.repeat_interval.class.should == String
120
- end
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
- it "has an active duration of '3600'" do
123
- @parsed_sdp.active_duration.should == '3600'
124
- @parsed_sdp.active_duration.class.should == String
125
- end
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
- it "has a offsets from start time of '0 90000'" do
128
- @parsed_sdp.offsets_from_start_time.should == '0 90000'
129
- @parsed_sdp.offsets_from_start_time.class.should == String
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
- it "has a time zone adjustment of '2882844526'" do
133
- @parsed_sdp.time_zones[:adjustment_time].should == '2882844526'
134
- @parsed_sdp.time_zones[:adjustment_time].class.should == String
135
- end
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
- it "has a time zone offset of '-1h'" do
138
- @parsed_sdp.time_zones[:offset].should == '-1h'
139
- @parsed_sdp.time_zones[:offset].class.should == String
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 nettype of 'IN'" do
144
- @parsed_sdp.network_type.should == "IN"
145
- @parsed_sdp.network_type.class.should == String
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.address_type.should == "IP4"
150
- @parsed_sdp.address_type.class.should == String
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
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - sloveless